Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1739929
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 7/7] PCI: pciehp: Check that the device is really present before touching it |
| Date | 2017-09-26 16:20 +0200 |
| Message-ID | <utYSm-5Rt-27@gated-at.bofh.it> (permalink) |
| References | <utYSl-5Rt-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
During surprise hot-unplug the device is not there anymore. When that
happens we read 0xffffffff from the registers and pciehp_unconfigure_device()
inadvertently thinks the device is a display device because bridge
control register returns 0xff refusing to remove it:
pciehp 0000:00:1c.0:pcie004: Slot(0): Link Down
pciehp 0000:00:1c.0:pcie004: Slot(0): Card present
pciehp 0000:00:1c.0:pcie004: Cannot remove display device 0000:01:00.0
This causes the hotplug functionality to leave the hierarcy untouched
preventing further hotplug operations.
To fix this verify presence of a device by calling pci_device_is_present()
for it before we touch it any further.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/pci/hotplug/pciehp_pci.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index b31702f76149..2a3a62393ba9 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -101,8 +101,14 @@ int pciehp_unconfigure_device(struct slot *p_slot)
*/
list_for_each_entry_safe_reverse(dev, temp, &parent->devices,
bus_list) {
+ bool present;
+
pci_dev_get(dev);
- if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && presence) {
+
+ /* Check if the device is really there anymore */
+ present = presence ? pci_device_is_present(dev) : false;
+
+ if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && present) {
pci_read_config_byte(dev, PCI_BRIDGE_CONTROL, &bctl);
if (bctl & PCI_BRIDGE_CTL_VGA) {
ctrl_err(ctrl,
@@ -113,7 +119,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
break;
}
}
- if (!presence) {
+ if (!present) {
pci_dev_set_disconnected(dev, NULL);
if (pci_has_subordinate(dev))
pci_walk_bus(dev->subordinate,
@@ -124,7 +130,7 @@ int pciehp_unconfigure_device(struct slot *p_slot)
* Ensure that no new Requests will be generated from
* the device.
*/
- if (presence) {
+ if (present) {
pci_read_config_word(dev, PCI_COMMAND, &command);
command &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
command |= PCI_COMMAND_INTX_DISABLE;
--
2.14.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/7] PCI: Improvements for native PCIe hotplug Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200 [PATCH 7/7] PCI: pciehp: Check that the device is really present before touching it Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200 [PATCH 5/7] PCI: pciehp: Fix race condition handling surprise link down Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200 [PATCH 6/7] PCI: pciehp: Do not clear Presence Detect Changed during initialization Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200 [PATCH 4/7] PCI: Distribute available resources to hotplug capable PCIe downstream ports Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200 [PATCH 1/7] PCI: Do not allocate more buses than available in parent Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-26 16:20 +0200
csiph-web