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>,
Kevin Hilman <khilman@ti.com>,
Alan Stern <stern@rowland.harvard.edu>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Paul Walmsley <paul@pwsan.com>, Greg KH <gregkh@suse.de>,
Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH 7 v2] PM / Domains: Queue up power off work only if it is not pending
Date: Sun, 10 Jul 2011 14:29:26 +0200 [thread overview]
Message-ID: <201107101429.26416.rjw@sisk.pl> (raw)
In-Reply-To: <201107101059.30322.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
In theory it is possible that pm_genpd_poweroff() for two different
subdomains of the same parent domain will attempt to queue up the
execution of pm_genpd_poweroff() for the parent twice in a row. This
would lead to unpleasant consequences, so prevent it from happening
by checking if genpd->power_off_work is pending before attempting to
queue it up.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
One more patch to the "PM / Domains: Generic PM domains improvements" series,
the changelog should explain everything. :-)
Thanks,
Rafael
---
drivers/base/power/domain.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
Index: linux-2.6/drivers/base/power/domain.c
===================================================================
--- linux-2.6.orig/drivers/base/power/domain.c
+++ linux-2.6/drivers/base/power/domain.c
@@ -213,6 +213,19 @@ static bool genpd_abort_poweroff(struct
}
/**
+ * genpd_queue_power_off_work - Queue up the execution of pm_genpd_poweroff().
+ * @genpd: PM domait to power off.
+ *
+ * Queue up the execution of pm_genpd_poweroff() unless it's already been done
+ * before.
+ */
+static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
+{
+ if (!work_pending(&genpd->power_off_work))
+ queue_work(pm_wq, &genpd->power_off_work);
+}
+
+/**
* pm_genpd_poweroff - Remove power from a given PM domain.
* @genpd: PM domain to power down.
*
@@ -304,7 +317,7 @@ static int pm_genpd_poweroff(struct gene
if (parent) {
genpd_sd_counter_dec(parent);
if (parent->sd_count == 0)
- queue_work(pm_wq, &parent->power_off_work);
+ genpd_queue_power_off_work(parent);
genpd_release_lock(parent);
}
prev parent reply other threads:[~2011-07-10 12:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-06 20:48 [PATCH 0/5 v1] PM / Domains: Generic PM domains improvements Rafael J. Wysocki
2011-07-06 20:50 ` [PATCH 1/5 v1] PM / Domains: Set device state to "active" during system resume Rafael J. Wysocki
2011-07-06 20:50 ` Rafael J. Wysocki
2011-07-06 20:51 ` [PATCH 2/5 v1] PM / Domains: Make failing pm_genpd_prepare() clean up properly Rafael J. Wysocki
2011-07-06 20:51 ` Rafael J. Wysocki
2011-07-06 20:53 ` [PATCH 3/5 v1] PM / Domains: Rework locking Rafael J. Wysocki
2011-07-06 20:53 ` Rafael J. Wysocki
2011-07-08 10:21 ` [Update][PATCH 3/5] " Rafael J. Wysocki
2011-07-08 10:21 ` Rafael J. Wysocki
2011-07-06 21:00 ` [PATCH 4/5 v1] PM / Domains: Allow callbacks to execute arbitrary runtime PM helpers Rafael J. Wysocki
2011-07-07 19:59 ` [Update][PATCH 4/5] PM / Domains: Allow callbacks to execute all " Rafael J. Wysocki
2011-07-07 19:59 ` Rafael J. Wysocki
2011-07-06 21:00 ` [PATCH 4/5 v1] PM / Domains: Allow callbacks to execute arbitrary " Rafael J. Wysocki
2011-07-06 21:01 ` [PATCH 5/5 v1] PM / Domains: Do not restore all devices on power off error Rafael J. Wysocki
2011-07-07 20:01 ` [Update][PATCH 5/5] " Rafael J. Wysocki
2011-07-07 20:01 ` Rafael J. Wysocki
2011-07-06 21:01 ` [PATCH 5/5 v1] " Rafael J. Wysocki
2011-07-06 21:08 ` [PATCH 0/5 v1] PM / Domains: Generic PM domains improvements Greg KH
2011-07-06 21:12 ` Rafael J. Wysocki
2011-07-06 21:12 ` Rafael J. Wysocki
2011-07-06 21:08 ` Greg KH
2011-07-10 8:59 ` [PATCH 0/6 v2] " Rafael J. Wysocki
2011-07-10 8:59 ` Rafael J. Wysocki
2011-07-10 9:05 ` [PATCH 1/6 v2] PM / Domains: Set device state to "active" during system resume Rafael J. Wysocki
2011-07-10 9:05 ` Rafael J. Wysocki
2011-07-10 9:06 ` [PATCH 2/6 v2] PM / Domains: Make failing pm_genpd_prepare() clean up properly Rafael J. Wysocki
2011-07-10 9:06 ` Rafael J. Wysocki
2011-07-10 9:07 ` [PATCH 3/6 v2] PM / Domains: Do not execute device callbacks under locks Rafael J. Wysocki
2011-07-10 9:07 ` Rafael J. Wysocki
2011-07-10 9:08 ` [PATCH 4/6 v2] PM / Domains: Allow callbacks to execute all runtime PM helpers Rafael J. Wysocki
2011-07-10 9:08 ` Rafael J. Wysocki
2011-07-10 9:08 ` [PATCH 5/6 v2] PM / Domains: Do not restore all devices on power off error Rafael J. Wysocki
2011-07-10 9:08 ` Rafael J. Wysocki
2011-07-10 9:09 ` [PATCH 6/6 v2] PM / Domains: Improve handling of wakeup devices during system suspend Rafael J. Wysocki
2011-07-10 9:09 ` Rafael J. Wysocki
2011-07-10 12:29 ` [PATCH 7 v2] PM / Domains: Queue up power off work only if it is not pending Rafael J. Wysocki
2011-07-10 12:29 ` Rafael J. Wysocki [this message]
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=201107101429.26416.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=cw00.choi@samsung.com \
--cc=gregkh@suse.de \
--cc=khilman@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=magnus.damm@gmail.com \
--cc=myungjoo.ham@samsung.com \
--cc=paul@pwsan.com \
--cc=stern@rowland.harvard.edu \
/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: link
Be 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.