linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling
@ 2012-12-14  2:52 Huang Ying
       [not found] ` <20121214051131.GA31440@richard.>
  2012-12-14 23:43 ` Rafael J. Wysocki
  0 siblings, 2 replies; 4+ messages in thread
From: Huang Ying @ 2012-12-14  2:52 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-kernel, linux-pci, linux-pm, Rafael J. Wysocki, Huang Ying

In

  http://www.mail-archive.com/linux-usb@vger.kernel.org/msg07976.html

Ulrich reported that his USB3 cardreader does not work reliably when
connected to the USB3 port.  It turns out that USB3 controller failed
to be waken up when plugging in the USB3 cardreader.  Further
experiment found that the USB3 host controller can only be waken up
via polling, while not via PME interrupt.  But if the PCIe port that
the USB3 host controller is connected is suspended, we can not poll
the USB3 host controller because its config space is not accessible if
the PCIe port is put into low power state.

To solve the issue, the PCIe port will not be suspended if any
subordinate device need PME polling.

Reported-by: Ulrich Eckhardt <usb@uli-eckhardt.de>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable@vger.kernel.org	# 3.6+
---
 drivers/pci/pcie/portdrv_pci.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(stru
 	return 0;
 }
 
+static int pci_dev_pme_poll(struct pci_dev *pdev, void *data)
+{
+	int *pme_poll = data;
+	*pme_poll = *pme_poll || pdev->pme_poll;
+	return 0;
+}
+
 static int pcie_port_runtime_idle(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
+	int pme_poll = false;
+
+	/*
+	 * If any subordinate device needs pme poll, we should keep
+	 * the port in D0, because we need port in D0 to poll it.
+	 */
+	pci_walk_bus(pdev->subordinate, pci_dev_pme_poll, &pme_poll);
 	/* Delay for a short while to prevent too frequent suspend/resume */
-	pm_schedule_suspend(dev, 10);
+	if (!pme_poll)
+		pm_schedule_suspend(dev, 10);
 	return -EBUSY;
 }
 #else

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

* Re: [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling
       [not found] ` <20121214051131.GA31440@richard.>
@ 2012-12-14 23:03   ` Rafael J. Wysocki
       [not found]     ` <50cdc89b.2788440a.0cfe.ffff8fb7SMTPIN_ADDED_BROKEN@mx.google.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2012-12-14 23:03 UTC (permalink / raw)
  To: Richard Yang; +Cc: Huang Ying, Bjorn Helgaas, linux-kernel, linux-pci, linux-pm

On Friday, December 14, 2012 01:11:31 PM Richard Yang wrote:
> On Fri, Dec 14, 2012 at 10:52:11AM +0800, Huang Ying wrote:
> >In
> >
> >  http://www.mail-archive.com/linux-usb@vger.kernel.org/msg07976.html
> >
> >Ulrich reported that his USB3 cardreader does not work reliably when
> >connected to the USB3 port.  It turns out that USB3 controller failed
> >to be waken up when plugging in the USB3 cardreader.  Further
> >experiment found that the USB3 host controller can only be waken up
> >via polling, while not via PME interrupt.  But if the PCIe port that
> >the USB3 host controller is connected is suspended, we can not poll
> >the USB3 host controller because its config space is not accessible if
> >the PCIe port is put into low power state.
> >
> >To solve the issue, the PCIe port will not be suspended if any
> >subordinate device need PME polling.
> >
> >Reported-by: Ulrich Eckhardt <usb@uli-eckhardt.de>
> >Signed-off-by: Huang Ying <ying.huang@intel.com>
> >Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
> >Cc: stable@vger.kernel.org	# 3.6+
> >---
> > drivers/pci/pcie/portdrv_pci.c |   18 +++++++++++++++++-
> > 1 file changed, 17 insertions(+), 1 deletion(-)
> >
> >--- a/drivers/pci/pcie/portdrv_pci.c
> >+++ b/drivers/pci/pcie/portdrv_pci.c
> >@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(stru
> > 	return 0;
> > }
> >
> >+static int pci_dev_pme_poll(struct pci_dev *pdev, void *data)
> >+{
> >+	int *pme_poll = data;
> >+	*pme_poll = *pme_poll || pdev->pme_poll;
> >+	return 0;
> >+}
> >+
> > static int pcie_port_runtime_idle(struct device *dev)
> > {
> >+	struct pci_dev *pdev = to_pci_dev(dev);
> >+	int pme_poll = false;
> 
> You want to use int or bool? 
> 
> I think bool is better?

Well, bool would be nicer, but it's not a big deal.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling
  2012-12-14  2:52 [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling Huang Ying
       [not found] ` <20121214051131.GA31440@richard.>
@ 2012-12-14 23:43 ` Rafael J. Wysocki
  1 sibling, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2012-12-14 23:43 UTC (permalink / raw)
  To: Huang Ying; +Cc: Bjorn Helgaas, linux-kernel, linux-pci, linux-pm

On Friday, December 14, 2012 10:52:11 AM Huang Ying wrote:
> In
> 
>   http://www.mail-archive.com/linux-usb@vger.kernel.org/msg07976.html
> 
> Ulrich reported that his USB3 cardreader does not work reliably when
> connected to the USB3 port.  It turns out that USB3 controller failed
> to be waken up when plugging in the USB3 cardreader.  Further
> experiment found that the USB3 host controller can only be waken up
> via polling, while not via PME interrupt.  But if the PCIe port that
> the USB3 host controller is connected is suspended, we can not poll
> the USB3 host controller because its config space is not accessible if
> the PCIe port is put into low power state.
> 
> To solve the issue, the PCIe port will not be suspended if any
> subordinate device need PME polling.
> 
> Reported-by: Ulrich Eckhardt <usb@uli-eckhardt.de>
> Signed-off-by: Huang Ying <ying.huang@intel.com>
> Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
> Cc: stable@vger.kernel.org	# 3.6+
> ---
>  drivers/pci/pcie/portdrv_pci.c |   18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> --- a/drivers/pci/pcie/portdrv_pci.c
> +++ b/drivers/pci/pcie/portdrv_pci.c
> @@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(stru
>  	return 0;
>  }
>  
> +static int pci_dev_pme_poll(struct pci_dev *pdev, void *data)
> +{
> +	int *pme_poll = data;
> +	*pme_poll = *pme_poll || pdev->pme_poll;

I would write that as

	*pme_poll ||= pdev->pme_poll;

It is not a big deal, though.

> +	return 0;
> +}
> +
>  static int pcie_port_runtime_idle(struct device *dev)
>  {
> +	struct pci_dev *pdev = to_pci_dev(dev);
> +	int pme_poll = false;
> +
> +	/*
> +	 * If any subordinate device needs pme poll, we should keep
> +	 * the port in D0, because we need port in D0 to poll it.
> +	 */
> +	pci_walk_bus(pdev->subordinate, pci_dev_pme_poll, &pme_poll);
>  	/* Delay for a short while to prevent too frequent suspend/resume */
> -	pm_schedule_suspend(dev, 10);
> +	if (!pme_poll)
> +		pm_schedule_suspend(dev, 10);
>  	return -EBUSY;
>  }
>  #else

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling
       [not found]     ` <50cdc89b.2788440a.0cfe.ffff8fb7SMTPIN_ADDED_BROKEN@mx.google.com>
@ 2012-12-20 21:44       ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2012-12-20 21:44 UTC (permalink / raw)
  To: Richard Yang
  Cc: Rafael J. Wysocki, Huang Ying, linux-kernel, linux-pci, linux-pm

On Sun, Dec 16, 2012 at 6:11 AM, Richard Yang
<weiyang@linux.vnet.ibm.com> wrote:
> On Sat, Dec 15, 2012 at 12:03:33AM +0100, Rafael J. Wysocki wrote:
>>On Friday, December 14, 2012 01:11:31 PM Richard Yang wrote:
>>> On Fri, Dec 14, 2012 at 10:52:11AM +0800, Huang Ying wrote:
>>> >In
>>> >
>>> >  http://www.mail-archive.com/linux-usb@vger.kernel.org/msg07976.html
>>> >
>>> >Ulrich reported that his USB3 cardreader does not work reliably when
>>> >connected to the USB3 port.  It turns out that USB3 controller failed
>>> >to be waken up when plugging in the USB3 cardreader.  Further
>>> >experiment found that the USB3 host controller can only be waken up
>>> >via polling, while not via PME interrupt.  But if the PCIe port that
>>> >the USB3 host controller is connected is suspended, we can not poll
>>> >the USB3 host controller because its config space is not accessible if
>>> >the PCIe port is put into low power state.
>>> >
>>> >To solve the issue, the PCIe port will not be suspended if any
>>> >subordinate device need PME polling.
>>> >
>>> >Reported-by: Ulrich Eckhardt <usb@uli-eckhardt.de>
>>> >Signed-off-by: Huang Ying <ying.huang@intel.com>
>>> >Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
>>> >Cc: stable@vger.kernel.org  # 3.6+
>>> >---
>>> > drivers/pci/pcie/portdrv_pci.c |   18 +++++++++++++++++-
>>> > 1 file changed, 17 insertions(+), 1 deletion(-)
>>> >
>>> >--- a/drivers/pci/pcie/portdrv_pci.c
>>> >+++ b/drivers/pci/pcie/portdrv_pci.c
>>> >@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(stru
>>> >    return 0;
>>> > }
>>> >
>>> >+static int pci_dev_pme_poll(struct pci_dev *pdev, void *data)
>>> >+{
>>> >+   int *pme_poll = data;
>>> >+   *pme_poll = *pme_poll || pdev->pme_poll;
>>> >+   return 0;
>>> >+}
>>> >+
>>> > static int pcie_port_runtime_idle(struct device *dev)
>>> > {
>>> >+   struct pci_dev *pdev = to_pci_dev(dev);
>>> >+   int pme_poll = false;
>>>
>>> You want to use int or bool?
>>>
>>> I think bool is better?
>>
>>Well, bool would be nicer, but it's not a big deal.
>>
>
> Yep, not a big deal.

I fixed up the int/bool confusion and added this to my pci/for-3.8
branch.  I'll push it soon after v3.8-rc1.  Thanks!

Bjorn

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

end of thread, other threads:[~2012-12-20 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-14  2:52 [PATCH] PCIe/PM: Do not suspend port if any subordinate device need PME polling Huang Ying
     [not found] ` <20121214051131.GA31440@richard.>
2012-12-14 23:03   ` Rafael J. Wysocki
     [not found]     ` <50cdc89b.2788440a.0cfe.ffff8fb7SMTPIN_ADDED_BROKEN@mx.google.com>
2012-12-20 21:44       ` Bjorn Helgaas
2012-12-14 23:43 ` Rafael J. Wysocki

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).