diff mbox series

[RESENT] cpufreq: amd-pstate: add quirk for Ryzen 3000 series processor

Message ID 20240809060905.777146-1-perry.yuan@amd.com
State Superseded
Headers show
Series [RESENT] cpufreq: amd-pstate: add quirk for Ryzen 3000 series processor | expand

Commit Message

Yuan, Perry Aug. 9, 2024, 6:09 a.m. UTC
The Ryzen 3000 series processors have been observed lacking the
nominal_freq and lowest_freq parameters in their ACPI tables. This
absence causes issues with loading the amd-pstate driver on these
systems. Introduces a fix to resolve the dependency issue
by adding a quirk specifically for the Ryzen 3000 series.

Reported-by: David Wang <00107082@163.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

David Wang Aug. 9, 2024, 1:06 p.m. UTC | #1
Hi, 

At 2024-08-09 14:09:05, "Perry Yuan" <perry.yuan@amd.com> wrote:
>The Ryzen 3000 series processors have been observed lacking the
>nominal_freq and lowest_freq parameters in their ACPI tables. This
>absence causes issues with loading the amd-pstate driver on these
>systems. Introduces a fix to resolve the dependency issue
>by adding a quirk specifically for the Ryzen 3000 series.
>
>Reported-by: David Wang <00107082@163.com>
>Signed-off-by: Perry Yuan <perry.yuan@amd.com>
>---
> drivers/cpufreq/amd-pstate.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
>diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>index 68c616b572f2..b39365b980b9 100644
>--- a/drivers/cpufreq/amd-pstate.c
>+++ b/drivers/cpufreq/amd-pstate.c
>@@ -142,6 +142,11 @@ static struct quirk_entry quirk_amd_7k62 = {
> 	.lowest_freq = 550,
> };
> 
>+static struct quirk_entry quirk_amd_mts = {
>+	.nominal_freq = 3600,
>+	.lowest_freq = 550,
>+};
>+
> static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
> {
> 	/**
>@@ -158,6 +163,21 @@ static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
> 	return 0;
> }
> 
>+static int __init dmi_matched_mts_bios_bug(const struct dmi_system_id *dmi)
>+{
>+	/**
>+	 * match the broken bios for ryzen 3000 series processor support CPPC V2
>+	 * broken BIOS lack of nominal_freq and lowest_freq capabilities
>+	 * definition in ACPI tables
>+	 */
>+	if (cpu_feature_enabled(X86_FEATURE_ZEN2)) {
>+		quirks = dmi->driver_data;
>+		pr_info("Overriding nominal and lowest frequencies for %s\n", dmi->ident);
>+		return 1;
>+	}
>+
>+	return 0;
>+}
> static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
> 	{
> 		.callback = dmi_matched_7k62_bios_bug,
>@@ -168,6 +188,16 @@ static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
> 		},
> 		.driver_data = &quirk_amd_7k62,
> 	},
>+	{
>+		.callback = dmi_matched_mts_bios_bug,
>+		.ident = "AMD Ryzen 3000",
>+		.matches = {
>+			DMI_MATCH(DMI_PRODUCT_NAME, "B450M MORTAR MAX (MS-7B89)"),
>+			DMI_MATCH(DMI_BIOS_RELEASE, "06/10/2020"),
>+			DMI_MATCH(DMI_BIOS_VERSION, "5.14"),
>+		},
>+		.driver_data = &quirk_amd_mts,
>+	},
> 	{}
> };
> MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);
>-- 
>2.34.1


I tried this patch on 6.11.0-rc2, sadly this config does not match my system (BIOS).
After some correction, I confirm following configuration matches my BIOS:

 static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
        {
                .callback = dmi_matched_7k62_bios_bug,
@@ -168,6 +190,16 @@ static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
                },
                .driver_data = &quirk_amd_7k62,
        },
+       {
+               .callback = dmi_matched_mts_bios_bug,
+               .ident = "AMD Ryzen 3000",
+               .matches = {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "MS-7B89"),
+                       DMI_MATCH(DMI_BIOS_RELEASE, "5.14"),
+                       DMI_MATCH(DMI_BIOS_VERSION, "2.80"),
+               },
+               .driver_data = &quirk_amd_mts,
+       },
        {}
 };
 MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);

And with this change, my system boots with no amd_pstate error. 
The old warning and a new info show up though, I guess that is acceptable?

[Fri Aug  9 19:35:29 2024] amd_pstate: The CPPC feature is supported but currently disabled by the BIOS.
                           Please enable it if your BIOS has the CPPC option.
[Fri Aug  9 19:35:29 2024] amd_pstate: Overriding nominal and lowest frequencies for AMD Ryzen 3000


This patch confuses me a little,
I do not see any bound between CPU identity "AMD Ryzen 3000" and my BIOS DMIs,
 it make no sense to me to infer the CPU identity just by some BIOS DMIs. 
What if another AMD CPU with different cpu frequency range installed on the same BIOS as mine?
(I guess current assumption is that my BIOS is way too old and weird, the possibility of "what if" mentioned above is very low?)


Anyway, after patching my system with a proper quirk,
I dose not notice any significant CPU performance changes,  yet. (My kernel build time dose not change much, at least)
And it seems to me that the amd_pstate module is active:

$ ls /sys/devices/system/cpu/cpufreq/policy0/*amd* -l
-r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_highest_perf
-r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_hw_prefcore
-r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq
-r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq
-r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_prefcore_ranking

 $ cpupower frequency-info  # when my system is idle
analyzing CPU 0:
  driver: amd-pstate-epp
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 550 MHz - 3.91 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 550 MHz and 3.91 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware 
  current CPU frequency: 550 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: no

$ cpupower frequency-info  # when my sytem is busy building kernel
analyzing CPU 0:
  driver: amd-pstate-epp
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 550 MHz - 3.91 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 550 MHz and 3.91 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.89 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: no


FYI
And thanks for your support tailoring for my system~!
David
Du, Xiaojian Aug. 22, 2024, 4:25 a.m. UTC | #2
[AMD Official Use Only - AMD Internal Distribution Only]

Hi David,

I built one test combination: B550 motherboard+ R9-3900X CPU+ 6.10-rc4 kernel.
On my test machine, amd-pstate driver passive/active mode works after enabling CPPC in BIOS, no code change in amd-pstate.
My BIOS is updated on 2023 Aug. But no matter CPPC is enabled or not in BIOS, "lscpu" won't show CPPC flag on R9-3900X CPU.
Any chance to update your BIOS first?
Noticed your motherboard is "MSI B450M MORTAR MAX", the latest three versions of BIOS are released in 2024 Aug. 21st/2024 Aug. 9th/2023 Oct. 26th.
https://www.msi.cn/Motherboard/B450M-MORTAR-MAX/support

If this issue is fixed in BIOS, no need to modify the upstream kernel code, right?

Thanks,
Xiaojian

-----邮件原件-----
发件人: Du, Xiaojian
发送时间: 2024年8月16日 16:00
收件人: David Wang <00107082@163.com>; Yuan, Perry <Perry.Yuan@amd.com>
抄送: rafael.j.wysocki@intel.com; Limonciello, Mario <Mario.Limonciello@amd.com>; viresh.kumar@linaro.org; Huang, Ray <Ray.Huang@amd.com>; Shenoy, Gautham Ranjal <gautham.shenoy@amd.com>; Petkov, Borislav <Borislav.Petkov@amd.com>; Huang, Shimmer <Shimmer.Huang@amd.com>; Du, Xiaojian <Xiaojian.Du@amd.com>; Meng, Li (Jassmine) <Li.Meng@amd.com>
主题: Re: [PATCH RESENT] cpufreq: amd-pstate: add quirk for Ryzen 3000 series processor


On 2024/8/9 21:06, David Wang wrote:
> Hi,
>
> At 2024-08-09 14:09:05, "Perry Yuan" <perry.yuan@amd.com> wrote:
>> The Ryzen 3000 series processors have been observed lacking the
>> nominal_freq and lowest_freq parameters in their ACPI tables. This
>> absence causes issues with loading the amd-pstate driver on these
>> systems. Introduces a fix to resolve the dependency issue
>> by adding a quirk specifically for the Ryzen 3000 series.
>>
>> Reported-by: David Wang <00107082@163.com>
>> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
>> ---
>> drivers/cpufreq/amd-pstate.c | 30 ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index 68c616b572f2..b39365b980b9 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -142,6 +142,11 @@ static struct quirk_entry quirk_amd_7k62 = {
>>      .lowest_freq = 550,
>> };
>>
>> +static struct quirk_entry quirk_amd_mts = {
>> +    .nominal_freq = 3600,
>> +    .lowest_freq = 550,
>> +};
>> +
>> static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
>> {
>>      /**
>> @@ -158,6 +163,21 @@ static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
>>      return 0;
>> }
>>
>> +static int __init dmi_matched_mts_bios_bug(const struct dmi_system_id *dmi)
>> +{
>> +    /**
>> +     * match the broken bios for ryzen 3000 series processor support CPPC V2
>> +     * broken BIOS lack of nominal_freq and lowest_freq capabilities
>> +     * definition in ACPI tables
>> +     */
>> +    if (cpu_feature_enabled(X86_FEATURE_ZEN2)) {
>> +            quirks = dmi->driver_data;
>> +            pr_info("Overriding nominal and lowest frequencies for %s\n", dmi->ident);
>> +            return 1;
>> +    }
>> +
>> +    return 0;
>> +}
>> static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
>>      {
>>              .callback = dmi_matched_7k62_bios_bug,
>> @@ -168,6 +188,16 @@ static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
>>              },
>>              .driver_data = &quirk_amd_7k62,
>>      },
>> +    {
>> +            .callback = dmi_matched_mts_bios_bug,
>> +            .ident = "AMD Ryzen 3000",
>> +            .matches = {
>> +                    DMI_MATCH(DMI_PRODUCT_NAME, "B450M MORTAR MAX (MS-7B89)"),
>> +                    DMI_MATCH(DMI_BIOS_RELEASE, "06/10/2020"),
>> +                    DMI_MATCH(DMI_BIOS_VERSION, "5.14"),
>> +            },
>> +            .driver_data = &quirk_amd_mts,
>> +    },
>>      {}
>> };
>> MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);
>> --
>> 2.34.1
>
> I tried this patch on 6.11.0-rc2, sadly this config does not match my system (BIOS).
> After some correction, I confirm following configuration matches my BIOS:
>
>   static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
>          {
>                  .callback = dmi_matched_7k62_bios_bug,
> @@ -168,6 +190,16 @@ static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
>                  },
>                  .driver_data = &quirk_amd_7k62,
>          },
> +       {
> +               .callback = dmi_matched_mts_bios_bug,
> +               .ident = "AMD Ryzen 3000",
> +               .matches = {
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "MS-7B89"),
> +                       DMI_MATCH(DMI_BIOS_RELEASE, "5.14"),
> +                       DMI_MATCH(DMI_BIOS_VERSION, "2.80"),
> +               },
> +               .driver_data = &quirk_amd_mts,
> +       },
>          {}
>   };
>   MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);
>
> And with this change, my system boots with no amd_pstate error.
> The old warning and a new info show up though, I guess that is acceptable?
>
> [Fri Aug  9 19:35:29 2024] amd_pstate: The CPPC feature is supported but currently disabled by the BIOS.
>                             Please enable it if your BIOS has the CPPC option.
> [Fri Aug  9 19:35:29 2024] amd_pstate: Overriding nominal and lowest frequencies for AMD Ryzen 3000
>
>
> This patch confuses me a little,
> I do not see any bound between CPU identity "AMD Ryzen 3000" and my BIOS DMIs,
>   it make no sense to me to infer the CPU identity just by some BIOS DMIs.
> What if another AMD CPU with different cpu frequency range installed on the same BIOS as mine?
> (I guess current assumption is that my BIOS is way too old and weird, the possibility of "what if" mentioned above is very low?)
>
Double checked the internal docs about the CPPC feature on Matisse CPU,
which is named Ryzen 3xxxx CPU, it uses the same solution with Vermeer
CPU, named Ryzen 5xxx CPU.
This means, if one motherboard supports the CPPC feature with Ryzen 5xxx
CPU, it also supports the same feature on Ryzen3xxx CPU.
So it is recommended to update the latest BIOS for motherboard to enable
CPPC feature from hardware aspect.

The motherboard I am using is Gigabyte AX370-Gaming 5 released in 2017,
it is using the BIOS updated in 04/28/2022, it has the native option for
CPPC feature.

Thanks,
Xiaojian

> Anyway, after patching my system with a proper quirk,
> I dose not notice any significant CPU performance changes,  yet. (My kernel build time dose not change much, at least)
> And it seems to me that the amd_pstate module is active:
>
> $ ls /sys/devices/system/cpu/cpufreq/policy0/*amd* -l
> -r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_highest_perf
> -r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_hw_prefcore
> -r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq
> -r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq
> -r--r--r-- 1 root root 4096 Aug  9 20:46 /sys/devices/system/cpu/cpufreq/policy0/amd_pstate_prefcore_ranking
>
>   $ cpupower frequency-info  # when my system is idle
> analyzing CPU 0:
>    driver: amd-pstate-epp
>    CPUs which run at the same hardware frequency: 0
>    CPUs which need to have their frequency coordinated by software: 0
>    maximum transition latency:  Cannot determine or is not supported.
>    hardware limits: 550 MHz - 3.91 GHz
>    available cpufreq governors: performance powersave
>    current policy: frequency should be within 550 MHz and 3.91 GHz.
>                    The governor "powersave" may decide which speed to use
>                    within this range.
>    current CPU frequency: Unable to call hardware
>    current CPU frequency: 550 MHz (asserted by call to kernel)
>    boost state support:
>      Supported: yes
>      Active: no
>
> $ cpupower frequency-info  # when my sytem is busy building kernel
> analyzing CPU 0:
>    driver: amd-pstate-epp
>    CPUs which run at the same hardware frequency: 0
>    CPUs which need to have their frequency coordinated by software: 0
>    maximum transition latency:  Cannot determine or is not supported.
>    hardware limits: 550 MHz - 3.91 GHz
>    available cpufreq governors: performance powersave
>    current policy: frequency should be within 550 MHz and 3.91 GHz.
>                    The governor "powersave" may decide which speed to use
>                    within this range.
>    current CPU frequency: Unable to call hardware
>    current CPU frequency: 3.89 GHz (asserted by call to kernel)
>    boost state support:
>      Supported: yes
>      Active: no
>
>
> FYI
> And thanks for your support tailoring for my system~!
> David
>
>
>
>
David Wang Aug. 22, 2024, 5:43 a.m. UTC | #3
Hi, 

At 2024-08-22 12:25:49, "Du, Xiaojian" <Xiaojian.Du@amd.com> wrote:
>[AMD Official Use Only - AMD Internal Distribution Only]
>
>Hi David,
>
>I built one test combination: B550 motherboard+ R9-3900X CPU+ 6.10-rc4 kernel.
>On my test machine, amd-pstate driver passive/active mode works after enabling CPPC in BIOS, no code change in amd-pstate.
>My BIOS is updated on 2023 Aug. But no matter CPPC is enabled or not in BIOS, "lscpu" won't show CPPC flag on R9-3900X CPU.
>Any chance to update your BIOS first?
>Noticed your motherboard is "MSI B450M MORTAR MAX", the latest three versions of BIOS are released in 2024 Aug. 21st/2024 Aug. 9th/2023 Oct. 26th.
>https://www.msi.cn/Motherboard/B450M-MORTAR-MAX/support
>
Thanks for the information.   (I did change my BIOS's CPPC config from "auto" to "enable", but error message still.)
But according to   another mail from gautham.shenoy@amd.com,  my understanding is that my CPU(AMD Ryzen 3 3100 4-Core Processor) does not have this CPPC feature,  would upgrade my BIOS really help?
```
    I checked the publicly available PPRs of the Family 17h models 0x60
    (Renoir) [1] and Family 17h model 0x71 (Matisse) [2]. In both these
    PPRs, CPUID 0x80000008 EBX[27] is a reserved bit.
    
    In fact, David reported this issue on Matisse system.
```

Anyway, I will give BIOS upgrading  a try. 

>If this issue is fixed in BIOS, no need to modify the upstream kernel code, right?

I think , even when upgrading BIOS would not help, the quirk just for my system is not worth be in kernel :)......

>
>Thanks,
>Xiaojian
>

Thanks
David
Gautham R. Shenoy Aug. 22, 2024, 5:59 a.m. UTC | #4
Hello David,

On Thu, Aug 22, 2024 at 01:43:12PM +0800, David Wang wrote:
> Hi, 
> >
> Thanks for the information.   (I did change my BIOS's CPPC config from "auto" to "enable", but error message still.)
> But according to   another mail from gautham.shenoy@amd.com,  my understanding is that my CPU(AMD Ryzen 3 3100 4-Core Processor) does not have this CPPC feature,  would upgrade my BIOS really help?
> ```

To clarify,

There are two ways in which the OS can communicate its CPPC
requirements with the platform firmware.

1. Via the following CPPC MSRs

#define MSR_AMD_CPPC_CAP1		0xc00102b0
#define MSR_AMD_CPPC_ENABLE		0xc00102b1
#define MSR_AMD_CPPC_CAP2		0xc00102b2
#define MSR_AMD_CPPC_REQ		0xc00102b3
#define MSR_AMD_CPPC_STATUS		0xc00102b4

2. Via the shared memory mechanism.


The presence of the CPPC MSRs is indicated via X86_FEATURE_CPPC (CPUID
0x80000008.EBX[27]). If available, the amd-pstate driver prefers that
over the shared-memory mechanism.

So the the following warning are intended only for platforms that are
known to have the MSR support, not for the platforms which don't have
the MSR support.

"The CPPC feature is supported but currently disabled by the BIOS.
Please enable it if your BIOS has the CPPC option"

Your platform has CPPC feature (evident from the fact that amd-pstate
worked for you with the BIOS quirk patch), and the amd-pstate driver can
work just as well using the shared-memory mechanism (2 above) as long
as your BIOS supports CPPC v3 (which advertises the nominal frequency
in addition to the nominal perf).

The current version of the BIOS that you are running doesn't seem to
support CPPC v3, which is why the amd-pstate driver won't work
out-of-box. This is why Xiaojian recommended upgrading the BIOS to the
latest version.


> 
> Anyway, I will give BIOS upgrading  a try.

Please do!

> 
> >If this issue is fixed in BIOS, no need to modify the upstream kernel code, right?
> 
> I think , even when upgrading BIOS would not help, the quirk just for my system is not worth be in kernel :)......
>

Fair point. However, in case you prefer to use amd-pstate, know that
this is one way of enabling it, if the BIOS upgrade doesn't help.

> 
> Thanks
> David

--
Thanks and Regards
gautham.
David Wang Aug. 22, 2024, 8:03 a.m. UTC | #5
Hi, 

I just upgrade my BIOS, now the error message is gone(without quirk), I only have following warning:

[Thu Aug 22 15:12:02 2024] amd_pstate: The CPPC feature is supported but currently disabled by the BIOS.
                           Please enable it if your BIOS has the CPPC option.


No significant performance changes noticed yet:

Clean kernel deb package build time is about the same as before:
$ time make deb-pkg  -j6

real	38m50.977s
user	217m5.970s
sys	19m55.164s


And amd-pstate seems working (more accurate than quirks?):

$ cat  /sys/devices/system/cpu/cpufreq/policy0/*amd*
166
enabled
1740000
3905000
176

$ cpupower frequency-info
analyzing CPU 0:
  driver: amd-pstate-epp
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 550 MHz - 3.91 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 550 MHz and 3.91 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.90 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: no


And thanks for all your support!!!

BTW, about the quirks, I still think the dmi-match is not enough, 
CPU family model should also be checked to determine a accurate static quirk_entry.
 
David



At 2024-08-22 13:59:57, "Gautham R. Shenoy" <gautham.shenoy@amd.com> wrote:
>Hello David,
>
>On Thu, Aug 22, 2024 at 01:43:12PM +0800, David Wang wrote:
>> Hi, 
>> >
>> Thanks for the information.   (I did change my BIOS's CPPC config from "auto" to "enable", but error message still.)
>> But according to   another mail from gautham.shenoy@amd.com,  my understanding is that my CPU(AMD Ryzen 3 3100 4-Core Processor) does not have this CPPC feature,  would upgrade my BIOS really help?
>> ```
>
>To clarify,
>
>There are two ways in which the OS can communicate its CPPC
>requirements with the platform firmware.
>
>1. Via the following CPPC MSRs
>
>#define MSR_AMD_CPPC_CAP1		0xc00102b0
>#define MSR_AMD_CPPC_ENABLE		0xc00102b1
>#define MSR_AMD_CPPC_CAP2		0xc00102b2
>#define MSR_AMD_CPPC_REQ		0xc00102b3
>#define MSR_AMD_CPPC_STATUS		0xc00102b4
>
>2. Via the shared memory mechanism.
>
>
>The presence of the CPPC MSRs is indicated via X86_FEATURE_CPPC (CPUID
>0x80000008.EBX[27]). If available, the amd-pstate driver prefers that
>over the shared-memory mechanism.
>
>So the the following warning are intended only for platforms that are
>known to have the MSR support, not for the platforms which don't have
>the MSR support.
>
>"The CPPC feature is supported but currently disabled by the BIOS.
>Please enable it if your BIOS has the CPPC option"
>
>Your platform has CPPC feature (evident from the fact that amd-pstate
>worked for you with the BIOS quirk patch), and the amd-pstate driver can
>work just as well using the shared-memory mechanism (2 above) as long
>as your BIOS supports CPPC v3 (which advertises the nominal frequency
>in addition to the nominal perf).
>
>The current version of the BIOS that you are running doesn't seem to
>support CPPC v3, which is why the amd-pstate driver won't work
>out-of-box. This is why Xiaojian recommended upgrading the BIOS to the
>latest version.
>
>
>> 
>> Anyway, I will give BIOS upgrading  a try.
>
>Please do!
>
>> 
>> >If this issue is fixed in BIOS, no need to modify the upstream kernel code, right?
>> 
>> I think , even when upgrading BIOS would not help, the quirk just for my system is not worth be in kernel :)......
>>
>
>Fair point. However, in case you prefer to use amd-pstate, know that
>this is one way of enabling it, if the BIOS upgrade doesn't help.
>
>> 
>> Thanks
>> David
>
>--
>Thanks and Regards
>gautham.
diff mbox series

Patch

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 68c616b572f2..b39365b980b9 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -142,6 +142,11 @@  static struct quirk_entry quirk_amd_7k62 = {
 	.lowest_freq = 550,
 };
 
+static struct quirk_entry quirk_amd_mts = {
+	.nominal_freq = 3600,
+	.lowest_freq = 550,
+};
+
 static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
 {
 	/**
@@ -158,6 +163,21 @@  static int __init dmi_matched_7k62_bios_bug(const struct dmi_system_id *dmi)
 	return 0;
 }
 
+static int __init dmi_matched_mts_bios_bug(const struct dmi_system_id *dmi)
+{
+	/**
+	 * match the broken bios for ryzen 3000 series processor support CPPC V2
+	 * broken BIOS lack of nominal_freq and lowest_freq capabilities
+	 * definition in ACPI tables
+	 */
+	if (cpu_feature_enabled(X86_FEATURE_ZEN2)) {
+		quirks = dmi->driver_data;
+		pr_info("Overriding nominal and lowest frequencies for %s\n", dmi->ident);
+		return 1;
+	}
+
+	return 0;
+}
 static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
 	{
 		.callback = dmi_matched_7k62_bios_bug,
@@ -168,6 +188,16 @@  static const struct dmi_system_id amd_pstate_quirks_table[] __initconst = {
 		},
 		.driver_data = &quirk_amd_7k62,
 	},
+	{
+		.callback = dmi_matched_mts_bios_bug,
+		.ident = "AMD Ryzen 3000",
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "B450M MORTAR MAX (MS-7B89)"),
+			DMI_MATCH(DMI_BIOS_RELEASE, "06/10/2020"),
+			DMI_MATCH(DMI_BIOS_VERSION, "5.14"),
+		},
+		.driver_data = &quirk_amd_mts,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);