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

Configure Feed

Select the types of activity you want to include in your feed.

powercap: intel_rapl: Consolidate PL4 and PMU support flags into rapl_defaults

Currently, PL4 and MSR-based RAPL PMU support are detected using
separate CPU ID tables (pl4_support_ids and pmu_support_ids) in the
MSR driver probe path. This creates a maintenance burden since adding
a new CPU requires updates in two places: the rapl_ids table and one
or both of these capability tables.

Consolidate PL4 and PMU capability information directly into
struct rapl_defaults by adding msr_pl4_support and msr_pmu_support
flags. This allows per-CPU capability to be expressed in a single
place alongside other per-CPU defaults, eliminating the duplicate
CPU ID tables entirely.

No functional changes are intended.

Co-developed-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/20260331211950.3329932-8-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Kuppuswamy Sathyanarayanan and committed by
Rafael J. Wysocki
c3bb8d4f b0ee5110

+38 -47
+36 -47
drivers/powercap/intel_rapl_msr.c
··· 216 216 return ra->err; 217 217 } 218 218 219 - /* List of verified CPUs. */ 220 - static const struct x86_cpu_id pl4_support_ids[] = { 221 - X86_MATCH_VFM(INTEL_ICELAKE_L, NULL), 222 - X86_MATCH_VFM(INTEL_TIGERLAKE_L, NULL), 223 - X86_MATCH_VFM(INTEL_ALDERLAKE, NULL), 224 - X86_MATCH_VFM(INTEL_ALDERLAKE_L, NULL), 225 - X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, NULL), 226 - X86_MATCH_VFM(INTEL_RAPTORLAKE, NULL), 227 - X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL), 228 - X86_MATCH_VFM(INTEL_METEORLAKE, NULL), 229 - X86_MATCH_VFM(INTEL_METEORLAKE_L, NULL), 230 - X86_MATCH_VFM(INTEL_ARROWLAKE_U, NULL), 231 - X86_MATCH_VFM(INTEL_ARROWLAKE_H, NULL), 232 - X86_MATCH_VFM(INTEL_PANTHERLAKE_L, NULL), 233 - X86_MATCH_VFM(INTEL_WILDCATLAKE_L, NULL), 234 - X86_MATCH_VFM(INTEL_NOVALAKE, NULL), 235 - X86_MATCH_VFM(INTEL_NOVALAKE_L, NULL), 236 - {} 237 - }; 238 - 239 - /* List of MSR-based RAPL PMU support CPUs */ 240 - static const struct x86_cpu_id pmu_support_ids[] = { 241 - X86_MATCH_VFM(INTEL_PANTHERLAKE_L, NULL), 242 - X86_MATCH_VFM(INTEL_WILDCATLAKE_L, NULL), 243 - {} 244 - }; 245 - 246 219 static int rapl_check_unit_atom(struct rapl_domain *rd) 247 220 { 248 221 struct reg_action ra; ··· 393 420 .check_unit = rapl_default_check_unit, 394 421 }; 395 422 423 + static const struct rapl_defaults rapl_defaults_core_pl4 = { 424 + .floor_freq_reg_addr = 0, 425 + .check_unit = rapl_default_check_unit, 426 + .set_floor_freq = rapl_default_set_floor_freq, 427 + .compute_time_window = rapl_default_compute_time_window, 428 + .msr_pl4_support = 1, 429 + }; 430 + 431 + static const struct rapl_defaults rapl_defaults_core_pl4_pmu = { 432 + .floor_freq_reg_addr = 0, 433 + .check_unit = rapl_default_check_unit, 434 + .set_floor_freq = rapl_default_set_floor_freq, 435 + .compute_time_window = rapl_default_compute_time_window, 436 + .msr_pl4_support = 1, 437 + .msr_pmu_support = 1, 438 + }; 439 + 396 440 static const struct x86_cpu_id rapl_ids[] = { 397 441 X86_MATCH_VFM(INTEL_SANDYBRIDGE, &rapl_defaults_core), 398 442 X86_MATCH_VFM(INTEL_SANDYBRIDGE_X, &rapl_defaults_core), ··· 433 443 X86_MATCH_VFM(INTEL_KABYLAKE_L, &rapl_defaults_core), 434 444 X86_MATCH_VFM(INTEL_KABYLAKE, &rapl_defaults_core), 435 445 X86_MATCH_VFM(INTEL_CANNONLAKE_L, &rapl_defaults_core), 436 - X86_MATCH_VFM(INTEL_ICELAKE_L, &rapl_defaults_core), 446 + X86_MATCH_VFM(INTEL_ICELAKE_L, &rapl_defaults_core_pl4), 437 447 X86_MATCH_VFM(INTEL_ICELAKE, &rapl_defaults_core), 438 448 X86_MATCH_VFM(INTEL_ICELAKE_NNPI, &rapl_defaults_core), 439 449 X86_MATCH_VFM(INTEL_ICELAKE_X, &rapl_defaults_hsw_server), 440 450 X86_MATCH_VFM(INTEL_ICELAKE_D, &rapl_defaults_hsw_server), 441 451 X86_MATCH_VFM(INTEL_COMETLAKE_L, &rapl_defaults_core), 442 452 X86_MATCH_VFM(INTEL_COMETLAKE, &rapl_defaults_core), 443 - X86_MATCH_VFM(INTEL_TIGERLAKE_L, &rapl_defaults_core), 453 + X86_MATCH_VFM(INTEL_TIGERLAKE_L, &rapl_defaults_core_pl4), 444 454 X86_MATCH_VFM(INTEL_TIGERLAKE, &rapl_defaults_core), 445 455 X86_MATCH_VFM(INTEL_ROCKETLAKE, &rapl_defaults_core), 446 - X86_MATCH_VFM(INTEL_ALDERLAKE, &rapl_defaults_core), 447 - X86_MATCH_VFM(INTEL_ALDERLAKE_L, &rapl_defaults_core), 448 - X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, &rapl_defaults_core), 449 - X86_MATCH_VFM(INTEL_RAPTORLAKE, &rapl_defaults_core), 450 - X86_MATCH_VFM(INTEL_RAPTORLAKE_P, &rapl_defaults_core), 456 + X86_MATCH_VFM(INTEL_ALDERLAKE, &rapl_defaults_core_pl4), 457 + X86_MATCH_VFM(INTEL_ALDERLAKE_L, &rapl_defaults_core_pl4), 458 + X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, &rapl_defaults_core_pl4), 459 + X86_MATCH_VFM(INTEL_RAPTORLAKE, &rapl_defaults_core_pl4), 460 + X86_MATCH_VFM(INTEL_RAPTORLAKE_P, &rapl_defaults_core_pl4), 451 461 X86_MATCH_VFM(INTEL_RAPTORLAKE_S, &rapl_defaults_core), 452 462 X86_MATCH_VFM(INTEL_BARTLETTLAKE, &rapl_defaults_core), 453 - X86_MATCH_VFM(INTEL_METEORLAKE, &rapl_defaults_core), 454 - X86_MATCH_VFM(INTEL_METEORLAKE_L, &rapl_defaults_core), 463 + X86_MATCH_VFM(INTEL_METEORLAKE, &rapl_defaults_core_pl4), 464 + X86_MATCH_VFM(INTEL_METEORLAKE_L, &rapl_defaults_core_pl4), 455 465 X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, &rapl_defaults_spr_server), 456 466 X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, &rapl_defaults_spr_server), 457 467 X86_MATCH_VFM(INTEL_LUNARLAKE_M, &rapl_defaults_core), 458 - X86_MATCH_VFM(INTEL_PANTHERLAKE_L, &rapl_defaults_core), 459 - X86_MATCH_VFM(INTEL_WILDCATLAKE_L, &rapl_defaults_core), 460 - X86_MATCH_VFM(INTEL_NOVALAKE, &rapl_defaults_core), 461 - X86_MATCH_VFM(INTEL_NOVALAKE_L, &rapl_defaults_core), 462 - X86_MATCH_VFM(INTEL_ARROWLAKE_H, &rapl_defaults_core), 468 + X86_MATCH_VFM(INTEL_PANTHERLAKE_L, &rapl_defaults_core_pl4_pmu), 469 + X86_MATCH_VFM(INTEL_WILDCATLAKE_L, &rapl_defaults_core_pl4_pmu), 470 + X86_MATCH_VFM(INTEL_NOVALAKE, &rapl_defaults_core_pl4), 471 + X86_MATCH_VFM(INTEL_NOVALAKE_L, &rapl_defaults_core_pl4), 472 + X86_MATCH_VFM(INTEL_ARROWLAKE_H, &rapl_defaults_core_pl4), 463 473 X86_MATCH_VFM(INTEL_ARROWLAKE, &rapl_defaults_core), 464 - X86_MATCH_VFM(INTEL_ARROWLAKE_U, &rapl_defaults_core), 474 + X86_MATCH_VFM(INTEL_ARROWLAKE_U, &rapl_defaults_core_pl4), 465 475 X86_MATCH_VFM(INTEL_LAKEFIELD, &rapl_defaults_core), 466 476 467 477 X86_MATCH_VFM(INTEL_ATOM_SILVERMONT, &rapl_defaults_byt), ··· 488 498 489 499 static int rapl_msr_probe(struct platform_device *pdev) 490 500 { 491 - const struct x86_cpu_id *id = x86_match_cpu(pl4_support_ids); 492 501 int ret; 493 502 494 503 switch (boot_cpu_data.x86_vendor) { ··· 507 518 rapl_msr_priv->defaults = (const struct rapl_defaults *)pdev->dev.platform_data; 508 519 rapl_msr_priv->rpi = rpi_msr; 509 520 510 - if (id) { 521 + if (rapl_msr_priv->defaults->msr_pl4_support) { 511 522 rapl_msr_priv->limits[RAPL_DOMAIN_PACKAGE] |= BIT(POWER_LIMIT4); 512 523 rapl_msr_priv->regs[RAPL_DOMAIN_PACKAGE][RAPL_DOMAIN_REG_PL4].msr = 513 524 MSR_VR_CURRENT_CONFIG; 514 - pr_info("PL4 support detected.\n"); 525 + pr_info("PL4 support detected (updated).\n"); 515 526 } 516 527 517 - if (x86_match_cpu(pmu_support_ids)) { 528 + if (rapl_msr_priv->defaults->msr_pmu_support) { 518 529 rapl_msr_pmu = true; 519 - pr_info("MSR-based RAPL PMU support enabled\n"); 530 + pr_info("MSR-based RAPL PMU support enabled (updated)\n"); 520 531 } 521 532 522 533 rapl_msr_priv->control_type = powercap_register_control_type(NULL, "intel-rapl", NULL);
+2
include/linux/intel_rapl.h
··· 135 135 unsigned int dram_domain_energy_unit; 136 136 unsigned int psys_domain_energy_unit; 137 137 bool spr_psys_bits; 138 + bool msr_pl4_support; 139 + bool msr_pmu_support; 138 140 }; 139 141 140 142 #define PRIMITIVE_INFO_INIT(p, m, s, i, u, f) { \