PCI/PM: Skip resuming to D0 if disconnected
PATCH v4 1/1 PCI/PM: Skip resuming to D0 if disconnected
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to pci_channel_io_perm_failure which pci_dev_is_disconnected() will check.
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Use pci_dev_is_disconnected()
v1: https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b
--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/pci/pci.c +5 -0
@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; } +if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold; +return -EIO ; + } +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);if (PCI_POSSIBLE_ERROR (pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n",
Signature · 1 line
2.43.0
[cc += Rafael, Mika]
Quoted 8 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to
pci_channel_io_perm_failurewhichpci_dev_is_disconnected()will check.
Quoted 5 lines
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by Mario Limonciello <[email protected]>
Quoted 31 lines
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Usepci_dev_is_disconnected()
v1: https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/pci.c +5
-0@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; } +if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold; +return -EIO ; + } +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);if (PCI_POSSIBLE_ERROR (pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n",Signature · 1 line
2.43.0
Quoted 41 lines · Lukas Wunner
[cc += Rafael, Mika]
Quoted 8 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to
pci_channel_io_perm_failurewhichpci_dev_is_disconnected()will check.Quoted 5 lines
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Quoted 21 lines
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Usepci_dev_is_disconnected()
v1: https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/pci.c +0
-0@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; }
Quoted 2 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1378
Quoted 2 lines
drivers/pci/pci.c +2
-0+if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold;
Why not PCI_UNKNOWN?
Quoted 8 lines
Quoted 8 lines
drivers/pci/pci.c +3
-1+return -EIO ; + } +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);if (PCI_POSSIBLE_ERROR (pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n", --2.43.0
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Lukas Wunner
[cc += Rafael, Mika]
Quoted 8 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to
pci_channel_io_perm_failurewhichpci_dev_is_disconnected()will check.Quoted 5 lines
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Quoted 21 lines
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Usepci_dev_is_disconnected()
v1: https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/pci.c +0
-0@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; }
Quoted 4 lines
Quoted 2 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1378
Quoted 2 lines
drivers/pci/pci.c +2
-0+if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold;Why not
PCI_UNKNOWN?
It was following what other situations of failure did:
* existing error in pci_power_up()
* error in pci_update_current_state()
* error in pci_set_low_power_state()
I view all of these cases as unrecoverable failures.
So perhaps if changing this one to PCI_UNKNOWN those three should those also be PCI_UNKNOWN?
Bjorn, Lukas, thoughts?
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/pci/pci.c +3
-1+return -EIO ; + } +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);if (PCI_POSSIBLE_ERROR (pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n", --2.43.0
Ilpo Järvinen
Reviewed-byQuoted 55 lines · Mario Limonciello
Quoted 44 lines · Rafael J. Wysocki
Quoted 43 lines · Lukas Wunner
[cc += Rafael, Mika]
Quoted 9 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to
pci_channel_io_perm_failurewhichpci_dev_is_disconnected()will check.Quoted 5 lines
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Quoted 22 lines
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Usepci_dev_is_disconnected()
v1:
https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/pci.c +0
-0@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; }Quoted 4 lines
Quoted 2 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1378
Quoted 2 lines
drivers/pci/pci.c +2
-0+if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold;Why not
PCI_UNKNOWN?It was following what other situations of failure did:
* existing error inpci_power_up()
* error inpci_update_current_state()
* error inpci_set_low_power_state()
Quoted 15 lines
I view all of these cases as unrecoverable failures.
So perhaps if changing this one to
PCI_UNKNOWNthose three should those also bePCI_UNKNOWN?Bjorn, Lukas, thoughts?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/pci/pci.c +3
-0+return -EIO ; + } +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);if (PCI_POSSIBLE_ERROR (pmcsr)) { pci_err(dev, "Unable to change power state from %s to D0,device inaccessible\n",
(I've no opinion on PCI_UNKNOWN or not.)
Signature · 1 line
i.
Rafael J. Wysocki
Acked-byQuoted 54 lines · Mario Limonciello
Quoted 42 lines · Rafael J. Wysocki
Quoted 41 lines · Lukas Wunner
[cc += Rafael, Mika]
Quoted 8 lines · Mario Limonciello
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to
pci_channel_io_perm_failurewhichpci_dev_is_disconnected()will check.Quoted 5 lines
It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.
Suggested-by Lukas Wunner <[email protected]>Signed-off-by Mario Limonciello <[email protected]>Reviewed-by Lukas Wunner <[email protected]>Quoted 21 lines
---
v4:
* no info message
v3:
* Adjust text and subject
* Add an info message instead
v2:
* Usepci_dev_is_disconnected()
v1: https://lore.kernel.org/linux-usb/[email protected]/T/#mf95c947990d016fbfccfd11afe60b8ae08aafa0b--- drivers/pci/pci.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/pci/pci.c +0
-0@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)return -EIO ; }Quoted 4 lines
Quoted 2 lines
drivers/pci/pci.c int pci_power_up(struct pci_dev *dev) · line 1378
Quoted 2 lines
drivers/pci/pci.c +2
-0+if (pci_dev_is_disconnected (dev)) { + dev->current_state = PCI_D3cold;Why not
PCI_UNKNOWN?It was following what other situations of failure did:
* existing error inpci_power_up()
* error inpci_update_current_state()
* error inpci_set_low_power_state()
Quoted 6 lines
I view all of these cases as unrecoverable failures.
So perhaps if changing this one to
PCI_UNKNOWNthose three should those also bePCI_UNKNOWN?Bjorn, Lukas, thoughts?
Note that pci_device_remove() sets power_state to PCI_UNKNOWN, but only if the old value is PCI_D0, so it would be good to make all of that consistent at one point.
Anyway, feel free to add
to this patch.
Thanks!