|
27 | 27 | #include <linux/pm_qos.h>
|
28 | 28 | #include <trace/events/power.h>
|
29 | 29 |
|
| 30 | +#include <asm/cpu.h> |
30 | 31 | #include <asm/div64.h>
|
31 | 32 | #include <asm/msr.h>
|
32 | 33 | #include <asm/cpu_device_id.h>
|
@@ -398,16 +399,6 @@ static int intel_pstate_get_cppc_guaranteed(int cpu)
|
398 | 399 |
|
399 | 400 | return cppc_perf.nominal_perf;
|
400 | 401 | }
|
401 |
| - |
402 |
| -static u32 intel_pstate_cppc_nominal(int cpu) |
403 |
| -{ |
404 |
| - u64 nominal_perf; |
405 |
| - |
406 |
| - if (cppc_get_nominal_perf(cpu, &nominal_perf)) |
407 |
| - return 0; |
408 |
| - |
409 |
| - return nominal_perf; |
410 |
| -} |
411 | 402 | #else /* CONFIG_ACPI_CPPC_LIB */
|
412 | 403 | static inline void intel_pstate_set_itmt_prio(int cpu)
|
413 | 404 | {
|
@@ -532,34 +523,17 @@ static void intel_pstate_hybrid_hwp_adjust(struct cpudata *cpu)
|
532 | 523 | int perf_ctl_max_phys = cpu->pstate.max_pstate_physical;
|
533 | 524 | int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling;
|
534 | 525 | int perf_ctl_turbo = pstate_funcs.get_turbo(cpu->cpu);
|
535 |
| - int turbo_freq = perf_ctl_turbo * perf_ctl_scaling; |
536 | 526 | int scaling = cpu->pstate.scaling;
|
537 | 527 |
|
538 | 528 | pr_debug("CPU%d: perf_ctl_max_phys = %d\n", cpu->cpu, perf_ctl_max_phys);
|
539 |
| - pr_debug("CPU%d: perf_ctl_max = %d\n", cpu->cpu, pstate_funcs.get_max(cpu->cpu)); |
540 | 529 | pr_debug("CPU%d: perf_ctl_turbo = %d\n", cpu->cpu, perf_ctl_turbo);
|
541 | 530 | pr_debug("CPU%d: perf_ctl_scaling = %d\n", cpu->cpu, perf_ctl_scaling);
|
542 | 531 | pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate);
|
543 | 532 | pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate);
|
544 | 533 | pr_debug("CPU%d: HWP-to-frequency scaling factor: %d\n", cpu->cpu, scaling);
|
545 | 534 |
|
546 |
| - /* |
547 |
| - * If the product of the HWP performance scaling factor and the HWP_CAP |
548 |
| - * highest performance is greater than the maximum turbo frequency |
549 |
| - * corresponding to the pstate_funcs.get_turbo() return value, the |
550 |
| - * scaling factor is too high, so recompute it to make the HWP_CAP |
551 |
| - * highest performance correspond to the maximum turbo frequency. |
552 |
| - */ |
553 |
| - cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * scaling; |
554 |
| - if (turbo_freq < cpu->pstate.turbo_freq) { |
555 |
| - cpu->pstate.turbo_freq = turbo_freq; |
556 |
| - scaling = DIV_ROUND_UP(turbo_freq, cpu->pstate.turbo_pstate); |
557 |
| - cpu->pstate.scaling = scaling; |
558 |
| - |
559 |
| - pr_debug("CPU%d: refined HWP-to-frequency scaling factor: %d\n", |
560 |
| - cpu->cpu, scaling); |
561 |
| - } |
562 |
| - |
| 535 | + cpu->pstate.turbo_freq = rounddown(cpu->pstate.turbo_pstate * scaling, |
| 536 | + perf_ctl_scaling); |
563 | 537 | cpu->pstate.max_freq = rounddown(cpu->pstate.max_pstate * scaling,
|
564 | 538 | perf_ctl_scaling);
|
565 | 539 |
|
@@ -1965,37 +1939,24 @@ static int knl_get_turbo_pstate(int cpu)
|
1965 | 1939 | return ret;
|
1966 | 1940 | }
|
1967 | 1941 |
|
1968 |
| -#ifdef CONFIG_ACPI_CPPC_LIB |
1969 |
| -static u32 hybrid_ref_perf; |
1970 |
| - |
1971 |
| -static int hybrid_get_cpu_scaling(int cpu) |
| 1942 | +static void hybrid_get_type(void *data) |
1972 | 1943 | {
|
1973 |
| - return DIV_ROUND_UP(core_get_scaling() * hybrid_ref_perf, |
1974 |
| - intel_pstate_cppc_nominal(cpu)); |
| 1944 | + u8 *cpu_type = data; |
| 1945 | + |
| 1946 | + *cpu_type = get_this_hybrid_cpu_type(); |
1975 | 1947 | }
|
1976 | 1948 |
|
1977 |
| -static void intel_pstate_cppc_set_cpu_scaling(void) |
| 1949 | +static int hybrid_get_cpu_scaling(int cpu) |
1978 | 1950 | {
|
1979 |
| - u32 min_nominal_perf = U32_MAX; |
1980 |
| - int cpu; |
| 1951 | + u8 cpu_type = 0; |
1981 | 1952 |
|
1982 |
| - for_each_present_cpu(cpu) { |
1983 |
| - u32 nominal_perf = intel_pstate_cppc_nominal(cpu); |
| 1953 | + smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1); |
| 1954 | + /* P-cores have a smaller perf level-to-freqency scaling factor. */ |
| 1955 | + if (cpu_type == 0x40) |
| 1956 | + return 78741; |
1984 | 1957 |
|
1985 |
| - if (nominal_perf && nominal_perf < min_nominal_perf) |
1986 |
| - min_nominal_perf = nominal_perf; |
1987 |
| - } |
1988 |
| - |
1989 |
| - if (min_nominal_perf < U32_MAX) { |
1990 |
| - hybrid_ref_perf = min_nominal_perf; |
1991 |
| - pstate_funcs.get_cpu_scaling = hybrid_get_cpu_scaling; |
1992 |
| - } |
| 1958 | + return core_get_scaling(); |
1993 | 1959 | }
|
1994 |
| -#else |
1995 |
| -static inline void intel_pstate_cppc_set_cpu_scaling(void) |
1996 |
| -{ |
1997 |
| -} |
1998 |
| -#endif /* CONFIG_ACPI_CPPC_LIB */ |
1999 | 1960 |
|
2000 | 1961 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate)
|
2001 | 1962 | {
|
@@ -3450,7 +3411,7 @@ static int __init intel_pstate_init(void)
|
3450 | 3411 | default_driver = &intel_pstate;
|
3451 | 3412 |
|
3452 | 3413 | if (boot_cpu_has(X86_FEATURE_HYBRID_CPU))
|
3453 |
| - intel_pstate_cppc_set_cpu_scaling(); |
| 3414 | + pstate_funcs.get_cpu_scaling = hybrid_get_cpu_scaling; |
3454 | 3415 |
|
3455 | 3416 | goto hwp_cpu_matched;
|
3456 | 3417 | }
|
|
0 commit comments