linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yuan, Perry" <Perry.Yuan@amd.com>
To: "Limonciello, Mario" <Mario.Limonciello@amd.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>, "Huang, Ray" <Ray.Huang@amd.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"Shenoy, Gautham Ranjal" <gautham.shenoy@amd.com>,
	"Karny, Wyes" <Wyes.Karny@amd.com>
Subject: RE: [PATCH v3 2/3] cpufreq: amd-pstate: Set a fallback policy based on preferred_profile
Date: Wed, 21 Jun 2023 04:25:04 +0000	[thread overview]
Message-ID: <CYYPR12MB8655DF3FCF6714BAC247287E9C5DA@CYYPR12MB8655.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20230620172433.21325-3-mario.limonciello@amd.com>

[AMD Official Use Only - General]

> -----Original Message-----
> From: Limonciello, Mario <Mario.Limonciello@amd.com>
> Sent: Wednesday, June 21, 2023 1:25 AM
> To: Rafael J . Wysocki <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>; Huang, Ray <Ray.Huang@amd.com>;
> linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> pm@vger.kernel.org; Shenoy, Gautham Ranjal
> <gautham.shenoy@amd.com>; Karny, Wyes <Wyes.Karny@amd.com>;
> Yuan, Perry <Perry.Yuan@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>
> Subject: [PATCH v3 2/3] cpufreq: amd-pstate: Set a fallback policy based on
> preferred_profile
>
> If a user's configuration doesn't explicitly specify the cpufreq scaling governor
> then the code currently explicitly falls back to 'powersave'. This default is fine
> for notebooks and desktops, but servers and undefined machines should
> default to 'performance'.
>
> Look at the 'preferred_profile' field from the FADT to set this policy
> accordingly.
>
> Link:
> https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/05_ACPI_Software_Progr
> amming_Model/ACPI_Software_Programming_Model.html#fixed-acpi-
> description-table-fadt
> Acked-by: Huang Rui <ray.huang@amd.com>
> Suggested-by: Wyes Karny <Wyes.Karny@amd.com>
> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v2->v3:
>  * Move new symbols out of patch 1 into this patch
>  * Add Ray's tag
> ---
>  drivers/cpufreq/amd-pstate.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index d8269994322e..3546d7db614d 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1071,6 +1071,26 @@ static const struct attribute_group
> amd_pstate_global_attr_group = {
>       .attrs = pstate_global_attributes,
>  };
>
> +static bool amd_pstate_acpi_pm_profile_server(void)
> +{
> +     switch (acpi_gbl_FADT.preferred_profile) {
> +     case PM_ENTERPRISE_SERVER:
> +     case PM_SOHO_SERVER:
> +     case PM_PERFORMANCE_SERVER:
> +             return true;
> +     }
> +     return false;
> +}
> +
> +static bool amd_pstate_acpi_pm_profile_undefined(void)
> +{
> +     if (acpi_gbl_FADT.preferred_profile == PM_UNSPECIFIED)
> +             return true;
> +     if (acpi_gbl_FADT.preferred_profile >= NR_PM_PROFILES)
> +             return true;
> +     return false;
> +}
> +
>  static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)  {
>       int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
> @@ -1128,10 +1148,14 @@ static int amd_pstate_epp_cpu_init(struct
> cpufreq_policy *policy)
>       policy->max = policy->cpuinfo.max_freq;
>
>       /*
> -      * Set the policy to powersave to provide a valid fallback value in case
> +      * Set the policy to provide a valid fallback value in case
>        * the default cpufreq governor is neither powersave nor
> performance.
>        */
> -     policy->policy = CPUFREQ_POLICY_POWERSAVE;
> +     if (amd_pstate_acpi_pm_profile_server() ||
> +         amd_pstate_acpi_pm_profile_undefined())
> +             policy->policy = CPUFREQ_POLICY_PERFORMANCE;
> +     else
> +             policy->policy = CPUFREQ_POLICY_POWERSAVE;
>
>       if (boot_cpu_has(X86_FEATURE_CPPC)) {
>               ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ,
> &value);
> --
> 2.34.1
Reviewed-by: Perry Yuan <Perry.Yuan@amd.com>

  reply	other threads:[~2023-06-21  4:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 17:24 [PATCH v3 0/3] Enable amd-pstate active mode by default Mario Limonciello
2023-06-20 17:24 ` [PATCH v3 1/3] ACPI: CPPC: Add definition for undefined FADT preferred PM profile value Mario Limonciello
2023-06-21  4:23   ` Yuan, Perry
2023-06-20 17:24 ` [PATCH v3 2/3] cpufreq: amd-pstate: Set a fallback policy based on preferred_profile Mario Limonciello
2023-06-21  4:25   ` Yuan, Perry [this message]
2023-06-20 17:24 ` [PATCH v3 3/3] cpufreq: amd-pstate: Add a kernel config option to set default mode Mario Limonciello
2023-06-21 17:38 ` [PATCH v3 0/3] Enable amd-pstate active mode by default Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CYYPR12MB8655DF3FCF6714BAC247287E9C5DA@CYYPR12MB8655.namprd12.prod.outlook.com \
    --to=perry.yuan@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=Wyes.Karny@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).