LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI/PM: Report runtime wakeup is not supported if bridge isn't bound to driver
@ 2019-12-27  9:24 Kai-Heng Feng
  2019-12-27 10:36 ` Rafael J. Wysocki
  0 siblings, 1 reply; 5+ messages in thread
From: Kai-Heng Feng @ 2019-12-27  9:24 UTC (permalink / raw)
  To: bhelgaas, rafael.j.wysocki; +Cc: linux-pci, linux-kernel, Kai-Heng Feng

We have a Pericom USB add-on card that has three USB controller
functions 06:00.[0-2], connected to bridge device 05:03.0, which is
connected to another bridge device 04:00.0:

-[0000:00]-+-00.0
           +-1c.6-[04-06]----00.0-[05-06]----03.0-[06]--+-00.0
           |                                            +-00.1
           |                                            \-00.2

When bridge device (05:03.0) and all three USB controller functions
(06:00.[0-2]) are runtime suspended, they don't get woken up by plugging
USB devices into the add-on card.

This is because the pcieport driver failed to probe on 04:00.0, since
the device supports neither legacy IRQ, MSI nor MSI-X. Because of that,
there's no native PCIe PME can work for devices connected to it.

So let's correctly report runtime wakeup isn't supported when any of
PCIe bridges isn't bound to pcieport driver.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=205981
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/pci/pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 951099279192..ca686cfbd65e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2493,6 +2493,18 @@ bool pci_dev_run_wake(struct pci_dev *dev)
 	if (!pci_pme_capable(dev, pci_target_state(dev, true)))
 		return false;
 
+	/* If any upstream PCIe bridge isn't bound to pcieport driver, there's
+	 * no IRQ for PME.
+	 */
+	if (pci_is_pcie(dev)) {
+		while (bus->parent) {
+			if (!bus->self->driver)
+				return false;
+
+			bus = bus->parent;
+		}
+	}
+
 	if (device_can_wakeup(&dev->dev))
 		return true;
 
-- 
2.17.1


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

end of thread, other threads:[~2019-12-30  7:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-27  9:24 [PATCH] PCI/PM: Report runtime wakeup is not supported if bridge isn't bound to driver Kai-Heng Feng
2019-12-27 10:36 ` Rafael J. Wysocki
2019-12-27 17:15   ` Kai-Heng Feng
2019-12-29 22:37     ` Rafael J. Wysocki
2019-12-30  7:21       ` Kai-Heng Feng

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 read-only IMAP folder(s) and NNTP newsgroup(s).