mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
PM / QoS: Make it possible to expose device latency tolerance to userspace
Typically when a device is created the bus core it belongs to (for example PCI) does not know if the device supports things like latency tolerance. This is left to the driver that binds to the device in question. However, at that time the device has already been created and there is no way to set its dev->power.set_latency_tolerance anymore. So follow what has been done for other PM QoS attributes as well and allow drivers to expose and hide latency tolerance from userspace, if the device supports it. Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
bc0195aad0
commit
13b2c4a0c3
4 changed files with 55 additions and 0 deletions
|
@ -883,3 +883,40 @@ int dev_pm_qos_update_user_latency_tolerance(struct device *dev, s32 val)
|
|||
mutex_unlock(&dev_pm_qos_mtx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_pm_qos_expose_latency_tolerance - Expose latency tolerance to userspace
|
||||
* @dev: Device whose latency tolerance to expose
|
||||
*/
|
||||
int dev_pm_qos_expose_latency_tolerance(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!dev->power.set_latency_tolerance)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&dev_pm_qos_sysfs_mtx);
|
||||
ret = pm_qos_sysfs_add_latency_tolerance(dev);
|
||||
mutex_unlock(&dev_pm_qos_sysfs_mtx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_qos_expose_latency_tolerance);
|
||||
|
||||
/**
|
||||
* dev_pm_qos_hide_latency_tolerance - Hide latency tolerance from userspace
|
||||
* @dev: Device whose latency tolerance to hide
|
||||
*/
|
||||
void dev_pm_qos_hide_latency_tolerance(struct device *dev)
|
||||
{
|
||||
mutex_lock(&dev_pm_qos_sysfs_mtx);
|
||||
pm_qos_sysfs_remove_latency_tolerance(dev);
|
||||
mutex_unlock(&dev_pm_qos_sysfs_mtx);
|
||||
|
||||
/* Remove the request from user space now */
|
||||
pm_runtime_get_sync(dev);
|
||||
dev_pm_qos_update_user_latency_tolerance(dev,
|
||||
PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT);
|
||||
pm_runtime_put(dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_qos_hide_latency_tolerance);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue