From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Liu, Chuansheng" <chuansheng.liu@intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
"Li, Fei" <fei.li@intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"Lan, Tianyu" <tianyu.lan@intel.com>,
"sarah.a.sharp@linux.intel.com" <sarah.a.sharp@linux.intel.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/5 V2] usb: call pm_runtime_put_sync in pm_runtime_get_sync failed case
Date: Fri, 01 Mar 2013 03:18:53 +0100 [thread overview]
Message-ID: <1476854.U40sJ4h30h@vostro.rjw.lan> (raw)
In-Reply-To: <27240C0AC20F114CBF8149A2696CBE4A24257F@SHSMSX101.ccr.corp.intel.com>
On Friday, March 01, 2013 12:59:23 AM Liu, Chuansheng wrote:
>
> > -----Original Message-----
> > From: Rafael J. Wysocki [mailto:rjw@sisk.pl]
> > Sent: Friday, March 01, 2013 8:51 AM
> > To: Liu, Chuansheng
> > Cc: Alan Stern; Li, Fei; gregkh@linuxfoundation.org; Lan, Tianyu;
> > sarah.a.sharp@linux.intel.com; linux-usb@vger.kernel.org;
> > linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH 4/5 V2] usb: call pm_runtime_put_sync in
> > pm_runtime_get_sync failed case
> >
> > On Friday, March 01, 2013 12:38:07 AM Liu, Chuansheng wrote:
> > >
> > > > -----Original Message-----
> > > > From: Alan Stern [mailto:stern@rowland.harvard.edu]
> > > > Sent: Thursday, February 28, 2013 11:17 PM
> > > > To: Li, Fei
> > > > Cc: gregkh@linuxfoundation.org; Lan, Tianyu;
> > sarah.a.sharp@linux.intel.com;
> > > > rjw@sisk.pl; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Liu,
> > > > Chuansheng
> > > > Subject: Re: [PATCH 4/5 V2] usb: call pm_runtime_put_sync in
> > > > pm_runtime_get_sync failed case
> > > >
> > > > On Thu, 28 Feb 2013, Li Fei wrote:
> > > >
> > > > >
> > > > > Even in failed case of pm_runtime_get_sync, the usage_count
> > > > > is incremented. In order to keep the usage_count with correct
> > > > > value and runtime power management to behave correctly, call
> > > > > pm_runtime_put(_sync) in such case.
> > > > >
> > > > > Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
> > > > > Signed-off-by: Li Fei <fei.li@intel.com>
> > > > > ---
> > > > > drivers/usb/core/hub.c | 3 ++-
> > > > > 1 files changed, 2 insertions(+), 1 deletions(-)
> > > > >
> > > > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > > > > index 5480352..f72dede 100644
> > > > > --- a/drivers/usb/core/hub.c
> > > > > +++ b/drivers/usb/core/hub.c
> > > > > @@ -3148,12 +3148,13 @@ int usb_port_resume(struct usb_device
> > *udev,
> > > > pm_message_t msg)
> > > > >
> > > > > if (port_dev->did_runtime_put) {
> > > > > status = pm_runtime_get_sync(&port_dev->dev);
> > > > > - port_dev->did_runtime_put = false;
> > > > > if (status < 0) {
> > > > > dev_dbg(&udev->dev, "can't resume usb port,
> > status %d\n",
> > > > > status);
> > > > > + pm_runtime_put_sync(&port_dev->dev);
> > > > > return status;
> > > > > }
> > > > > + port_dev->did_runtime_put = false;
> > > > > }
> > > >
> > > > I don't see much point in this. After a failed resume, the port's
> > > > runtime PM status is undefined. Whether or not you do a
> > > > pm_runtime_put_sync won't make any difference.
> > > In case of failed resume, calling pm_runtime_put_sync() is just for decrease
> > the dev->power.usage_count,
> > > because pm_runtime_get_sync() always increase the
> > dev->power.usage_count even failed.
> > >
> > > If not pairing runtime_get/put, after that case, the device can not enter
> > runtime suspend any more due to dev->power.usage_count > 0 always.
> > > Is it making sense?
> >
> > Well, not really.
> >
> > Before returning an error code, rpm_callback() assigns that code to
> > dev->power.runtime_error and that will effectively disable runtime PM for dev
> > going forward anyway.
> Thanks your pointing out.
> dev->power.runtime_error!=0 will really block the runtime PM resume/suspend to continue.
>
> But in case of rpm_resume return error when dev->power.disable_depth > 0, the dev->power.runtime_error
> is not set yet. Is it the case?
Yes, it is.
> And another case is when user called pm_runtime_set_status to clear the runtime_error after dev->power.runtime_error
> is set during pm_runtime_get_sync(), the runtime_resume/suspend() can be tried again? But the dev->power.usage_count is still wrong?
If you clear runtime_error using pm_runtime_set_status(), you can correct the
reference counter as well.
But I agree that with runtime PM disabled it is actually useful to keep the
reference counter balanced appropriately so that you don't need to special
case that. All depends on how runtime PM is used in the given piece of code.
That's why I didn't comment your other patches. That said, I didn't look at
them in detail either.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2013-03-01 2:12 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 7:37 [PATCH 1/5] regmap: irq: call pm_runtime_put " Li Fei
2013-02-28 7:44 ` [PATCH 2/5] mmc: core: call pm_runtime_put_sync " Li Fei
2013-02-28 7:51 ` [PATCH 3/5] wl1251: " Li Fei
2013-02-28 7:57 ` [PATCH 4/5] usb: " Li Fei
2013-02-28 8:02 ` [PATCH 5/5] hwspinlock/core: call pm_runtime_put " Li Fei
2013-04-05 6:27 ` Ohad Ben-Cohen
2013-04-05 11:39 ` Rafael J. Wysocki
2013-04-05 11:42 ` Rafael J. Wysocki
2013-04-05 13:13 ` Li, Fei
2013-04-05 13:20 ` [PATCH 5/5 V2] " Li Fei
2013-04-05 14:46 ` Ohad Ben-Cohen
2013-02-28 8:37 ` [PATCH 4/5] usb: call pm_runtime_put_sync " Lan Tianyu
2013-02-28 9:00 ` Li, Fei
2013-02-28 15:14 ` Alan Stern
2013-02-28 9:06 ` [PATCH 4/5 V2] " Li Fei
2013-02-28 15:17 ` Alan Stern
2013-03-01 0:38 ` Liu, Chuansheng
2013-03-01 0:50 ` Rafael J. Wysocki
2013-03-01 0:59 ` Liu, Chuansheng
2013-03-01 2:18 ` Rafael J. Wysocki [this message]
2013-03-01 2:07 ` Liu, Chuansheng
2013-03-01 2:22 ` Rafael J. Wysocki
2013-03-01 2:23 ` Liu, Chuansheng
2013-03-01 2:57 ` [PATCH 4/5 V3] usb: call pm_runtime_put_noidle " Li Fei
2013-03-01 2:59 ` Li Fei
2013-02-28 8:18 ` [PATCH 3/5] wl1251: call pm_runtime_put_sync " Luciano Coelho
2013-03-05 8:51 ` Luciano Coelho
2013-04-07 10:39 ` [PATCH 2/5] mmc: core: " Ohad Ben-Cohen
2013-04-08 1:36 ` Li, Fei
2013-04-08 1:36 ` [PATCH 2/5 V2] mmc: core: call pm_runtime_put_noidle " Li Fei
2013-04-08 12:48 ` Ohad Ben-Cohen
2013-04-12 18:15 ` Chris Ball
2013-03-01 6:55 ` [PATCH 1/5] regmap: irq: call pm_runtime_put " Mark Brown
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=1476854.U40sJ4h30h@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=chuansheng.liu@intel.com \
--cc=fei.li@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sarah.a.sharp@linux.intel.com \
--cc=stern@rowland.harvard.edu \
--cc=tianyu.lan@intel.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: 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
all inboxes | Powered by JetHome®