From: mark gross <markgross@thegnar.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kevin Hilman <khilman@ti.com>,
Magnus Damm <magnus.damm@gmail.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
markgross@thegnar.org, Jean Pihet <j-pihet@ti.com>
Subject: Re: [PATCH 1/2] PM / QoS: Create device constraints objects on notifier registration
Date: Sat, 28 Apr 2012 08:33:35 -0700 [thread overview]
Message-ID: <20120428153335.GA13787@G62> (raw)
In-Reply-To: <201204272348.18533.rjw@sisk.pl>
On Fri, Apr 27, 2012 at 11:48:18PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> The current behavior of dev_pm_qos_add_notifier() makes device PM QoS
> notifiers less than useful. Namely, it silently returns success when
> called before any PM QoS constraints are added for the device, so the
> caller will assume that the notifier has been registered, but when
> someone actually adds some nontrivial constraints for the device
> eventually, the previous callers of dev_pm_qos_add_notifier()
> will not know about that and their notifier routines will not be
> executed (contrary to their expectations).
>
> To address this problem make dev_pm_qos_add_notifier() create the
> constraints object for the device if it is not present when the
> routine is called.
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
> drivers/base/power/qos.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> Index: linux/drivers/base/power/qos.c
> ===================================================================
> --- linux.orig/drivers/base/power/qos.c
> +++ linux/drivers/base/power/qos.c
> @@ -352,21 +352,26 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_requ
> *
> * Will register the notifier into a notification chain that gets called
> * upon changes to the target value for the device.
> + *
> + * If the device's constraints object doesn't exist when this routine is called,
> + * it will be created (or error code will be returned if that fails).
> */
> int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier)
> {
> - int retval = 0;
> + int ret = 0;
>
> mutex_lock(&dev_pm_qos_mtx);
>
> - /* Silently return if the constraints object is not present. */
> - if (dev->power.constraints)
> - retval = blocking_notifier_chain_register(
> - dev->power.constraints->notifiers,
> - notifier);
FWIW (and IIRC) I did this because some audio use of pm_qos had a series
of re-allocation of constraints and clean up that would fall over so I
had this silent hack to deal with that "complexity".
> + if (!dev->power.constraints)
> + ret = dev->power.power_state.event != PM_EVENT_INVALID ?
> + dev_pm_qos_constraints_allocate(dev) : -ENODEV;
> +
> + if (!ret)
> + ret = blocking_notifier_chain_register(
> + dev->power.constraints->notifiers, notifier);
>
> mutex_unlock(&dev_pm_qos_mtx);
> - return retval;
> + return ret;
> }
> EXPORT_SYMBOL_GPL(dev_pm_qos_add_notifier);
>
Definitely a change for the better (but we should check that the audio
stuff still works before committing this. I'll see if I can check that
this weekend.)
Acked-by : markgross <markgross@thegnar.org>
--mark
next prev parent reply other threads:[~2012-04-28 15:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 21:46 [PATCH 0/2] PM / QoS / Domains: Fix and optimization Rafael J. Wysocki
2012-04-27 21:48 ` [PATCH 1/2] PM / QoS: Create device constraints objects on notifier registration Rafael J. Wysocki
2012-04-28 15:33 ` mark gross [this message]
2012-04-28 21:10 ` Rafael J. Wysocki
2012-04-27 21:53 ` [PATCH 2/2][RFC] PM / Domains: Cache device stop and domain power off governor results Rafael J. Wysocki
2012-04-29 1:08 ` [PATCH 0/3] PM / QoS / Domains: Fixes and optimization, take 2 Rafael J. Wysocki
2012-04-29 1:11 ` [PATCH 1/3] PM / QoS: Create device constraints objects on notifier registration Rafael J. Wysocki
2012-04-30 8:57 ` Jean Pihet
2012-04-29 1:12 ` [PATCH 2/3] PM / Domains: Make device removal more straightforward Rafael J. Wysocki
2012-04-29 1:14 ` [PATCH 3/3][RFC] PM / Domains: Cache device stop and domain power off governor results, v2 Rafael J. Wysocki
2012-04-29 14:12 ` [Update][PATCH 3/3][RFC] PM / Domains: Cache device stop and domain power off governor results, v3 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=20120428153335.GA13787@G62 \
--to=markgross@thegnar.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=j-pihet@ti.com \
--cc=khilman@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=rjw@sisk.pl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox