Lines Matching +full:row +full:- +full:hold

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
22 #define pr_fmt(fmt) "intel-hfi: " fmt
33 #include <linux/percpu-defs.h>
79 * struct hfi_cpu_data - HFI capabilities per CPU
92 * struct hfi_hdr - Header of the HFI table
104 * struct hfi_instance - Representation of an HFI instance (i.e., a table)
133 * struct hfi_features - Supported HFI features
136 * processor within the table (i.e., row stride)
148 * struct hfi_cpu_info - Per-CPU attributes to consume HFI data
149 * @index: Row of this CPU in its HFI table
152 * Parameters to link a logical processor to an HFI table and a row within it.
159 static DEFINE_PER_CPU(struct hfi_cpu_info, hfi_cpu_info) = { .index = -1 };
177 raw_spin_lock_irq(&hfi_instance->table_lock); in get_hfi_caps()
178 for_each_cpu(cpu, hfi_instance->cpus) { in get_hfi_caps()
183 caps = hfi_instance->data + index * hfi_features.cpu_stride; in get_hfi_caps()
190 cpu_caps[i].performance = caps->perf_cap << 2; in get_hfi_caps()
191 cpu_caps[i].efficiency = caps->ee_cap << 2; in get_hfi_caps()
195 raw_spin_unlock_irq(&hfi_instance->table_lock); in get_hfi_caps()
209 cpu_count = cpumask_weight(hfi_instance->cpus); in update_capabilities()
231 cpu_count = cpu_count - i; in update_capabilities()
269 * local APIC is unmasked. Hence, info->hfi_instance cannot be NULL in intel_hfi_process_event()
272 hfi_instance = info->hfi_instance; in intel_hfi_process_event()
279 * On most systems, all CPUs in the package receive a package-level in intel_hfi_process_event()
284 if (!raw_spin_trylock(&hfi_instance->event_lock)) in intel_hfi_process_event()
290 raw_spin_unlock(&hfi_instance->event_lock); in intel_hfi_process_event()
299 new_timestamp = *(u64 *)hfi_instance->hw_table; in intel_hfi_process_event()
300 if (*hfi_instance->timestamp == new_timestamp) { in intel_hfi_process_event()
302 raw_spin_unlock(&hfi_instance->event_lock); in intel_hfi_process_event()
306 raw_spin_lock(&hfi_instance->table_lock); in intel_hfi_process_event()
312 memcpy(hfi_instance->local_table, hfi_instance->hw_table, in intel_hfi_process_event()
321 raw_spin_unlock(&hfi_instance->table_lock); in intel_hfi_process_event()
322 raw_spin_unlock(&hfi_instance->event_lock); in intel_hfi_process_event()
324 queue_delayed_work(hfi_updates_wq, &hfi_instance->update_work, in intel_hfi_process_event()
332 /* Do not re-read @cpu's index if it has already been initialized. */ in init_hfi_cpu_index()
333 if (info->index > -1) in init_hfi_cpu_index()
337 info->index = edx.split.index; in init_hfi_cpu_index()
346 /* The HFI header is below the time-stamp. */ in init_hfi_instance()
347 hfi_instance->hdr = hfi_instance->local_table + in init_hfi_instance()
348 sizeof(*hfi_instance->timestamp); in init_hfi_instance()
351 hfi_instance->data = hfi_instance->hdr + hfi_features.hdr_size; in init_hfi_instance()
354 /* Caller must hold hfi_instance_lock. */
369 hw_table_pa = virt_to_phys(hfi_instance->hw_table); in hfi_set_hw_table()
374 /* Caller must hold hfi_instance_lock. */
401 * intel_hfi_online() - Enable HFI on @cpu
429 hfi_instance = info->hfi_instance; in intel_hfi_online()
435 info->hfi_instance = hfi_instance; in intel_hfi_online()
447 if (hfi_instance->hdr) in intel_hfi_online()
452 * frame of the table. Hence, the allocated memory must be page-aligned. in intel_hfi_online()
458 hfi_instance->hw_table = alloc_pages_exact(hfi_features.nr_table_pages, in intel_hfi_online()
460 if (!hfi_instance->hw_table) in intel_hfi_online()
467 hfi_instance->local_table = kzalloc(hfi_features.nr_table_pages << PAGE_SHIFT, in intel_hfi_online()
469 if (!hfi_instance->local_table) in intel_hfi_online()
474 INIT_DELAYED_WORK(&hfi_instance->update_work, hfi_update_work_fn); in intel_hfi_online()
475 raw_spin_lock_init(&hfi_instance->table_lock); in intel_hfi_online()
476 raw_spin_lock_init(&hfi_instance->event_lock); in intel_hfi_online()
479 cpumask_set_cpu(cpu, hfi_instance->cpus); in intel_hfi_online()
483 * there are user-space clients of thermal events. in intel_hfi_online()
485 if (cpumask_weight(hfi_instance->cpus) == 1 && hfi_clients_nr > 0) { in intel_hfi_online()
495 free_pages_exact(hfi_instance->hw_table, hfi_features.nr_table_pages); in intel_hfi_online()
500 * intel_hfi_offline() - Disable HFI on @cpu
515 * Check if @cpu as an associated, initialized (i.e., with a non-NULL in intel_hfi_offline()
519 hfi_instance = info->hfi_instance; in intel_hfi_offline()
523 if (!hfi_instance->hdr) in intel_hfi_offline()
527 cpumask_clear_cpu(cpu, hfi_instance->cpus); in intel_hfi_offline()
529 if (!cpumask_weight(hfi_instance->cpus)) in intel_hfi_offline()
541 return -ENODEV; in hfi_parse_features()
551 return -ENODEV; in hfi_parse_features()
599 struct hfi_instance *hfi_instance = info->hfi_instance; in hfi_syscore_resume()
628 if (notify->mcgrp != THERMAL_GENL_EVENT_GROUP) in hfi_thermal_notify()
642 if (--hfi_clients_nr == 0) in hfi_thermal_notify()
652 if (cpumask_empty(hfi_instance->cpus)) in hfi_thermal_notify()
655 cpu = cpumask_any(hfi_instance->cpus); in hfi_thermal_notify()
680 * Special handling would be needed if this happens on an HFI-capable in intel_hfi_init()
696 if (!zalloc_cpumask_var(&hfi_instance->cpus, GFP_KERNEL)) in intel_hfi_init()
700 hfi_updates_wq = create_singlethread_workqueue("hfi-updates"); in intel_hfi_init()
706 * As kernel build-in drivers they are initialized before user-space in intel_hfi_init()
723 free_cpumask_var(hfi_instance->cpus); in intel_hfi_init()