Re: [PATCH v2 2/3] ACPI: CPPC: Add u64 wrappers for the autonomous selection register

"zhenglifeng (A)" <[email protected]>
Newsgroups org.kernel.vger.linux-tegra,dev.linux.lists.acpica-devel,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm
Message-ID <[email protected]>
On 7/16/2026 11:38 PM, Sumit Gupta wrote:
> cppc_get_auto_sel()/cppc_set_auto_sel() use a bool, unlike the other
> CPPC register get/set helpers which use a u64.
> 
> The next patch in this series saves and restores the OSPM-set registers
> across CPU hotplug using a common table of get/set helpers typed as
> int (*)(int, u64 *) and int (*)(int, u64), which the bool autonomous
> selection helpers do not fit.
> 
> Add cppc_get_auto_sel_u64()/cppc_set_auto_sel_u64() wrappers with the u64
> signature so the autonomous selection register fits alongside the others.
> 
> Suggested-by: Pierre Gondois <[email protected]>
> Signed-off-by: Sumit Gupta <[email protected]>

If this is necessary, I think it is better to just change the input parameter
of the original cppc_get/set_auto_sel() to u64.

> ---
>  drivers/acpi/cppc_acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  include/acpi/cppc_acpi.h | 10 ++++++++++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 9f572f481241..a7fec6c93178 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1788,6 +1788,46 @@ int cppc_set_auto_sel(int cpu, bool enable)
>  }
>  EXPORT_SYMBOL_GPL(cppc_set_auto_sel);
>  
> +/**
> + * cppc_get_auto_sel_u64 - Read the autonomous selection register as a u64.
> + * @cpu: CPU from which to read the register.
> + * @val: Return address, set to 0 or 1.
> + *
> + * u64-typed wrapper around cppc_get_auto_sel() for callers that keep CPPC
> + * register accessors in a common table.
> + *
> + * Return: 0 for success, -ERRNO otherwise.
> + */
> +int cppc_get_auto_sel_u64(int cpu, u64 *val)
> +{
> +	bool enable;
> +	int ret;
> +
> +	ret = cppc_get_auto_sel(cpu, &enable);
> +	if (ret)
> +		return ret;
> +
> +	*val = enable;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(cppc_get_auto_sel_u64);
> +
> +/**
> + * cppc_set_auto_sel_u64 - Write the autonomous selection register from a u64.
> + * @cpu: CPU to which to write the register.
> + * @val: Value to write, any non-zero value enables autonomous selection.
> + *
> + * u64-typed wrapper around cppc_set_auto_sel().
> + *
> + * Return: 0 for success, -ERRNO otherwise.
> + */
> +int cppc_set_auto_sel_u64(int cpu, u64 val)
> +{
> +	return cppc_set_auto_sel(cpu, !!val);
> +}
> +EXPORT_SYMBOL_GPL(cppc_set_auto_sel_u64);
> +
>  /**
>   * cppc_set_enable - Set to enable CPPC on the processor by writing the
>   * Continuous Performance Control package EnableRegister field.
> diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
> index 8693890a7275..cd07e1e92bf4 100644
> --- a/include/acpi/cppc_acpi.h
> +++ b/include/acpi/cppc_acpi.h
> @@ -184,6 +184,8 @@ extern int cppc_get_auto_act_window(int cpu, u64 *auto_act_window);
>  extern int cppc_set_auto_act_window(int cpu, u64 auto_act_window);
>  extern int cppc_get_auto_sel(int cpu, bool *enable);
>  extern int cppc_set_auto_sel(int cpu, bool enable);
> +extern int cppc_get_auto_sel_u64(int cpu, u64 *val);
> +extern int cppc_set_auto_sel_u64(int cpu, u64 val);
>  extern int cppc_get_perf_limited(int cpu, u64 *perf_limited);
>  extern int cppc_set_perf_limited(int cpu, u64 bits_to_clear);
>  extern int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf);
> @@ -282,6 +284,14 @@ static inline int cppc_set_auto_sel(int cpu, bool enable)
>  {
>  	return -EOPNOTSUPP;
>  }
> +static inline int cppc_get_auto_sel_u64(int cpu, u64 *val)
> +{
> +	return -EOPNOTSUPP;
> +}
> +static inline int cppc_set_auto_sel_u64(int cpu, u64 val)
> +{
> +	return -EOPNOTSUPP;
> +}
>  static inline int cppc_get_perf_limited(int cpu, u64 *perf_limited)
>  {
>  	return -EOPNOTSUPP;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.