The `struct cppc_cpudata` is populated by the cppc_cpufreq driver. Outside of the driver's code, it is only used acpi_get_psd_map(). To facilitate a re-implementation of the cppc_cpufreq driver and its internal data structure in rust: - Move the structure definition to the driver's code - Udate acpi_get_psd_map() to take individual parameters instead Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx> --- drivers/acpi/cppc_acpi.c | 26 ++++++++++++++++---------- drivers/cpufreq/cppc_cpufreq.c | 13 ++++++++++++- include/acpi/cppc_acpi.h | 13 ++----------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 1d857978f5f4..b0fd141acb9d 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -468,17 +468,23 @@ EXPORT_SYMBOL_GPL(cppc_allow_fast_switch); /** * acpi_get_psd_map - Map the CPUs in the freq domain of a given cpu * @cpu: Find all CPUs that share a domain with cpu. - * @cpu_data: Pointer to CPU specific CPPC data including PSD info. + * @shared_cpu_map: cpumask to populate with CPUs belonging to the same _PSD + * domain. + * @shared_type: P-state coordination type for CPUs in the same _PSD as @cpu. * * Return: 0 for success or negative value for err. */ -int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data) +int acpi_get_psd_map(unsigned int cpu, cpumask_var_t shared_cpu_map, + unsigned int *shared_type) { struct cpc_desc *cpc_ptr, *match_cpc_ptr; struct acpi_psd_package *match_pdomain; struct acpi_psd_package *pdomain; int count_target, i; + if (!shared_cpu_map || !shared_type) + return -EINVAL; + /* * Now that we have _PSD data from all CPUs, let's setup P-state * domain info. @@ -488,18 +494,18 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data) return -EFAULT; pdomain = &(cpc_ptr->domain_info); - cpumask_set_cpu(cpu, cpu_data->shared_cpu_map); + cpumask_set_cpu(cpu, shared_cpu_map); if (pdomain->num_processors <= 1) return 0; /* Validate the Domain info */ count_target = pdomain->num_processors; if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL) - cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ALL; + *shared_type = CPUFREQ_SHARED_TYPE_ALL; else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) - cpu_data->shared_type = CPUFREQ_SHARED_TYPE_HW; + *shared_type = CPUFREQ_SHARED_TYPE_HW; else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) - cpu_data->shared_type = CPUFREQ_SHARED_TYPE_ANY; + *shared_type = CPUFREQ_SHARED_TYPE_ANY; for_each_possible_cpu(i) { if (i == cpu) @@ -520,16 +526,16 @@ int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data) if (pdomain->coord_type != match_pdomain->coord_type) goto err_fault; - cpumask_set_cpu(i, cpu_data->shared_cpu_map); + cpumask_set_cpu(i, shared_cpu_map); } return 0; err_fault: /* Assume no coordination on any error parsing domain info */ - cpumask_clear(cpu_data->shared_cpu_map); - cpumask_set_cpu(cpu, cpu_data->shared_cpu_map); - cpu_data->shared_type = CPUFREQ_SHARED_TYPE_NONE; + cpumask_clear(shared_cpu_map); + cpumask_set_cpu(cpu, shared_cpu_map); + *shared_type = CPUFREQ_SHARED_TYPE_NONE; return -EFAULT; } diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 32780bb4e911..208d7b176fd0 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -26,6 +26,16 @@ #include <acpi/cppc_acpi.h> +/* Per CPU container for runtime CPPC management. */ +struct cppc_cpudata { + struct list_head node; + struct cppc_perf_caps perf_caps; + struct cppc_perf_ctrls perf_ctrls; + struct cppc_perf_fb_ctrs perf_fb_ctrs; + unsigned int shared_type; + cpumask_var_t shared_cpu_map; +}; + /* * This list contains information parsed from per CPU ACPI _CPC and _PSD * structures: e.g. the highest and lowest supported performance, capabilities, @@ -572,7 +582,8 @@ static struct cppc_cpudata *cppc_cpufreq_get_cpu_data(unsigned int cpu) if (!zalloc_cpumask_var(&cpu_data->shared_cpu_map, GFP_KERNEL)) goto free_cpu; - ret = acpi_get_psd_map(cpu, cpu_data); + ret = acpi_get_psd_map(cpu, cpu_data->shared_cpu_map, + &cpu_data->shared_type); if (ret) { pr_debug("Err parsing CPU%d PSD data: ret:%d\n", cpu, ret); goto free_mask; diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 930b6afba6f4..5164aaca7eb0 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -126,16 +126,6 @@ struct cppc_perf_fb_ctrs { u64 wraparound_time; }; -/* Per CPU container for runtime CPPC management. */ -struct cppc_cpudata { - struct list_head node; - struct cppc_perf_caps perf_caps; - struct cppc_perf_ctrls perf_ctrls; - struct cppc_perf_fb_ctrs perf_fb_ctrs; - unsigned int shared_type; - cpumask_var_t shared_cpu_map; -}; - #ifdef CONFIG_ACPI_CPPC_LIB extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf); extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf); @@ -149,7 +139,8 @@ extern unsigned int cppc_perf_to_khz(struct cppc_perf_caps *caps, unsigned int p extern unsigned int cppc_khz_to_perf(struct cppc_perf_caps *caps, unsigned int freq); extern bool acpi_cpc_valid(void); extern bool cppc_allow_fast_switch(void); -extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data); +extern int acpi_get_psd_map(unsigned int cpu, cpumask_var_t shared_cpu_map, + unsigned int *shared_type); extern unsigned int cppc_get_transition_latency(int cpu); extern bool cpc_ffh_supported(void); extern bool cpc_supported_by_cpu(void); -- 2.25.1