* [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend
2014-02-20 15:31 [PATCH " Ulf Hansson
@ 2014-02-20 15:31 ` Ulf Hansson
0 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-02-20 15:31 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Mark Brown,
Russell King, Linus Walleij, Wolfram Sang, Alessandro Rubini,
Ulf Hansson
In runtime suspended state, we are not expecting IRQs and thus we can
safely mask them, not only for pwrreg_nopower variants but for all.
Obviously we then also need to make sure we restore the IRQ mask while
becoming runtime resumed.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/host/mmci.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index b931226..178868a 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1758,35 +1758,34 @@ static void mmci_save(struct mmci_host *host)
{
unsigned long flags;
- if (host->variant->pwrreg_nopower) {
- spin_lock_irqsave(&host->lock, flags);
+ spin_lock_irqsave(&host->lock, flags);
- writel(0, host->base + MMCIMASK0);
+ writel(0, host->base + MMCIMASK0);
+ if (host->variant->pwrreg_nopower) {
writel(0, host->base + MMCIDATACTRL);
writel(0, host->base + MMCIPOWER);
writel(0, host->base + MMCICLOCK);
- mmci_reg_delay(host);
-
- spin_unlock_irqrestore(&host->lock, flags);
}
+ mmci_reg_delay(host);
+ spin_unlock_irqrestore(&host->lock, flags);
}
static void mmci_restore(struct mmci_host *host)
{
unsigned long flags;
- if (host->variant->pwrreg_nopower) {
- spin_lock_irqsave(&host->lock, flags);
+ spin_lock_irqsave(&host->lock, flags);
+ if (host->variant->pwrreg_nopower) {
writel(host->clk_reg, host->base + MMCICLOCK);
writel(host->datactrl_reg, host->base + MMCIDATACTRL);
writel(host->pwr_reg, host->base + MMCIPOWER);
- writel(MCI_IRQENABLE, host->base + MMCIMASK0);
- mmci_reg_delay(host);
-
- spin_unlock_irqrestore(&host->lock, flags);
}
+ writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+ mmci_reg_delay(host);
+
+ spin_unlock_irqrestore(&host->lock, flags);
}
static int mmci_runtime_suspend(struct device *dev)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
@ 2014-03-01 10:56 Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
` (8 more replies)
0 siblings, 9 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
Patch 1 -> 2:
These patches provides two new runtime PM helper functions which intend to be
used from system suspend/resume callbacks, to make sure devices are put into low
power state during system suspend and brought back to full power at system
resume.
The prerequisite is to have all levels of a device's runtime PM callbacks to be
defined through the SET_PM_RUNTIME_PM_OPS macro, which means these are available
for CONFIG_PM.
By using the new runtime PM helper functions especially the two scenarios below
will be addressed.
1) The PM core prevents .runtime_suspend callbacks from being invoked during
system suspend. That means even for a runtime PM centric subsystem and driver,
the device needs to be put into low power state from a system suspend callback.
Otherwise it may very well be left in full power state (runtime resumed) while
the system is suspended. By using the new helper functions, we make sure to walk
the hierarchy of a device's power domain, subsystem and driver.
2) Subsystems and drivers need to cope with all the combinations of
CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions smothly
addresses this.
Patch 3 -> 4:
Fixup system suspend for spi-pl022 driver, by using the new runtime PM helper
functions.
These patches is based upon the latest next-branch for spi-pl022 driver. They
will not apply to Rafael's linux-pm tree, but are included in this patchset for
reference and to receive comments/acks.
Patch 5:
Fixup system suspend for i2c-nomadik driver, by using the new runtime PM helper
functions.
This patch is based upon the latest next-branch for the i2c-nomadik driver. They
will not apply to Rafael's linux-pm tree, but are included in this patchset for
reference and to receive comments/acks.
Patch 6 -> 8:
Fixup system suspend for mmci driver, by using the new runtime PM helper
functions.
A final note, the amba bus has converted to use the SET_PM_RUNTIME_PM_OPS
which is needed for these patches to work with only CONFIG_PM_SLEEP and not
CONFIG_PM_RUNTIME. Anyway, the patches for the amba bus have recently been
applied by Russell and resides in his ARM tree.
Changes in v3:
This is repost of the patchset. Only patch 1 and patch 2 has been
updated to v3, the rest are still in v1.
Ulf Hansson (8):
PM / Runtime: Fetch runtime PM callbacks using a macro
PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions
spi: pl022: Let runtime PM callbacks be available for CONFIG_PM
spi: pl022: Don't ignore power domain and amba bus at system suspend
i2c: nomadik: Fixup system suspend
mmc: mmci: Mask IRQs for all variants during runtime suspend
mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM
mmc: mmci: Put the device into low power state at system suspend
drivers/base/power/Makefile | 3 +-
drivers/base/power/runtime.c | 162 +++++++++++++++++++++++++++++---------
drivers/i2c/busses/i2c-nomadik.c | 14 ++--
drivers/mmc/host/mmci.c | 60 ++++----------
drivers/spi/spi-pl022.c | 58 +++++---------
include/linux/pm_runtime.h | 4 +
6 files changed, 170 insertions(+), 131 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH V3 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions Ulf Hansson
` (7 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
While fetching the proper runtime PM callback, we walk the hierarchy of
device's power domains, subsystems and drivers.
This is common for rpm_suspend(), rpm_idle() and rpm_resume(). Let's
clean up the code by using a macro that handles this.
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Alessandro Rubini <rubini@unipv.it>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Changes in v3:
Added functions to return the callbacks, which will be the only users of
the macro. According to comments from Alan Stern and Kevin Hilman.
Changes in v2:
Updated the macro to return a callback instead.
Suggested by Josh Cartwright.
---
drivers/base/power/runtime.c | 78 +++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 39 deletions(-)
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 72e00e6..ac495b1 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -13,6 +13,42 @@
#include <trace/events/rpm.h>
#include "power.h"
+#define RPM_GET_CALLBACK(dev, cb) \
+({ \
+ int (*__rpm_cb)(struct device *__d); \
+ \
+ if (dev->pm_domain) \
+ __rpm_cb = dev->pm_domain->ops.cb; \
+ else if (dev->type && dev->type->pm) \
+ __rpm_cb = dev->type->pm->cb; \
+ else if (dev->class && dev->class->pm) \
+ __rpm_cb = dev->class->pm->cb; \
+ else if (dev->bus && dev->bus->pm) \
+ __rpm_cb = dev->bus->pm->cb; \
+ else \
+ __rpm_cb = NULL; \
+ \
+ if (!__rpm_cb && dev->driver && dev->driver->pm) \
+ __rpm_cb = dev->driver->pm->cb; \
+ \
+ __rpm_cb; \
+})
+
+static int (*rpm_get_suspend_cb(struct device *dev))(struct device *)
+{
+ return RPM_GET_CALLBACK(dev, runtime_suspend);
+}
+
+static int (*rpm_get_resume_cb(struct device *dev))(struct device *)
+{
+ return RPM_GET_CALLBACK(dev, runtime_resume);
+}
+
+static int (*rpm_get_idle_cb(struct device *dev))(struct device *)
+{
+ return RPM_GET_CALLBACK(dev, runtime_idle);
+}
+
static int rpm_resume(struct device *dev, int rpmflags);
static int rpm_suspend(struct device *dev, int rpmflags);
@@ -310,19 +346,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
dev->power.idle_notification = true;
- if (dev->pm_domain)
- callback = dev->pm_domain->ops.runtime_idle;
- else if (dev->type && dev->type->pm)
- callback = dev->type->pm->runtime_idle;
- else if (dev->class && dev->class->pm)
- callback = dev->class->pm->runtime_idle;
- else if (dev->bus && dev->bus->pm)
- callback = dev->bus->pm->runtime_idle;
- else
- callback = NULL;
-
- if (!callback && dev->driver && dev->driver->pm)
- callback = dev->driver->pm->runtime_idle;
+ callback = rpm_get_idle_cb(dev);
if (callback)
retval = __rpm_callback(callback, dev);
@@ -492,19 +516,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
__update_runtime_status(dev, RPM_SUSPENDING);
- if (dev->pm_domain)
- callback = dev->pm_domain->ops.runtime_suspend;
- else if (dev->type && dev->type->pm)
- callback = dev->type->pm->runtime_suspend;
- else if (dev->class && dev->class->pm)
- callback = dev->class->pm->runtime_suspend;
- else if (dev->bus && dev->bus->pm)
- callback = dev->bus->pm->runtime_suspend;
- else
- callback = NULL;
-
- if (!callback && dev->driver && dev->driver->pm)
- callback = dev->driver->pm->runtime_suspend;
+ callback = rpm_get_suspend_cb(dev);
retval = rpm_callback(callback, dev);
if (retval)
@@ -724,19 +736,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
__update_runtime_status(dev, RPM_RESUMING);
- if (dev->pm_domain)
- callback = dev->pm_domain->ops.runtime_resume;
- else if (dev->type && dev->type->pm)
- callback = dev->type->pm->runtime_resume;
- else if (dev->class && dev->class->pm)
- callback = dev->class->pm->runtime_resume;
- else if (dev->bus && dev->bus->pm)
- callback = dev->bus->pm->runtime_resume;
- else
- callback = NULL;
-
- if (!callback && dev->driver && dev->driver->pm)
- callback = dev->driver->pm->runtime_resume;
+ callback = rpm_get_resume_cb(dev);
retval = rpm_callback(callback, dev);
if (retval) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-03 8:30 ` Kevin Hilman
2014-03-01 10:56 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
This patch provides two new runtime PM helper functions which intend to
be used from system suspend/resume callbacks, to make sure devices are
put into low power state during system suspend and brought back to full
power at system resume.
The prerequisite is to have all levels of a device's runtime PM
callbacks to be defined through the SET_PM_RUNTIME_PM_OPS macro, which
means these are available for CONFIG_PM.
By using the new runtime PM helper functions especially the two
scenarios below will be addressed.
1) The PM core prevents .runtime_suspend callbacks from being invoked
during system suspend. That means even for a runtime PM centric
subsystem and driver, the device needs to be put into low power state
from a system suspend callback. Otherwise it may very well be left in
full power state (runtime resumed) while the system is suspended. By
using the new helper functions, we make sure to walk the hierarchy of
a device's power domain, subsystem and driver.
2) Subsystems and drivers need to cope with all the combinations of
CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions
smothly addresses this.
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Alessandro Rubini <rubini@unipv.it>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
Changes in v3:
Use rpm_get_suspend|resume_cb() instead of the macro.
Changes in v2:
Adopt to version 2 of the RPM_GET_CALLBACK macro.
---
drivers/base/power/Makefile | 3 +-
drivers/base/power/runtime.c | 84 ++++++++++++++++++++++++++++++++++++++++++
include/linux/pm_runtime.h | 4 ++
3 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 2e58ebb..1cb8544 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,6 +1,5 @@
-obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o
+obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o runtime.o
obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
-obj-$(CONFIG_PM_RUNTIME) += runtime.o
obj-$(CONFIG_PM_TRACE_RTC) += trace.o
obj-$(CONFIG_PM_OPP) += opp.o
obj-$(CONFIG_PM_GENERIC_DOMAINS) += domain.o domain_governor.o
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index ac495b1..4776cf5 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -44,6 +44,7 @@ static int (*rpm_get_resume_cb(struct device *dev))(struct device *)
return RPM_GET_CALLBACK(dev, runtime_resume);
}
+#ifdef CONFIG_PM_RUNTIME
static int (*rpm_get_idle_cb(struct device *dev))(struct device *)
{
return RPM_GET_CALLBACK(dev, runtime_idle);
@@ -1401,3 +1402,86 @@ void pm_runtime_remove(struct device *dev)
if (dev->power.irq_safe && dev->parent)
pm_runtime_put(dev->parent);
}
+#endif
+
+/**
+ * pm_runtime_force_suspend - Force a device into suspend state if needed.
+ * @dev: Device to suspend.
+ *
+ * Disable runtime PM so we safely can check the device's runtime PM status and
+ * if it is active, invoke it's .runtime_suspend callback to bring it into
+ * suspend state. Keep runtime PM disabled to preserve the state unless we
+ * encounter errors.
+ *
+ * Typically this function may be invoked from a system suspend callback to make
+ * sure the device is put into low power state.
+ */
+int pm_runtime_force_suspend(struct device *dev)
+{
+ int (*callback)(struct device *);
+ int ret = 0;
+
+ pm_runtime_disable(dev);
+
+ /*
+ * Note that pm_runtime_status_suspended() returns false while
+ * !CONFIG_PM_RUNTIME, which means the device will be put into low
+ * power state.
+ */
+ if (pm_runtime_status_suspended(dev))
+ return 0;
+
+ callback = rpm_get_suspend_cb(dev);
+
+ if (!callback) {
+ ret = -ENOSYS;
+ goto err;
+ }
+
+ ret = callback(dev);
+ if (ret)
+ goto err;
+
+ pm_runtime_set_suspended(dev);
+ return 0;
+err:
+ pm_runtime_enable(dev);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pm_runtime_force_suspend);
+
+/**
+ * pm_runtime_force_resume - Force a device into resume state.
+ * @dev: Device to resume.
+ *
+ * Prior invoking this function we expect the user to have brought the device
+ * into low power state by a call to pm_runtime_force_suspend(). Here we reverse
+ * those actions and brings the device into full power. We update the runtime PM
+ * status and re-enables runtime PM.
+ *
+ * Typically this function may be invoked from a system resume callback to make
+ * sure the device is put into full power state.
+ */
+int pm_runtime_force_resume(struct device *dev)
+{
+ int (*callback)(struct device *);
+ int ret = 0;
+
+ callback = rpm_get_resume_cb(dev);
+
+ if (!callback) {
+ ret = -ENOSYS;
+ goto out;
+ }
+
+ ret = callback(dev);
+ if (ret)
+ goto out;
+
+ pm_runtime_set_active(dev);
+ pm_runtime_mark_last_busy(dev);
+out:
+ pm_runtime_enable(dev);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(pm_runtime_force_resume);
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 16c9a62..2a5897a 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -26,9 +26,13 @@
#ifdef CONFIG_PM
extern int pm_generic_runtime_suspend(struct device *dev);
extern int pm_generic_runtime_resume(struct device *dev);
+extern int pm_runtime_force_suspend(struct device *dev);
+extern int pm_runtime_force_resume(struct device *dev);
#else
static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
+static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
+static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
#endif
#ifdef CONFIG_PM_RUNTIME
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-06 4:45 ` Mark Brown
2014-03-01 10:56 ` [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson
` (5 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
callbacks. This means the callbacks becomes available for both
CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
combinations of these scenarios.
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/spi/spi-pl022.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 74a0729..6dfcabf 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2277,7 +2277,7 @@ pl022_remove(struct amba_device *adev)
return 0;
}
-#if defined(CONFIG_SUSPEND) || defined(CONFIG_PM_RUNTIME)
+#ifdef CONFIG_PM
/*
* These two functions are used from both suspend/resume and
* the runtime counterparts to handle external resources like
@@ -2343,7 +2343,7 @@ static int pl022_resume(struct device *dev)
}
#endif /* CONFIG_PM */
-#ifdef CONFIG_PM_RUNTIME
+#ifdef CONFIG_PM
static int pl022_runtime_suspend(struct device *dev)
{
struct pl022 *pl022 = dev_get_drvdata(dev);
@@ -2363,7 +2363,7 @@ static int pl022_runtime_resume(struct device *dev)
static const struct dev_pm_ops pl022_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(pl022_suspend, pl022_resume)
- SET_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
+ SET_PM_RUNTIME_PM_OPS(pl022_runtime_suspend, pl022_runtime_resume, NULL)
};
static struct vendor_data vendor_arm = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (2 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-06 4:45 ` Mark Brown
2014-03-01 10:56 ` [PATCH 5/8] i2c: nomadik: Fixup " Ulf Hansson
` (4 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
Previously only the resources controlled by the driver were put into
low power state at system suspend. Both the amba bus and a potential
power domain were ignored.
Moreover, while putting the device into low power state we first
brought it back to full power, but for no particular reason.
To handle both issues above, use pm_runtime_force_suspend|resume() from
the system suspend|resume callbacks.
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/spi/spi-pl022.c | 54 ++++++++++++++++-------------------------------
1 file changed, 18 insertions(+), 36 deletions(-)
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 6dfcabf..d37e840 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2277,35 +2277,7 @@ pl022_remove(struct amba_device *adev)
return 0;
}
-#ifdef CONFIG_PM
-/*
- * These two functions are used from both suspend/resume and
- * the runtime counterparts to handle external resources like
- * clocks, pins and regulators when going to sleep.
- */
-static void pl022_suspend_resources(struct pl022 *pl022, bool runtime)
-{
- clk_disable_unprepare(pl022->clk);
-
- if (runtime)
- pinctrl_pm_select_idle_state(&pl022->adev->dev);
- else
- pinctrl_pm_select_sleep_state(&pl022->adev->dev);
-}
-
-static void pl022_resume_resources(struct pl022 *pl022, bool runtime)
-{
- /* First go to the default state */
- pinctrl_pm_select_default_state(&pl022->adev->dev);
- if (!runtime)
- /* Then let's idle the pins until the next transfer happens */
- pinctrl_pm_select_idle_state(&pl022->adev->dev);
-
- clk_prepare_enable(pl022->clk);
-}
-#endif
-
-#ifdef CONFIG_SUSPEND
+#ifdef CONFIG_PM_SLEEP
static int pl022_suspend(struct device *dev)
{
struct pl022 *pl022 = dev_get_drvdata(dev);
@@ -2317,8 +2289,13 @@ static int pl022_suspend(struct device *dev)
return ret;
}
- pm_runtime_get_sync(dev);
- pl022_suspend_resources(pl022, false);
+ ret = pm_runtime_force_suspend(dev);
+ if (ret) {
+ spi_master_resume(pl022->master);
+ return ret;
+ }
+
+ pinctrl_pm_select_sleep_state(dev);
dev_dbg(dev, "suspended\n");
return 0;
@@ -2329,8 +2306,9 @@ static int pl022_resume(struct device *dev)
struct pl022 *pl022 = dev_get_drvdata(dev);
int ret;
- pl022_resume_resources(pl022, false);
- pm_runtime_put(dev);
+ ret = pm_runtime_force_resume(dev);
+ if (ret)
+ dev_err(dev, "problem resuming\n");
/* Start the queue running */
ret = spi_master_resume(pl022->master);
@@ -2341,14 +2319,16 @@ static int pl022_resume(struct device *dev)
return ret;
}
-#endif /* CONFIG_PM */
+#endif
#ifdef CONFIG_PM
static int pl022_runtime_suspend(struct device *dev)
{
struct pl022 *pl022 = dev_get_drvdata(dev);
- pl022_suspend_resources(pl022, true);
+ clk_disable_unprepare(pl022->clk);
+ pinctrl_pm_select_idle_state(dev);
+
return 0;
}
@@ -2356,7 +2336,9 @@ static int pl022_runtime_resume(struct device *dev)
{
struct pl022 *pl022 = dev_get_drvdata(dev);
- pl022_resume_resources(pl022, true);
+ pinctrl_pm_select_default_state(dev);
+ clk_prepare_enable(pl022->clk);
+
return 0;
}
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/8] i2c: nomadik: Fixup system suspend
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (3 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-06 7:10 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
` (3 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
For !CONFIG_PM_RUNTIME, the device were never put back into active
state while resuming.
For CONFIG_PM_RUNTIME, we blindly trusted the device to be inactive
while we were about to handle it at suspend late, which is just too
optimistic.
Even if the driver uses pm_runtime_put_sync() after each tranfer to
return it's runtime PM resources, there are no guarantees this will
actually mean the device will inactivated. The reason is that the PM
core will prevent runtime suspend during system suspend, and thus when
a transfer occurs during the early phases of system suspend the device
will be kept active after the transfer.
To handle both issues above, use pm_runtime_force_suspend|resume() from
the system suspend|resume callbacks.
Cc: Alessandro Rubini <rubini@unipv.it>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/i2c/busses/i2c-nomadik.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 8082f5c..519f5b8 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -879,19 +879,19 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)
#ifdef CONFIG_PM_SLEEP
static int nmk_i2c_suspend_late(struct device *dev)
{
- pinctrl_pm_select_sleep_state(dev);
+ int ret;
+ ret = pm_runtime_force_suspend(dev);
+ if (ret)
+ return ret;
+
+ pinctrl_pm_select_sleep_state(dev);
return 0;
}
static int nmk_i2c_resume_early(struct device *dev)
{
- /* First go to the default state */
- pinctrl_pm_select_default_state(dev);
- /* Then let's idle the pins until the next transfer happens */
- pinctrl_pm_select_idle_state(dev);
-
- return 0;
+ return pm_runtime_force_resume(dev);
}
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (4 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 5/8] i2c: nomadik: Fixup " Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-10 12:46 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH 7/8] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
` (2 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
In runtime suspended state, we are not expecting IRQs and thus we can
safely mask them, not only for pwrreg_nopower variants but for all.
Obviously we then also need to make sure we restore the IRQ mask while
becoming runtime resumed.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/host/mmci.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index b931226..178868a 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1758,35 +1758,34 @@ static void mmci_save(struct mmci_host *host)
{
unsigned long flags;
- if (host->variant->pwrreg_nopower) {
- spin_lock_irqsave(&host->lock, flags);
+ spin_lock_irqsave(&host->lock, flags);
- writel(0, host->base + MMCIMASK0);
+ writel(0, host->base + MMCIMASK0);
+ if (host->variant->pwrreg_nopower) {
writel(0, host->base + MMCIDATACTRL);
writel(0, host->base + MMCIPOWER);
writel(0, host->base + MMCICLOCK);
- mmci_reg_delay(host);
-
- spin_unlock_irqrestore(&host->lock, flags);
}
+ mmci_reg_delay(host);
+ spin_unlock_irqrestore(&host->lock, flags);
}
static void mmci_restore(struct mmci_host *host)
{
unsigned long flags;
- if (host->variant->pwrreg_nopower) {
- spin_lock_irqsave(&host->lock, flags);
+ spin_lock_irqsave(&host->lock, flags);
+ if (host->variant->pwrreg_nopower) {
writel(host->clk_reg, host->base + MMCICLOCK);
writel(host->datactrl_reg, host->base + MMCIDATACTRL);
writel(host->pwr_reg, host->base + MMCIPOWER);
- writel(MCI_IRQENABLE, host->base + MMCIMASK0);
- mmci_reg_delay(host);
-
- spin_unlock_irqrestore(&host->lock, flags);
}
+ writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+ mmci_reg_delay(host);
+
+ spin_unlock_irqrestore(&host->lock, flags);
}
static int mmci_runtime_suspend(struct device *dev)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 7/8] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (5 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH 8/8] mmc: mmci: Put the device into low power state at system suspend Ulf Hansson
2014-03-01 23:38 ` [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's " Rafael J. Wysocki
8 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
callbacks. This means the callbacks becomes available for both
CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
combinations of these scenarios.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/host/mmci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 178868a..c88da1c 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1753,7 +1753,7 @@ static int mmci_resume(struct device *dev)
}
#endif
-#ifdef CONFIG_PM_RUNTIME
+#ifdef CONFIG_PM
static void mmci_save(struct mmci_host *host)
{
unsigned long flags;
@@ -1821,7 +1821,7 @@ static int mmci_runtime_resume(struct device *dev)
static const struct dev_pm_ops mmci_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume)
- SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
+ SET_PM_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
};
static struct amba_id mmci_ids[] = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 8/8] mmc: mmci: Put the device into low power state at system suspend
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (6 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 7/8] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
@ 2014-03-01 10:56 ` Ulf Hansson
2014-03-01 23:38 ` [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's " Rafael J. Wysocki
8 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-01 10:56 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm
Cc: linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Mark Brown, Russell King, Linus Walleij, Wolfram Sang,
Alessandro Rubini, Josh Cartwright, Ulf Hansson
For CONFIG_PM_SLEEP, the device were always left in full power state
after system suspend.
We solely relied on a power domain to put it into low power state,
which is an unreasonable requirement to put on SOCs to implement.
Especially for those SOCs not supporting power domains at all.
Use pm_runtime_force_suspend|resume() as the system suspend callbacks,
to resolve the issue.
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/host/mmci.c | 33 ++-------------------------------
1 file changed, 2 insertions(+), 31 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index c88da1c..1432ae2 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1723,36 +1723,6 @@ static int mmci_remove(struct amba_device *dev)
return 0;
}
-#ifdef CONFIG_SUSPEND
-static int mmci_suspend(struct device *dev)
-{
- struct amba_device *adev = to_amba_device(dev);
- struct mmc_host *mmc = amba_get_drvdata(adev);
-
- if (mmc) {
- struct mmci_host *host = mmc_priv(mmc);
- pm_runtime_get_sync(dev);
- writel(0, host->base + MMCIMASK0);
- }
-
- return 0;
-}
-
-static int mmci_resume(struct device *dev)
-{
- struct amba_device *adev = to_amba_device(dev);
- struct mmc_host *mmc = amba_get_drvdata(adev);
-
- if (mmc) {
- struct mmci_host *host = mmc_priv(mmc);
- writel(MCI_IRQENABLE, host->base + MMCIMASK0);
- pm_runtime_put(dev);
- }
-
- return 0;
-}
-#endif
-
#ifdef CONFIG_PM
static void mmci_save(struct mmci_host *host)
{
@@ -1820,7 +1790,8 @@ static int mmci_runtime_resume(struct device *dev)
#endif
static const struct dev_pm_ops mmci_dev_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume)
+ SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+ pm_runtime_force_resume)
SET_PM_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
` (7 preceding siblings ...)
2014-03-01 10:56 ` [PATCH 8/8] mmc: mmci: Put the device into low power state at system suspend Ulf Hansson
@ 2014-03-01 23:38 ` Rafael J. Wysocki
2014-03-03 7:29 ` Ulf Hansson
2014-03-05 6:16 ` Mark Brown
8 siblings, 2 replies; 21+ messages in thread
From: Rafael J. Wysocki @ 2014-03-01 23:38 UTC (permalink / raw)
To: Ulf Hansson
Cc: Len Brown, Pavel Machek, linux-pm, linux-arm-kernel, Kevin Hilman,
Alan Stern, Greg Kroah-Hartman, Mark Brown, Russell King,
Linus Walleij, Wolfram Sang, Alessandro Rubini, Josh Cartwright
On Saturday, March 01, 2014 11:56:03 AM Ulf Hansson wrote:
> Patch 1 -> 2:
> These patches provides two new runtime PM helper functions which intend to be
> used from system suspend/resume callbacks, to make sure devices are put into low
> power state during system suspend and brought back to full power at system
> resume.
>
> The prerequisite is to have all levels of a device's runtime PM callbacks to be
> defined through the SET_PM_RUNTIME_PM_OPS macro, which means these are available
> for CONFIG_PM.
>
> By using the new runtime PM helper functions especially the two scenarios below
> will be addressed.
>
> 1) The PM core prevents .runtime_suspend callbacks from being invoked during
> system suspend. That means even for a runtime PM centric subsystem and driver,
> the device needs to be put into low power state from a system suspend callback.
> Otherwise it may very well be left in full power state (runtime resumed) while
> the system is suspended. By using the new helper functions, we make sure to walk
> the hierarchy of a device's power domain, subsystem and driver.
>
> 2) Subsystems and drivers need to cope with all the combinations of
> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions smothly
> addresses this.
OK, I've queued up [1-2/8] for 3.15. The rest generally didn't apply for me
and I think it'd be better to push them through the respective subsystem trees
later anyway.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
2014-03-01 23:38 ` [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's " Rafael J. Wysocki
@ 2014-03-03 7:29 ` Ulf Hansson
2014-03-05 6:16 ` Mark Brown
1 sibling, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-03 7:29 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Len Brown, Pavel Machek, linux-pm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Kevin Hilman, Alan Stern,
Greg Kroah-Hartman, Mark Brown, Russell King, Linus Walleij,
Wolfram Sang, Alessandro Rubini, Josh Cartwright
On 2 March 2014 00:38, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Saturday, March 01, 2014 11:56:03 AM Ulf Hansson wrote:
>> Patch 1 -> 2:
>> These patches provides two new runtime PM helper functions which intend to be
>> used from system suspend/resume callbacks, to make sure devices are put into low
>> power state during system suspend and brought back to full power at system
>> resume.
>>
>> The prerequisite is to have all levels of a device's runtime PM callbacks to be
>> defined through the SET_PM_RUNTIME_PM_OPS macro, which means these are available
>> for CONFIG_PM.
>>
>> By using the new runtime PM helper functions especially the two scenarios below
>> will be addressed.
>>
>> 1) The PM core prevents .runtime_suspend callbacks from being invoked during
>> system suspend. That means even for a runtime PM centric subsystem and driver,
>> the device needs to be put into low power state from a system suspend callback.
>> Otherwise it may very well be left in full power state (runtime resumed) while
>> the system is suspended. By using the new helper functions, we make sure to walk
>> the hierarchy of a device's power domain, subsystem and driver.
>>
>> 2) Subsystems and drivers need to cope with all the combinations of
>> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions smothly
>> addresses this.
>
> OK, I've queued up [1-2/8] for 3.15. The rest generally didn't apply for me
> and I think it'd be better to push them through the respective subsystem trees
> later anyway.
Thanks Rafael!
Agree, regarding 3->8, they were at this point mostly included for
your reference.
Kind regards
Uffe
>
> Thanks!
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions
2014-03-01 10:56 ` [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions Ulf Hansson
@ 2014-03-03 8:30 ` Kevin Hilman
0 siblings, 0 replies; 21+ messages in thread
From: Kevin Hilman @ 2014-03-03 8:30 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm,
linux-arm-kernel, Alan Stern, Greg Kroah-Hartman, Mark Brown,
Russell King, Linus Walleij, Wolfram Sang, Alessandro Rubini,
Josh Cartwright
Ulf Hansson <ulf.hansson@linaro.org> writes:
> This patch provides two new runtime PM helper functions which intend to
> be used from system suspend/resume callbacks, to make sure devices are
> put into low power state during system suspend and brought back to full
> power at system resume.
>
> The prerequisite is to have all levels of a device's runtime PM
> callbacks to be defined through the SET_PM_RUNTIME_PM_OPS macro, which
> means these are available for CONFIG_PM.
>
> By using the new runtime PM helper functions especially the two
> scenarios below will be addressed.
>
> 1) The PM core prevents .runtime_suspend callbacks from being invoked
> during system suspend. That means even for a runtime PM centric
> subsystem and driver, the device needs to be put into low power state
> from a system suspend callback. Otherwise it may very well be left in
> full power state (runtime resumed) while the system is suspended. By
> using the new helper functions, we make sure to walk the hierarchy of
> a device's power domain, subsystem and driver.
>
> 2) Subsystems and drivers need to cope with all the combinations of
> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. The two new helper functions
> smothly addresses this.
>
> Cc: Kevin Hilman <khilman@linaro.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Alessandro Rubini <rubini@unipv.it>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
FWIW
Acked-by: Kevin Hilman <khilman@linaro.org>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
2014-03-01 23:38 ` [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's " Rafael J. Wysocki
2014-03-03 7:29 ` Ulf Hansson
@ 2014-03-05 6:16 ` Mark Brown
2014-03-05 13:02 ` Rafael J. Wysocki
1 sibling, 1 reply; 21+ messages in thread
From: Mark Brown @ 2014-03-05 6:16 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Ulf Hansson, Len Brown, Pavel Machek, linux-pm, linux-arm-kernel,
Kevin Hilman, Alan Stern, Greg Kroah-Hartman, Russell King,
Linus Walleij, Wolfram Sang, Alessandro Rubini, Josh Cartwright
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
On Sun, Mar 02, 2014 at 12:38:47AM +0100, Rafael J. Wysocki wrote:
> OK, I've queued up [1-2/8] for 3.15. The rest generally didn't apply for me
> and I think it'd be better to push them through the respective subsystem trees
> later anyway.
Is there a tag we can pull to get those patches? The driver changes
depend on the new API introduced in patch 2.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
2014-03-05 6:16 ` Mark Brown
@ 2014-03-05 13:02 ` Rafael J. Wysocki
2014-03-06 4:43 ` Mark Brown
0 siblings, 1 reply; 21+ messages in thread
From: Rafael J. Wysocki @ 2014-03-05 13:02 UTC (permalink / raw)
To: Mark Brown
Cc: Ulf Hansson, Len Brown, Pavel Machek, linux-pm, linux-arm-kernel,
Kevin Hilman, Alan Stern, Greg Kroah-Hartman, Russell King,
Linus Walleij, Wolfram Sang, Alessandro Rubini, Josh Cartwright
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
On Wednesday, March 05, 2014 02:16:47 PM Mark Brown wrote:
> On Sun, Mar 02, 2014 at 12:38:47AM +0100, Rafael J. Wysocki wrote:
>
> > OK, I've queued up [1-2/8] for 3.15. The rest generally didn't apply for me
> > and I think it'd be better to push them through the respective subsystem trees
> > later anyway.
>
> Is there a tag we can pull to get those patches? The driver changes
> depend on the new API introduced in patch 2.
They are in the pm-drivers branch of linux-pm.git.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend
2014-03-05 13:02 ` Rafael J. Wysocki
@ 2014-03-06 4:43 ` Mark Brown
0 siblings, 0 replies; 21+ messages in thread
From: Mark Brown @ 2014-03-06 4:43 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Ulf Hansson, Len Brown, Pavel Machek, linux-pm, linux-arm-kernel,
Kevin Hilman, Alan Stern, Greg Kroah-Hartman, Russell King,
Linus Walleij, Wolfram Sang, Alessandro Rubini, Josh Cartwright
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
On Wed, Mar 05, 2014 at 02:02:24PM +0100, Rafael J. Wysocki wrote:
> On Wednesday, March 05, 2014 02:16:47 PM Mark Brown wrote:
> > Is there a tag we can pull to get those patches? The driver changes
> > depend on the new API introduced in patch 2.
> They are in the pm-drivers branch of linux-pm.git.
I've pulled them now, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM
2014-03-01 10:56 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
@ 2014-03-06 4:45 ` Mark Brown
0 siblings, 0 replies; 21+ messages in thread
From: Mark Brown @ 2014-03-06 4:45 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm,
linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Russell King, Linus Walleij, Wolfram Sang, Alessandro Rubini,
Josh Cartwright
[-- Attachment #1: Type: text/plain, Size: 321 bytes --]
On Sat, Mar 01, 2014 at 11:56:06AM +0100, Ulf Hansson wrote:
> Convert to the SET_PM_RUNTIME_PM macro while defining the runtime PM
> callbacks. This means the callbacks becomes available for both
> CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME, which is needed to handle the
> combinations of these scenarios.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend
2014-03-01 10:56 ` [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson
@ 2014-03-06 4:45 ` Mark Brown
0 siblings, 0 replies; 21+ messages in thread
From: Mark Brown @ 2014-03-06 4:45 UTC (permalink / raw)
To: Ulf Hansson
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, linux-pm,
linux-arm-kernel, Kevin Hilman, Alan Stern, Greg Kroah-Hartman,
Russell King, Linus Walleij, Wolfram Sang, Alessandro Rubini,
Josh Cartwright
[-- Attachment #1: Type: text/plain, Size: 250 bytes --]
On Sat, Mar 01, 2014 at 11:56:07AM +0100, Ulf Hansson wrote:
> Previously only the resources controlled by the driver were put into
> low power state at system suspend. Both the amba bus and a potential
> power domain were ignored.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/8] i2c: nomadik: Fixup system suspend
2014-03-01 10:56 ` [PATCH 5/8] i2c: nomadik: Fixup " Ulf Hansson
@ 2014-03-06 7:10 ` Ulf Hansson
0 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-06 7:10 UTC (permalink / raw)
To: Wolfram Sang
Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Kevin Hilman, Pavel Machek, Rafael J. Wysocki, Alan Stern,
Len Brown, Greg Kroah-Hartman, Mark Brown, Russell King,
Linus Walleij, Alessandro Rubini, Josh Cartwright, Ulf Hansson
On 1 March 2014 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> For !CONFIG_PM_RUNTIME, the device were never put back into active
> state while resuming.
>
> For CONFIG_PM_RUNTIME, we blindly trusted the device to be inactive
> while we were about to handle it at suspend late, which is just too
> optimistic.
>
> Even if the driver uses pm_runtime_put_sync() after each tranfer to
> return it's runtime PM resources, there are no guarantees this will
> actually mean the device will inactivated. The reason is that the PM
> core will prevent runtime suspend during system suspend, and thus when
> a transfer occurs during the early phases of system suspend the device
> will be kept active after the transfer.
>
> To handle both issues above, use pm_runtime_force_suspend|resume() from
> the system suspend|resume callbacks.
>
> Cc: Alessandro Rubini <rubini@unipv.it>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Hi Wolfram,
The pm-drivers branch of the linux-pm.git, contains the helper
functions this patch depends on.
If you decide to pull that branch to your tree, to be able to apply
this patch, please let me know. Otherwise I will repost this patch
once 3.15 rc1 is available.
Kind regards
Ulf Hansson
> ---
> drivers/i2c/busses/i2c-nomadik.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index 8082f5c..519f5b8 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c
> @@ -879,19 +879,19 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)
> #ifdef CONFIG_PM_SLEEP
> static int nmk_i2c_suspend_late(struct device *dev)
> {
> - pinctrl_pm_select_sleep_state(dev);
> + int ret;
>
> + ret = pm_runtime_force_suspend(dev);
> + if (ret)
> + return ret;
> +
> + pinctrl_pm_select_sleep_state(dev);
> return 0;
> }
>
> static int nmk_i2c_resume_early(struct device *dev)
> {
> - /* First go to the default state */
> - pinctrl_pm_select_default_state(dev);
> - /* Then let's idle the pins until the next transfer happens */
> - pinctrl_pm_select_idle_state(dev);
> -
> - return 0;
> + return pm_runtime_force_resume(dev);
> }
> #endif
>
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend
2014-03-01 10:56 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
@ 2014-03-10 12:46 ` Ulf Hansson
2014-03-10 12:49 ` Ulf Hansson
0 siblings, 1 reply; 21+ messages in thread
From: Ulf Hansson @ 2014-03-10 12:46 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek,
linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, Kevin Hilman, Alan Stern,
Greg Kroah-Hartman, Mark Brown, Russell King, Linus Walleij,
Wolfram Sang, Alessandro Rubini, Josh Cartwright, Ulf Hansson
On 1 March 2014 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> In runtime suspended state, we are not expecting IRQs and thus we can
> safely mask them, not only for pwrreg_nopower variants but for all.
>
> Obviously we then also need to make sure we restore the IRQ mask while
> becoming runtime resumed.
>
> Cc: Russell King <linux@arm.linux.org.uk>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Hi Russell,
I suppose we have discussed and sorted out the concerns you had around
this patch!?
It's available in your patch tracker, would be nice to get it merged
for 3.15, if that's possible.
Kind regards
Uffe
> ---
> drivers/mmc/host/mmci.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index b931226..178868a 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1758,35 +1758,34 @@ static void mmci_save(struct mmci_host *host)
> {
> unsigned long flags;
>
> - if (host->variant->pwrreg_nopower) {
> - spin_lock_irqsave(&host->lock, flags);
> + spin_lock_irqsave(&host->lock, flags);
>
> - writel(0, host->base + MMCIMASK0);
> + writel(0, host->base + MMCIMASK0);
> + if (host->variant->pwrreg_nopower) {
> writel(0, host->base + MMCIDATACTRL);
> writel(0, host->base + MMCIPOWER);
> writel(0, host->base + MMCICLOCK);
> - mmci_reg_delay(host);
> -
> - spin_unlock_irqrestore(&host->lock, flags);
> }
> + mmci_reg_delay(host);
>
> + spin_unlock_irqrestore(&host->lock, flags);
> }
>
> static void mmci_restore(struct mmci_host *host)
> {
> unsigned long flags;
>
> - if (host->variant->pwrreg_nopower) {
> - spin_lock_irqsave(&host->lock, flags);
> + spin_lock_irqsave(&host->lock, flags);
>
> + if (host->variant->pwrreg_nopower) {
> writel(host->clk_reg, host->base + MMCICLOCK);
> writel(host->datactrl_reg, host->base + MMCIDATACTRL);
> writel(host->pwr_reg, host->base + MMCIPOWER);
> - writel(MCI_IRQENABLE, host->base + MMCIMASK0);
> - mmci_reg_delay(host);
> -
> - spin_unlock_irqrestore(&host->lock, flags);
> }
> + writel(MCI_IRQENABLE, host->base + MMCIMASK0);
> + mmci_reg_delay(host);
> +
> + spin_unlock_irqrestore(&host->lock, flags);
> }
>
> static int mmci_runtime_suspend(struct device *dev)
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend
2014-03-10 12:46 ` Ulf Hansson
@ 2014-03-10 12:49 ` Ulf Hansson
0 siblings, 0 replies; 21+ messages in thread
From: Ulf Hansson @ 2014-03-10 12:49 UTC (permalink / raw)
To: Russell King
Cc: linux-arm-kernel@lists.infradead.org, Len Brown,
linux-pm@vger.kernel.org, Kevin Hilman, Pavel Machek, Alan Stern,
Rafael J. Wysocki, Greg Kroah-Hartman, Mark Brown, Linus Walleij,
Wolfram Sang, Alessandro Rubini, Josh Cartwright, Ulf Hansson
On 10 March 2014 13:46, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 1 March 2014 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> In runtime suspended state, we are not expecting IRQs and thus we can
>> safely mask them, not only for pwrreg_nopower variants but for all.
>>
>> Obviously we then also need to make sure we restore the IRQ mask while
>> becoming runtime resumed.
>>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Hi Russell,
>
> I suppose we have discussed and sorted out the concerns you had around
> this patch!?
>
> It's available in your patch tracker, would be nice to get it merged
> for 3.15, if that's possible.
>
> Kind regards
> Uffe
Sorry for spamming, this went to the wrong addresses. Let's try again.
Kind regards
Uffe
>
>> ---
>> drivers/mmc/host/mmci.c | 23 +++++++++++------------
>> 1 file changed, 11 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
>> index b931226..178868a 100644
>> --- a/drivers/mmc/host/mmci.c
>> +++ b/drivers/mmc/host/mmci.c
>> @@ -1758,35 +1758,34 @@ static void mmci_save(struct mmci_host *host)
>> {
>> unsigned long flags;
>>
>> - if (host->variant->pwrreg_nopower) {
>> - spin_lock_irqsave(&host->lock, flags);
>> + spin_lock_irqsave(&host->lock, flags);
>>
>> - writel(0, host->base + MMCIMASK0);
>> + writel(0, host->base + MMCIMASK0);
>> + if (host->variant->pwrreg_nopower) {
>> writel(0, host->base + MMCIDATACTRL);
>> writel(0, host->base + MMCIPOWER);
>> writel(0, host->base + MMCICLOCK);
>> - mmci_reg_delay(host);
>> -
>> - spin_unlock_irqrestore(&host->lock, flags);
>> }
>> + mmci_reg_delay(host);
>>
>> + spin_unlock_irqrestore(&host->lock, flags);
>> }
>>
>> static void mmci_restore(struct mmci_host *host)
>> {
>> unsigned long flags;
>>
>> - if (host->variant->pwrreg_nopower) {
>> - spin_lock_irqsave(&host->lock, flags);
>> + spin_lock_irqsave(&host->lock, flags);
>>
>> + if (host->variant->pwrreg_nopower) {
>> writel(host->clk_reg, host->base + MMCICLOCK);
>> writel(host->datactrl_reg, host->base + MMCIDATACTRL);
>> writel(host->pwr_reg, host->base + MMCIPOWER);
>> - writel(MCI_IRQENABLE, host->base + MMCIMASK0);
>> - mmci_reg_delay(host);
>> -
>> - spin_unlock_irqrestore(&host->lock, flags);
>> }
>> + writel(MCI_IRQENABLE, host->base + MMCIMASK0);
>> + mmci_reg_delay(host);
>> +
>> + spin_unlock_irqrestore(&host->lock, flags);
>> }
>>
>> static int mmci_runtime_suspend(struct device *dev)
>> --
>> 1.7.9.5
>>
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2014-03-10 12:49 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-01 10:56 [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 1/8] PM / Runtime: Fetch runtime PM callbacks using a macro Ulf Hansson
2014-03-01 10:56 ` [PATCH V3 2/8] PM / Sleep / Runtime: Add pm_runtime_suspend|resume_force functions Ulf Hansson
2014-03-03 8:30 ` Kevin Hilman
2014-03-01 10:56 ` [PATCH 3/8] spi: pl022: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
2014-03-06 4:45 ` Mark Brown
2014-03-01 10:56 ` [PATCH 4/8] spi: pl022: Don't ignore power domain and amba bus at system suspend Ulf Hansson
2014-03-06 4:45 ` Mark Brown
2014-03-01 10:56 ` [PATCH 5/8] i2c: nomadik: Fixup " Ulf Hansson
2014-03-06 7:10 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
2014-03-10 12:46 ` Ulf Hansson
2014-03-10 12:49 ` Ulf Hansson
2014-03-01 10:56 ` [PATCH 7/8] mmc: mmci: Let runtime PM callbacks be available for CONFIG_PM Ulf Hansson
2014-03-01 10:56 ` [PATCH 8/8] mmc: mmci: Put the device into low power state at system suspend Ulf Hansson
2014-03-01 23:38 ` [PATCH V3 0/8] PM / Sleep / Runtime: Fixup some driver's " Rafael J. Wysocki
2014-03-03 7:29 ` Ulf Hansson
2014-03-05 6:16 ` Mark Brown
2014-03-05 13:02 ` Rafael J. Wysocki
2014-03-06 4:43 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2014-02-20 15:31 [PATCH " Ulf Hansson
2014-02-20 15:31 ` [PATCH 6/8] mmc: mmci: Mask IRQs for all variants during runtime suspend Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).