Skip to content

Commit 45f0a85

Browse files
committed
PM / Runtime: Rework the "runtime idle" helper routine
The "runtime idle" helper routine, rpm_idle(), currently ignores return values from .runtime_idle() callbacks executed by it. However, it turns out that many subsystems use pm_generic_runtime_idle() which checks the return value of the driver's callback and executes pm_runtime_suspend() for the device unless that value is not 0. If that logic is moved to rpm_idle() instead, pm_generic_runtime_idle() can be dropped and its users will not need any .runtime_idle() callbacks any more. Moreover, the PCI, SCSI, and SATA subsystems' .runtime_idle() routines, pci_pm_runtime_idle(), scsi_runtime_idle(), and ata_port_runtime_idle(), respectively, as well as a few drivers' ones may be simplified if rpm_idle() calls rpm_suspend() after 0 has been returned by the .runtime_idle() callback executed by it. To reduce overall code bloat, make the changes described above. Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Kevin Hilman <khilman@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Alan Stern <stern@rowland.harvard.edu>
1 parent cd38ca8 commit 45f0a85

23 files changed

Lines changed: 28 additions & 92 deletions

File tree

‎Documentation/power/runtime_pm.txt‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,6 @@ Subsystems may wish to conserve code space by using the set of generic power
660660
management callbacks provided by the PM core, defined in
661661
driver/base/power/generic_ops.c:
662662

663-
int pm_generic_runtime_idle(struct device *dev);
664-
- invoke the ->runtime_idle() callback provided by the driver of this
665-
device, if defined, and call pm_runtime_suspend() for this device if the
666-
return value is 0 or the callback is not defined
667-
668663
int pm_generic_runtime_suspend(struct device *dev);
669664
- invoke the ->runtime_suspend() callback provided by the driver of this
670665
device and return its result, or return -EINVAL if not defined

‎arch/arm/mach-omap2/omap_device.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,6 @@ static int _od_runtime_suspend(struct device *dev)
591591
return ret;
592592
}
593593

594-
static int _od_runtime_idle(struct device *dev)
595-
{
596-
return pm_generic_runtime_idle(dev);
597-
}
598-
599594
static int _od_runtime_resume(struct device *dev)
600595
{
601596
struct platform_device *pdev = to_platform_device(dev);
@@ -653,7 +648,7 @@ static int _od_resume_noirq(struct device *dev)
653648
struct dev_pm_domain omap_device_pm_domain = {
654649
.ops = {
655650
SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
656-
_od_runtime_idle)
651+
NULL)
657652
USE_PLATFORM_PM_SLEEP_OPS
658653
.suspend_noirq = _od_suspend_noirq,
659654
.resume_noirq = _od_resume_noirq,

‎drivers/acpi/device_pm.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ static struct dev_pm_domain acpi_general_pm_domain = {
886886
#ifdef CONFIG_PM_RUNTIME
887887
.runtime_suspend = acpi_subsys_runtime_suspend,
888888
.runtime_resume = acpi_subsys_runtime_resume,
889-
.runtime_idle = pm_generic_runtime_idle,
890889
#endif
891890
#ifdef CONFIG_PM_SLEEP
892891
.prepare = acpi_subsys_prepare,

‎drivers/amba/bus.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static const struct dev_pm_ops amba_pm = {
284284
SET_RUNTIME_PM_OPS(
285285
amba_pm_runtime_suspend,
286286
amba_pm_runtime_resume,
287-
pm_generic_runtime_idle
287+
NULL
288288
)
289289
};
290290

‎drivers/ata/libata-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5430,7 +5430,7 @@ static int ata_port_runtime_idle(struct device *dev)
54305430
return -EBUSY;
54315431
}
54325432

5433-
return pm_runtime_suspend(dev);
5433+
return 0;
54345434
}
54355435

54365436
static int ata_port_runtime_suspend(struct device *dev)

‎drivers/base/platform.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,6 @@ int platform_pm_restore(struct device *dev)
888888
static const struct dev_pm_ops platform_dev_pm_ops = {
889889
.runtime_suspend = pm_generic_runtime_suspend,
890890
.runtime_resume = pm_generic_runtime_resume,
891-
.runtime_idle = pm_generic_runtime_idle,
892891
USE_PLATFORM_PM_SLEEP_OPS
893892
};
894893

‎drivers/base/power/domain.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,6 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
21432143
genpd->max_off_time_changed = true;
21442144
genpd->domain.ops.runtime_suspend = pm_genpd_runtime_suspend;
21452145
genpd->domain.ops.runtime_resume = pm_genpd_runtime_resume;
2146-
genpd->domain.ops.runtime_idle = pm_generic_runtime_idle;
21472146
genpd->domain.ops.prepare = pm_genpd_prepare;
21482147
genpd->domain.ops.suspend = pm_genpd_suspend;
21492148
genpd->domain.ops.suspend_late = pm_genpd_suspend_late;

‎drivers/base/power/generic_ops.c‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@
1111
#include <linux/export.h>
1212

1313
#ifdef CONFIG_PM_RUNTIME
14-
/**
15-
* pm_generic_runtime_idle - Generic runtime idle callback for subsystems.
16-
* @dev: Device to handle.
17-
*
18-
* If PM operations are defined for the @dev's driver and they include
19-
* ->runtime_idle(), execute it and return its error code, if nonzero.
20-
* Otherwise, execute pm_runtime_suspend() for the device and return 0.
21-
*/
22-
int pm_generic_runtime_idle(struct device *dev)
23-
{
24-
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
25-
26-
if (pm && pm->runtime_idle) {
27-
int ret = pm->runtime_idle(dev);
28-
if (ret)
29-
return ret;
30-
}
31-
32-
pm_runtime_suspend(dev);
33-
return 0;
34-
}
35-
EXPORT_SYMBOL_GPL(pm_generic_runtime_idle);
36-
3714
/**
3815
* pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
3916
* @dev: Device to suspend.

‎drivers/base/power/runtime.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,8 @@ static int rpm_idle(struct device *dev, int rpmflags)
293293
/* Pending requests need to be canceled. */
294294
dev->power.request = RPM_REQ_NONE;
295295

296-
if (dev->power.no_callbacks) {
297-
/* Assume ->runtime_idle() callback would have suspended. */
298-
retval = rpm_suspend(dev, rpmflags);
296+
if (dev->power.no_callbacks)
299297
goto out;
300-
}
301298

302299
/* Carry out an asynchronous or a synchronous idle notification. */
303300
if (rpmflags & RPM_ASYNC) {
@@ -306,7 +303,8 @@ static int rpm_idle(struct device *dev, int rpmflags)
306303
dev->power.request_pending = true;
307304
queue_work(pm_wq, &dev->power.work);
308305
}
309-
goto out;
306+
trace_rpm_return_int(dev, _THIS_IP_, 0);
307+
return 0;
310308
}
311309

312310
dev->power.idle_notification = true;
@@ -326,14 +324,14 @@ static int rpm_idle(struct device *dev, int rpmflags)
326324
callback = dev->driver->pm->runtime_idle;
327325

328326
if (callback)
329-
__rpm_callback(callback, dev);
327+
retval = __rpm_callback(callback, dev);
330328

331329
dev->power.idle_notification = false;
332330
wake_up_all(&dev->power.wait_queue);
333331

334332
out:
335333
trace_rpm_return_int(dev, _THIS_IP_, retval);
336-
return retval;
334+
return retval ? retval : rpm_suspend(dev, rpmflags);
337335
}
338336

339337
/**

‎drivers/dma/intel_mid_dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,7 @@ static int dma_runtime_idle(struct device *dev)
14051405
return -EAGAIN;
14061406
}
14071407

1408-
return pm_schedule_suspend(dev, 0);
1408+
return 0;
14091409
}
14101410

14111411
/******************************************************************************

0 commit comments

Comments
 (0)