Source
5051
5051
&slot->bus->devices, bus_list) {
5052
5052
if (!dev->slot || dev->slot != slot)
5053
5053
continue;
5054
5054
if (dev->subordinate)
5055
5055
pci_bus_unlock(dev->subordinate);
5056
5056
pci_dev_unlock(dev);
5057
5057
}
5058
5058
return 0;
5059
5059
}
5060
5060
5061
-
/* Save and disable devices from the top of the tree down */
5062
-
static void pci_bus_save_and_disable(struct pci_bus *bus)
5061
+
/*
5062
+
* Save and disable devices from the top of the tree down while holding
5063
+
* the @dev mutex lock for the entire tree.
5064
+
*/
5065
+
static void pci_bus_save_and_disable_locked(struct pci_bus *bus)
5063
5066
{
5064
5067
struct pci_dev *dev;
5065
5068
5066
5069
list_for_each_entry(dev, &bus->devices, bus_list) {
5067
-
pci_dev_lock(dev);
5068
5070
pci_dev_save_and_disable(dev);
5069
-
pci_dev_unlock(dev);
5070
5071
if (dev->subordinate)
5071
-
pci_bus_save_and_disable(dev->subordinate);
5072
+
pci_bus_save_and_disable_locked(dev->subordinate);
5072
5073
}
5073
5074
}
5074
5075
5075
5076
/*
5076
-
* Restore devices from top of the tree down - parent bridges need to be
5077
-
* restored before we can get to subordinate devices.
5077
+
* Restore devices from top of the tree down while holding @dev mutex lock
5078
+
* for the entire tree. Parent bridges need to be restored before we can
5079
+
* get to subordinate devices.
5078
5080
*/
5079
-
static void pci_bus_restore(struct pci_bus *bus)
5081
+
static void pci_bus_restore_locked(struct pci_bus *bus)
5080
5082
{
5081
5083
struct pci_dev *dev;
5082
5084
5083
5085
list_for_each_entry(dev, &bus->devices, bus_list) {
5084
-
pci_dev_lock(dev);
5085
5086
pci_dev_restore(dev);
5086
-
pci_dev_unlock(dev);
5087
5087
if (dev->subordinate)
5088
-
pci_bus_restore(dev->subordinate);
5088
+
pci_bus_restore_locked(dev->subordinate);
5089
5089
}
5090
5090
}
5091
5091
5092
-
/* Save and disable devices from the top of the tree down */
5093
-
static void pci_slot_save_and_disable(struct pci_slot *slot)
5092
+
/*
5093
+
* Save and disable devices from the top of the tree down while holding
5094
+
* the @dev mutex lock for the entire tree.
5095
+
*/
5096
+
static void pci_slot_save_and_disable_locked(struct pci_slot *slot)
5094
5097
{
5095
5098
struct pci_dev *dev;
5096
5099
5097
5100
list_for_each_entry(dev, &slot->bus->devices, bus_list) {
5098
5101
if (!dev->slot || dev->slot != slot)
5099
5102
continue;
5100
5103
pci_dev_save_and_disable(dev);
5101
5104
if (dev->subordinate)
5102
-
pci_bus_save_and_disable(dev->subordinate);
5105
+
pci_bus_save_and_disable_locked(dev->subordinate);
5103
5106
}
5104
5107
}
5105
5108
5106
5109
/*
5107
-
* Restore devices from top of the tree down - parent bridges need to be
5108
-
* restored before we can get to subordinate devices.
5110
+
* Restore devices from top of the tree down while holding @dev mutex lock
5111
+
* for the entire tree. Parent bridges need to be restored before we can
5112
+
* get to subordinate devices.
5109
5113
*/
5110
-
static void pci_slot_restore(struct pci_slot *slot)
5114
+
static void pci_slot_restore_locked(struct pci_slot *slot)
5111
5115
{
5112
5116
struct pci_dev *dev;
5113
5117
5114
5118
list_for_each_entry(dev, &slot->bus->devices, bus_list) {
5115
5119
if (!dev->slot || dev->slot != slot)
5116
5120
continue;
5117
-
pci_dev_lock(dev);
5118
5121
pci_dev_restore(dev);
5119
-
pci_dev_unlock(dev);
5120
5122
if (dev->subordinate)
5121
-
pci_bus_restore(dev->subordinate);
5123
+
pci_bus_restore_locked(dev->subordinate);
5122
5124
}
5123
5125
}
5124
5126
5125
5127
static int pci_slot_reset(struct pci_slot *slot, int probe)
5126
5128
{
5127
5129
int rc;
5128
5130
5129
5131
if (!slot || !pci_slot_resetable(slot))
5130
5132
return -ENOTTY;
5131
5133
5170
5172
* Same as above except return -EAGAIN if the slot cannot be locked
5171
5173
*/
5172
5174
static int __pci_reset_slot(struct pci_slot *slot)
5173
5175
{
5174
5176
int rc;
5175
5177
5176
5178
rc = pci_slot_reset(slot, 1);
5177
5179
if (rc)
5178
5180
return rc;
5179
5181
5180
-
pci_slot_save_and_disable(slot);
5181
-
5182
5182
if (pci_slot_trylock(slot)) {
5183
+
pci_slot_save_and_disable_locked(slot);
5183
5184
might_sleep();
5184
5185
rc = pci_reset_hotplug_slot(slot->hotplug, 0);
5186
+
pci_slot_restore_locked(slot);
5185
5187
pci_slot_unlock(slot);
5186
5188
} else
5187
5189
rc = -EAGAIN;
5188
5190
5189
-
pci_slot_restore(slot);
5190
-
5191
5191
return rc;
5192
5192
}
5193
5193
5194
5194
static int pci_bus_reset(struct pci_bus *bus, int probe)
5195
5195
{
5196
5196
int ret;
5197
5197
5198
5198
if (!bus->self || !pci_bus_resetable(bus))
5199
5199
return -ENOTTY;
5200
5200
5266
5266
* Same as above except return -EAGAIN if the bus cannot be locked
5267
5267
*/
5268
5268
static int __pci_reset_bus(struct pci_bus *bus)
5269
5269
{
5270
5270
int rc;
5271
5271
5272
5272
rc = pci_bus_reset(bus, 1);
5273
5273
if (rc)
5274
5274
return rc;
5275
5275
5276
-
pci_bus_save_and_disable(bus);
5277
-
5278
5276
if (pci_bus_trylock(bus)) {
5277
+
pci_bus_save_and_disable_locked(bus);
5279
5278
might_sleep();
5280
5279
rc = pci_bridge_secondary_bus_reset(bus->self);
5280
+
pci_bus_restore_locked(bus);
5281
5281
pci_bus_unlock(bus);
5282
5282
} else
5283
5283
rc = -EAGAIN;
5284
5284
5285
-
pci_bus_restore(bus);
5286
-
5287
5285
return rc;
5288
5286
}
5289
5287
5290
5288
/**
5291
5289
* pci_reset_bus - Try to reset a PCI bus
5292
5290
* @pdev: top level PCI device to reset via slot/bus
5293
5291
*
5294
5292
* Same as above except return -EAGAIN if the bus cannot be locked
5295
5293
*/
5296
5294
int pci_reset_bus(struct pci_dev *pdev)