All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jean Pihet <jean.pihet@newoldbits.com>
Cc: Linux PM mailing list <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux-sh list <linux-sh@vger.kernel.org>
Subject: Re: [PATCH 3/5] PM / QoS: Add function dev_pm_qos_read_value()
Date: Sat, 3 Sep 2011 01:55:27 +0200	[thread overview]
Message-ID: <201109030155.28031.rjw__401.780688162212$1315007720$gmane$org@sisk.pl> (raw)
In-Reply-To: <CAORVsuVAzc8Q2tG0-WW+96Ad9GhR5OCq2bAuweggs1rimFMcqg@mail.gmail.com>

On Friday, September 02, 2011, Jean Pihet wrote:
> On Fri, Sep 2, 2011 at 12:07 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > Hi,
> >
> > On Thursday, September 01, 2011, Jean Pihet wrote:
> >> Hi Rafael,
> >>
> >> On Wed, Aug 31, 2011 at 12:21 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> >> > From: Rafael J. Wysocki <rjw@sisk.pl>
> >> >
> >> > To read the current PM QoS value for a given device we need to
> >> > make sure that the device's power.constraints object won't be
> >> > removed while we're doing that.  For this reason, put the
> >> > operation under dev->power.lock and acquire the lock
> >> > around the initialization and removal of power.constraints.
> >> Ok.
> >>
> >> > Moreover, since we're using the value of power.constraints to
> >> > determine whether or not the object is present, the
> >> > power.constraints_state field isn't necessary any more and may be
> >> > removed.  However, dev_pm_qos_add_request() needs to check if the
> >> > device is being removed from the system before allocating a new
> >> > PM QoS constraints object for it, so it has to use device_pm_lock()
> >> > and the device PM QoS initialization and destruction should be done
> >> > under device_pm_lock() as well.
> >> Ok that makes sense.
> >> The constraints_state field can be replaced by a combination of
> >> dev->power.constraints and list_empty(&dev->power.entry), which makes
> >> the code more compact and less redundant.
> >>
> >> >
> >> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> >> > ---
> >> >  drivers/base/power/main.c |    4 -
> >> >  drivers/base/power/qos.c  |  167 ++++++++++++++++++++++++++--------------------
> >> >  include/linux/pm.h        |    8 --
> >> >  include/linux/pm_qos.h    |    3
> >> >  4 files changed, 101 insertions(+), 81 deletions(-)
> >> >
> >> > Index: linux/drivers/base/power/qos.c
> >> > ===================================================================
> >> > --- linux.orig/drivers/base/power/qos.c
> >> > +++ linux/drivers/base/power/qos.c
> >> > @@ -30,15 +30,6 @@
> >> ...
> >>
> >> >
> >> > @@ -178,8 +202,8 @@ void dev_pm_qos_constraints_destroy(stru
> >> >  *
> >> >  * Returns 1 if the aggregated constraint value has changed,
> >> >  * 0 if the aggregated constraint value has not changed,
> >> > - * -EINVAL in case of wrong parameters, -ENODEV if the device has been
> >> > - * removed from the system
> >> > + * -EINVAL in case of wrong parameters, -ENOMEM if there's not enough memory
> >> > + * to allocate for data structures.
> >> Why not use -ENODEV in case there is no device?
> >
> > I don't think it's useful for the caller.  If the device is gone, the
> > constraing simply doesn't matter, so there's no error to handle.
> >
> >> >  */
> >> >  int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req,
> >> >                           s32 value)
> >> > @@ -195,28 +219,35 @@ int dev_pm_qos_add_request(struct device
> >> >                return -EINVAL;
> >> >        }
> >> >
> >> > -       mutex_lock(&dev_pm_qos_mtx);
> >> >        req->dev = dev;
> >> >
> >> > -       /* Return if the device has been removed */
> >> > -       if (req->dev->power.constraints_state == DEV_PM_QOS_NO_DEVICE) {
> >> > -               ret = -ENODEV;
> >> > -               goto out;
> >> > -       }
> >> > +       device_pm_lock();
> >> > +       mutex_lock(&dev_pm_qos_mtx);
> >> >
> >> > -       /*
> >> > -        * Allocate the constraints data on the first call to add_request,
> >> > -        * i.e. only if the data is not already allocated and if the device has
> >> > -        * not been removed
> >> > -        */
> >> > -       if (dev->power.constraints_state == DEV_PM_QOS_DEVICE_PRESENT)
> >> > -               ret = dev_pm_qos_constraints_allocate(dev);
> >> > +       if (dev->power.constraints) {
> >> > +               device_pm_unlock();
> >> > +       } else {
> >> > +               if (list_empty(&dev->power.entry)) {
> >> > +                       /* The device has been removed from the system. */
> >> > +                       device_pm_unlock();
> >> > +                       goto out;
> >> 0 is silently returned in case the device has been removed. Is that
> >> the intention?
> >
> > Pretty much it is.  Is that a problem?
> I think the caller needs to know if the constraint has been applied
> correctly or not.

However, the removal of the device is a special case.  What would the caller
be supposed to do when it learned that the device had been removed while it had
been trying to add a QoS constraing for it?  Not much I guess.

Thanks,
Rafael

  reply	other threads:[~2011-09-02 23:55 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 [this message]
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   ` [PATCH 2/3] PM / Runtime: Don't run callbacks under lock for power.irq_safe set Rafael J. Wysocki
2011-09-24 21:25     ` 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='201109030155.28031.rjw__401.780688162212$1315007720$gmane$org@sisk.pl' \
    --to=rjw@sisk.pl \
    --cc=jean.pihet@newoldbits.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-sh@vger.kernel.org \
    /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.