11.. SPDX-License-Identifier: GPL-2.0
22 .. include :: <isonum.txt>
33
4- .. |struct cpuidle_governor | replace :: :c:type: `struct cpuidle_governor <cpuidle_governor> `
5- .. |struct cpuidle_device | replace :: :c:type: `struct cpuidle_device <cpuidle_device> `
6- .. |struct cpuidle_driver | replace :: :c:type: `struct cpuidle_driver <cpuidle_driver> `
7- .. |struct cpuidle_state | replace :: :c:type: `struct cpuidle_state <cpuidle_state> `
8-
94========================
105CPU Idle Time Management
116========================
@@ -54,7 +49,7 @@ platform that the Linux kernel can run on. For this reason, data structures
5449operated on by them cannot depend on any hardware architecture or platform
5550design details as well.
5651
57- The governor itself is represented by a | struct cpuidle_governor | object
52+ The governor itself is represented by a struct cpuidle_governor object
5853containing four callback pointers, :c:member: `enable `, :c:member: `disable `,
5954:c:member: `select `, :c:member: `reflect `, a :c:member: `rating ` field described
6055below, and a name (string) used for identifying it.
@@ -83,11 +78,11 @@ callbacks:
8378 int (*enable) (struct cpuidle_driver *drv, struct cpuidle_device *dev);
8479
8580 The role of this callback is to prepare the governor for handling the
86- (logical) CPU represented by the | struct cpuidle_device | object pointed
87- to by the ``dev `` argument. The | struct cpuidle_driver | object pointed
81+ (logical) CPU represented by the struct cpuidle_device object pointed
82+ to by the ``dev `` argument. The struct cpuidle_driver object pointed
8883 to by the ``drv `` argument represents the ``CPUIdle `` driver to be used
8984 with that CPU (among other things, it should contain the list of
90- | struct cpuidle_state | objects representing idle states that the
85+ struct cpuidle_state objects representing idle states that the
9186 processor holding the given CPU can be asked to enter).
9287
9388 It may fail, in which case it is expected to return a negative error
@@ -102,7 +97,7 @@ callbacks:
10297 void (*disable) (struct cpuidle_driver *drv, struct cpuidle_device *dev);
10398
10499 Called to make the governor stop handling the (logical) CPU represented
105- by the | struct cpuidle_device | object pointed to by the ``dev ``
100+ by the struct cpuidle_device object pointed to by the ``dev ``
106101 argument.
107102
108103 It is expected to reverse any changes made by the ``->enable() ``
@@ -116,12 +111,12 @@ callbacks:
116111 bool *stop_tick);
117112
118113 Called to select an idle state for the processor holding the (logical)
119- CPU represented by the | struct cpuidle_device | object pointed to by the
114+ CPU represented by the struct cpuidle_device object pointed to by the
120115 ``dev `` argument.
121116
122117 The list of idle states to take into consideration is represented by the
123- :c:member: `states ` array of | struct cpuidle_state | objects held by the
124- | struct cpuidle_driver | object pointed to by the ``drv `` argument (which
118+ :c:member: `states ` array of struct cpuidle_state objects held by the
119+ struct cpuidle_driver object pointed to by the ``drv `` argument (which
125120 represents the ``CPUIdle `` driver to be used with the CPU at hand). The
126121 value returned by this callback is interpreted as an index into that
127122 array (unless it is a negative error code).
@@ -136,7 +131,7 @@ callbacks:
136131 asking the processor to enter the idle state).
137132
138133 This callback is mandatory (i.e. the :c:member: `select ` callback pointer
139- in | struct cpuidle_governor | must not be ``NULL `` for the registration
134+ in struct cpuidle_governor must not be ``NULL `` for the registration
140135 of the governor to succeed).
141136
142137:c:member: `reflect `
@@ -167,21 +162,21 @@ CPU idle time management (``CPUIdle``) drivers provide an interface between the
167162other parts of ``CPUIdle `` and the hardware.
168163
169164First of all, a ``CPUIdle `` driver has to populate the :c:member: `states ` array
170- of | struct cpuidle_state | objects included in the | struct cpuidle_driver | object
165+ of struct cpuidle_state objects included in the struct cpuidle_driver object
171166representing it. Going forward this array will represent the list of available
172167idle states that the processor hardware can be asked to enter shared by all of
173168the logical CPUs handled by the given driver.
174169
175170The entries in the :c:member: `states ` array are expected to be sorted by the
176- value of the :c:member: `target_residency ` field in | struct cpuidle_state | in
171+ value of the :c:member: `target_residency ` field in struct cpuidle_state in
177172the ascending order (that is, index 0 should correspond to the idle state with
178173the minimum value of :c:member: `target_residency `). [Since the
179174:c:member: `target_residency ` value is expected to reflect the "depth" of the
180- idle state represented by the | struct cpuidle_state | object holding it, this
175+ idle state represented by the struct cpuidle_state object holding it, this
181176sorting order should be the same as the ascending sorting order by the idle
182177state "depth".]
183178
184- Three fields in | struct cpuidle_state | are used by the existing ``CPUIdle ``
179+ Three fields in struct cpuidle_state are used by the existing ``CPUIdle ``
185180governors for computations related to idle state selection:
186181
187182:c:member: `target_residency `
@@ -203,7 +198,7 @@ governors for computations related to idle state selection:
203198 any idle state at all. [There are other flags used by the ``CPUIdle ``
204199 core in special situations.]
205200
206- The :c:member: `enter ` callback pointer in | struct cpuidle_state | , which must not
201+ The :c:member: `enter ` callback pointer in struct cpuidle_state, which must not
207202be ``NULL ``, points to the routine to execute in order to ask the processor to
208203enter this particular idle state:
209204
@@ -212,63 +207,63 @@ enter this particular idle state:
212207 void (*enter) (struct cpuidle_device *dev, struct cpuidle_driver *drv,
213208 int index);
214209
215- The first two arguments of it point to the | struct cpuidle_device | object
210+ The first two arguments of it point to the struct cpuidle_device object
216211representing the logical CPU running this callback and the
217- | struct cpuidle_driver | object representing the driver itself, respectively,
218- and the last one is an index of the | struct cpuidle_state | entry in the driver's
212+ struct cpuidle_driver object representing the driver itself, respectively,
213+ and the last one is an index of the struct cpuidle_state entry in the driver's
219214:c:member: `states ` array representing the idle state to ask the processor to
220215enter.
221216
222- The analogous ``->enter_s2idle() `` callback in | struct cpuidle_state | is used
217+ The analogous ``->enter_s2idle() `` callback in struct cpuidle_state is used
223218only for implementing the suspend-to-idle system-wide power management feature.
224219The difference between in and ``->enter() `` is that it must not re-enable
225220interrupts at any point (even temporarily) or attempt to change the states of
226221clock event devices, which the ``->enter() `` callback may do sometimes.
227222
228223Once the :c:member: `states ` array has been populated, the number of valid
229224entries in it has to be stored in the :c:member: `state_count ` field of the
230- | struct cpuidle_driver | object representing the driver. Moreover, if any
225+ struct cpuidle_driver object representing the driver. Moreover, if any
231226entries in the :c:member: `states ` array represent "coupled" idle states (that
232227is, idle states that can only be asked for if multiple related logical CPUs are
233- idle), the :c:member: `safe_state_index ` field in | struct cpuidle_driver | needs
228+ idle), the :c:member: `safe_state_index ` field in struct cpuidle_driver needs
234229to be the index of an idle state that is not "coupled" (that is, one that can be
235230asked for if only one logical CPU is idle).
236231
237232In addition to that, if the given ``CPUIdle `` driver is only going to handle a
238233subset of logical CPUs in the system, the :c:member: `cpumask ` field in its
239- | struct cpuidle_driver | object must point to the set (mask) of CPUs that will be
234+ struct cpuidle_driver object must point to the set (mask) of CPUs that will be
240235handled by it.
241236
242237A ``CPUIdle `` driver can only be used after it has been registered. If there
243238are no "coupled" idle state entries in the driver's :c:member: `states ` array,
244- that can be accomplished by passing the driver's | struct cpuidle_driver | object
239+ that can be accomplished by passing the driver's struct cpuidle_driver object
245240to :c:func: `cpuidle_register_driver() `. Otherwise, :c:func: `cpuidle_register() `
246241should be used for this purpose.
247242
248- However, it also is necessary to register | struct cpuidle_device | objects for
243+ However, it also is necessary to register struct cpuidle_device objects for
249244all of the logical CPUs to be handled by the given ``CPUIdle `` driver with the
250245help of :c:func: `cpuidle_register_device() ` after the driver has been registered
251246and :c:func: `cpuidle_register_driver() `, unlike :c:func: `cpuidle_register() `,
252247does not do that automatically. For this reason, the drivers that use
253248:c:func: `cpuidle_register_driver() ` to register themselves must also take care
254- of registering the | struct cpuidle_device | objects as needed, so it is generally
249+ of registering the struct cpuidle_device objects as needed, so it is generally
255250recommended to use :c:func: `cpuidle_register() ` for ``CPUIdle `` driver
256251registration in all cases.
257252
258- The registration of a | struct cpuidle_device | object causes the ``CPUIdle ``
253+ The registration of a struct cpuidle_device object causes the ``CPUIdle ``
259254``sysfs `` interface to be created and the governor's ``->enable() `` callback to
260255be invoked for the logical CPU represented by it, so it must take place after
261256registering the driver that will handle the CPU in question.
262257
263- ``CPUIdle `` drivers and | struct cpuidle_device | objects can be unregistered
258+ ``CPUIdle `` drivers and struct cpuidle_device objects can be unregistered
264259when they are not necessary any more which allows some resources associated with
265260them to be released. Due to dependencies between them, all of the
266- | struct cpuidle_device | objects representing CPUs handled by the given
261+ struct cpuidle_device objects representing CPUs handled by the given
267262``CPUIdle `` driver must be unregistered, with the help of
268263:c:func: `cpuidle_unregister_device() `, before calling
269264:c:func: `cpuidle_unregister_driver() ` to unregister the driver. Alternatively,
270265:c:func: `cpuidle_unregister() ` can be called to unregister a ``CPUIdle `` driver
271- along with all of the | struct cpuidle_device | objects representing CPUs handled
266+ along with all of the struct cpuidle_device objects representing CPUs handled
272267by it.
273268
274269``CPUIdle `` drivers can respond to runtime system configuration changes that
@@ -277,8 +272,8 @@ happen, for example, when the system's power source is switched from AC to
277272battery or the other way around). Upon a notification of such a change,
278273a ``CPUIdle `` driver is expected to call :c:func: `cpuidle_pause_and_lock() ` to
279274turn ``CPUIdle `` off temporarily and then :c:func: `cpuidle_disable_device() ` for
280- all of the | struct cpuidle_device | objects representing CPUs affected by that
275+ all of the struct cpuidle_device objects representing CPUs affected by that
281276change. Next, it can update its :c:member: `states ` array in accordance with
282277the new configuration of the system, call :c:func: `cpuidle_enable_device() ` for
283- all of the relevant | struct cpuidle_device | objects and invoke
278+ all of the relevant struct cpuidle_device objects and invoke
284279:c:func: `cpuidle_resume_and_unlock() ` to allow ``CPUIdle `` to be used again.
0 commit comments