Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05d658b5 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-sleep'

* pm-sleep:
  freezer: Fix typo in freezable_schedule_timeout() comment
  PM / s2idle: Clear the events_check_enabled flag
  PM / sleep: Remove pm_complete_with_resume_check()
  PM: ARM: locomo: Drop suspend and resume bus type callbacks
  PM: Use a more common logging style
  PM: Document rules on using pm_runtime_resume() in system suspend callbacks
parents 794c3355 2dd9789c
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -328,7 +328,10 @@ the phases are: ``prepare``, ``suspend``, ``suspend_late``, ``suspend_noirq``.
	After the ``->prepare`` callback method returns, no new children may be
	registered below the device.  The method may also prepare the device or
	driver in some way for the upcoming system power transition, but it
	should not put the device into a low-power state.
	should not put the device into a low-power state.  Moreover, if the
	device supports runtime power management, the ``->prepare`` callback
	method must not update its state in case it is necessary to resume it
	from runtime suspend later on.

	For devices supporting runtime power management, the return value of the
	prepare callback can be used to indicate to the PM core that it may
@@ -356,6 +359,16 @@ the phases are: ``prepare``, ``suspend``, ``suspend_late``, ``suspend_noirq``.
	the appropriate low-power state, depending on the bus type the device is
	on, and they may enable wakeup events.

	However, for devices supporting runtime power management, the
	``->suspend`` methods provided by subsystems (bus types and PM domains
	in particular) must follow an additional rule regarding what can be done
	to the devices before their drivers' ``->suspend`` methods are called.
	Namely, they can only resume the devices from runtime suspend by
	calling :c:func:`pm_runtime_resume` for them, if that is necessary, and
	they must not update the state of the devices in any other way at that
	time (in case the drivers need to resume the devices from runtime
	suspend in their ``->suspend`` methods).

    3.	For a number of devices it is convenient to split suspend into the
	"quiesce device" and "save device state" phases, in which cases
	``suspend_late`` is meant to do the latter.  It is always executed after
@@ -729,6 +742,16 @@ state temporarily, for example so that its system wakeup capability can be
disabled.  This all depends on the hardware and the design of the subsystem and
device driver in question.

If it is necessary to resume a device from runtime suspend during a system-wide
transition into a sleep state, that can be done by calling
:c:func:`pm_runtime_resume` for it from the ``->suspend`` callback (or its
couterpart for transitions related to hibernation) of either the device's driver
or a subsystem responsible for it (for example, a bus type or a PM domain).
That is guaranteed to work by the requirement that subsystems must not change
the state of devices (possibly except for resuming them from runtime suspend)
from their ``->prepare`` and ``->suspend`` callbacks (or equivalent) *before*
invoking device drivers' ``->suspend`` callbacks (or equivalent).

During system-wide resume from a sleep state it's easiest to put devices into
the full-power state, as explained in :file:`Documentation/power/runtime_pm.txt`.
Refer to that document for more information regarding this particular issue as
+0 −24
Original line number Diff line number Diff line
@@ -826,28 +826,6 @@ static int locomo_match(struct device *_dev, struct device_driver *_drv)
	return dev->devid == drv->devid;
}

static int locomo_bus_suspend(struct device *dev, pm_message_t state)
{
	struct locomo_dev *ldev = LOCOMO_DEV(dev);
	struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
	int ret = 0;

	if (drv && drv->suspend)
		ret = drv->suspend(ldev, state);
	return ret;
}

static int locomo_bus_resume(struct device *dev)
{
	struct locomo_dev *ldev = LOCOMO_DEV(dev);
	struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
	int ret = 0;

	if (drv && drv->resume)
		ret = drv->resume(ldev);
	return ret;
}

static int locomo_bus_probe(struct device *dev)
{
	struct locomo_dev *ldev = LOCOMO_DEV(dev);
@@ -875,8 +853,6 @@ struct bus_type locomo_bus_type = {
	.match		= locomo_match,
	.probe		= locomo_bus_probe,
	.remove		= locomo_bus_remove,
	.suspend	= locomo_bus_suspend,
	.resume		= locomo_bus_resume,
};

int locomo_driver_register(struct locomo_driver *driver)
+0 −2
Original line number Diff line number Diff line
@@ -189,8 +189,6 @@ struct locomo_driver {
	unsigned int		devid;
	int (*probe)(struct locomo_dev *);
	int (*remove)(struct locomo_dev *);
	int (*suspend)(struct locomo_dev *, pm_message_t);
	int (*resume)(struct locomo_dev *);
};

#define LOCOMO_DRV(_d)	container_of((_d), struct locomo_driver, drv)
+0 −23
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/export.h>
#include <linux/suspend.h>

#ifdef CONFIG_PM
/**
@@ -298,26 +297,4 @@ void pm_generic_complete(struct device *dev)
	if (drv && drv->pm && drv->pm->complete)
		drv->pm->complete(dev);
}

/**
 * pm_complete_with_resume_check - Complete a device power transition.
 * @dev: Device to handle.
 *
 * Complete a device power transition during a system-wide power transition and
 * optionally schedule a runtime resume of the device if the system resume in
 * progress has been initated by the platform firmware and the device had its
 * power.direct_complete flag set.
 */
void pm_complete_with_resume_check(struct device *dev)
{
	pm_generic_complete(dev);
	/*
	 * If the device had been runtime-suspended before the system went into
	 * the sleep state it is going out of and it has never been resumed till
	 * now, resume it in case the firmware powered it up.
	 */
	if (dev->power.direct_complete && pm_resume_via_firmware())
		pm_request_resume(dev);
}
EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
#endif /* CONFIG_PM_SLEEP */
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ static inline void freezable_schedule_unsafe(void)
}

/*
 * Like freezable_schedule_timeout(), but should not block the freezer.  Do not
 * Like schedule_timeout(), but should not block the freezer.  Do not
 * call this with locks held.
 */
static inline long freezable_schedule_timeout(long timeout)
Loading