2020-11-25 15:07:06

by Punit Agrawal

[permalink] [raw]
Subject: [RFC PATCH 4/4] cpufreq: acpi-cpufreq: Use identifiers for AMD processor family

Replace the raw values for AMD processor family with recently
introduced identifier macros to improve code readability and
maintainability.

Signed-off-by: Punit Agrawal <[email protected]>
---
drivers/cpufreq/acpi-cpufreq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 29f1cd93541e..d8b8300ae9e0 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -202,8 +202,8 @@ static int override_acpi_psd(unsigned int cpu_id)
* CPU's before Zen3 (except some Zen2) need the
* override.
*/
- return (c->x86 < 0x19) &&
- !(c->x86 == 0x17 && c->x86_model == 0x60 &&
+ return (c->x86 < AMD_FAM_ZEN3) &&
+ !(c->x86 == AMD_FAM_ZEN && c->x86_model == 0x60 &&
c->x86_stepping == 0x1);
}

@@ -735,7 +735,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
switch (perf->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
- boot_cpu_data.x86 == 0xf) {
+ boot_cpu_data.x86 == AMD_FAM_K8) {
pr_debug("AMD K8 systems must use native drivers.\n");
result = -ENODEV;
goto err_unreg;
--
2.29.2


2020-11-30 14:05:30

by Borislav Petkov

[permalink] [raw]
Subject: Re: [RFC PATCH 4/4] cpufreq: acpi-cpufreq: Use identifiers for AMD processor family

On Wed, Nov 25, 2020 at 11:48:47PM +0900, Punit Agrawal wrote:
> Replace the raw values for AMD processor family with recently
> introduced identifier macros to improve code readability and
> maintainability.
>
> Signed-off-by: Punit Agrawal <[email protected]>
> ---
> drivers/cpufreq/acpi-cpufreq.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index 29f1cd93541e..d8b8300ae9e0 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -202,8 +202,8 @@ static int override_acpi_psd(unsigned int cpu_id)
> * CPU's before Zen3 (except some Zen2) need the
> * override.
> */
> - return (c->x86 < 0x19) &&
> - !(c->x86 == 0x17 && c->x86_model == 0x60 &&
> + return (c->x86 < AMD_FAM_ZEN3) &&
> + !(c->x86 == AMD_FAM_ZEN && c->x86_model == 0x60 &&

This is what I mean - that's Zen2 as the comment above says so having

c->x86 == AMD_FAM_ZEN

is not enough. And you have a comment above it stating which CPUs are
matched here so I'm not sure those family defines make it any better...

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

2020-12-02 14:34:08

by Punit Agrawal

[permalink] [raw]
Subject: Re: [RFC PATCH 4/4] cpufreq: acpi-cpufreq: Use identifiers for AMD processor family

Borislav Petkov <[email protected]> writes:

> On Wed, Nov 25, 2020 at 11:48:47PM +0900, Punit Agrawal wrote:
>> Replace the raw values for AMD processor family with recently
>> introduced identifier macros to improve code readability and
>> maintainability.
>>
>> Signed-off-by: Punit Agrawal <[email protected]>
>> ---
>> drivers/cpufreq/acpi-cpufreq.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index 29f1cd93541e..d8b8300ae9e0 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -202,8 +202,8 @@ static int override_acpi_psd(unsigned int cpu_id)
>> * CPU's before Zen3 (except some Zen2) need the
>> * override.
>> */
>> - return (c->x86 < 0x19) &&
>> - !(c->x86 == 0x17 && c->x86_model == 0x60 &&
>> + return (c->x86 < AMD_FAM_ZEN3) &&
>> + !(c->x86 == AMD_FAM_ZEN && c->x86_model == 0x60 &&
>
> This is what I mean - that's Zen2 as the comment above says so having
>
> c->x86 == AMD_FAM_ZEN
>
> is not enough. And you have a comment above it stating which CPUs are
> matched here so I'm not sure those family defines make it any better...

Hmm.. for this series, it probably doesn't add much value - especially
with the comment and macro mismatch.

The last two patches were posted to check if there's wider interest in
the changes. If the macro conversion is useful, I can split the patches
from this series into a separate set with more sites being updated. I'll
wait to see if there's any further feedback.

Thanks,
Punit