lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <CYYPR12MB8655F08276F5482A321562409C442@CYYPR12MB8655.namprd12.prod.outlook.com>
Date: Thu, 8 Feb 2024 03:58:29 +0000
From: "Yuan, Perry" <Perry.Yuan@....com>
To: "Limonciello, Mario" <Mario.Limonciello@....com>,
	"rafael.j.wysocki@...el.com" <rafael.j.wysocki@...el.com>,
	"viresh.kumar@...aro.org" <viresh.kumar@...aro.org>, "Huang, Ray"
	<Ray.Huang@....com>, "Shenoy, Gautham Ranjal" <gautham.shenoy@....com>,
	"Petkov, Borislav" <Borislav.Petkov@....com>
CC: "Deucher, Alexander" <Alexander.Deucher@....com>, "Huang, Shimmer"
	<Shimmer.Huang@....com>, "Du, Xiaojian" <Xiaojian.Du@....com>, "Meng, Li
 (Jassmine)" <Li.Meng@....com>, "linux-pm@...r.kernel.org"
	<linux-pm@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v5 6/6] cpufreq:amd-pstate: add quirk for the pstate CPPC
 capabilities missing

[AMD Official Use Only - General]

 Hi Mario

> -----Original Message-----
> From: Limonciello, Mario <Mario.Limonciello@....com>
> Sent: Thursday, February 8, 2024 4:58 AM
> To: Yuan, Perry <Perry.Yuan@....com>; rafael.j.wysocki@...el.com;
> viresh.kumar@...aro.org; Huang, Ray <Ray.Huang@....com>; Shenoy,
> Gautham Ranjal <gautham.shenoy@....com>; Petkov, Borislav
> <Borislav.Petkov@....com>
> Cc: Deucher, Alexander <Alexander.Deucher@....com>; Huang, Shimmer
> <Shimmer.Huang@....com>; Du, Xiaojian <Xiaojian.Du@....com>; Meng,
> Li (Jassmine) <Li.Meng@....com>; linux-pm@...r.kernel.org; linux-
> kernel@...r.kernel.org
> Subject: Re: [PATCH v5 6/6] cpufreq:amd-pstate: add quirk for the pstate
> CPPC capabilities missing
>
> On 2/6/2024 20:46, Perry Yuan wrote:
> > Add quirks table to get CPPC capabilities issue fixed by providing
> > correct perf or frequency values while driver loading.
> >
> > If CPPC capabilities are not defined in the ACPI tables or wrongly
> > defined by platform firmware, it needs to use quick to get those
> > issues fixed with correct workaround values to make pstate driver can
> > be loaded even though there are CPPC capabilities errors.
> >
> > The workaround will match the broken BIOS which lack of CPPC
> > capabilities nominal_freq and lowest_freq definition in the ACPI table.
> >
> > $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/lowest_freq
> > 0
> > $ cat /sys/devices/system/cpu/cpu0/acpi_cppc/nominal_freq
> > 0
> >
> > Signed-off-by: Perry Yuan <perry.yuan@....com>
> Reviewed-by: Mario Limonciello <mario.limonciello@....com>

Thank you help to review the patchset.
As the quirk is not only added for CPPC v2 support but also we can use it to fix other CPPC problems, it makes sense to implement it in this series.

Hi Gautham,
The frequency table support will be in next improvement items we can make if it is workable,  as the quick support for end user, the quirk table
Is a good way to release in short term.

Perry.

> > ---
> >   drivers/cpufreq/amd-pstate.c | 57
> ++++++++++++++++++++++++++++++++++--
> >   include/linux/amd-pstate.h   |  6 ++++
> >   2 files changed, 61 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c
> > b/drivers/cpufreq/amd-pstate.c index 77effc3caf6c..ff4727c22dce 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -67,6 +67,7 @@ static struct cpufreq_driver amd_pstate_epp_driver;
> >   static int cppc_state = AMD_PSTATE_UNDEFINED;
> >   static bool cppc_enabled;
> >   static bool amd_pstate_prefcore = true;
> > +static struct quirk_entry *quirks;
> >
> >   /*
> >    * AMD Energy Preference Performance (EPP) @@ -111,6 +112,41 @@
> > static unsigned int epp_values[] = {
> >
> >   typedef int (*cppc_mode_transition_fn)(int);
> >
> > +static struct quirk_entry quirk_amd_7k62 = {
> > +   .nominal_freq = 2600,
> > +   .lowest_freq = 550,
> > +};
> > +
> > +static int __init dmi_matched_7k62_bios_bug(const struct
> > +dmi_system_id *dmi) {
> > +   /**
> > +    * match the broken bios for family 17h processor support CPPC V2
> > +    * broken BIOS lack of nominal_freq and lowest_freq capabilities
> > +    * definition in ACPI tables
> > +    */
> > +   if (boot_cpu_has(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,
> > +           .ident = "AMD EPYC 7K62",
> > +           .matches = {
> > +                   DMI_MATCH(DMI_BIOS_VERSION, "5.14"),
> > +                   DMI_MATCH(DMI_BIOS_RELEASE, "12/12/2019"),
> > +           },
> > +           .driver_data = &quirk_amd_7k62,
> > +   },
> > +   {}
> > +};
> > +MODULE_DEVICE_TABLE(dmi, amd_pstate_quirks_table);
> > +
> >   static inline int get_mode_idx_from_str(const char *str, size_t size)
> >   {
> >     int i;
> > @@ -600,13 +636,19 @@ static void amd_pstate_adjust_perf(unsigned int
> cpu,
> >   static int amd_get_min_freq(struct amd_cpudata *cpudata)
> >   {
> >     struct cppc_perf_caps cppc_perf;
> > +   u32 lowest_freq;
> >
> >     int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> >     if (ret)
> >             return ret;
> >
> > +   if (quirks && quirks->lowest_freq)
> > +           lowest_freq = quirks->lowest_freq;
> > +   else
> > +           lowest_freq = cppc_perf.lowest_freq;
> > +
> >     /* Switch to khz */
> > -   return cppc_perf.lowest_freq * 1000;
> > +   return lowest_freq * 1000;
> >   }
> >
> >   static int amd_get_max_freq(struct amd_cpudata *cpudata) @@ -635,12
> > +677,18 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata)
> >   static int amd_get_nominal_freq(struct amd_cpudata *cpudata)
> >   {
> >     struct cppc_perf_caps cppc_perf;
> > +   u32 nominal_freq;
> >
> >     int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> >     if (ret)
> >             return ret;
> >
> > -   return cppc_perf.nominal_freq;
> > +   if (quirks && quirks->nominal_freq)
> > +           nominal_freq = quirks->nominal_freq;
> > +   else
> > +           nominal_freq = cppc_perf.nominal_freq;
> > +
> > +   return nominal_freq;
> >   }
> >
> >   static int amd_get_lowest_nonlinear_freq(struct amd_cpudata
> > *cpudata) @@ -1672,6 +1720,11 @@ static int __init amd_pstate_init(void)
> >     if (cpufreq_get_current_driver())
> >             return -EEXIST;
> >
> > +   quirks = NULL;
> > +
> > +   /* check if this machine need CPPC quirks */
> > +   dmi_check_system(amd_pstate_quirks_table);
> > +
> >     switch (cppc_state) {
> >     case AMD_PSTATE_UNDEFINED:
> >             /* Disable on the following configs by default:
> > diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h
> > index d21838835abd..7b2cbb892fd9 100644
> > --- a/include/linux/amd-pstate.h
> > +++ b/include/linux/amd-pstate.h
> > @@ -124,4 +124,10 @@ static const char * const
> amd_pstate_mode_string[] = {
> >     [AMD_PSTATE_GUIDED]      = "guided",
> >     NULL,
> >   };
> > +
> > +struct quirk_entry {
> > +   u32 nominal_freq;
> > +   u32 lowest_freq;
> > +};
> > +
> >   #endif /* _LINUX_AMD_PSTATE_H */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ