PM: runtime: Mark last busy stamp in pm_runtime_put_autosuspend()
Set device's last busy timestamp to current time in pm_runtime_put_autosuspend(). Callers wishing not to do that will need to use __pm_runtime_put_autosuspend(). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://patch.msgid.link/20250616061212.2286741-3-sakari.ailus@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
271ff96d60
commit
b3db492e83
@@ -411,8 +411,9 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
|
|||||||
pm_request_idle(dev) and return its result
|
pm_request_idle(dev) and return its result
|
||||||
|
|
||||||
`int pm_runtime_put_autosuspend(struct device *dev);`
|
`int pm_runtime_put_autosuspend(struct device *dev);`
|
||||||
- does the same as __pm_runtime_put_autosuspend() for now, but in the
|
- set the power.last_busy field to the current time and decrement the
|
||||||
future, will also call pm_runtime_mark_last_busy() as well, DO NOT USE!
|
device's usage counter; if the result is 0 then run
|
||||||
|
pm_request_autosuspend(dev) and return its result
|
||||||
|
|
||||||
`int __pm_runtime_put_autosuspend(struct device *dev);`
|
`int __pm_runtime_put_autosuspend(struct device *dev);`
|
||||||
- decrement the device's usage counter; if the result is 0 then run
|
- decrement the device's usage counter; if the result is 0 then run
|
||||||
@@ -870,11 +871,9 @@ device is automatically suspended (the subsystem or driver still has to call
|
|||||||
the appropriate PM routines); rather it means that runtime suspends will
|
the appropriate PM routines); rather it means that runtime suspends will
|
||||||
automatically be delayed until the desired period of inactivity has elapsed.
|
automatically be delayed until the desired period of inactivity has elapsed.
|
||||||
|
|
||||||
Inactivity is determined based on the power.last_busy field. Drivers should
|
Inactivity is determined based on the power.last_busy field. The desired length
|
||||||
call pm_runtime_mark_last_busy() to update this field after carrying out I/O,
|
of the inactivity period is a matter of policy. Subsystems can set this length
|
||||||
typically just before calling __pm_runtime_put_autosuspend(). The desired
|
initially by calling pm_runtime_set_autosuspend_delay(), but after device
|
||||||
length of the inactivity period is a matter of policy. Subsystems can set this
|
|
||||||
length initially by calling pm_runtime_set_autosuspend_delay(), but after device
|
|
||||||
registration the length should be controlled by user space, using the
|
registration the length should be controlled by user space, using the
|
||||||
/sys/devices/.../power/autosuspend_delay_ms attribute.
|
/sys/devices/.../power/autosuspend_delay_ms attribute.
|
||||||
|
|
||||||
@@ -885,7 +884,7 @@ instead of the non-autosuspend counterparts::
|
|||||||
|
|
||||||
Instead of: pm_runtime_suspend use: pm_runtime_autosuspend;
|
Instead of: pm_runtime_suspend use: pm_runtime_autosuspend;
|
||||||
Instead of: pm_schedule_suspend use: pm_request_autosuspend;
|
Instead of: pm_schedule_suspend use: pm_request_autosuspend;
|
||||||
Instead of: pm_runtime_put use: __pm_runtime_put_autosuspend;
|
Instead of: pm_runtime_put use: pm_runtime_put_autosuspend;
|
||||||
Instead of: pm_runtime_put_sync use: pm_runtime_put_sync_autosuspend.
|
Instead of: pm_runtime_put_sync use: pm_runtime_put_sync_autosuspend.
|
||||||
|
|
||||||
Drivers may also continue to use the non-autosuspend helper functions; they
|
Drivers may also continue to use the non-autosuspend helper functions; they
|
||||||
@@ -922,12 +921,10 @@ Here is a schematic pseudo-code example::
|
|||||||
foo_io_completion(struct foo_priv *foo, void *req)
|
foo_io_completion(struct foo_priv *foo, void *req)
|
||||||
{
|
{
|
||||||
lock(&foo->private_lock);
|
lock(&foo->private_lock);
|
||||||
if (--foo->num_pending_requests == 0) {
|
if (--foo->num_pending_requests == 0)
|
||||||
pm_runtime_mark_last_busy(&foo->dev);
|
pm_runtime_put_autosuspend(&foo->dev);
|
||||||
__pm_runtime_put_autosuspend(&foo->dev);
|
else
|
||||||
} else {
|
|
||||||
foo_process_next_request(foo);
|
foo_process_next_request(foo);
|
||||||
}
|
|
||||||
unlock(&foo->private_lock);
|
unlock(&foo->private_lock);
|
||||||
/* Send req result back to the user ... */
|
/* Send req result back to the user ... */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,11 +568,13 @@ static inline int __pm_runtime_put_autosuspend(struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
|
* pm_runtime_put_autosuspend - Update the last access time of a device, drop
|
||||||
|
* its usage counter and queue autosuspend if the usage counter becomes 0.
|
||||||
* @dev: Target device.
|
* @dev: Target device.
|
||||||
*
|
*
|
||||||
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
* Update the last access time of @dev, decrement runtime PM usage counter of
|
||||||
* equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
|
* @dev and if it turns out to be equal to 0, queue up a work item for @dev like
|
||||||
|
* in pm_request_autosuspend().
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* * 0: Success.
|
* * 0: Success.
|
||||||
@@ -587,8 +589,8 @@ static inline int __pm_runtime_put_autosuspend(struct device *dev)
|
|||||||
*/
|
*/
|
||||||
static inline int pm_runtime_put_autosuspend(struct device *dev)
|
static inline int pm_runtime_put_autosuspend(struct device *dev)
|
||||||
{
|
{
|
||||||
return __pm_runtime_suspend(dev,
|
pm_runtime_mark_last_busy(dev);
|
||||||
RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
|
return __pm_runtime_put_autosuspend(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user