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

cpufreq: powernv: Add boost files to export ultra-turbo frequencies

In P8+, Workload Optimized Frequency(WOF) provides the capability to
boost the cpu frequency based on the utilization of the other cpus
running in the chip. The On-Chip-Controller(OCC) firmware will control
the achievability of these frequencies depending on the power headroom
available in the chip. Currently the ultra-turbo frequencies provided
by this feature are exported along with the turbo and sub-turbo
frequencies as scaling_available_frequencies. This patch will export
the ultra-turbo frequencies separately as scaling_boost_frequencies in
WOF enabled systems. This patch will add the boost sysfs file which
can be used to disable/enable ultra-turbo frequencies.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Shilpasri G Bhat and committed by
Rafael J. Wysocki
b12f7a2b 7de962c0

+48 -4
+48 -4
drivers/cpufreq/powernv-cpufreq.c
··· 144 144 unsigned int max; 145 145 unsigned int nominal; 146 146 unsigned int nr_pstates; 147 + bool wof_enabled; 147 148 } powernv_pstate_info; 148 149 149 150 /* Use following macros for conversions between pstate_id and index */ ··· 204 203 const __be32 *pstate_ids, *pstate_freqs; 205 204 u32 len_ids, len_freqs; 206 205 u32 pstate_min, pstate_max, pstate_nominal; 206 + u32 pstate_turbo, pstate_ultra_turbo; 207 207 208 208 power_mgt = of_find_node_by_path("/ibm,opal/power-mgt"); 209 209 if (!power_mgt) { ··· 227 225 pr_warn("ibm,pstate-nominal not found\n"); 228 226 return -ENODEV; 229 227 } 228 + 229 + if (of_property_read_u32(power_mgt, "ibm,pstate-ultra-turbo", 230 + &pstate_ultra_turbo)) { 231 + powernv_pstate_info.wof_enabled = false; 232 + goto next; 233 + } 234 + 235 + if (of_property_read_u32(power_mgt, "ibm,pstate-turbo", 236 + &pstate_turbo)) { 237 + powernv_pstate_info.wof_enabled = false; 238 + goto next; 239 + } 240 + 241 + if (pstate_turbo == pstate_ultra_turbo) 242 + powernv_pstate_info.wof_enabled = false; 243 + else 244 + powernv_pstate_info.wof_enabled = true; 245 + 246 + next: 230 247 pr_info("cpufreq pstate min %d nominal %d max %d\n", pstate_min, 231 248 pstate_nominal, pstate_max); 249 + pr_info("Workload Optimized Frequency is %s in the platform\n", 250 + (powernv_pstate_info.wof_enabled) ? "enabled" : "disabled"); 232 251 233 252 pstate_ids = of_get_property(power_mgt, "ibm,pstate-ids", &len_ids); 234 253 if (!pstate_ids) { ··· 291 268 powernv_pstate_info.nominal = i; 292 269 else if (id == pstate_min) 293 270 powernv_pstate_info.min = i; 271 + 272 + if (powernv_pstate_info.wof_enabled && id == pstate_turbo) { 273 + int j; 274 + 275 + for (j = i - 1; j >= (int)powernv_pstate_info.max; j--) 276 + powernv_freqs[j].flags = CPUFREQ_BOOST_FREQ; 277 + } 294 278 } 295 279 296 280 /* End of list marker entry */ ··· 335 305 struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq = 336 306 __ATTR_RO(cpuinfo_nominal_freq); 337 307 308 + #define SCALING_BOOST_FREQS_ATTR_INDEX 2 309 + 338 310 static struct freq_attr *powernv_cpu_freq_attr[] = { 339 311 &cpufreq_freq_attr_scaling_available_freqs, 340 312 &cpufreq_freq_attr_cpuinfo_nominal_freq, 313 + &cpufreq_freq_attr_scaling_boost_freqs, 341 314 NULL, 342 315 }; 343 316 ··· 1046 1013 register_reboot_notifier(&powernv_cpufreq_reboot_nb); 1047 1014 opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb); 1048 1015 1049 - rc = cpufreq_register_driver(&powernv_cpufreq_driver); 1050 - if (!rc) 1051 - return 0; 1016 + if (powernv_pstate_info.wof_enabled) 1017 + powernv_cpufreq_driver.boost_enabled = true; 1018 + else 1019 + powernv_cpu_freq_attr[SCALING_BOOST_FREQS_ATTR_INDEX] = NULL; 1052 1020 1053 - pr_info("Failed to register the cpufreq driver (%d)\n", rc); 1021 + rc = cpufreq_register_driver(&powernv_cpufreq_driver); 1022 + if (rc) { 1023 + pr_info("Failed to register the cpufreq driver (%d)\n", rc); 1024 + goto cleanup_notifiers; 1025 + } 1026 + 1027 + if (powernv_pstate_info.wof_enabled) 1028 + cpufreq_enable_boost_support(); 1029 + 1030 + return 0; 1031 + cleanup_notifiers: 1054 1032 unregister_all_notifiers(); 1055 1033 clean_chip_info(); 1056 1034 out: