Skip to content

Commit 83e9903

Browse files
committed
Merge branch 'pm-cpufreq'
Merge cpufreq updates for 7.1-rc1: - Update qcom-hw DT bindings to include Eliza hardware (Abel Vesa) - Update cpufreq-dt-platdev blocklist (Faruque Ansari) - Minor updates to driver and dt-bindings for Tegra (Thierry Reding, Rosen Penev) - Add MAINTAINERS entry for CPPC driver (Viresh Kumar) - Add support for new features: CPPC performance priority, Dynamic EPP, Raw EPP, and new unit tests for them to amd-pstate (Gautham Shenoy, Mario Limonciello) - Fix sysfs files being present when HW missing and broken/outdated documentation in the amd-pstate driver (Ninad Naik, Gautham Shenoy) - Pass the policy to cpufreq_driver->adjust_perf() to avoid using cpufreq_cpu_get() in the .adjust_perf() callback in amd-pstate which leads to a scheduling-while-atomic bug (K Prateek Nayak) - Clean up dead code in Kconfig for cpufreq (Julian Braha) - Remove max_freq_req update for pre-existing cpufreq policy and add a boost_freq_req QoS request to save the boost constraint instead of overwriting the last scaling_max_freq constraint (Pierre Gondois) - Embed cpufreq QoS freq_req objects in cpufreq policy so they all are allocated in one go along with the policy to simplify lifetime rules and avoid error handling issues (Viresh Kumar) - Use DMI max speed when CPPC is unavailable in the acpi-cpufreq scaling driver (Henry Tseng) - Switch policy_is_shared() in cpufreq to using cpumask_nth() instead of cpumask_weight() because the former is more efficient (Yury Norov) - Use sysfs_emit() in sysfs show functions for cpufreq governor attributes (Thorsten Blum) - Update intel_pstate to stop returning an error when "off" is written to its status sysfs attribute while the driver is already off (Fabio De Francesco) - Include current frequency in the debug message printed by __cpufreq_driver_target() (Pengjie Zhang) * pm-cpufreq: (38 commits) cpufreq/amd-pstate: Add POWER_SUPPLY select for dynamic EPP MAINTAINERS: amd-pstate: Step down as maintainer, add Prateek as reviewer cpufreq: Pass the policy to cpufreq_driver->adjust_perf() cpufreq/amd-pstate: Pass the policy to amd_pstate_update() cpufreq/amd-pstate-ut: Add a unit test for raw EPP cpufreq/amd-pstate: Add support for raw EPP writes cpufreq/amd-pstate: Add support for platform profile class cpufreq/amd-pstate: add kernel command line to override dynamic epp cpufreq/amd-pstate: Add dynamic energy performance preference Documentation: amd-pstate: fix dead links in the reference section cpufreq/amd-pstate: Cache the max frequency in cpudata Documentation/amd-pstate: Add documentation for amd_pstate_floor_{freq,count} Documentation/amd-pstate: List amd_pstate_prefcore_ranking sysfs file Documentation/amd-pstate: List amd_pstate_hw_prefcore sysfs file amd-pstate-ut: Add a testcase to validate the visibility of driver attributes amd-pstate-ut: Add module parameter to select testcases amd-pstate: Introduce a tracepoint trace_amd_pstate_cppc_req2() amd-pstate: Add sysfs support for floor_freq and floor_count amd-pstate: Add support for CPPC_REQ2 and FLOOR_PERF x86/cpufeatures: Add AMD CPPC Performance Priority feature. ...
2 parents 2acabc8 + 6793439 commit 83e9903

28 files changed

Lines changed: 1105 additions & 200 deletions

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ Kernel parameters
493493
disable
494494
Disable amd-pstate preferred core.
495495

496+
amd_dynamic_epp=
497+
[X86]
498+
disable
499+
Disable amd-pstate dynamic EPP.
500+
enable
501+
Enable amd-pstate dynamic EPP.
502+
496503
amijoy.map= [HW,JOY] Amiga joystick support
497504
Map of devices attached to JOY0DAT and JOY1DAT
498505
Format: <a>,<b>

Documentation/admin-guide/pm/amd-pstate.rst

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ control its functionality at the system level. They are located in the
239239

240240
root@hr-test1:/home/ray# ls /sys/devices/system/cpu/cpufreq/policy0/*amd*
241241
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_highest_perf
242+
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_hw_prefcore
242243
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_lowest_nonlinear_freq
243244
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_max_freq
245+
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_floor_freq
246+
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_floor_count
247+
/sys/devices/system/cpu/cpufreq/policy0/amd_pstate_prefcore_ranking
244248

245249

246250
``amd_pstate_highest_perf / amd_pstate_max_freq``
@@ -264,14 +268,46 @@ This attribute is read-only.
264268

265269
``amd_pstate_hw_prefcore``
266270

267-
Whether the platform supports the preferred core feature and it has been
268-
enabled. This attribute is read-only.
271+
Whether the platform supports the preferred core feature and it has
272+
been enabled. This attribute is read-only. This file is only visible
273+
on platforms which support the preferred core feature.
269274

270275
``amd_pstate_prefcore_ranking``
271276

272277
The performance ranking of the core. This number doesn't have any unit, but
273278
larger numbers are preferred at the time of reading. This can change at
274-
runtime based on platform conditions. This attribute is read-only.
279+
runtime based on platform conditions. This attribute is read-only. This file
280+
is only visible on platforms which support the preferred core feature.
281+
282+
``amd_pstate_floor_freq``
283+
284+
The floor frequency associated with each CPU. Userspace can write any
285+
value between ``cpuinfo_min_freq`` and ``scaling_max_freq`` into this
286+
file. When the system is under power or thermal constraints, the
287+
platform firmware will attempt to throttle the CPU frequency to the
288+
value specified in ``amd_pstate_floor_freq`` before throttling it
289+
further. This allows userspace to specify different floor frequencies
290+
to different CPUs. For optimal results, threads of the same core
291+
should have the same floor frequency value. This file is only visible
292+
on platforms that support the CPPC Performance Priority feature.
293+
294+
295+
``amd_pstate_floor_count``
296+
297+
The number of distinct Floor Performance levels supported by the
298+
platform. For example, if this value is 2, then the number of unique
299+
values obtained from the command ``cat
300+
/sys/devices/system/cpu/cpufreq/policy*/amd_pstate_floor_freq |
301+
sort -n | uniq`` should be at most this number for the behavior
302+
described in ``amd_pstate_floor_freq`` to take effect. A zero value
303+
implies that the platform supports unlimited floor performance levels.
304+
This file is only visible on platforms that support the CPPC
305+
Performance Priority feature.
306+
307+
**Note**: When ``amd_pstate_floor_count`` is non-zero, the frequency to
308+
which the CPU is throttled under power or thermal constraints is
309+
undefined when the number of unique values of ``amd_pstate_floor_freq``
310+
across all CPUs in the system exceeds ``amd_pstate_floor_count``.
275311

276312
``energy_performance_available_preferences``
277313

@@ -280,16 +316,22 @@ A list of all the supported EPP preferences that could be used for
280316
These profiles represent different hints that are provided
281317
to the low-level firmware about the user's desired energy vs efficiency
282318
tradeoff. ``default`` represents the epp value is set by platform
283-
firmware. This attribute is read-only.
319+
firmware. ``custom`` designates that integer values 0-255 may be written
320+
as well. This attribute is read-only.
284321

285322
``energy_performance_preference``
286323

287324
The current energy performance preference can be read from this attribute.
288325
and user can change current preference according to energy or performance needs
289-
Please get all support profiles list from
290-
``energy_performance_available_preferences`` attribute, all the profiles are
291-
integer values defined between 0 to 255 when EPP feature is enabled by platform
292-
firmware, if EPP feature is disabled, driver will ignore the written value
326+
Coarse named profiles are available in the attribute
327+
``energy_performance_available_preferences``.
328+
Users can also write individual integer values between 0 to 255.
329+
When dynamic EPP is enabled, writes to energy_performance_preference are blocked
330+
even when EPP feature is enabled by platform firmware. Lower epp values shift the bias
331+
towards improved performance while a higher epp value shifts the bias towards
332+
power-savings. The exact impact can change from one platform to the other.
333+
If a valid integer was last written, then a number will be returned on future reads.
334+
If a valid string was last written then a string will be returned on future reads.
293335
This attribute is read-write.
294336

295337
``boost``
@@ -311,6 +353,24 @@ boost or `1` to enable it, for the respective CPU using the sysfs path
311353
Other performance and frequency values can be read back from
312354
``/sys/devices/system/cpu/cpuX/acpi_cppc/``, see :ref:`cppc_sysfs`.
313355

356+
Dynamic energy performance profile
357+
==================================
358+
The amd-pstate driver supports dynamically selecting the energy performance
359+
profile based on whether the machine is running on AC or DC power.
360+
361+
Whether this behavior is enabled by default depends on the kernel
362+
config option `CONFIG_X86_AMD_PSTATE_DYNAMIC_EPP`. This behavior can also be overridden
363+
at runtime by the sysfs file ``/sys/devices/system/cpu/cpufreq/policyX/dynamic_epp``.
364+
365+
When set to enabled, the driver will select a different energy performance
366+
profile when the machine is running on battery or AC power. The driver will
367+
also register with the platform profile handler to receive notifications of
368+
user desired power state and react to those.
369+
When set to disabled, the driver will not change the energy performance profile
370+
based on the power source and will not react to user desired power state.
371+
372+
Attempting to manually write to the ``energy_performance_preference`` sysfs
373+
file will fail when ``dynamic_epp`` is enabled.
314374

315375
``amd-pstate`` vs ``acpi-cpufreq``
316376
======================================
@@ -422,6 +482,13 @@ For systems that support ``amd-pstate`` preferred core, the core rankings will
422482
always be advertised by the platform. But OS can choose to ignore that via the
423483
kernel parameter ``amd_prefcore=disable``.
424484

485+
``amd_dynamic_epp``
486+
487+
When AMD pstate is in auto mode, dynamic EPP will control whether the kernel
488+
autonomously changes the EPP mode. The default is configured by
489+
``CONFIG_X86_AMD_PSTATE_DYNAMIC_EPP`` but can be explicitly enabled with
490+
``amd_dynamic_epp=enable`` or disabled with ``amd_dynamic_epp=disable``.
491+
425492
User Space Interface in ``sysfs`` - General
426493
===========================================
427494

@@ -790,13 +857,13 @@ Reference
790857
===========
791858

792859
.. [1] AMD64 Architecture Programmer's Manual Volume 2: System Programming,
793-
https://www.amd.com/system/files/TechDocs/24593.pdf
860+
https://docs.amd.com/v/u/en-US/24593_3.44_APM_Vol2
794861
795862
.. [2] Advanced Configuration and Power Interface Specification,
796863
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
797864
798865
.. [3] Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors
799-
https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip
866+
https://docs.amd.com/v/u/en-US/56569-A1-PUB_3.03
800867
801868
.. [4] Linux Kernel Selftests,
802869
https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html

Documentation/devicetree/bindings/arm/tegra/nvidia,tegra-ccplex-cluster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ properties:
2424
enum:
2525
- nvidia,tegra186-ccplex-cluster
2626
- nvidia,tegra234-ccplex-cluster
27+
- nvidia,tegra238-ccplex-cluster
2728

2829
reg:
2930
maxItems: 1

Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ properties:
3535
- description: v2 of CPUFREQ HW (EPSS)
3636
items:
3737
- enum:
38+
- qcom,eliza-cpufreq-epss
3839
- qcom,milos-cpufreq-epss
3940
- qcom,qcs8300-cpufreq-epss
4041
- qcom,qdu1000-cpufreq-epss

MAINTAINERS

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@ F: drivers/gpu/drm/amd/pm/
12341234

12351235
AMD PSTATE DRIVER
12361236
M: Huang Rui <ray.huang@amd.com>
1237-
M: Gautham R. Shenoy <gautham.shenoy@amd.com>
12381237
M: Mario Limonciello <mario.limonciello@amd.com>
12391238
R: Perry Yuan <perry.yuan@amd.com>
1239+
R: K Prateek Nayak <kprateek.nayak@amd.com>
12401240
L: linux-pm@vger.kernel.org
12411241
S: Supported
12421242
F: Documentation/admin-guide/pm/amd-pstate.rst
@@ -6616,6 +6616,17 @@ M: Bence Csókás <bence98@sch.bme.hu>
66166616
S: Maintained
66176617
F: drivers/i2c/busses/i2c-cp2615.c
66186618

6619+
CPU FREQUENCY DRIVERS - CPPC CPUFREQ
6620+
M: "Rafael J. Wysocki" <rafael@kernel.org>
6621+
M: Viresh Kumar <viresh.kumar@linaro.org>
6622+
R: Jie Zhan <zhanjie9@hisilicon.com>
6623+
R: Lifeng Zheng <zhenglifeng1@huawei.com>
6624+
R: Pierre Gondois <pierre.gondois@arm.com>
6625+
R: Sumit Gupta <sumitg@nvidia.com>
6626+
L: linux-pm@vger.kernel.org
6627+
S: Maintained
6628+
F: drivers/cpufreq/cppc_cpufreq.c
6629+
66196630
CPU FREQUENCY DRIVERS - VEXPRESS SPC ARM BIG LITTLE
66206631
M: Viresh Kumar <viresh.kumar@linaro.org>
66216632
M: Sudeep Holla <sudeep.holla@kernel.org>
@@ -6624,6 +6635,12 @@ S: Maintained
66246635
W: http://www.arm.com/products/processors/technologies/biglittleprocessing.php
66256636
F: drivers/cpufreq/vexpress-spc-cpufreq.c
66266637

6638+
CPU FREQUENCY DRIVERS - VIRTUAL MACHINE CPUFREQ
6639+
M: Saravana Kannan <saravanak@kernel.org>
6640+
L: linux-pm@vger.kernel.org
6641+
S: Maintained
6642+
F: drivers/cpufreq/virtual-cpufreq.c
6643+
66276644
CPU FREQUENCY SCALING FRAMEWORK
66286645
M: "Rafael J. Wysocki" <rafael@kernel.org>
66296646
M: Viresh Kumar <viresh.kumar@linaro.org>
@@ -6643,12 +6660,6 @@ F: kernel/sched/cpufreq*.c
66436660
F: rust/kernel/cpufreq.rs
66446661
F: tools/testing/selftests/cpufreq/
66456662

6646-
CPU FREQUENCY DRIVERS - VIRTUAL MACHINE CPUFREQ
6647-
M: Saravana Kannan <saravanak@kernel.org>
6648-
L: linux-pm@vger.kernel.org
6649-
S: Maintained
6650-
F: drivers/cpufreq/virtual-cpufreq.c
6651-
66526663
CPU HOTPLUG
66536664
M: Thomas Gleixner <tglx@kernel.org>
66546665
M: Peter Zijlstra <peterz@infradead.org>

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
*/
416416
#define X86_FEATURE_OVERFLOW_RECOV (17*32+ 0) /* "overflow_recov" MCA overflow recovery support */
417417
#define X86_FEATURE_SUCCOR (17*32+ 1) /* "succor" Uncorrectable error containment and recovery */
418-
418+
#define X86_FEATURE_CPPC_PERF_PRIO (17*32+ 2) /* CPPC Floor Perf support */
419419
#define X86_FEATURE_SMCA (17*32+ 3) /* "smca" Scalable MCA */
420420

421421
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */

arch/x86/include/asm/msr-index.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,19 +765,24 @@
765765
#define MSR_AMD_CPPC_CAP2 0xc00102b2
766766
#define MSR_AMD_CPPC_REQ 0xc00102b3
767767
#define MSR_AMD_CPPC_STATUS 0xc00102b4
768+
#define MSR_AMD_CPPC_REQ2 0xc00102b5
768769

769770
/* Masks for use with MSR_AMD_CPPC_CAP1 */
770771
#define AMD_CPPC_LOWEST_PERF_MASK GENMASK(7, 0)
771772
#define AMD_CPPC_LOWNONLIN_PERF_MASK GENMASK(15, 8)
772773
#define AMD_CPPC_NOMINAL_PERF_MASK GENMASK(23, 16)
773774
#define AMD_CPPC_HIGHEST_PERF_MASK GENMASK(31, 24)
775+
#define AMD_CPPC_FLOOR_PERF_CNT_MASK GENMASK_ULL(39, 32)
774776

775777
/* Masks for use with MSR_AMD_CPPC_REQ */
776778
#define AMD_CPPC_MAX_PERF_MASK GENMASK(7, 0)
777779
#define AMD_CPPC_MIN_PERF_MASK GENMASK(15, 8)
778780
#define AMD_CPPC_DES_PERF_MASK GENMASK(23, 16)
779781
#define AMD_CPPC_EPP_PERF_MASK GENMASK(31, 24)
780782

783+
/* Masks for use with MSR_AMD_CPPC_REQ2 */
784+
#define AMD_CPPC_FLOOR_PERF_MASK GENMASK(7, 0)
785+
781786
/* AMD Performance Counter Global Status and Control MSRs */
782787
#define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS 0xc0000300
783788
#define MSR_AMD64_PERF_CNTR_GLOBAL_CTL 0xc0000301

arch/x86/kernel/cpu/scattered.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static const struct cpuid_bit cpuid_bits[] = {
5252
{ X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 },
5353
{ X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 },
5454
{ X86_FEATURE_AMD_FAST_CPPC, CPUID_EDX, 15, 0x80000007, 0 },
55+
{ X86_FEATURE_CPPC_PERF_PRIO, CPUID_EDX, 16, 0x80000007, 0 },
5556
{ X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 },
5657
{ X86_FEATURE_X2AVIC_EXT, CPUID_ECX, 6, 0x8000000a, 0 },
5758
{ X86_FEATURE_COHERENCY_SFW_NO, CPUID_EBX, 31, 0x8000001f, 0 },

drivers/acpi/cppc_acpi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private)
19441944
}
19451945

19461946
/* Look up the max frequency in DMI */
1947-
static u64 cppc_get_dmi_max_khz(void)
1947+
u64 cppc_get_dmi_max_khz(void)
19481948
{
19491949
u16 mhz = 0;
19501950

@@ -1958,6 +1958,7 @@ static u64 cppc_get_dmi_max_khz(void)
19581958

19591959
return KHZ_PER_MHZ * mhz;
19601960
}
1961+
EXPORT_SYMBOL_GPL(cppc_get_dmi_max_khz);
19611962

19621963
/*
19631964
* If CPPC lowest_freq and nominal_freq registers are exposed then we can

drivers/cpufreq/Kconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ config CPU_FREQ_GOV_ONDEMAND
163163

164164
config CPU_FREQ_GOV_CONSERVATIVE
165165
tristate "'conservative' cpufreq governor"
166-
depends on CPU_FREQ
167166
select CPU_FREQ_GOV_COMMON
168167
help
169168
'conservative' - this driver is rather similar to the 'ondemand'
@@ -188,7 +187,7 @@ config CPU_FREQ_GOV_CONSERVATIVE
188187

189188
config CPU_FREQ_GOV_SCHEDUTIL
190189
bool "'schedutil' cpufreq policy governor"
191-
depends on CPU_FREQ && SMP
190+
depends on SMP
192191
select CPU_FREQ_GOV_ATTR_SET
193192
select IRQ_WORK
194193
help
@@ -365,6 +364,6 @@ config ACPI_CPPC_CPUFREQ_FIE
365364

366365
If in doubt, say N.
367366

368-
endif
367+
endif # CPU_FREQ
369368

370369
endmenu

0 commit comments

Comments
 (0)