Skip to contentSkip to conversation

Unreliable USB3 with NEC uPD720200 and Delock Cardreader

DISCUSSION Bjørn Mork 6 participants 12 messages Nov 26, 2012 – Dec 13, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Bjørn

#2 lore raw
Quoted 12 lines · Bjørn Mork
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Quoted 6 lines

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Turning off D3 cold didn't help. Once the PCI device is suspended, connect events do not generate an interrupt.

I'll go see if I can figure out which kernel this worked on and bisect.

Sarah Sharp

#3 lore raw
Quoted 16 lines · Sarah Sharp
Quoted 15 lines · Bjørn Mork
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

Quoted 8 lines
Quoted 3 lines

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Turning off D3 cold didn't help. Once the PCI device is suspended, connect events do not generate an interrupt.

I'll go see if I can figure out which kernel this worked on and bisect.

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?

Sarah Sharp

#4 lore raw
Quoted 29 lines · Sarah Sharp
Quoted 16 lines · Sarah Sharp
Quoted 15 lines · Bjørn Mork
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

Quoted 8 lines
Quoted 3 lines

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Turning off D3 cold didn't help. Once the PCI device is suspended, connect events do not generate an interrupt.

I'll go see if I can figure out which kernel this worked on and bisect.

Wakeup from D3 works fine on the 3.5.0 kernel, but fails on 3.6.2. I haven't fully bisected yet.

Quoted 7 lines

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:

3d8387e PCI/PM: Fix config reg access for D3cold and bridge suspending ea8c88f PCI/PM: Keep parent bridge active when probing device 4f9c139 PCI/PM: Enable D3/D3cold by default for most devices 448bd85 PCI/PM: add PCIe runtime D3cold support
71a83bd PCI/PM: add runtime PM support to PCIe port
ee85f54 ACPI/PM: specify lowest allowed state for device sleep state

Generally, please try to bisect changes in drivers/pci between v3.5 and v3.6.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#11 lore raw
In reply to Sarah Sharp
Quoted 29 lines · Sarah Sharp
Quoted 16 lines · Sarah Sharp
Quoted 15 lines · Bjørn Mork
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

Quoted 8 lines
Quoted 3 lines

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Turning off D3 cold didn't help. Once the PCI device is suspended, connect events do not generate an interrupt.

I'll go see if I can figure out which kernel this worked on and bisect.

Wakeup from D3 works fine on the 3.5.0 kernel, but fails on 3.6.2. I haven't fully bisected yet.

Quoted 7 lines

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?

I do some debug with my NEC uPD720200, the patch is attached. I found that NEC uPD720200 can not generate PME interrupt, so it can be remote waken up only via polling. But if the PCIe bridge connected to NEC uPD720200 goes into suspended, we can not poll it. Maybe we need a way to disable PCIe bridge suspended if the underlying device can only be waken up via polling.

Best Regards,
Huang Ying

drivers/pci/pci.c +4 -1
Index: linux.git/drivers/pci/pci.c
===================================================================
@@ -1473,12 +1473,15 @@
 		dev->pme_poll = false;
 
 	if (pci_check_pme_status(dev)) {
+		if (pme_poll_reset)
+			dev_info(&dev->dev, "pme wakeup\n");
+		else
+			dev_info(&dev->dev, "poll wakeup\n");
 		pci_wakeup_event(dev);
 		pm_request_resume(&dev->dev);
 	}
 	return 0;
 }
-
 /**
  * pci_pme_wakeup_bus - Walk given bus and wake up devices on it, if necessary.
  * @bus: Top bus of the subtree to walk.
drivers/pci/pci-acpi.c +1 -0
Index: linux.git/drivers/pci/pci-acpi.c
===================================================================
@@ -56,6 +56,7 @@
 
 	if (!pci_dev->pm_cap || !pci_dev->pme_support
 	     || pci_check_pme_status(pci_dev)) {
+		dev_info(&pci_dev->dev, "pme wakeup\n");
 		if (pci_dev->pme_poll)
 			pci_dev->pme_poll = false;
 
drivers/pci/pcie/pme.c +3 -0
Index: linux.git/drivers/pci/pcie/pme.c
===================================================================
@@ -79,6 +79,7 @@
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		/* Skip PCIe devices in case we started from a root port. */
 		if (!pci_is_pcie(dev) && pci_check_pme_status(dev)) {
+			dev_info(&dev->dev, "pme wakeup\n");
 			if (dev->pme_poll)
 				dev->pme_poll = false;
 
@@ -144,6 +145,7 @@
 			port->pme_poll = false;
 
 		if (pci_check_pme_status(port)) {
+			dev_info(&dev->dev, "pme wakeup\n");
 			pm_request_resume(&port->dev);
 			found = true;
 		} else {
@@ -188,6 +190,7 @@
 		/* The device is there, but we have to check its PME status. */
 		found = pci_check_pme_status(dev);
 		if (found) {
+			dev_info(&dev->dev, "pme wakeup\n");
 			if (dev->pme_poll)
 				dev->pme_poll = false;
 
#12 lore raw
Quoted 38 lines · Huang Ying
Quoted 29 lines · Sarah Sharp
Quoted 16 lines · Sarah Sharp
Quoted 15 lines · Bjørn Mork
Quoted 9 lines · Sarah Sharp

It looks like both Ulrich and Andrew have the same issue. I also have a Lenovo x220, and I confirmed that when I turn on PCI runtime suspend, the NEC host controller does not report port status changes when a new USB device is plugged in.

I'm running 3.6.7, and I'm pretty sure that runtime suspend worked for the NEC host on some older kernel. I don't think the NEC host went into D3cold on that kernel, though. Is there a way to disable D3cold and just use D3hot instead?

Yes, you have /sys/bus/pci/devices/.../d3cold_allowed See Documentation/ABI/testing/sysfs-bus-pci

Quoted 8 lines
Quoted 3 lines

If this really is a problem with the D3cold support that went into 3.6 then I guess you should include Huang Ying in the discussions as well (CCed).

Turning off D3 cold didn't help. Once the PCI device is suspended, connect events do not generate an interrupt.

I'll go see if I can figure out which kernel this worked on and bisect.

Wakeup from D3 works fine on the 3.5.0 kernel, but fails on 3.6.2. I haven't fully bisected yet.

Quoted 7 lines

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?

Quoted 6 lines

I do some debug with my NEC uPD720200, the patch is attached. I found that NEC uPD720200 can not generate PME interrupt, so it can be remote waken up only via polling. But if the PCIe bridge connected to NEC uPD720200 goes into suspended, we can not poll it. Maybe we need a way to disable PCIe bridge suspended if the underlying device can only be waken up via polling.

I think we need to be more intelligent about that. It looks like we can only suspend a port (or bridge in general) if all devices below it have the pme_poll flag unset.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#5 lore raw
In reply to Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Sarah Sharp

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 1 line

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.

Sarah Sharp

#6 lore raw
Quoted 17 lines · Sarah Sharp
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Sarah Sharp

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 8 lines

Ok, I ran git bisect with only the drivers/pci directory as a target.

Quoted 1 line

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

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#7 lore raw
Quoted 22 lines · Rafael J. Wysocki
Quoted 21 lines · Sarah Sharp
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Sarah Sharp

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 1 line

ee85f54 ACPI/PM: specify lowest allowed state for device sleep state

Quoted 8 lines
Quoted 4 lines

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

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.

---
 drivers/pci/pcie/portdrv_pci.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/pci/pcie/portdrv_pci.c +17 -1
@@ -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
#8 lore raw
Quoted 28 lines · Huang Ying
Quoted 27 lines · Rafael J. Wysocki
Quoted 25 lines · Sarah Sharp
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Sarah Sharp

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 1 line

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.

Quoted 6 lines
Quoted 3 lines

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.

Potentially silly question: is this better than waking up the PCIe port when polling the device (and putting it back to sleep again)?

--Andy

Quoted 4 lines

Best Regards,
Huang Ying

#9 lore raw
Quoted 33 lines · Andrew Lutomirski
Quoted 32 lines · Huang Ying
Quoted 30 lines · Rafael J. Wysocki
Quoted 17 lines · Sarah Sharp
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Sarah Sharp

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 8 lines

Ok, I ran git bisect with only the drivers/pci directory as a target.

Quoted 1 line

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

Quoted 5 lines
Quoted 2 lines

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

Potentially silly question: is this better than waking up the PCIe port when polling the device (and putting it back to sleep again)?

Put PCI devices into/out of low power state can be very time consuming. For D3hot, it is at least 20ms, and for D3cold, it is at least 200ms.

Best Regards,
Huang Ying

Tested-by
#10 lore raw
In reply to Huang Ying
Quoted 2 lines · Huang Ying

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

This patch works for me. When I enable runtime PM for both the root port and the host controller, and I see the xHCI host go into PCI runtime suspend, but there's no longer a message about the power state changing to D3cold. USB device connects while the PCI host is suspended work now, as well as remote wakeup.

Please mark this for stable.

Thanks,
Sarah Sharp