aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index cab05f31223f..e9d4fd861ba1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3271,7 +3271,8 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
3271{ 3271{
3272 struct pci_dev *pdev; 3272 struct pci_dev *pdev;
3273 3273
3274 if (pci_is_root_bus(dev->bus) || dev->subordinate || !dev->bus->self) 3274 if (pci_is_root_bus(dev->bus) || dev->subordinate ||
3275 !dev->bus->self || dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
3275 return -ENOTTY; 3276 return -ENOTTY;
3276 3277
3277 list_for_each_entry(pdev, &dev->bus->devices, bus_list) 3278 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
@@ -3305,7 +3306,8 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
3305{ 3306{
3306 struct pci_dev *pdev; 3307 struct pci_dev *pdev;
3307 3308
3308 if (dev->subordinate || !dev->slot) 3309 if (dev->subordinate || !dev->slot ||
3310 dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
3309 return -ENOTTY; 3311 return -ENOTTY;
3310 3312
3311 list_for_each_entry(pdev, &dev->bus->devices, bus_list) 3313 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
@@ -3557,6 +3559,20 @@ int pci_try_reset_function(struct pci_dev *dev)
3557} 3559}
3558EXPORT_SYMBOL_GPL(pci_try_reset_function); 3560EXPORT_SYMBOL_GPL(pci_try_reset_function);
3559 3561
3562/* Do any devices on or below this bus prevent a bus reset? */
3563static bool pci_bus_resetable(struct pci_bus *bus)
3564{
3565 struct pci_dev *dev;
3566
3567 list_for_each_entry(dev, &bus->devices, bus_list) {
3568 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
3569 (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
3570 return false;
3571 }
3572
3573 return true;
3574}
3575
3560/* Lock devices from the top of the tree down */ 3576/* Lock devices from the top of the tree down */
3561static void pci_bus_lock(struct pci_bus *bus) 3577static void pci_bus_lock(struct pci_bus *bus)
3562{ 3578{
@@ -3607,6 +3623,22 @@ unlock:
3607 return 0; 3623 return 0;
3608} 3624}
3609 3625
3626/* Do any devices on or below this slot prevent a bus reset? */
3627static bool pci_slot_resetable(struct pci_slot *slot)
3628{
3629 struct pci_dev *dev;
3630
3631 list_for_each_entry(dev, &slot->bus->devices, bus_list) {
3632 if (!dev->slot || dev->slot != slot)
3633 continue;
3634 if (dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
3635 (dev->subordinate && !pci_bus_resetable(dev->subordinate)))
3636 return false;
3637 }
3638
3639 return true;
3640}
3641
3610/* Lock devices from the top of the tree down */ 3642/* Lock devices from the top of the tree down */
3611static void pci_slot_lock(struct pci_slot *slot) 3643static void pci_slot_lock(struct pci_slot *slot)
3612{ 3644{
@@ -3728,7 +3760,7 @@ static int pci_slot_reset(struct pci_slot *slot, int probe)
3728{ 3760{
3729 int rc; 3761 int rc;
3730 3762
3731 if (!slot) 3763 if (!slot || !pci_slot_resetable(slot))
3732 return -ENOTTY; 3764 return -ENOTTY;
3733 3765
3734 if (!probe) 3766 if (!probe)
@@ -3820,7 +3852,7 @@ EXPORT_SYMBOL_GPL(pci_try_reset_slot);
3820 3852
3821static int pci_bus_reset(struct pci_bus *bus, int probe) 3853static int pci_bus_reset(struct pci_bus *bus, int probe)
3822{ 3854{
3823 if (!bus->self) 3855 if (!bus->self || !pci_bus_resetable(bus))
3824 return -ENOTTY; 3856 return -ENOTTY;
3825 3857
3826 if (probe) 3858 if (probe)