|
25 | 25 | #include <linux/acpi.h>
|
26 | 26 | #include <linux/vmalloc.h>
|
27 | 27 | #include <linux/pm_qos.h>
|
| 28 | +#include <linux/bitfield.h> |
28 | 29 | #include <trace/events/power.h>
|
29 | 30 |
|
30 | 31 | #include <asm/cpu.h>
|
@@ -3401,14 +3402,29 @@ static bool intel_pstate_hwp_is_enabled(void)
|
3401 | 3402 | return !!(value & 0x1);
|
3402 | 3403 | }
|
3403 | 3404 |
|
3404 |
| -static const struct x86_cpu_id intel_epp_balance_perf[] = { |
| 3405 | +#define POWERSAVE_MASK GENMASK(7, 0) |
| 3406 | +#define BALANCE_POWER_MASK GENMASK(15, 8) |
| 3407 | +#define BALANCE_PERFORMANCE_MASK GENMASK(23, 16) |
| 3408 | +#define PERFORMANCE_MASK GENMASK(31, 24) |
| 3409 | + |
| 3410 | +#define HWP_SET_EPP_VALUES(powersave, balance_power, balance_perf, performance) \ |
| 3411 | + (FIELD_PREP_CONST(POWERSAVE_MASK, powersave) |\ |
| 3412 | + FIELD_PREP_CONST(BALANCE_POWER_MASK, balance_power) |\ |
| 3413 | + FIELD_PREP_CONST(BALANCE_PERFORMANCE_MASK, balance_perf) |\ |
| 3414 | + FIELD_PREP_CONST(PERFORMANCE_MASK, performance)) |
| 3415 | + |
| 3416 | +#define HWP_SET_DEF_BALANCE_PERF_EPP(balance_perf) \ |
| 3417 | + (HWP_SET_EPP_VALUES(HWP_EPP_POWERSAVE, HWP_EPP_BALANCE_POWERSAVE,\ |
| 3418 | + balance_perf, HWP_EPP_PERFORMANCE)) |
| 3419 | + |
| 3420 | +static const struct x86_cpu_id intel_epp_default[] = { |
3405 | 3421 | /*
|
3406 | 3422 | * Set EPP value as 102, this is the max suggested EPP
|
3407 | 3423 | * which can result in one core turbo frequency for
|
3408 | 3424 | * AlderLake Mobile CPUs.
|
3409 | 3425 | */
|
3410 |
| - X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, 102), |
3411 |
| - X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, 32), |
| 3426 | + X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L, HWP_SET_DEF_BALANCE_PERF_EPP(102)), |
| 3427 | + X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, HWP_SET_DEF_BALANCE_PERF_EPP(32)), |
3412 | 3428 | {}
|
3413 | 3429 | };
|
3414 | 3430 |
|
@@ -3506,11 +3522,24 @@ static int __init intel_pstate_init(void)
|
3506 | 3522 | intel_pstate_sysfs_expose_params();
|
3507 | 3523 |
|
3508 | 3524 | if (hwp_active) {
|
3509 |
| - const struct x86_cpu_id *id = x86_match_cpu(intel_epp_balance_perf); |
| 3525 | + const struct x86_cpu_id *id = x86_match_cpu(intel_epp_default); |
3510 | 3526 | const struct x86_cpu_id *hybrid_id = x86_match_cpu(intel_hybrid_scaling_factor);
|
3511 | 3527 |
|
3512 |
| - if (id) |
3513 |
| - epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = id->driver_data; |
| 3528 | + if (id) { |
| 3529 | + epp_values[EPP_INDEX_POWERSAVE] = |
| 3530 | + FIELD_GET(POWERSAVE_MASK, id->driver_data); |
| 3531 | + epp_values[EPP_INDEX_BALANCE_POWERSAVE] = |
| 3532 | + FIELD_GET(BALANCE_POWER_MASK, id->driver_data); |
| 3533 | + epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = |
| 3534 | + FIELD_GET(BALANCE_PERFORMANCE_MASK, id->driver_data); |
| 3535 | + epp_values[EPP_INDEX_PERFORMANCE] = |
| 3536 | + FIELD_GET(PERFORMANCE_MASK, id->driver_data); |
| 3537 | + pr_debug("Updated EPPs powersave:%x balanced power:%x balanced perf:%x performance:%x\n", |
| 3538 | + epp_values[EPP_INDEX_POWERSAVE], |
| 3539 | + epp_values[EPP_INDEX_BALANCE_POWERSAVE], |
| 3540 | + epp_values[EPP_INDEX_BALANCE_PERFORMANCE], |
| 3541 | + epp_values[EPP_INDEX_PERFORMANCE]); |
| 3542 | + } |
3514 | 3543 |
|
3515 | 3544 | if (hybrid_id) {
|
3516 | 3545 | hybrid_scaling_factor = hybrid_id->driver_data;
|
|
0 commit comments