linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	Andrew Lutomirski <luto@mit.edu>,
	Ulrich Eckhardt <usb@uli-eckhardt.de>
Cc: "Bjørn Mork" <bjorn@mork.no>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Ming Lei" <ming.lei@canonical.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	linux-pci@vger.kernel.org
Subject: Re: Unreliable USB3 with NEC uPD720200 and Delock Cardreader
Date: Wed, 12 Dec 2012 10:32:05 +0800	[thread overview]
Message-ID: <1355279525.7216.154.camel@yhuang-dev> (raw)
In-Reply-To: <7766249.mqYLvmhmrJ@vostro.rjw.lan>

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

On Fri, 2012-12-07 at 22:00 +0100, Rafael J. Wysocki wrote:
> On Thursday, December 06, 2012 04:28:08 PM Sarah Sharp wrote:
> > On Thu, Dec 06, 2012 at 01:43:32AM +0100, Rafael J. Wysocki wrote:
> > > On Wednesday, December 05, 2012 04:33:44 PM Sarah Sharp wrote:
> > > > Wakeup from D3 works fine on the 3.5.0 kernel, but fails on 3.6.2.  I
> > > > haven't fully bisected yet.
> > > > 
> > > > In debugging, I found that if you only enable runtime suspend for the
> > > > NEC host controller, the host successfully comes out of D3 when you plug
> > > > in a USB device.  However, if you enable runtime PM for the parent PCIe root
> > > > port, it stops working.  Disabling D3cold for both devices did not help.
> > > > 
> > > > It looks like a PCI issue, so what sort of debugging info do you need
> > > > from me?
> > > 
> > > It looks like this is related to one of the following commits:
> > 
> > > Generally, please try to bisect changes in drivers/pci between v3.5 and v3.6.
> > 
> > Ok, I ran git bisect with only the drivers/pci directory as a target.
> > 
> > > ee85f54 ACPI/PM: specify lowest allowed state for device sleep state
> > 
> > git bisect ended up identifying this as the bad patch, although
> > reverting just that patch after the bisect finished didn't seem to help.
> > However, it does make sense that this would be the culprit patch, if
> > Huang Ying's theory about the PME polling is correct.
> 
> Well, we surely don't handle this particular case correctly, and it shouldn't
> be very difficult to fix, so let's hope that this is the culprit. :-)
> 

Please try the patch attached.  With it, USB host controller can be
waken up with USB card reader plugging in on my test machine.

Best Regards,
Huang Ying


[-- Attachment #2: port_suspend_no_poll.patch --]
[-- Type: text/x-patch, Size: 1728 bytes --]

Subject: [BUGFIX] PCIe/PM: Do not suspend port if any subordinate device need PME polling

In

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 the
USB3 host controller 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>
---
 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

  reply	other threads:[~2012-12-12  2:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20121126191002.GE6504@xanatos>
2012-11-26 21:48 ` Unreliable USB3 with NEC uPD720200 and Delock Cardreader Bjørn Mork
2012-11-28 22:54   ` Sarah Sharp
2012-12-06  0:33     ` Sarah Sharp
2012-12-06  0:43       ` Rafael J. Wysocki
2012-12-07  0:28         ` Sarah Sharp
2012-12-07 21:00           ` Rafael J. Wysocki
2012-12-12  2:32             ` Huang Ying [this message]
2012-12-12  2:34               ` Andrew Lutomirski
2012-12-12  3:18                 ` huang ying
2012-12-13 19:53               ` Sarah Sharp
2012-12-06  7:17       ` Huang Ying
2012-12-06 12:43         ` Rafael J. Wysocki
     [not found] <50841CCC.9030809@uli-eckhardt.de>
2012-10-22 23:40 ` Sarah Sharp
2012-10-23 13:54   ` Bjorn Helgaas
2012-10-23 17:14   ` Ulrich Eckhardt
2012-10-24 20:18     ` Bjorn Helgaas
2012-10-24 21:10       ` Rafael J. Wysocki
2012-10-24 21:13         ` Bjorn Helgaas
2012-10-24 21:31           ` Rafael J. Wysocki
2012-10-25  1:24             ` Ming Lei
2012-10-25 13:33               ` Bjorn Helgaas
2012-10-25 17:43               ` Ulrich Eckhardt
2012-10-25 18:19                 ` Alan Stern
2012-10-27 13:02                   ` Ulrich Eckhardt
2012-10-25 17:15           ` Ulrich Eckhardt
2012-10-25 20:11             ` Rafael J. Wysocki
2012-10-26 16:41               ` Ulrich Eckhardt
2012-10-25 20:09       ` 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=1355279525.7216.154.camel@yhuang-dev \
    --to=ying.huang@intel.com \
    --cc=bhelgaas@google.com \
    --cc=bjorn@mork.no \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luto@mit.edu \
    --cc=ming.lei@canonical.com \
    --cc=rjw@sisk.pl \
    --cc=sarah.a.sharp@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=usb@uli-eckhardt.de \
    /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;
as well as URLs for NNTP newsgroup(s).