mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: "Mario Limonciello (AMD)" <superm1@kernel.org>
Cc: Perry Yuan <perry.yuan@amd.com>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<linux-kernel@vger.kernel.org>,
	"open list:CPU FREQUENCY SCALING FRAMEWORK"
	<linux-pm@vger.kernel.org>, Vishal Badole <Vishal.Badole@amd.com>,
	Richard Gong <Richard.Gong@amd.com>
Subject: Re: [PATCH v2 1/3] cpufreq/amd-pstate: Add per SoC and per core type EPP tuning values
Date: Tue, 8 Sep 2026 11:49:48 +0530	[thread overview]
Message-ID: <eadc9b88-534c-4a49-b2a5-c2d9ffcf569a@amd.com> (raw)
In-Reply-To: <20260908041935.402116-2-superm1@kernel.org>

Hello Mario,

On 9/8/2026 9:49 AM, Mario Limonciello (AMD) wrote:
> +/*
> + * The numeric EPP value programmed for each named preference. First dimension
> + * is CPU type (TOPO_CPU_TYPE_ANY for non-hybrid, TOPO_CPU_TYPE_PERFORMANCE/
> + * EFFICIENCY/LOW_POWER for hybrid). The initializer holds the legacy values
> + * used as the fallback on any platform not listed in amd_pstate_epp_soc_ids[];
> + * amd_pstate_init_epp_values() overwrites slots at boot when the running SoC
> + * has a per-SoC (and potentially per-CPU-type) override.
> + */
> +static u8 epp_values[][EPP_INDEX_MAX] = {
> +	[TOPO_CPU_TYPE_ANY] = {
> +		[EPP_INDEX_DEFAULT] = 0,
> +		[EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_BALANCE_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_LEGACY_BALANCE_POWERSAVE,
> +		[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_LEGACY_POWERSAVE,
> +	},
> +	[TOPO_CPU_TYPE_PERFORMANCE] = {
> +		[EPP_INDEX_DEFAULT] = 0,
> +		[EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_BALANCE_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_LEGACY_BALANCE_POWERSAVE,
> +		[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_LEGACY_POWERSAVE,
> +	},
> +	[TOPO_CPU_TYPE_EFFICIENCY] = {
> +		[EPP_INDEX_DEFAULT] = 0,
> +		[EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_BALANCE_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_LEGACY_BALANCE_POWERSAVE,
> +		[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_LEGACY_POWERSAVE,
> +	},
> +	[TOPO_CPU_TYPE_LOW_POWER] = {
> +		[EPP_INDEX_DEFAULT] = 0,
> +		[EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_BALANCE_PERFORMANCE,
> +		[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_LEGACY_BALANCE_POWERSAVE,
> +		[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_LEGACY_POWERSAVE,
> +	},
> +};

If my eyes aren't decieveing me, all the indices are initialized to same
value so we can perhaps do:

    static u8 epp_values[][EPP_INDEX_MAX] = {
        /*
         * Initialize all CPU types to legacy defaults.
         * amd_pstate_init_epp_values() will fix these up
         * based on the platform during boot.
	 */
        [TOPO_CPU_TYPE_ANY ... TOPO_CPU_TYPE_LOW_POWER] = {
            [EPP_INDEX_DEFAULT] = 0,
            [EPP_INDEX_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_PERFORMANCE,
            [EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_LEGACY_BALANCE_PERFORMANCE,
            [EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_LEGACY_BALANCE_POWERSAVE,
            [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_LEGACY_POWERSAVE,
        },
    };

> +static_assert(ARRAY_SIZE(epp_values) == TOPO_CPU_TYPE_LOW_POWER + 1,
> +	      "epp_values must have entries for all CPU types up to TOPO_CPU_TYPE_LOW_POWER");
> +
> +/*
> + * Get the EPP value row for a given CPU, accounting for hybrid CPU types.
> + * Non-hybrid systems use TOPO_CPU_TYPE_ANY; hybrid systems use the CPU's
> + * actual type (PERFORMANCE/EFFICIENCY/LOW_POWER).
> + */
> +static inline u8 *amd_pstate_cpu_epp_values(int cpu)
> +{
> +	enum x86_topology_cpu_type type = cpu_data(cpu).topo.cpu_type;

Can we cache this in cpudata to avoid an additional dereference?

> +

I would prefer a:

    if (!cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
        return epp_values[TOPO_CPU_TYPE_ANY];

here to avoid the branches for non-heterogenoeus platforms.

> +	if (type == TOPO_CPU_TYPE_PERFORMANCE ||
> +	    type == TOPO_CPU_TYPE_EFFICIENCY ||
> +	    type == TOPO_CPU_TYPE_LOW_POWER)
> +		return epp_values[type];
> +
> +	return epp_values[TOPO_CPU_TYPE_ANY];

A switch case might look prettier ;-)

> +}
-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-09-08  6:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  4:19 [PATCH v2 0/3] Add support for Zen 6 client EPP tunings Mario Limonciello (AMD)
2026-09-08  4:19 ` [PATCH v2 1/3] cpufreq/amd-pstate: Add per SoC and per core type EPP tuning values Mario Limonciello (AMD)
2026-09-08  6:19   ` K Prateek Nayak [this message]
2026-09-08 19:38     ` Mario Limonciello
2026-09-08  4:19 ` [PATCH v2 2/3] cpufreq/amd-pstate: Add EPP tunings for Zen6 client platforms Mario Limonciello (AMD)
2026-09-08  4:19 ` [PATCH v2 3/3] cpufreq/amd-pstate: Show a warning if missing EPP tunings Mario Limonciello (AMD)

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=eadc9b88-534c-4a49-b2a5-c2d9ffcf569a@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=Richard.Gong@amd.com \
    --cc=Vishal.Badole@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=perry.yuan@amd.com \
    --cc=superm1@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

all inboxes | Powered by JetHome®