PCIe/PM: Do not suspend port if any subordinate device need PME polling
PATCH 1/1 PCIe/PM: Do not suspend port if any subordinate device need PME polling
In
http://www.mail-archive.com/[email protected]/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.
--- 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
Quoted 45 lines · Richard Yang
Quoted 31 lines · Huang Ying
In
http://www.mail-archive.com/[email protected]/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 <[email protected]>Signed-off-by Huang Ying <[email protected]>Tested-by Sarah Sharp <[email protected]>Cc [email protected] # 3.6+---
drivers/pci/pcie/portdrv_pci.c| 18 +++++++++++++++++-1 file changed, 17 insertions(+), 1 deletion(-)drivers/pci/pcie/portdrv_pci.c +1
-0@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(strureturn 0 ; } +static int pci_dev_pme_poll (struct pci_dev *pdev,void *data)drivers/pci/pcie/portdrv_pci.c static int pcie_port_runtime_resume(stru · line 147
Quoted 10 lines
drivers/pci/pcie/portdrv_pci.c +8
-0+{ +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?
Quoted 1 line
I think bool is better?
Well, bool would be nicer, but it's not a big deal.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 27 lines · Huang Ying
In
http://www.mail-archive.com/[email protected]/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 <[email protected]>Signed-off-by Huang Ying <[email protected]>Tested-by Sarah Sharp <[email protected]>Cc [email protected] # 3.6+--- drivers/pci/pcie/portdrv_pci.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/pci/pcie/portdrv_pci.c static int pcie_port_runtime_resume(stru · line 140
Quoted 7 lines
drivers/pci/pcie/portdrv_pci.c +4
-0@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(strureturn 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.
Quoted 10 lines
drivers/pci/pcie/portdrv_pci.c +8
-0+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
drivers/pci/pcie/portdrv_pci.c static int pcie_port_runtime_resume(stru · line 159
Quoted 10 lines
drivers/pci/pcie/portdrv_pci.c +5
-1+* 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
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Bjorn Helgaas
maintainerQuoted 47 lines · Richard Yang
Quoted 46 lines · Rafael J. Wysocki
Quoted 45 lines · Richard Yang
Quoted 31 lines · Huang Ying
In
http://www.mail-archive.com/[email protected]/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 <[email protected]>Signed-off-by Huang Ying <[email protected]>Tested-by Sarah Sharp <[email protected]>Cc [email protected] # 3.6+---
drivers/pci/pcie/portdrv_pci.c| 18 +++++++++++++++++-1 file changed, 17 insertions(+), 1 deletion(-)drivers/pci/pcie/portdrv_pci.c +1
-0@@ -134,10 +134,26 @@ static int pcie_port_runtime_resume(strureturn 0 ; } +static int pci_dev_pme_poll (struct pci_dev *pdev,void *data)drivers/pci/pcie/portdrv_pci.c static int pcie_port_runtime_resume(stru · line 147
Quoted 10 lines
drivers/pci/pcie/portdrv_pci.c +8
-0+{ +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?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
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