xref: /openbmc/linux/Documentation/admin-guide/pm/cpufreq_drivers.rst (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
1*03b22496SRafael J. Wysocki.. SPDX-License-Identifier: GPL-2.0
2*03b22496SRafael J. Wysocki
3*03b22496SRafael J. Wysocki=======================================================
4*03b22496SRafael J. WysockiLegacy Documentation of CPU Performance Scaling Drivers
5*03b22496SRafael J. Wysocki=======================================================
6*03b22496SRafael J. Wysocki
7*03b22496SRafael J. WysockiIncluded below are historic documents describing assorted
8*03b22496SRafael J. Wysocki:doc:`CPU performance scaling <cpufreq>` drivers.  They are reproduced verbatim,
9*03b22496SRafael J. Wysockiwith the original white space formatting and indentation preserved, except for
10*03b22496SRafael J. Wysockithe added leading space character in every line of text.
11*03b22496SRafael J. Wysocki
12*03b22496SRafael J. Wysocki
13*03b22496SRafael J. WysockiAMD PowerNow! Drivers
14*03b22496SRafael J. Wysocki=====================
15*03b22496SRafael J. Wysocki
16*03b22496SRafael J. Wysocki::
17*03b22496SRafael J. Wysocki
18*03b22496SRafael J. Wysocki PowerNow! and Cool'n'Quiet are AMD names for frequency
19*03b22496SRafael J. Wysocki management capabilities in AMD processors. As the hardware
20*03b22496SRafael J. Wysocki implementation changes in new generations of the processors,
21*03b22496SRafael J. Wysocki there is a different cpu-freq driver for each generation.
22*03b22496SRafael J. Wysocki
23*03b22496SRafael J. Wysocki Note that the driver's will not load on the "wrong" hardware,
24*03b22496SRafael J. Wysocki so it is safe to try each driver in turn when in doubt as to
25*03b22496SRafael J. Wysocki which is the correct driver.
26*03b22496SRafael J. Wysocki
27*03b22496SRafael J. Wysocki Note that the functionality to change frequency (and voltage)
28*03b22496SRafael J. Wysocki is not available in all processors. The drivers will refuse
29*03b22496SRafael J. Wysocki to load on processors without this capability. The capability
30*03b22496SRafael J. Wysocki is detected with the cpuid instruction.
31*03b22496SRafael J. Wysocki
32*03b22496SRafael J. Wysocki The drivers use BIOS supplied tables to obtain frequency and
33*03b22496SRafael J. Wysocki voltage information appropriate for a particular platform.
34*03b22496SRafael J. Wysocki Frequency transitions will be unavailable if the BIOS does
35*03b22496SRafael J. Wysocki not supply these tables.
36*03b22496SRafael J. Wysocki
37*03b22496SRafael J. Wysocki 6th Generation: powernow-k6
38*03b22496SRafael J. Wysocki
39*03b22496SRafael J. Wysocki 7th Generation: powernow-k7: Athlon, Duron, Geode.
40*03b22496SRafael J. Wysocki
41*03b22496SRafael J. Wysocki 8th Generation: powernow-k8: Athlon, Athlon 64, Opteron, Sempron.
42*03b22496SRafael J. Wysocki Documentation on this functionality in 8th generation processors
43*03b22496SRafael J. Wysocki is available in the "BIOS and Kernel Developer's Guide", publication
44*03b22496SRafael J. Wysocki 26094, in chapter 9, available for download from www.amd.com.
45*03b22496SRafael J. Wysocki
46*03b22496SRafael J. Wysocki BIOS supplied data, for powernow-k7 and for powernow-k8, may be
47*03b22496SRafael J. Wysocki from either the PSB table or from ACPI objects. The ACPI support
48*03b22496SRafael J. Wysocki is only available if the kernel config sets CONFIG_ACPI_PROCESSOR.
49*03b22496SRafael J. Wysocki The powernow-k8 driver will attempt to use ACPI if so configured,
50*03b22496SRafael J. Wysocki and fall back to PST if that fails.
51*03b22496SRafael J. Wysocki The powernow-k7 driver will try to use the PSB support first, and
52*03b22496SRafael J. Wysocki fall back to ACPI if the PSB support fails. A module parameter,
53*03b22496SRafael J. Wysocki acpi_force, is provided to force ACPI support to be used instead
54*03b22496SRafael J. Wysocki of PSB support.
55*03b22496SRafael J. Wysocki
56*03b22496SRafael J. Wysocki
57*03b22496SRafael J. Wysocki``cpufreq-nforce2``
58*03b22496SRafael J. Wysocki===================
59*03b22496SRafael J. Wysocki
60*03b22496SRafael J. Wysocki::
61*03b22496SRafael J. Wysocki
62*03b22496SRafael J. Wysocki The cpufreq-nforce2 driver changes the FSB on nVidia nForce2 platforms.
63*03b22496SRafael J. Wysocki
64*03b22496SRafael J. Wysocki This works better than on other platforms, because the FSB of the CPU
65*03b22496SRafael J. Wysocki can be controlled independently from the PCI/AGP clock.
66*03b22496SRafael J. Wysocki
67*03b22496SRafael J. Wysocki The module has two options:
68*03b22496SRafael J. Wysocki
69*03b22496SRafael J. Wysocki 	fid: 	 multiplier * 10 (for example 8.5 = 85)
70*03b22496SRafael J. Wysocki 	min_fsb: minimum FSB
71*03b22496SRafael J. Wysocki
72*03b22496SRafael J. Wysocki If not set, fid is calculated from the current CPU speed and the FSB.
73*03b22496SRafael J. Wysocki min_fsb defaults to FSB at boot time - 50 MHz.
74*03b22496SRafael J. Wysocki
75*03b22496SRafael J. Wysocki IMPORTANT: The available range is limited downwards!
76*03b22496SRafael J. Wysocki            Also the minimum available FSB can differ, for systems
77*03b22496SRafael J. Wysocki            booting with 200 MHz, 150 should always work.
78*03b22496SRafael J. Wysocki
79*03b22496SRafael J. Wysocki
80*03b22496SRafael J. Wysocki``pcc-cpufreq``
81*03b22496SRafael J. Wysocki===============
82*03b22496SRafael J. Wysocki
83*03b22496SRafael J. Wysocki::
84*03b22496SRafael J. Wysocki
85*03b22496SRafael J. Wysocki /*
86*03b22496SRafael J. Wysocki  *  pcc-cpufreq.txt - PCC interface documentation
87*03b22496SRafael J. Wysocki  *
88*03b22496SRafael J. Wysocki  *  Copyright (C) 2009 Red Hat, Matthew Garrett <mjg@redhat.com>
89*03b22496SRafael J. Wysocki  *  Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
90*03b22496SRafael J. Wysocki  *      Nagananda Chumbalkar <nagananda.chumbalkar@hp.com>
91*03b22496SRafael J. Wysocki  */
92*03b22496SRafael J. Wysocki
93*03b22496SRafael J. Wysocki
94*03b22496SRafael J. Wysocki 			Processor Clocking Control Driver
95*03b22496SRafael J. Wysocki 			---------------------------------
96*03b22496SRafael J. Wysocki
97*03b22496SRafael J. Wysocki Contents:
98*03b22496SRafael J. Wysocki ---------
99*03b22496SRafael J. Wysocki 1.	Introduction
100*03b22496SRafael J. Wysocki 1.1	PCC interface
101*03b22496SRafael J. Wysocki 1.1.1	Get Average Frequency
102*03b22496SRafael J. Wysocki 1.1.2	Set Desired Frequency
103*03b22496SRafael J. Wysocki 1.2	Platforms affected
104*03b22496SRafael J. Wysocki 2.	Driver and /sys details
105*03b22496SRafael J. Wysocki 2.1	scaling_available_frequencies
106*03b22496SRafael J. Wysocki 2.2	cpuinfo_transition_latency
107*03b22496SRafael J. Wysocki 2.3	cpuinfo_cur_freq
108*03b22496SRafael J. Wysocki 2.4	related_cpus
109*03b22496SRafael J. Wysocki 3.	Caveats
110*03b22496SRafael J. Wysocki
111*03b22496SRafael J. Wysocki 1. Introduction:
112*03b22496SRafael J. Wysocki ----------------
113*03b22496SRafael J. Wysocki Processor Clocking Control (PCC) is an interface between the platform
114*03b22496SRafael J. Wysocki firmware and OSPM. It is a mechanism for coordinating processor
115*03b22496SRafael J. Wysocki performance (ie: frequency) between the platform firmware and the OS.
116*03b22496SRafael J. Wysocki
117*03b22496SRafael J. Wysocki The PCC driver (pcc-cpufreq) allows OSPM to take advantage of the PCC
118*03b22496SRafael J. Wysocki interface.
119*03b22496SRafael J. Wysocki
120*03b22496SRafael J. Wysocki OS utilizes the PCC interface to inform platform firmware what frequency the
121*03b22496SRafael J. Wysocki OS wants for a logical processor. The platform firmware attempts to achieve
122*03b22496SRafael J. Wysocki the requested frequency. If the request for the target frequency could not be
123*03b22496SRafael J. Wysocki satisfied by platform firmware, then it usually means that power budget
124*03b22496SRafael J. Wysocki conditions are in place, and "power capping" is taking place.
125*03b22496SRafael J. Wysocki
126*03b22496SRafael J. Wysocki 1.1 PCC interface:
127*03b22496SRafael J. Wysocki ------------------
128*03b22496SRafael J. Wysocki The complete PCC specification is available here:
129*03b22496SRafael J. Wysocki https://acpica.org/sites/acpica/files/Processor-Clocking-Control-v1p0.pdf
130*03b22496SRafael J. Wysocki
131*03b22496SRafael J. Wysocki PCC relies on a shared memory region that provides a channel for communication
132*03b22496SRafael J. Wysocki between the OS and platform firmware. PCC also implements a "doorbell" that
133*03b22496SRafael J. Wysocki is used by the OS to inform the platform firmware that a command has been
134*03b22496SRafael J. Wysocki sent.
135*03b22496SRafael J. Wysocki
136*03b22496SRafael J. Wysocki The ACPI PCCH() method is used to discover the location of the PCC shared
137*03b22496SRafael J. Wysocki memory region. The shared memory region header contains the "command" and
138*03b22496SRafael J. Wysocki "status" interface. PCCH() also contains details on how to access the platform
139*03b22496SRafael J. Wysocki doorbell.
140*03b22496SRafael J. Wysocki
141*03b22496SRafael J. Wysocki The following commands are supported by the PCC interface:
142*03b22496SRafael J. Wysocki * Get Average Frequency
143*03b22496SRafael J. Wysocki * Set Desired Frequency
144*03b22496SRafael J. Wysocki
145*03b22496SRafael J. Wysocki The ACPI PCCP() method is implemented for each logical processor and is
146*03b22496SRafael J. Wysocki used to discover the offsets for the input and output buffers in the shared
147*03b22496SRafael J. Wysocki memory region.
148*03b22496SRafael J. Wysocki
149*03b22496SRafael J. Wysocki When PCC mode is enabled, the platform will not expose processor performance
150*03b22496SRafael J. Wysocki or throttle states (_PSS, _TSS and related ACPI objects) to OSPM. Therefore,
151*03b22496SRafael J. Wysocki the native P-state driver (such as acpi-cpufreq for Intel, powernow-k8 for
152*03b22496SRafael J. Wysocki AMD) will not load.
153*03b22496SRafael J. Wysocki
154*03b22496SRafael J. Wysocki However, OSPM remains in control of policy. The governor (eg: "ondemand")
155*03b22496SRafael J. Wysocki computes the required performance for each processor based on server workload.
156*03b22496SRafael J. Wysocki The PCC driver fills in the command interface, and the input buffer and
157*03b22496SRafael J. Wysocki communicates the request to the platform firmware. The platform firmware is
158*03b22496SRafael J. Wysocki responsible for delivering the requested performance.
159*03b22496SRafael J. Wysocki
160*03b22496SRafael J. Wysocki Each PCC command is "global" in scope and can affect all the logical CPUs in
161*03b22496SRafael J. Wysocki the system. Therefore, PCC is capable of performing "group" updates. With PCC
162*03b22496SRafael J. Wysocki the OS is capable of getting/setting the frequency of all the logical CPUs in
163*03b22496SRafael J. Wysocki the system with a single call to the BIOS.
164*03b22496SRafael J. Wysocki
165*03b22496SRafael J. Wysocki 1.1.1 Get Average Frequency:
166*03b22496SRafael J. Wysocki ----------------------------
167*03b22496SRafael J. Wysocki This command is used by the OSPM to query the running frequency of the
168*03b22496SRafael J. Wysocki processor since the last time this command was completed. The output buffer
169*03b22496SRafael J. Wysocki indicates the average unhalted frequency of the logical processor expressed as
170*03b22496SRafael J. Wysocki a percentage of the nominal (ie: maximum) CPU frequency. The output buffer
171*03b22496SRafael J. Wysocki also signifies if the CPU frequency is limited by a power budget condition.
172*03b22496SRafael J. Wysocki
173*03b22496SRafael J. Wysocki 1.1.2 Set Desired Frequency:
174*03b22496SRafael J. Wysocki ----------------------------
175*03b22496SRafael J. Wysocki This command is used by the OSPM to communicate to the platform firmware the
176*03b22496SRafael J. Wysocki desired frequency for a logical processor. The output buffer is currently
177*03b22496SRafael J. Wysocki ignored by OSPM. The next invocation of "Get Average Frequency" will inform
178*03b22496SRafael J. Wysocki OSPM if the desired frequency was achieved or not.
179*03b22496SRafael J. Wysocki
180*03b22496SRafael J. Wysocki 1.2 Platforms affected:
181*03b22496SRafael J. Wysocki -----------------------
182*03b22496SRafael J. Wysocki The PCC driver will load on any system where the platform firmware:
183*03b22496SRafael J. Wysocki * supports the PCC interface, and the associated PCCH() and PCCP() methods
184*03b22496SRafael J. Wysocki * assumes responsibility for managing the hardware clocking controls in order
185*03b22496SRafael J. Wysocki to deliver the requested processor performance
186*03b22496SRafael J. Wysocki
187*03b22496SRafael J. Wysocki Currently, certain HP ProLiant platforms implement the PCC interface. On those
188*03b22496SRafael J. Wysocki platforms PCC is the "default" choice.
189*03b22496SRafael J. Wysocki
190*03b22496SRafael J. Wysocki However, it is possible to disable this interface via a BIOS setting. In
191*03b22496SRafael J. Wysocki such an instance, as is also the case on platforms where the PCC interface
192*03b22496SRafael J. Wysocki is not implemented, the PCC driver will fail to load silently.
193*03b22496SRafael J. Wysocki
194*03b22496SRafael J. Wysocki 2. Driver and /sys details:
195*03b22496SRafael J. Wysocki ---------------------------
196*03b22496SRafael J. Wysocki When the driver loads, it merely prints the lowest and the highest CPU
197*03b22496SRafael J. Wysocki frequencies supported by the platform firmware.
198*03b22496SRafael J. Wysocki
199*03b22496SRafael J. Wysocki The PCC driver loads with a message such as:
200*03b22496SRafael J. Wysocki pcc-cpufreq: (v1.00.00) driver loaded with frequency limits: 1600 MHz, 2933
201*03b22496SRafael J. Wysocki MHz
202*03b22496SRafael J. Wysocki
203*03b22496SRafael J. Wysocki This means that the OPSM can request the CPU to run at any frequency in
204*03b22496SRafael J. Wysocki between the limits (1600 MHz, and 2933 MHz) specified in the message.
205*03b22496SRafael J. Wysocki
206*03b22496SRafael J. Wysocki Internally, there is no need for the driver to convert the "target" frequency
207*03b22496SRafael J. Wysocki to a corresponding P-state.
208*03b22496SRafael J. Wysocki
209*03b22496SRafael J. Wysocki The VERSION number for the driver will be of the format v.xy.ab.
210*03b22496SRafael J. Wysocki eg: 1.00.02
211*03b22496SRafael J. Wysocki    ----- --
212*03b22496SRafael J. Wysocki     |    |
213*03b22496SRafael J. Wysocki     |    -- this will increase with bug fixes/enhancements to the driver
214*03b22496SRafael J. Wysocki     |-- this is the version of the PCC specification the driver adheres to
215*03b22496SRafael J. Wysocki
216*03b22496SRafael J. Wysocki
217*03b22496SRafael J. Wysocki The following is a brief discussion on some of the fields exported via the
218*03b22496SRafael J. Wysocki /sys filesystem and how their values are affected by the PCC driver:
219*03b22496SRafael J. Wysocki
220*03b22496SRafael J. Wysocki 2.1 scaling_available_frequencies:
221*03b22496SRafael J. Wysocki ----------------------------------
222*03b22496SRafael J. Wysocki scaling_available_frequencies is not created in /sys. No intermediate
223*03b22496SRafael J. Wysocki frequencies need to be listed because the BIOS will try to achieve any
224*03b22496SRafael J. Wysocki frequency, within limits, requested by the governor. A frequency does not have
225*03b22496SRafael J. Wysocki to be strictly associated with a P-state.
226*03b22496SRafael J. Wysocki
227*03b22496SRafael J. Wysocki 2.2 cpuinfo_transition_latency:
228*03b22496SRafael J. Wysocki -------------------------------
229*03b22496SRafael J. Wysocki The cpuinfo_transition_latency field is 0. The PCC specification does
230*03b22496SRafael J. Wysocki not include a field to expose this value currently.
231*03b22496SRafael J. Wysocki
232*03b22496SRafael J. Wysocki 2.3 cpuinfo_cur_freq:
233*03b22496SRafael J. Wysocki ---------------------
234*03b22496SRafael J. Wysocki A) Often cpuinfo_cur_freq will show a value different than what is declared
235*03b22496SRafael J. Wysocki in the scaling_available_frequencies or scaling_cur_freq, or scaling_max_freq.
236*03b22496SRafael J. Wysocki This is due to "turbo boost" available on recent Intel processors. If certain
237*03b22496SRafael J. Wysocki conditions are met the BIOS can achieve a slightly higher speed than requested
238*03b22496SRafael J. Wysocki by OSPM. An example:
239*03b22496SRafael J. Wysocki
240*03b22496SRafael J. Wysocki scaling_cur_freq	: 2933000
241*03b22496SRafael J. Wysocki cpuinfo_cur_freq	: 3196000
242*03b22496SRafael J. Wysocki
243*03b22496SRafael J. Wysocki B) There is a round-off error associated with the cpuinfo_cur_freq value.
244*03b22496SRafael J. Wysocki Since the driver obtains the current frequency as a "percentage" (%) of the
245*03b22496SRafael J. Wysocki nominal frequency from the BIOS, sometimes, the values displayed by
246*03b22496SRafael J. Wysocki scaling_cur_freq and cpuinfo_cur_freq may not match. An example:
247*03b22496SRafael J. Wysocki
248*03b22496SRafael J. Wysocki scaling_cur_freq	: 1600000
249*03b22496SRafael J. Wysocki cpuinfo_cur_freq	: 1583000
250*03b22496SRafael J. Wysocki
251*03b22496SRafael J. Wysocki In this example, the nominal frequency is 2933 MHz. The driver obtains the
252*03b22496SRafael J. Wysocki current frequency, cpuinfo_cur_freq, as 54% of the nominal frequency:
253*03b22496SRafael J. Wysocki
254*03b22496SRafael J. Wysocki 	54% of 2933 MHz = 1583 MHz
255*03b22496SRafael J. Wysocki
256*03b22496SRafael J. Wysocki Nominal frequency is the maximum frequency of the processor, and it usually
257*03b22496SRafael J. Wysocki corresponds to the frequency of the P0 P-state.
258*03b22496SRafael J. Wysocki
259*03b22496SRafael J. Wysocki 2.4 related_cpus:
260*03b22496SRafael J. Wysocki -----------------
261*03b22496SRafael J. Wysocki The related_cpus field is identical to affected_cpus.
262*03b22496SRafael J. Wysocki
263*03b22496SRafael J. Wysocki affected_cpus	: 4
264*03b22496SRafael J. Wysocki related_cpus	: 4
265*03b22496SRafael J. Wysocki
266*03b22496SRafael J. Wysocki Currently, the PCC driver does not evaluate _PSD. The platforms that support
267*03b22496SRafael J. Wysocki PCC do not implement SW_ALL. So OSPM doesn't need to perform any coordination
268*03b22496SRafael J. Wysocki to ensure that the same frequency is requested of all dependent CPUs.
269*03b22496SRafael J. Wysocki
270*03b22496SRafael J. Wysocki 3. Caveats:
271*03b22496SRafael J. Wysocki -----------
272*03b22496SRafael J. Wysocki The "cpufreq_stats" module in its present form cannot be loaded and
273*03b22496SRafael J. Wysocki expected to work with the PCC driver. Since the "cpufreq_stats" module
274*03b22496SRafael J. Wysocki provides information wrt each P-state, it is not applicable to the PCC driver.
275