All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Vivek Gautam <gautamvivek1987@gmail.com>
Cc: <balbi@ti.com>, Kishon Vijay Abraham I <kishon@ti.com>,
	Vivek Gautam <gautam.vivek@samsung.com>,
	<linux-usb@vger.kernel.org>, <linux-samsung-soc@vger.kernel.org>,
	<linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<gregkh@linuxfoundation.org>, <stern@rowland.harvard.edu>,
	<sarah.a.sharp@linux.intel.com>, <rob.herring@calxeda.com>,
	<kgene.kim@samsung.com>, <dianders@chromium.org>,
	<t.figa@samsung.com>, <p.paneri@samsung.com>
Subject: Re: [PATCH v3 01/11] usb: phy: Add APIs for runtime power management
Date: Wed, 3 Apr 2013 16:54:14 +0300	[thread overview]
Message-ID: <20130403135414.GG14680@arwen.pp.htv.fi> (raw)
In-Reply-To: <CAFp+6iHXW8z2sc44c1hq2au_UnUyVZEr9D0t5BM4mfqcQKZgbA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3951 bytes --]

HI,

On Wed, Apr 03, 2013 at 06:42:48PM +0530, Vivek Gautam wrote:
> >> >> Adding  APIs to handle runtime power management on PHY
> >> >> devices. PHY consumers may need to wake-up/suspend PHYs
> >> >> when they work across autosuspend.
> >> >>
> >> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> >> >> ---
> >> >>   include/linux/usb/phy.h |  141
> >> >> +++++++++++++++++++++++++++++++++++++++++++++++
> >> >>   1 files changed, 141 insertions(+), 0 deletions(-)
> >> >>
> >> >> diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
> >> >> index 6b5978f..01bf9c1 100644
> >> >> --- a/include/linux/usb/phy.h
> >> >> +++ b/include/linux/usb/phy.h
> >> >> @@ -297,4 +297,145 @@ static inline const char *usb_phy_type_string(enum
> >> >> usb_phy_type type)
> >> >>                 return "UNKNOWN PHY TYPE";
> >> >>         }
> >> >>   }
> >> >> +
> >> >> +static inline void usb_phy_autopm_enable(struct usb_phy *x)
> >> >> +{
> >> >> +       if (!x || !x->dev) {
> >> >> +               dev_err(x->dev, "no PHY or attached device available\n");
> >> >> +               return;
> >> >> +               }
> >> >> +
> >> >> +       pm_runtime_enable(x->dev);
> >> >> +}
> >> >
> >> >
> >> > IMO we need not have wrapper APIs for runtime_enable and runtime_disable
> >> > here. Generally runtime_enable and runtime_disable is done in probe and
> >> > remove of a driver respectively. So it's better to leave the
> >> > runtime_enable/runtime_disable to be done in *phy provider* driver than
> >> > having an API for it to be done by *phy user* driver. Felipe, what do you
> >> > think?
> >>
> >> Thanks!!
> >> That's very true, runtime_enable() and runtime_disable() calls are made by
> >> *phy_provider* only. But a querry here.
> >> Wouldn't in any case a PHY consumer might want to disable runtime_pm on PHY ?
> >> Say, when consumer failed to suspend the PHY properly
> >> (*put_sync(phy->dev)* fails), how much sure is the consumer about the
> >> state of PHY ?
> >
> > no no, wait a minute. We might not want to enable runtime pm for the PHY
> > until the UDC says it can handle runtime pm, no ? I guess this makes a
> > bit of sense (at least in my head :-p).
> >
> > Imagine if PHY is runtime suspended but e.g. DWC3 isn't runtime pm
> > enabled... Does it make sense to leave that control to the USB
> > controller drivers ?
> >
> > I'm open for suggestions
> 
> Of course unless the PHY consumer can handle runtime PM for PHY,
> PHY should not ideally be going into runtime_suspend.
> 
> Actually trying out few things, here are my observations
> 
> Enabling runtime_pm on PHY pushes PHY to go into runtime_suspend state.
> But a device detection wakes up DWC3 controller, and if i don't wake
> up PHY (using get_sync(phy->dev)) here
> in runtime_resume() callback of DWC3, i don't get PHY back in active state.
> So it becomes the duty of DWC3 controller to handle PHY's sleep and wake-up.
> Thereby it becomes logical that DWC3 controller has the right to
> enable runtime_pm
> of PHY.
> 
> But there's a catch here. if there are multiple consumers of PHY (like
> USB2 type PHY can
> have DWC3 controller as well as EHCI/OHCI or even HSGadget) then in that case,
> only one of the consumer can enable runtime_pm on PHY. So who decides this.
> 
> Aargh!! lot of confusion here :-(


hmmm, maybe add a flag to struct usb_phy and check it on
usb_phy_autopm_enable() ??

How does usbcore handle it ? They request class drivers to pass
supports_autosuspend, but while we should have a similar flag, that's
not enough. We also need a flag to tell us when pm_runtime has already
been enabled.

So how about:

usb_phy_autopm_enable()
{
	if (!phy->suports_autosuspend)
		return -ENOSYS;

	if (phy->autosuspend_enabled)
		return 0;

	phy->autosuspend_enabled = true;
	return pm_runtime_enable(phy->dev);
}

???

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@ti.com>
To: Vivek Gautam <gautamvivek1987@gmail.com>
Cc: balbi@ti.com, Kishon Vijay Abraham I <kishon@ti.com>,
	Vivek Gautam <gautam.vivek@samsung.com>,
	linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, stern@rowland.harvard.edu,
	sarah.a.sharp@linux.intel.com, rob.herring@calxeda.com,
	kgene.kim@samsung.com, dianders@chromium.org, t.figa@samsung.com,
	p.paneri@samsung.com
Subject: Re: [PATCH v3 01/11] usb: phy: Add APIs for runtime power management
Date: Wed, 3 Apr 2013 16:54:14 +0300	[thread overview]
Message-ID: <20130403135414.GG14680@arwen.pp.htv.fi> (raw)
In-Reply-To: <CAFp+6iHXW8z2sc44c1hq2au_UnUyVZEr9D0t5BM4mfqcQKZgbA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3951 bytes --]

HI,

On Wed, Apr 03, 2013 at 06:42:48PM +0530, Vivek Gautam wrote:
> >> >> Adding  APIs to handle runtime power management on PHY
> >> >> devices. PHY consumers may need to wake-up/suspend PHYs
> >> >> when they work across autosuspend.
> >> >>
> >> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> >> >> ---
> >> >>   include/linux/usb/phy.h |  141
> >> >> +++++++++++++++++++++++++++++++++++++++++++++++
> >> >>   1 files changed, 141 insertions(+), 0 deletions(-)
> >> >>
> >> >> diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
> >> >> index 6b5978f..01bf9c1 100644
> >> >> --- a/include/linux/usb/phy.h
> >> >> +++ b/include/linux/usb/phy.h
> >> >> @@ -297,4 +297,145 @@ static inline const char *usb_phy_type_string(enum
> >> >> usb_phy_type type)
> >> >>                 return "UNKNOWN PHY TYPE";
> >> >>         }
> >> >>   }
> >> >> +
> >> >> +static inline void usb_phy_autopm_enable(struct usb_phy *x)
> >> >> +{
> >> >> +       if (!x || !x->dev) {
> >> >> +               dev_err(x->dev, "no PHY or attached device available\n");
> >> >> +               return;
> >> >> +               }
> >> >> +
> >> >> +       pm_runtime_enable(x->dev);
> >> >> +}
> >> >
> >> >
> >> > IMO we need not have wrapper APIs for runtime_enable and runtime_disable
> >> > here. Generally runtime_enable and runtime_disable is done in probe and
> >> > remove of a driver respectively. So it's better to leave the
> >> > runtime_enable/runtime_disable to be done in *phy provider* driver than
> >> > having an API for it to be done by *phy user* driver. Felipe, what do you
> >> > think?
> >>
> >> Thanks!!
> >> That's very true, runtime_enable() and runtime_disable() calls are made by
> >> *phy_provider* only. But a querry here.
> >> Wouldn't in any case a PHY consumer might want to disable runtime_pm on PHY ?
> >> Say, when consumer failed to suspend the PHY properly
> >> (*put_sync(phy->dev)* fails), how much sure is the consumer about the
> >> state of PHY ?
> >
> > no no, wait a minute. We might not want to enable runtime pm for the PHY
> > until the UDC says it can handle runtime pm, no ? I guess this makes a
> > bit of sense (at least in my head :-p).
> >
> > Imagine if PHY is runtime suspended but e.g. DWC3 isn't runtime pm
> > enabled... Does it make sense to leave that control to the USB
> > controller drivers ?
> >
> > I'm open for suggestions
> 
> Of course unless the PHY consumer can handle runtime PM for PHY,
> PHY should not ideally be going into runtime_suspend.
> 
> Actually trying out few things, here are my observations
> 
> Enabling runtime_pm on PHY pushes PHY to go into runtime_suspend state.
> But a device detection wakes up DWC3 controller, and if i don't wake
> up PHY (using get_sync(phy->dev)) here
> in runtime_resume() callback of DWC3, i don't get PHY back in active state.
> So it becomes the duty of DWC3 controller to handle PHY's sleep and wake-up.
> Thereby it becomes logical that DWC3 controller has the right to
> enable runtime_pm
> of PHY.
> 
> But there's a catch here. if there are multiple consumers of PHY (like
> USB2 type PHY can
> have DWC3 controller as well as EHCI/OHCI or even HSGadget) then in that case,
> only one of the consumer can enable runtime_pm on PHY. So who decides this.
> 
> Aargh!! lot of confusion here :-(


hmmm, maybe add a flag to struct usb_phy and check it on
usb_phy_autopm_enable() ??

How does usbcore handle it ? They request class drivers to pass
supports_autosuspend, but while we should have a similar flag, that's
not enough. We also need a flag to tell us when pm_runtime has already
been enabled.

So how about:

usb_phy_autopm_enable()
{
	if (!phy->suports_autosuspend)
		return -ENOSYS;

	if (phy->autosuspend_enabled)
		return 0;

	phy->autosuspend_enabled = true;
	return pm_runtime_enable(phy->dev);
}

???

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-04-03 13:54 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01 13:53 [PATCH v3 00/11] usb: dwc3/xhci/phy: Enable runtime power management Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 01/11] usb: phy: Add APIs for " Vivek Gautam
2013-04-02  8:23   ` Felipe Balbi
2013-04-02  8:23     ` Felipe Balbi
2013-04-02 10:34     ` Vivek Gautam
2013-04-02 12:10       ` Felipe Balbi
2013-04-02 12:10         ` Felipe Balbi
2013-04-02 12:40         ` Vivek Gautam
2013-04-18 11:50           ` Kishon Vijay Abraham I
2013-04-18 11:50             ` Kishon Vijay Abraham I
2013-04-23 11:15             ` Felipe Balbi
2013-04-23 11:15               ` Felipe Balbi
2013-04-03  5:08   ` Kishon Vijay Abraham I
2013-04-03  5:08     ` Kishon Vijay Abraham I
2013-04-03  6:18     ` Vivek Gautam
2013-04-03  8:15       ` Felipe Balbi
2013-04-03  8:15         ` Felipe Balbi
2013-04-03 13:12         ` Vivek Gautam
2013-04-03 13:54           ` Felipe Balbi [this message]
2013-04-03 13:54             ` Felipe Balbi
2013-04-03 13:56             ` Felipe Balbi
2013-04-03 13:56               ` Felipe Balbi
2013-04-03 14:10               ` Vivek Gautam
2013-04-03 14:18                 ` Felipe Balbi
2013-04-03 14:18                   ` Felipe Balbi
2013-04-03 14:42                   ` Vivek Gautam
2013-04-03 18:14                   ` Alan Stern
2013-04-03 18:14                     ` Alan Stern
2013-04-04  7:18                     ` Felipe Balbi
2013-04-04  7:18                       ` Felipe Balbi
2013-04-04  8:56                       ` Vivek Gautam
2013-04-04  9:26                         ` Felipe Balbi
2013-04-04  9:26                           ` Felipe Balbi
2013-04-04 14:46                           ` Alan Stern
2013-04-04 14:46                             ` Alan Stern
2013-04-23 12:42                             ` Vivek Gautam
2013-04-23 16:53                               ` Alan Stern
2013-04-23 16:53                                 ` Alan Stern
2013-04-23 18:05                                 ` Vivek Gautam
2013-04-23 18:05                                   ` Vivek Gautam
2013-04-23 18:12                                   ` Alan Stern
2013-04-23 18:12                                     ` Alan Stern
2013-04-24 13:12                                     ` Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 02/11] USB: dwc3: Adjust runtime pm to allow autosuspend Vivek Gautam
2013-04-02  8:29   ` Felipe Balbi
2013-04-02  8:29     ` Felipe Balbi
2013-04-03  6:05     ` Vivek Gautam
2013-04-03  8:17       ` Felipe Balbi
2013-04-03  8:17         ` Felipe Balbi
2013-04-01 13:54 ` [PATCH v3 03/11] usb: dwc3: Enable runtime pm only after PHYs are initialized Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 04/11] usb: dwc3: Add runtime power management callbacks Vivek Gautam
2013-04-02  8:32   ` Felipe Balbi
2013-04-02  8:32     ` Felipe Balbi
2013-04-03  4:59     ` Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 05/11] usb: dwc3: exynos: Enable runtime power management Vivek Gautam
2013-04-02  8:33   ` Felipe Balbi
2013-04-02  8:33     ` Felipe Balbi
2013-04-01 13:54 ` [PATCH v3 06/11] usb: xhci: Enable runtime pm in xhci-plat Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 07/11] usb: phy: samsung: Enable runtime power management on usb2phy Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 08/11] usb: phy: samsung: Enable runtime power management on usb3phy Vivek Gautam
2013-04-01 13:54 ` [PATCH v3 09/11] usb: phy: samsung: Add support for external reference clock Vivek Gautam
2013-04-03 17:27 ` [PATCH v3 00/11] usb: dwc3/xhci/phy: Enable runtime power management Sarah Sharp
2013-04-04  5:04   ` Vivek Gautam
2013-04-04  7:10     ` Felipe Balbi
2013-04-04  7:10       ` Felipe Balbi
2013-04-04  7:32       ` Vivek Gautam
2013-04-04 16:40         ` Sarah Sharp

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=20130403135414.GG14680@arwen.pp.htv.fi \
    --to=balbi@ti.com \
    --cc=dianders@chromium.org \
    --cc=gautam.vivek@samsung.com \
    --cc=gautamvivek1987@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kgene.kim@samsung.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.paneri@samsung.com \
    --cc=rob.herring@calxeda.com \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=t.figa@samsung.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 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.