linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
@ 2014-02-24 16:29 Mathias Nyman
  2014-02-24 16:47 ` Dan Williams
  2014-02-24 17:44 ` Alan Stern
  0 siblings, 2 replies; 7+ messages in thread
From: Mathias Nyman @ 2014-02-24 16:29 UTC (permalink / raw)
  To: linux-usb
  Cc: sarah.a.sharp, david.a.cohen, jianqiang.tang, dan.j.williams,
	stern, linux-kernel, Mathias Nyman

xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
to register its usb-2 bus, and then continue to manually register the
usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
might thus trigger a runtime suspend before the usb-3 bus is ready.

Prevent the runtime suspend by increasing the usage count in the
beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
ready.

xhci-platform driver is not using usb_hcd_pci_probe to set up
busses and should not need to have it's usage count increased during probe.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci-pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 04f986d..ea7158b 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	struct usb_hcd *hcd;
 
 	driver = (struct hc_driver *)id->driver_data;
+
+	/* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
+	pm_runtime_get_noresume(&dev->dev);
+
 	/* Register the USB 2.0 roothub.
 	 * FIXME: USB core must know to register the USB 2.0 roothub first.
 	 * This is sort of silly, because we could just set the HCD driver flags
@@ -199,7 +203,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	retval = usb_hcd_pci_probe(dev, id);
 
 	if (retval)
-		return retval;
+		goto put_runtime_pm;
 
 	/* USB 2.0 roothub is stored in the PCI device now. */
 	hcd = dev_get_drvdata(&dev->dev);
@@ -228,12 +232,17 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (xhci->quirks & XHCI_LPM_SUPPORT)
 		hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
 
+	/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
+	pm_runtime_put_noidle(&dev->dev);
+
 	return 0;
 
 put_usb3_hcd:
 	usb_put_hcd(xhci->shared_hcd);
 dealloc_usb2_hcd:
 	usb_hcd_pci_remove(dev);
+put_runtime_pm:
+	pm_runtime_put_noidle(&dev->dev);
 	return retval;
 }
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-24 16:29 [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization Mathias Nyman
@ 2014-02-24 16:47 ` Dan Williams
  2014-02-24 17:44 ` Alan Stern
  1 sibling, 0 replies; 7+ messages in thread
From: Dan Williams @ 2014-02-24 16:47 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: USB list, Sarah Sharp, david.a.cohen, Jianqiang Tang, Alan Stern,
	linux-kernel

On Mon, Feb 24, 2014 at 8:29 AM, Mathias Nyman
<mathias.nyman@linux.intel.com> wrote:
> xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
> to register its usb-2 bus, and then continue to manually register the
> usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
> might thus trigger a runtime suspend before the usb-3 bus is ready.
>
> Prevent the runtime suspend by increasing the usage count in the
> beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
> ready.
>
> xhci-platform driver is not using usb_hcd_pci_probe to set up
> busses and should not need to have it's usage count increased during probe.
>
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>

Acked-by: Dan Williams <dan.j.williams@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-24 16:29 [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization Mathias Nyman
  2014-02-24 16:47 ` Dan Williams
@ 2014-02-24 17:44 ` Alan Stern
  2014-02-28 20:32   ` Sarah Sharp
  1 sibling, 1 reply; 7+ messages in thread
From: Alan Stern @ 2014-02-24 17:44 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: linux-usb, sarah.a.sharp, david.a.cohen, jianqiang.tang,
	dan.j.williams, linux-kernel

On Mon, 24 Feb 2014, Mathias Nyman wrote:

> xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
> to register its usb-2 bus, and then continue to manually register the
> usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
> might thus trigger a runtime suspend before the usb-3 bus is ready.
> 
> Prevent the runtime suspend by increasing the usage count in the
> beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
> ready.
> 
> xhci-platform driver is not using usb_hcd_pci_probe to set up
> busses and should not need to have it's usage count increased during probe.
> 
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> ---
>  drivers/usb/host/xhci-pci.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index 04f986d..ea7158b 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	struct usb_hcd *hcd;
>  
>  	driver = (struct hc_driver *)id->driver_data;
> +
> +	/* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
> +	pm_runtime_get_noresume(&dev->dev);

Strictly speaking, this prevents the _controller_ from going into
runtime suspend -- not the root hub.

> +
>  	/* Register the USB 2.0 roothub.
>  	 * FIXME: USB core must know to register the USB 2.0 roothub first.
>  	 * This is sort of silly, because we could just set the HCD driver flags
> @@ -199,7 +203,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	retval = usb_hcd_pci_probe(dev, id);
>  
>  	if (retval)
> -		return retval;
> +		goto put_runtime_pm;
>  
>  	/* USB 2.0 roothub is stored in the PCI device now. */
>  	hcd = dev_get_drvdata(&dev->dev);
> @@ -228,12 +232,17 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	if (xhci->quirks & XHCI_LPM_SUPPORT)
>  		hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
>  
> +	/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
> +	pm_runtime_put_noidle(&dev->dev);
> +
>  	return 0;
>  
>  put_usb3_hcd:
>  	usb_put_hcd(xhci->shared_hcd);
>  dealloc_usb2_hcd:
>  	usb_hcd_pci_remove(dev);
> +put_runtime_pm:
> +	pm_runtime_put_noidle(&dev->dev);
>  	return retval;
>  }

Apart from nit about the comment,

Acked-by: Alan Stern <stern@rowland.harvard.edu>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-24 17:44 ` Alan Stern
@ 2014-02-28 20:32   ` Sarah Sharp
  2014-02-28 20:41     ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Sarah Sharp @ 2014-02-28 20:32 UTC (permalink / raw)
  To: Alan Stern
  Cc: Mathias Nyman, linux-usb, david.a.cohen, jianqiang.tang,
	dan.j.williams, linux-kernel

On Mon, Feb 24, 2014 at 12:44:46PM -0500, Alan Stern wrote:
> On Mon, 24 Feb 2014, Mathias Nyman wrote:
> 
> > xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
> > to register its usb-2 bus, and then continue to manually register the
> > usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
> > might thus trigger a runtime suspend before the usb-3 bus is ready.
> > 
> > Prevent the runtime suspend by increasing the usage count in the
> > beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
> > ready.
> > 
> > xhci-platform driver is not using usb_hcd_pci_probe to set up
> > busses and should not need to have it's usage count increased during probe.
> > 
> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> > ---
> >  drivers/usb/host/xhci-pci.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> > index 04f986d..ea7158b 100644
> > --- a/drivers/usb/host/xhci-pci.c
> > +++ b/drivers/usb/host/xhci-pci.c
> > @@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
> >  	struct usb_hcd *hcd;
> >  
> >  	driver = (struct hc_driver *)id->driver_data;
> > +
> > +	/* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
> > +	pm_runtime_get_noresume(&dev->dev);
> 
> Strictly speaking, this prevents the _controller_ from going into
> runtime suspend -- not the root hub.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>

Mathias, want to fix this comment and queue this up to Greg?  It should
probably be marked for stable.

> Apart from nit about the comment,
> 
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-28 20:32   ` Sarah Sharp
@ 2014-02-28 20:41     ` Dan Williams
  2014-02-28 21:57       ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Williams @ 2014-02-28 20:41 UTC (permalink / raw)
  To: Sarah Sharp
  Cc: Alan Stern, Mathias Nyman, USB list, david.a.cohen,
	Jianqiang Tang, linux-kernel

On Fri, Feb 28, 2014 at 12:32 PM, Sarah Sharp
<sarah.a.sharp@linux.intel.com> wrote:
> On Mon, Feb 24, 2014 at 12:44:46PM -0500, Alan Stern wrote:
>> On Mon, 24 Feb 2014, Mathias Nyman wrote:
>>
>> > xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
>> > to register its usb-2 bus, and then continue to manually register the
>> > usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
>> > might thus trigger a runtime suspend before the usb-3 bus is ready.
>> >
>> > Prevent the runtime suspend by increasing the usage count in the
>> > beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
>> > ready.
>> >
>> > xhci-platform driver is not using usb_hcd_pci_probe to set up
>> > busses and should not need to have it's usage count increased during probe.
>> >
>> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>> > ---
>> >  drivers/usb/host/xhci-pci.c | 11 ++++++++++-
>> >  1 file changed, 10 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
>> > index 04f986d..ea7158b 100644
>> > --- a/drivers/usb/host/xhci-pci.c
>> > +++ b/drivers/usb/host/xhci-pci.c
>> > @@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>> >     struct usb_hcd *hcd;
>> >
>> >     driver = (struct hc_driver *)id->driver_data;
>> > +
>> > +   /* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
>> > +   pm_runtime_get_noresume(&dev->dev);
>>
>> Strictly speaking, this prevents the _controller_ from going into
>> runtime suspend -- not the root hub.
>
> Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>

Pardon the nitpick, but this is an acked-by if Mathias is submitting.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-28 20:41     ` Dan Williams
@ 2014-02-28 21:57       ` Greg KH
  2014-02-28 22:02         ` Dan Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2014-02-28 21:57 UTC (permalink / raw)
  To: Dan Williams
  Cc: Sarah Sharp, Alan Stern, Mathias Nyman, USB list, david.a.cohen,
	Jianqiang Tang, linux-kernel

On Fri, Feb 28, 2014 at 12:41:31PM -0800, Dan Williams wrote:
> On Fri, Feb 28, 2014 at 12:32 PM, Sarah Sharp
> <sarah.a.sharp@linux.intel.com> wrote:
> > On Mon, Feb 24, 2014 at 12:44:46PM -0500, Alan Stern wrote:
> >> On Mon, 24 Feb 2014, Mathias Nyman wrote:
> >>
> >> > xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
> >> > to register its usb-2 bus, and then continue to manually register the
> >> > usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
> >> > might thus trigger a runtime suspend before the usb-3 bus is ready.
> >> >
> >> > Prevent the runtime suspend by increasing the usage count in the
> >> > beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
> >> > ready.
> >> >
> >> > xhci-platform driver is not using usb_hcd_pci_probe to set up
> >> > busses and should not need to have it's usage count increased during probe.
> >> >
> >> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> >> > ---
> >> >  drivers/usb/host/xhci-pci.c | 11 ++++++++++-
> >> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> >> > index 04f986d..ea7158b 100644
> >> > --- a/drivers/usb/host/xhci-pci.c
> >> > +++ b/drivers/usb/host/xhci-pci.c
> >> > @@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
> >> >     struct usb_hcd *hcd;
> >> >
> >> >     driver = (struct hc_driver *)id->driver_data;
> >> > +
> >> > +   /* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
> >> > +   pm_runtime_get_noresume(&dev->dev);
> >>
> >> Strictly speaking, this prevents the _controller_ from going into
> >> runtime suspend -- not the root hub.
> >
> > Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
> 
> Pardon the nitpick, but this is an acked-by if Mathias is submitting.

No, it's a "chain of signed-off-by's" and this is allowed just fine (it
used to be the default-thing before we came up with the "acked-by"
line...)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization
  2014-02-28 21:57       ` Greg KH
@ 2014-02-28 22:02         ` Dan Williams
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Williams @ 2014-02-28 22:02 UTC (permalink / raw)
  To: Greg KH
  Cc: Sarah Sharp, Alan Stern, Mathias Nyman, USB list, david.a.cohen,
	Jianqiang Tang, linux-kernel

On Fri, Feb 28, 2014 at 1:57 PM, Greg KH <greg@kroah.com> wrote:
> On Fri, Feb 28, 2014 at 12:41:31PM -0800, Dan Williams wrote:
>> On Fri, Feb 28, 2014 at 12:32 PM, Sarah Sharp
>> <sarah.a.sharp@linux.intel.com> wrote:
>> > On Mon, Feb 24, 2014 at 12:44:46PM -0500, Alan Stern wrote:
>> >> On Mon, 24 Feb 2014, Mathias Nyman wrote:
>> >>
>> >> > xHCI driver has its own pci probe function that will call usb_hcd_pci_probe
>> >> > to register its usb-2 bus, and then continue to manually register the
>> >> > usb-3 bus. usb_hcd_pci_probe does a pm_runtime_put_noidle at the end and
>> >> > might thus trigger a runtime suspend before the usb-3 bus is ready.
>> >> >
>> >> > Prevent the runtime suspend by increasing the usage count in the
>> >> > beginning of xhci_pci_probe, and decrease it once the usb-3 bus is
>> >> > ready.
>> >> >
>> >> > xhci-platform driver is not using usb_hcd_pci_probe to set up
>> >> > busses and should not need to have it's usage count increased during probe.
>> >> >
>> >> > Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
>> >> > ---
>> >> >  drivers/usb/host/xhci-pci.c | 11 ++++++++++-
>> >> >  1 file changed, 10 insertions(+), 1 deletion(-)
>> >> >
>> >> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
>> >> > index 04f986d..ea7158b 100644
>> >> > --- a/drivers/usb/host/xhci-pci.c
>> >> > +++ b/drivers/usb/host/xhci-pci.c
>> >> > @@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>> >> >     struct usb_hcd *hcd;
>> >> >
>> >> >     driver = (struct hc_driver *)id->driver_data;
>> >> > +
>> >> > +   /* Prevent USB-2 roothub runtime suspend until USB-3 is initialized. */
>> >> > +   pm_runtime_get_noresume(&dev->dev);
>> >>
>> >> Strictly speaking, this prevents the _controller_ from going into
>> >> runtime suspend -- not the root hub.
>> >
>> > Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
>>
>> Pardon the nitpick, but this is an acked-by if Mathias is submitting.
>
> No, it's a "chain of signed-off-by's" and this is allowed just fine (it
> used to be the default-thing before we came up with the "acked-by"
> line...)

Ok. jejb picked on me about it once, but I'm more than willing to drop
this off my list of things to nitpick.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-28 22:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-24 16:29 [RFC PATCH v2] xhci: Prevent runtime pm from autosuspending during initialization Mathias Nyman
2014-02-24 16:47 ` Dan Williams
2014-02-24 17:44 ` Alan Stern
2014-02-28 20:32   ` Sarah Sharp
2014-02-28 20:41     ` Dan Williams
2014-02-28 21:57       ` Greg KH
2014-02-28 22:02         ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).