Lines Matching full:pm

14 Support for runtime power management (runtime PM) of I/O devices is provided
15 at the power management core (PM core) level by means of:
18 put their PM-related work items. It is strongly recommended that pm_wq be
19 used for queuing all work items related to runtime PM, because this allows
24 * A number of runtime PM fields in the 'power' member of 'struct device' (which
25 is of the type 'struct dev_pm_info', defined in include/linux/pm.h) that can
26 be used for synchronizing runtime PM operations with one another.
28 * Three device runtime PM callbacks in 'struct dev_pm_ops' (defined in
29 include/linux/pm.h).
32 used for carrying out runtime PM operations in such a way that the
33 synchronization between them is taken care of by the PM core. Bus types and
36 The runtime PM callbacks present in 'struct dev_pm_ops', the device runtime PM
38 runtime PM are described below.
40 2. Device Runtime PM Callbacks
43 There are three device runtime PM callbacks defined in 'struct dev_pm_ops'::
54 are executed by the PM core for the device's subsystem that may be either of
57 1. PM domain of the device, if the device's PM domain object, dev->pm_domain,
60 2. Device type of the device, if both dev->type and dev->type->pm are present.
62 3. Device class of the device, if both dev->class and dev->class->pm are
65 4. Bus type of the device, if both dev->bus and dev->bus->pm are present.
68 callback, the PM core will invoke the corresponding driver callback stored in
69 dev->driver->pm directly (if present).
71 The PM core always checks which callback to use in the order given above, so the
72 priority order of callbacks from high to low is: PM domain, device type, class
74 a low-priority one. The PM domain, bus type, device type and class callbacks
79 the PM core that it is safe to run the ->runtime_suspend(), ->runtime_resume()
89 PM core's point of view it is not necessary to implement a ->runtime_suspend()
94 if invoked directly) has completed successfully for the given device, the PM
99 PM status of a device after successful execution of the suspend callback is
102 * If the suspend callback returns -EBUSY or -EAGAIN, the device's runtime PM
107 -EAGAIN, the PM core regards this as a fatal error and will refuse to run
109 is directly set to either 'active', or 'suspended' (the PM core provides
124 PM core's point of view it is not necessary to implement a ->runtime_resume()
129 invoked directly) has completed successfully, the PM core regards the device
131 I/O operations as needed. The runtime PM status of the device is then
134 * If the resume callback returns an error code, the PM core regards this as a
137 'suspended' (by means of special helper functions provided by the PM core
141 executed by the PM core whenever the device appears to be idle, which is
142 indicated to the PM core by two counters, the device's usage counter and the
146 the PM core and it turns out to be equal to zero, the other counter is
147 checked. If that counter also is equal to zero, the PM core executes the
155 0, then the PM core will attempt to carry out a runtime suspend of the device,
159 value. Negative error return codes are ignored by the PM core.
161 The helper functions provided by the PM core, described in Section 4, guarantee
162 that the following constraints are met with respect to runtime PM callbacks for
173 devices (i.e. the PM core will only execute ->runtime_idle() or
174 ->runtime_suspend() for the devices the runtime PM status of which is
183 PM core will only execute ->runtime_resume() for the devices the runtime
184 PM status of which is 'suspended').
186 Additionally, the helper functions provided by the PM core obey the following
203 3. Runtime PM Device Fields
206 The following device runtime PM fields are present in 'struct dev_pm_info', as
207 defined in include/linux/pm.h:
238 equal to zero); the initial value of it is 1 (i.e. runtime PM is
262 - the runtime PM status of the device; this field's initial value is
264 PM core as 'suspended', regardless of its real hardware status
267 - the last runtime PM status of the device captured before disabling runtime
268 PM for it (invalid initially and when disable_depth is 0)
277 - indicates that the device does not use the runtime PM callbacks (see
291 - indicates that the PM core should attempt to carry out an autosuspend
304 4. Runtime PM Device Helper Functions
307 The following runtime PM helper functions are defined in
311 - initialize the device runtime PM fields in 'struct dev_pm_info'
314 - make sure that the runtime PM of the device will be disabled after
325 success, 1 if the device's runtime PM status was already 'suspended', or
337 success, 1 if the device's runtime PM status is already 'active' (also if
348 runtime PM status was already 'active') or the error code from
365 item is queued up immediately); returns 0 on success, 1 if the device's PM
374 success, 1 if the device's runtime PM status was already 'active', or
394 runtime PM status is RPM_ACTIVE and the runtime PM usage counter is
400 runtime PM status is RPM_ACTIVE, increment the counter and
434 to zero, the runtime PM helper functions can execute subsystem-level
439 field was previously zero, this prevents subsystem-level runtime PM
441 pending runtime PM operations on the device are either completed or
448 (synchronously) in that case, cancel any other pending runtime PM requests
449 regarding it and wait for all runtime PM operations on it in progress to
459 PM status to 'active' and update its parent's counter of 'active'
467 PM status to 'suspended' and update its parent's counter of 'active'
473 - return true if the device's runtime PM status is 'active' or its
477 - return true if the device's runtime PM status is 'suspended' and its
481 - return true if the device's runtime PM status is 'suspended'
495 PM attributes from /sys/devices/.../power (or prevent them from being
499 - set the power.irq_safe flag for the device, causing the runtime-PM
504 the runtime-PM callbacks to be invoked with interrupts off
568 5. Runtime PM Initialization, Device Probing and Removal
571 Initially, the runtime PM is disabled for all devices, which means that the
572 majority of the runtime PM helper functions described in Section 4 will return
575 In addition to that, the initial runtime PM status of all devices is
578 runtime PM status must be changed to 'active', with the help of
581 However, if the device has a parent and the parent's runtime PM is enabled,
584 parent won't be able to suspend at run time, using the PM core's helper
586 runtime PM is still disabled (i.e. pm_runtime_enable() hasn't been called for
589 should be called for it too as soon as reasonably possible or its runtime PM
593 If the default initial runtime PM status of the device (i.e. 'suspended')
595 ->probe() callback will likely need to wake it up using one of the PM core's
597 should be used. Of course, for this purpose the device's runtime PM has to be
612 Moreover, the driver core prevents runtime PM callbacks from racing with the bus
615 runtime PM functionality. It does so by calling pm_runtime_get_sync() before
624 drivers to make their ->remove() callbacks avoid races with runtime PM directly,
628 Drivers in ->remove() callback should undo the runtime PM changes done
637 Namely, during the initialization the driver can make sure that the runtime PM
644 6. Runtime PM and System Sleep
647 Runtime PM and system sleep (i.e., system suspend and hibernation, also known
652 The device may have different wake-up settings for runtime PM and system sleep.
681 brought back to full power during resume, then its runtime PM status will have
689 The PM core always increments the runtime usage counter before calling the
691 Hence disabling runtime PM temporarily like this will not cause any runtime
708 To this end, the PM core provides a mechanism allowing some coordination between
710 callback returns a positive number for a device, that indicates to the PM core
713 left in runtime suspend. If that happens, the PM core will not execute any
717 related to hibernation (see Documentation/driver-api/pm/devices.rst for more
720 The PM core does its best to reduce the probability of race conditions between
721 the runtime PM and system suspend/resume (and hibernation) callbacks by carrying
727 subsystem-level .suspend() callback for it. In addition to that the PM core
741 management callbacks provided by the PM core, defined in
764 if successful, change the device's runtime PM status to 'active'
801 if successful, change the device's runtime PM status to 'active'
806 These functions are the defaults used by the PM core if a subsystem doesn't
826 need of runtime PM callbacks; if the callbacks did exist, ->runtime_suspend()
830 Subsystems can tell the PM core about these devices by calling
834 prevent the non-debugging runtime PM sysfs attributes from being created.
836 When power.no_callbacks is set, the PM core will not invoke the
841 As a consequence, the PM core will never directly inform the device's subsystem
848 the runtime PM callbacks needs to be implemented, a platform dependent PM
851 in subsystems/drivers, the PM core allows runtime PM callbacks to be
852 unassigned. More precisely, if a callback pointer is NULL, the PM core will act
869 the appropriate PM routines); rather it means that runtime suspends will
898 pm_runtime_mark_last_busy()), the PM core will automatically reschedule the
904 However such use inevitably involves races, because the PM core can't