amd-pstate content for 6.19 (11/10/25)

* optimizations for parameter array handling
 * fix for mode changes with offline CPUs
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEECwtuSU6dXvs5GA2aLRkspiR3AnYFAmkSy/cTHHN1cGVybTFA
 a2VybmVsLm9yZwAKCRAtGSymJHcCdqSlD/4nv4PXetfH2Sul/ivGX9tWbGEMBxtD
 iVOGPmeVVDKEkUyptBbIMbN7elWz5BN6VF0EM3FGD2IZcwYDhPRAENoZeotl9isS
 QRgl8427M3UgZ3FbX7QU+SCZRbU6wmuTSxR9mlXtmuVpJ+QQT4BzYXFh0Jcxg9Mp
 6XrL5WFZtzSPrW5RnN/NUm26A+qRwIRZuRTAhxVV9K9Vd6ZlEq7/B+hTrlIz1GW4
 XqSlGnoOQTTTpIlUXlQTtYsn9bquqb+YoPpvEbme7LCWWOxIr9GrETrQ4Yj2ljW6
 cnHvFM1ky2Ld6+yfOMwAdS9aiSgcBtWD41UTxHecVVJyOVNXrw+yOxIpT9K8poWy
 2/iy8qlBz2z5q9VC2ZOM2GNDGlfoiSdKlZpFV8A3O9nb/ZTTKgwN782aycSHMNGC
 5Mj95tgaP00/TU6SIGHyaTg934vn9wnumzVb+cXjLNR35vQU8zfX24ER/Fo4lLSq
 ntTDo1byjCAKi78Ghp0Zlh3wqcWN1cKguqTZ04IRWB5I/D+NoYQvDldm8LGrUkpW
 YS11TxOMupuHFV5Jp7hraJeZDQB7/3wha15SdNUaOaMm+Bb++9zZj7tNAmW0sEz9
 291REgM5Iba1CPK7YGE/4/xtq0nVRzlK4PB2PDJxcTZfbqteiJfeR+9788vWVRIk
 QJIwYJ4sprrlVA==
 =zQeO
 -----END PGP SIGNATURE-----

Merge tag 'amd-pstate-v6.19-2025-11-10' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux

Pull amd-pstate content for 6.19 (11/10/25) from Mario Liminciello:

"* optimizations for parameter array handling
 * fix for mode changes with offline CPUs"

* tag 'amd-pstate-v6.19-2025-11-10' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux:
  cpufreq/amd-pstate: Call cppc_set_auto_sel() only for online CPUs
  cpufreq/amd-pstate: Add static asserts for EPP indices
  cpufreq/amd-pstate: Fix some whitespace issues
  cpufreq/amd-pstate: Adjust return values in amd_pstate_update_status()
  cpufreq/amd-pstate: Make amd_pstate_get_mode_string() never return NULL
  cpufreq/amd-pstate: Drop NULL value from amd_pstate_mode_string
  cpufreq/amd-pstate: Use sysfs_match_string() for epp
This commit is contained in:
Rafael J. Wysocki 2025-11-12 20:51:53 +01:00
commit 25ca66300a

View File

@ -65,13 +65,13 @@ static const char * const amd_pstate_mode_string[] = {
[AMD_PSTATE_PASSIVE] = "passive",
[AMD_PSTATE_ACTIVE] = "active",
[AMD_PSTATE_GUIDED] = "guided",
NULL,
};
static_assert(ARRAY_SIZE(amd_pstate_mode_string) == AMD_PSTATE_MAX);
const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode)
{
if (mode < 0 || mode >= AMD_PSTATE_MAX)
return NULL;
if (mode < AMD_PSTATE_UNDEFINED || mode >= AMD_PSTATE_MAX)
mode = AMD_PSTATE_UNDEFINED;
return amd_pstate_mode_string[mode];
}
EXPORT_SYMBOL_GPL(amd_pstate_get_mode_string);
@ -110,6 +110,7 @@ enum energy_perf_value_index {
EPP_INDEX_BALANCE_PERFORMANCE,
EPP_INDEX_BALANCE_POWERSAVE,
EPP_INDEX_POWERSAVE,
EPP_INDEX_MAX,
};
static const char * const energy_perf_strings[] = {
@ -118,8 +119,8 @@ static const char * const energy_perf_strings[] = {
[EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance",
[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
[EPP_INDEX_POWERSAVE] = "power",
NULL
};
static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX);
static unsigned int epp_values[] = {
[EPP_INDEX_DEFAULT] = 0,
@ -127,7 +128,8 @@ static unsigned int epp_values[] = {
[EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_BALANCE_PERFORMANCE,
[EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE,
[EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE,
};
};
static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX);
typedef int (*cppc_mode_transition_fn)(int);
@ -183,7 +185,7 @@ static inline int get_mode_idx_from_str(const char *str, size_t size)
{
int i;
for (i=0; i < AMD_PSTATE_MAX; i++) {
for (i = 0; i < AMD_PSTATE_MAX; i++) {
if (!strncmp(str, amd_pstate_mode_string[i], size))
return i;
}
@ -1137,16 +1139,15 @@ static ssize_t show_amd_pstate_hw_prefcore(struct cpufreq_policy *policy,
static ssize_t show_energy_performance_available_preferences(
struct cpufreq_policy *policy, char *buf)
{
int i = 0;
int offset = 0;
int offset = 0, i;
struct amd_cpudata *cpudata = policy->driver_data;
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
return sysfs_emit_at(buf, offset, "%s\n",
energy_perf_strings[EPP_INDEX_PERFORMANCE]);
while (energy_perf_strings[i] != NULL)
offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i++]);
for (i = 0; i < ARRAY_SIZE(energy_perf_strings); i++)
offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i]);
offset += sysfs_emit_at(buf, offset, "\n");
@ -1157,15 +1158,10 @@ static ssize_t store_energy_performance_preference(
struct cpufreq_policy *policy, const char *buf, size_t count)
{
struct amd_cpudata *cpudata = policy->driver_data;
char str_preference[21];
ssize_t ret;
u8 epp;
ret = sscanf(buf, "%20s", str_preference);
if (ret != 1)
return -EINVAL;
ret = match_string(energy_perf_strings, -1, str_preference);
ret = sysfs_match_string(energy_perf_strings, buf);
if (ret < 0)
return -EINVAL;
@ -1282,7 +1278,7 @@ static int amd_pstate_change_mode_without_dvr_change(int mode)
if (cpu_feature_enabled(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE)
return 0;
for_each_present_cpu(cpu) {
for_each_online_cpu(cpu) {
cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1);
}
@ -1353,9 +1349,8 @@ int amd_pstate_update_status(const char *buf, size_t size)
return -EINVAL;
mode_idx = get_mode_idx_from_str(buf, size);
if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX)
return -EINVAL;
if (mode_idx < 0)
return mode_idx;
if (mode_state_machine[cppc_state][mode_idx]) {
guard(mutex)(&amd_pstate_driver_lock);