Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+15 -20
+15 -20
drivers/cpufreq/amd-pstate.c
··· 65 65 [AMD_PSTATE_PASSIVE] = "passive", 66 66 [AMD_PSTATE_ACTIVE] = "active", 67 67 [AMD_PSTATE_GUIDED] = "guided", 68 - NULL, 69 68 }; 69 + static_assert(ARRAY_SIZE(amd_pstate_mode_string) == AMD_PSTATE_MAX); 70 70 71 71 const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode) 72 72 { 73 - if (mode < 0 || mode >= AMD_PSTATE_MAX) 74 - return NULL; 73 + if (mode < AMD_PSTATE_UNDEFINED || mode >= AMD_PSTATE_MAX) 74 + mode = AMD_PSTATE_UNDEFINED; 75 75 return amd_pstate_mode_string[mode]; 76 76 } 77 77 EXPORT_SYMBOL_GPL(amd_pstate_get_mode_string); ··· 110 110 EPP_INDEX_BALANCE_PERFORMANCE, 111 111 EPP_INDEX_BALANCE_POWERSAVE, 112 112 EPP_INDEX_POWERSAVE, 113 + EPP_INDEX_MAX, 113 114 }; 114 115 115 116 static const char * const energy_perf_strings[] = { ··· 119 118 [EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance", 120 119 [EPP_INDEX_BALANCE_POWERSAVE] = "balance_power", 121 120 [EPP_INDEX_POWERSAVE] = "power", 122 - NULL 123 121 }; 122 + static_assert(ARRAY_SIZE(energy_perf_strings) == EPP_INDEX_MAX); 124 123 125 124 static unsigned int epp_values[] = { 126 125 [EPP_INDEX_DEFAULT] = 0, ··· 128 127 [EPP_INDEX_BALANCE_PERFORMANCE] = AMD_CPPC_EPP_BALANCE_PERFORMANCE, 129 128 [EPP_INDEX_BALANCE_POWERSAVE] = AMD_CPPC_EPP_BALANCE_POWERSAVE, 130 129 [EPP_INDEX_POWERSAVE] = AMD_CPPC_EPP_POWERSAVE, 131 - }; 130 + }; 131 + static_assert(ARRAY_SIZE(epp_values) == EPP_INDEX_MAX); 132 132 133 133 typedef int (*cppc_mode_transition_fn)(int); 134 134 ··· 185 183 { 186 184 int i; 187 185 188 - for (i=0; i < AMD_PSTATE_MAX; i++) { 186 + for (i = 0; i < AMD_PSTATE_MAX; i++) { 189 187 if (!strncmp(str, amd_pstate_mode_string[i], size)) 190 188 return i; 191 189 } ··· 1139 1137 static ssize_t show_energy_performance_available_preferences( 1140 1138 struct cpufreq_policy *policy, char *buf) 1141 1139 { 1142 - int i = 0; 1143 - int offset = 0; 1140 + int offset = 0, i; 1144 1141 struct amd_cpudata *cpudata = policy->driver_data; 1145 1142 1146 1143 if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) 1147 1144 return sysfs_emit_at(buf, offset, "%s\n", 1148 1145 energy_perf_strings[EPP_INDEX_PERFORMANCE]); 1149 1146 1150 - while (energy_perf_strings[i] != NULL) 1151 - offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i++]); 1147 + for (i = 0; i < ARRAY_SIZE(energy_perf_strings); i++) 1148 + offset += sysfs_emit_at(buf, offset, "%s ", energy_perf_strings[i]); 1152 1149 1153 1150 offset += sysfs_emit_at(buf, offset, "\n"); 1154 1151 ··· 1158 1157 struct cpufreq_policy *policy, const char *buf, size_t count) 1159 1158 { 1160 1159 struct amd_cpudata *cpudata = policy->driver_data; 1161 - char str_preference[21]; 1162 1160 ssize_t ret; 1163 1161 u8 epp; 1164 1162 1165 - ret = sscanf(buf, "%20s", str_preference); 1166 - if (ret != 1) 1167 - return -EINVAL; 1168 - 1169 - ret = match_string(energy_perf_strings, -1, str_preference); 1163 + ret = sysfs_match_string(energy_perf_strings, buf); 1170 1164 if (ret < 0) 1171 1165 return -EINVAL; 1172 1166 ··· 1278 1282 if (cpu_feature_enabled(X86_FEATURE_CPPC) || cppc_state == AMD_PSTATE_ACTIVE) 1279 1283 return 0; 1280 1284 1281 - for_each_present_cpu(cpu) { 1285 + for_each_online_cpu(cpu) { 1282 1286 cppc_set_auto_sel(cpu, (cppc_state == AMD_PSTATE_PASSIVE) ? 0 : 1); 1283 1287 } 1284 1288 ··· 1349 1353 return -EINVAL; 1350 1354 1351 1355 mode_idx = get_mode_idx_from_str(buf, size); 1352 - 1353 - if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX) 1354 - return -EINVAL; 1356 + if (mode_idx < 0) 1357 + return mode_idx; 1355 1358 1356 1359 if (mode_state_machine[cppc_state][mode_idx]) { 1357 1360 guard(mutex)(&amd_pstate_driver_lock);