2020-11-25 20:24:57

by Punit Agrawal

[permalink] [raw]
Subject: [RFC PATCH 1/4] cpufreq: acpi-cpufreq: Re-factor overriding ACPI PSD

Re-factor the code to override the firmware provided frequency domain
information (via PSD) to localise the checks in one function.

No functional change intended.

Signed-off-by: Punit Agrawal <[email protected]>
Cc: Wei Huang <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 1e4fbb002a31..b1e7df96d428 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -191,6 +191,20 @@ static int check_amd_hwpstate_cpu(unsigned int cpuid)
return cpu_has(cpu, X86_FEATURE_HW_PSTATE);
}

+static int override_acpi_psd(unsigned int cpu_id)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ if (c->x86_vendor == X86_VENDOR_AMD) {
+ if (!check_amd_hwpstate_cpu(cpu_id))
+ return false;
+
+ return c->x86 < 0x19;
+ }
+
+ return false;
+}
+
static unsigned extract_io(struct cpufreq_policy *policy, u32 value)
{
struct acpi_cpufreq_data *data = policy->driver_data;
@@ -691,8 +705,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
}

- if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 &&
- !acpi_pstate_strict) {
+ if (override_acpi_psd(cpu) && !acpi_pstate_strict) {
cpumask_clear(policy->cpus);
cpumask_set_cpu(cpu, policy->cpus);
cpumask_copy(data->freqdomain_cpus,
--
2.29.2


2020-12-07 19:31:54

by Wei Huang

[permalink] [raw]
Subject: Re: [RFC PATCH 1/4] cpufreq: acpi-cpufreq: Re-factor overriding ACPI PSD



On 11/25/20 8:48 AM, Punit Agrawal wrote:
> Re-factor the code to override the firmware provided frequency domain
> information (via PSD) to localise the checks in one function.
>
> No functional change intended.
>
> Signed-off-by: Punit Agrawal <[email protected]>
> Cc: Wei Huang <[email protected]>
> ---
> drivers/cpufreq/acpi-cpufreq.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 1e4fbb002a31..b1e7df96d428 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -191,6 +191,20 @@ static int check_amd_hwpstate_cpu(unsigned int cpuid)
> return cpu_has(cpu, X86_FEATURE_HW_PSTATE);
> }
>
> +static int override_acpi_psd(unsigned int cpu_id)
^^^^^
int is fine, but it might be better to use bool. Otherwise I don't see
any issues with this patch.

> +{
> + struct cpuinfo_x86 *c = &boot_cpu_data;
> +
> + if (c->x86_vendor == X86_VENDOR_AMD) {
> + if (!check_amd_hwpstate_cpu(cpu_id))
> + return false;
> +
> + return c->x86 < 0x19;
> + }
> +
> + return false;
> +}
> +
> static unsigned extract_io(struct cpufreq_policy *policy, u32 value)
> {
> struct acpi_cpufreq_data *data = policy->driver_data;
> @@ -691,8 +705,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
> cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
> }
>
> - if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 &&
> - !acpi_pstate_strict) {
> + if (override_acpi_psd(cpu) && !acpi_pstate_strict) {
> cpumask_clear(policy->cpus);
> cpumask_set_cpu(cpu, policy->cpus);
> cpumask_copy(data->freqdomain_cpus,
>

2020-12-08 23:36:40

by Punit Agrawal

[permalink] [raw]
Subject: Re: [RFC PATCH 1/4] cpufreq: acpi-cpufreq: Re-factor overriding ACPI PSD

Hi Wei,

Wei Huang <[email protected]> writes:

> On 11/25/20 8:48 AM, Punit Agrawal wrote:
>> Re-factor the code to override the firmware provided frequency domain
>> information (via PSD) to localise the checks in one function.
>>
>> No functional change intended.
>>
>> Signed-off-by: Punit Agrawal <[email protected]>
>> Cc: Wei Huang <[email protected]>
>> ---
>> drivers/cpufreq/acpi-cpufreq.c | 17 +++++++++++++++--
>> 1 file changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 1e4fbb002a31..b1e7df96d428 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -191,6 +191,20 @@ static int check_amd_hwpstate_cpu(unsigned int cpuid)
>> return cpu_has(cpu, X86_FEATURE_HW_PSTATE);
>> }
>>
>> +static int override_acpi_psd(unsigned int cpu_id)
> ^^^^^
> int is fine, but it might be better to use bool. Otherwise I don't see
> any issues with this patch.

Makes sense - I will switch to a boolean in the next update.

Thanks for taking a look.

Punit

>
>> +{
>> + struct cpuinfo_x86 *c = &boot_cpu_data;
>> +
>> + if (c->x86_vendor == X86_VENDOR_AMD) {
>> + if (!check_amd_hwpstate_cpu(cpu_id))
>> + return false;
>> +
>> + return c->x86 < 0x19;
>> + }
>> +
>> + return false;
>> +}
>> +
>> static unsigned extract_io(struct cpufreq_policy *policy, u32 value)
>> {
>> struct acpi_cpufreq_data *data = policy->driver_data;
>> @@ -691,8 +705,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
>> cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
>> }
>>
>> - if (check_amd_hwpstate_cpu(cpu) && boot_cpu_data.x86 < 0x19 &&
>> - !acpi_pstate_strict) {
>> + if (override_acpi_psd(cpu) && !acpi_pstate_strict) {
>> cpumask_clear(policy->cpus);
>> cpumask_set_cpu(cpu, policy->cpus);
>> cpumask_copy(data->freqdomain_cpus,
>>