mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>,
	trenn@suse.com, shuah@kernel.org
Cc: ananth.narayan@amd.com, gautham.shenoy@amd.com,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	rafael@kernel.org, Perry.Yuan@amd.com
Subject: Re: [PATCH] tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs
Date: Tue, 30 Apr 2024 12:06:20 -0500	[thread overview]
Message-ID: <13bcd356-a5a0-4cf0-9222-bccc01177032@amd.com> (raw)
In-Reply-To: <20240430083706.69641-1-Dhananjay.Ugwekar@amd.com>

On 4/30/2024 03:37, Dhananjay Ugwekar wrote:
> Update cpupower's P-State frequency calculation and reporting with AMD
> Family 1Ah+ processors, when using the acpi-cpufreq driver. This is due
> to a change in the PStateDef MSR layout in AMD Family 1Ah+.
> 
> [ dhananjay: commit log, tested on 4th and 5th Gen AMD EPYC system ]
> 
> Signed-off-by: Ananth Narayan <Ananth.Narayan@amd.com>
> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   tools/power/cpupower/utils/helpers/amd.c | 26 +++++++++++++++++++++---
>   1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c
> index c519cc89c97f..0a56e22240fc 100644
> --- a/tools/power/cpupower/utils/helpers/amd.c
> +++ b/tools/power/cpupower/utils/helpers/amd.c
> @@ -41,6 +41,16 @@ union core_pstate {
>   		unsigned res1:31;
>   		unsigned en:1;
>   	} pstatedef;
> +	/* since fam 1Ah: */
> +	struct {
> +		unsigned fid:12;
> +		unsigned res1:2;
> +		unsigned vid:8;
> +		unsigned iddval:8;
> +		unsigned idddiv:2;
> +		unsigned res2:31;
> +		unsigned en:1;
> +	} pstatedef2;
>   	unsigned long long val;
>   };
>   
> @@ -48,6 +58,10 @@ static int get_did(union core_pstate pstate)
>   {
>   	int t;
>   
> +	/* Fam 1Ah onward do not use did */
> +	if (cpupower_cpu_info.family >= 0x1A)
> +		return 0;
> +
>   	if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF)
>   		t = pstate.pstatedef.did;
>   	else if (cpupower_cpu_info.family == 0x12)
> @@ -61,12 +75,18 @@ static int get_did(union core_pstate pstate)
>   static int get_cof(union core_pstate pstate)
>   {
>   	int t;
> -	int fid, did, cof;
> +	int fid, did, cof = 0;
>   
>   	did = get_did(pstate);
>   	if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) {
> -		fid = pstate.pstatedef.fid;
> -		cof = 200 * fid / did;
> +		if (cpupower_cpu_info.family >= 0x1A) {
> +			fid = pstate.pstatedef2.fid;
> +			if (fid > 0x0f)
> +				cof = (fid * 5);
> +		} else {
> +			fid = pstate.pstatedef.fid;
> +			cof = 200 * fid / did;
> +		}
>   	} else {
>   		t = 0x10;
>   		fid = pstate.pstate.fid;


  reply	other threads:[~2024-04-30 17:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30  8:37 Dhananjay Ugwekar
2024-04-30 17:06 ` Mario Limonciello [this message]
2024-05-02 15:41   ` Shuah Khan

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=13bcd356-a5a0-4cf0-9222-bccc01177032@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Dhananjay.Ugwekar@amd.com \
    --cc=Perry.Yuan@amd.com \
    --cc=ananth.narayan@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=shuah@kernel.org \
    --cc=trenn@suse.com \
    /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

all inboxes | Powered by JetHome®