aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_core.c
diff options
context:
space:
mode:
authorRajat Jain <rajatxjain@gmail.com>2014-02-04 21:31:11 -0500
committerBjorn Helgaas <bhelgaas@google.com>2014-02-11 18:13:16 -0500
commit50b52fdee050745935d92e7026373edea2647e60 (patch)
tree0739f5a0135b070c7626542ffd593074341d950b /drivers/pci/hotplug/pciehp_core.c
parentc4f2f5e4981073a5aa0739f93b6733060cd37648 (diff)
PCI: pciehp: Add hotplug_lock to serialize hotplug events
Today it is there is no protection around pciehp_enable_slot() and pciehp_disable_slot() to ensure that they complete before another hot-plug operation can be done on that particular slot. This patch introduces the slot->hotplug_lock to ensure that any hotplug operations (add / remove) complete before another hotplug event can begin processing on that particular slot. Signed-off-by: Rajat Jain <rajatxjain@gmail.com> Signed-off-by: Rajat Jain <rajatjain@juniper.net> Signed-off-by: Guenter Roeck <groeck@juniper.net> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug/pciehp_core.c')
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 53b58debc288..23b4bde8aad3 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -283,8 +283,11 @@ static int pciehp_probe(struct pcie_device *dev)
283 slot = ctrl->slot; 283 slot = ctrl->slot;
284 pciehp_get_adapter_status(slot, &occupied); 284 pciehp_get_adapter_status(slot, &occupied);
285 pciehp_get_power_status(slot, &poweron); 285 pciehp_get_power_status(slot, &poweron);
286 if (occupied && pciehp_force) 286 if (occupied && pciehp_force) {
287 mutex_lock(&slot->hotplug_lock);
287 pciehp_enable_slot(slot); 288 pciehp_enable_slot(slot);
289 mutex_unlock(&slot->hotplug_lock);
290 }
288 /* If empty slot's power status is on, turn power off */ 291 /* If empty slot's power status is on, turn power off */
289 if (!occupied && poweron && POWER_CTRL(ctrl)) 292 if (!occupied && poweron && POWER_CTRL(ctrl))
290 pciehp_power_off_slot(slot); 293 pciehp_power_off_slot(slot);
@@ -328,10 +331,12 @@ static int pciehp_resume (struct pcie_device *dev)
328 331
329 /* Check if slot is occupied */ 332 /* Check if slot is occupied */
330 pciehp_get_adapter_status(slot, &status); 333 pciehp_get_adapter_status(slot, &status);
334 mutex_lock(&slot->hotplug_lock);
331 if (status) 335 if (status)
332 pciehp_enable_slot(slot); 336 pciehp_enable_slot(slot);
333 else 337 else
334 pciehp_disable_slot(slot); 338 pciehp_disable_slot(slot);
339 mutex_unlock(&slot->hotplug_lock);
335 return 0; 340 return 0;
336} 341}
337#endif /* PM */ 342#endif /* PM */