From: "Rafael J. Wysocki" <rjw@sisk.pl> To: Linux PM mailing list <linux-pm@lists.linux-foundation.org> Cc: LKML <linux-kernel@vger.kernel.org>, Linux-sh list <linux-sh@vger.kernel.org>, Magnus Damm <magnus.damm@gmail.com>, Kevin Hilman <khilman@ti.com>, jean.pihet@newoldbits.com, Ming Lei <tom.leiming@gmail.com> Subject: [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for power.irq_safe set Date: Sat, 24 Sep 2011 21:25:53 +0000 [thread overview] Message-ID: <201109242325.53563.rjw@sisk.pl> (raw) In-Reply-To: <201109242323.03474.rjw@sisk.pl> From: Rafael J. Wysocki <rjw@sisk.pl> The rpm_suspend() and rpm_resume() routines execute subsystem or PM domain callbacks under power.lock if power.irq_safe is set for the given device. This is inconsistent with that rpm_idle() does after commit 02b2677 (PM / Runtime: Allow _put_sync() from interrupts-disabled context) and is problematic for subsystems and PM domains wanting to use power.lock for synchronization in their runtime PM callbacks. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> --- drivers/base/power/runtime.c | 68 +++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 22 deletions(-) Index: linux/drivers/base/power/runtime.c =================================--- linux.orig/drivers/base/power/runtime.c +++ linux/drivers/base/power/runtime.c @@ -155,6 +155,31 @@ static int rpm_check_suspend_allowed(str } /** + * __rpm_callback - Run a given runtime PM callback for a given device. + * @cb: Runtime PM callback to run. + * @dev: Device to run the callback for. + */ +static int __rpm_callback(int (*cb)(struct device *), struct device *dev) + __releases(&dev->power.lock) __acquires(&dev->power.lock) +{ + int retval; + + if (dev->power.irq_safe) + spin_unlock(&dev->power.lock); + else + spin_unlock_irq(&dev->power.lock); + + retval = cb(dev); + + if (dev->power.irq_safe) + spin_lock(&dev->power.lock); + else + spin_lock_irq(&dev->power.lock); + + return retval; +} + +/** * rpm_idle - Notify device bus type if the device can be suspended. * @dev: Device to notify the bus type about. * @rpmflags: Flag bits. @@ -225,19 +250,8 @@ static int rpm_idle(struct device *dev, else callback = NULL; - if (callback) { - if (dev->power.irq_safe) - spin_unlock(&dev->power.lock); - else - spin_unlock_irq(&dev->power.lock); - - callback(dev); - - if (dev->power.irq_safe) - spin_lock(&dev->power.lock); - else - spin_lock_irq(&dev->power.lock); - } + if (callback) + __rpm_callback(callback, dev); dev->power.idle_notification = false; wake_up_all(&dev->power.wait_queue); @@ -252,22 +266,14 @@ static int rpm_idle(struct device *dev, * @dev: Device to run the callback for. */ static int rpm_callback(int (*cb)(struct device *), struct device *dev) - __releases(&dev->power.lock) __acquires(&dev->power.lock) { int retval; if (!cb) return -ENOSYS; - if (dev->power.irq_safe) { - retval = cb(dev); - } else { - spin_unlock_irq(&dev->power.lock); - - retval = cb(dev); + retval = __rpm_callback(cb, dev); - spin_lock_irq(&dev->power.lock); - } dev->power.runtime_error = retval; return retval != -EACCES ? retval : -EIO; } @@ -347,6 +353,15 @@ static int rpm_suspend(struct device *de goto out; } + if (dev->power.irq_safe) { + spin_unlock(&dev->power.lock); + + cpu_relax(); + + spin_lock(&dev->power.lock); + goto repeat; + } + /* Wait for the other suspend running in parallel with us. */ for (;;) { prepare_to_wait(&dev->power.wait_queue, &wait, @@ -496,6 +511,15 @@ static int rpm_resume(struct device *dev goto out; } + if (dev->power.irq_safe) { + spin_unlock(&dev->power.lock); + + cpu_relax(); + + spin_lock(&dev->power.lock); + goto repeat; + } + /* Wait for the operation carried out in parallel with us. */ for (;;) { prepare_to_wait(&dev->power.wait_queue, &wait,
WARNING: multiple messages have this Message-ID (diff)
From: "Rafael J. Wysocki" <rjw@sisk.pl> To: Linux PM mailing list <linux-pm@lists.linux-foundation.org> Cc: LKML <linux-kernel@vger.kernel.org>, "Linux-sh list" <linux-sh@vger.kernel.org>, Magnus Damm <magnus.damm@gmail.com>, Kevin Hilman <khilman@ti.com>, jean.pihet@newoldbits.com, Ming Lei <tom.leiming@gmail.com> Subject: [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for power.irq_safe set Date: Sat, 24 Sep 2011 23:25:53 +0200 [thread overview] Message-ID: <201109242325.53563.rjw@sisk.pl> (raw) In-Reply-To: <201109242323.03474.rjw@sisk.pl> From: Rafael J. Wysocki <rjw@sisk.pl> The rpm_suspend() and rpm_resume() routines execute subsystem or PM domain callbacks under power.lock if power.irq_safe is set for the given device. This is inconsistent with that rpm_idle() does after commit 02b2677 (PM / Runtime: Allow _put_sync() from interrupts-disabled context) and is problematic for subsystems and PM domains wanting to use power.lock for synchronization in their runtime PM callbacks. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> --- drivers/base/power/runtime.c | 68 +++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 22 deletions(-) Index: linux/drivers/base/power/runtime.c =================================================================== --- linux.orig/drivers/base/power/runtime.c +++ linux/drivers/base/power/runtime.c @@ -155,6 +155,31 @@ static int rpm_check_suspend_allowed(str } /** + * __rpm_callback - Run a given runtime PM callback for a given device. + * @cb: Runtime PM callback to run. + * @dev: Device to run the callback for. + */ +static int __rpm_callback(int (*cb)(struct device *), struct device *dev) + __releases(&dev->power.lock) __acquires(&dev->power.lock) +{ + int retval; + + if (dev->power.irq_safe) + spin_unlock(&dev->power.lock); + else + spin_unlock_irq(&dev->power.lock); + + retval = cb(dev); + + if (dev->power.irq_safe) + spin_lock(&dev->power.lock); + else + spin_lock_irq(&dev->power.lock); + + return retval; +} + +/** * rpm_idle - Notify device bus type if the device can be suspended. * @dev: Device to notify the bus type about. * @rpmflags: Flag bits. @@ -225,19 +250,8 @@ static int rpm_idle(struct device *dev, else callback = NULL; - if (callback) { - if (dev->power.irq_safe) - spin_unlock(&dev->power.lock); - else - spin_unlock_irq(&dev->power.lock); - - callback(dev); - - if (dev->power.irq_safe) - spin_lock(&dev->power.lock); - else - spin_lock_irq(&dev->power.lock); - } + if (callback) + __rpm_callback(callback, dev); dev->power.idle_notification = false; wake_up_all(&dev->power.wait_queue); @@ -252,22 +266,14 @@ static int rpm_idle(struct device *dev, * @dev: Device to run the callback for. */ static int rpm_callback(int (*cb)(struct device *), struct device *dev) - __releases(&dev->power.lock) __acquires(&dev->power.lock) { int retval; if (!cb) return -ENOSYS; - if (dev->power.irq_safe) { - retval = cb(dev); - } else { - spin_unlock_irq(&dev->power.lock); - - retval = cb(dev); + retval = __rpm_callback(cb, dev); - spin_lock_irq(&dev->power.lock); - } dev->power.runtime_error = retval; return retval != -EACCES ? retval : -EIO; } @@ -347,6 +353,15 @@ static int rpm_suspend(struct device *de goto out; } + if (dev->power.irq_safe) { + spin_unlock(&dev->power.lock); + + cpu_relax(); + + spin_lock(&dev->power.lock); + goto repeat; + } + /* Wait for the other suspend running in parallel with us. */ for (;;) { prepare_to_wait(&dev->power.wait_queue, &wait, @@ -496,6 +511,15 @@ static int rpm_resume(struct device *dev goto out; } + if (dev->power.irq_safe) { + spin_unlock(&dev->power.lock); + + cpu_relax(); + + spin_lock(&dev->power.lock); + goto repeat; + } + /* Wait for the operation carried out in parallel with us. */ for (;;) { prepare_to_wait(&dev->power.wait_queue, &wait,
next prev parent reply other threads:[~2011-09-24 21:25 UTC|newest] Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-08-30 22:17 [PATCH 0/5] PM: Generic PM domains and device PM QoS Rafael J. Wysocki 2011-08-30 22:17 ` Rafael J. Wysocki 2011-08-30 22:18 ` [PATCH 1/5] PM / Domains: Split device PM domain data into base and need_restore Rafael J. Wysocki 2011-08-30 22:18 ` Rafael J. Wysocki 2011-08-30 22:18 ` Rafael J. Wysocki 2011-08-30 22:20 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for power.irq_safe set Rafael J. Wysocki 2011-08-30 22:20 ` Rafael J. Wysocki 2011-09-12 8:26 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for Ming Lei 2011-09-12 8:26 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for power.irq_safe set Ming Lei 2011-09-12 21:52 ` Rafael J. Wysocki 2011-09-12 21:52 ` Rafael J. Wysocki [not found] ` <201109122344.02386.rjw@sisk.pl> 2011-09-13 1:22 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for Ming Lei 2011-09-13 1:22 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for power.irq_safe set Ming Lei 2011-09-13 16:06 ` Rafael J. Wysocki 2011-09-13 16:06 ` Rafael J. Wysocki 2011-09-14 1:12 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for Ming Lei 2011-09-14 1:12 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for power.irq_safe set Ming Lei 2011-09-14 20:45 ` Rafael J. Wysocki 2011-09-14 20:45 ` Rafael J. Wysocki 2011-09-15 10:55 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for Ming Lei 2011-09-15 10:55 ` [PATCH 2/5] PM / Runtime: Do not run callbacks under lock for power.irq_safe set Ming Lei 2011-08-30 22:20 ` Rafael J. Wysocki 2011-08-30 22:21 ` [PATCH 3/5] PM / QoS: Add function dev_pm_qos_read_value() Rafael J. Wysocki 2011-08-30 22:21 ` Rafael J. Wysocki 2011-08-30 22:21 ` Rafael J. Wysocki 2011-09-01 15:13 ` Jean Pihet 2011-09-01 15:13 ` Jean Pihet 2011-09-01 22:07 ` Rafael J. Wysocki 2011-09-01 22:07 ` Rafael J. Wysocki 2011-09-01 22:07 ` Rafael J. Wysocki 2011-09-02 6:49 ` Jean Pihet 2011-09-02 6:49 ` Jean Pihet 2011-09-02 6:49 ` Jean Pihet 2011-09-02 23:55 ` Rafael J. Wysocki 2011-09-02 23:55 ` Rafael J. Wysocki 2011-09-02 23:55 ` Rafael J. Wysocki 2011-09-03 8:02 ` Rafael J. Wysocki 2011-09-03 8:02 ` Rafael J. Wysocki 2011-09-05 7:51 ` Jean Pihet 2011-09-05 7:51 ` Jean Pihet 2011-09-05 7:51 ` Jean Pihet 2011-09-05 15:30 ` Rafael J. Wysocki 2011-09-05 15:30 ` Rafael J. Wysocki 2011-09-05 15:30 ` Rafael J. Wysocki 2011-09-03 8:02 ` Rafael J. Wysocki 2011-09-05 7:44 ` Jean Pihet 2011-09-05 7:44 ` Jean Pihet 2011-09-05 7:44 ` Jean Pihet 2011-09-01 15:13 ` Jean Pihet 2011-08-30 22:21 ` [RFC][PATCH 4/5] PM / Domains: Add device stop governor function Rafael J. Wysocki 2011-08-30 22:21 ` Rafael J. Wysocki 2011-08-30 22:21 ` Rafael J. Wysocki 2011-08-30 22:22 ` [RFC][PATCH 5/5] PM / Domains: Add default power off " Rafael J. Wysocki 2011-08-30 22:22 ` Rafael J. Wysocki 2011-08-30 22:22 ` Rafael J. Wysocki 2011-09-01 15:17 ` Jean Pihet 2011-09-01 15:17 ` Jean Pihet 2011-09-01 15:17 ` Jean Pihet 2011-09-01 22:11 ` Rafael J. Wysocki 2011-09-01 22:11 ` Rafael J. Wysocki 2011-09-01 22:11 ` Rafael J. Wysocki 2011-09-01 15:28 ` [PATCH 0/5] PM: Generic PM domains and device PM QoS Jean Pihet 2011-09-01 15:28 ` Jean Pihet 2011-09-01 22:14 ` Rafael J. Wysocki 2011-09-01 22:14 ` Rafael J. Wysocki 2011-09-01 22:14 ` Rafael J. Wysocki 2011-09-01 15:28 ` Jean Pihet 2011-09-24 21:23 ` [PATCH 0/3] PM: Runtime PM and device PM QoS refinements Rafael J. Wysocki 2011-09-24 21:23 ` Rafael J. Wysocki 2011-09-24 21:24 ` [PATCH 1/3] PM / Domains: Split device PM domain data into base and need_restore Rafael J. Wysocki 2011-09-24 21:24 ` Rafael J. Wysocki 2011-09-24 21:25 ` Rafael J. Wysocki [this message] 2011-09-24 21:25 ` [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for power.irq_safe set Rafael J. Wysocki 2011-09-25 8:24 ` [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for Ming Lei 2011-09-25 8:24 ` [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for power.irq_safe set Ming Lei 2011-09-26 23:59 ` Kevin Hilman 2011-09-26 23:59 ` Kevin Hilman 2011-09-27 17:16 ` Rafael J. Wysocki 2011-09-27 17:16 ` Rafael J. Wysocki 2011-09-27 19:50 ` Rafael J. Wysocki 2011-09-27 19:50 ` Rafael J. Wysocki 2011-09-29 0:17 ` Kevin Hilman 2011-09-29 0:17 ` Kevin Hilman 2011-09-24 21:26 ` [PATCH 3/3] PM / QoS: Add function dev_pm_qos_read_value() (v2) Rafael J. Wysocki 2011-09-24 21:26 ` Rafael J. Wysocki 2011-09-29 8:11 ` Jean Pihet 2011-09-29 8:11 ` Jean Pihet 2011-09-29 20:33 ` Rafael J. Wysocki 2011-09-29 20:33 ` Rafael J. Wysocki 2011-09-30 8:08 ` Jean Pihet 2011-09-30 8:08 ` Jean Pihet 2011-09-30 16:46 ` Rafael J. Wysocki 2011-09-30 16:46 ` Rafael J. Wysocki
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=201109242325.53563.rjw@sisk.pl \ --to=rjw@sisk.pl \ --cc=jean.pihet@newoldbits.com \ --cc=khilman@ti.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@lists.linux-foundation.org \ --cc=linux-sh@vger.kernel.org \ --cc=magnus.damm@gmail.com \ --cc=tom.leiming@gmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.