PCI: acpiphp: Protect acpiphp data structures from concurrent updates
authorJiang Liu <liuj97@gmail.com>
Fri, 12 Apr 2013 05:44:28 +0000 (05:44 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 16 Apr 2013 16:27:14 +0000 (10:27 -0600)
commit3d54a3160fb6ba877324ffffa5d301dec8038fd9
tree03589d2bc780b2a410336fb5b47cb1af94f8b340
parentad41dd9dd0c8ca1876f30b62c5c79625ffe83174
PCI: acpiphp: Protect acpiphp data structures from concurrent updates

Now acpiphp_enumerate_slots() and acpiphp_remove_slots() may be invoked
concurrently by the PCI core, so add a bridge_mutex and reference count
mechanism to protect acpiphp bridge/slot/function data structures.

To avoid deadlock, handle_hotplug_event_bridge() will requeue the
hotplug event onto the kacpi_hotplug_wq by calling alloc_acpi_hp_work().
But the workaround has introduced a minor race window because the
'bridge' passed to _handle_hotplug_event_bridge() may have already been
destroyed when _handle_hotplug_event_bridge() is actually executed by
the kacpi_hotplug_wq.  So hold a reference count on the passed 'bridge'.
Fix the same issue for handle_hotplug_event_func() too.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Yinghai Lu <yinghai@kernel.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
drivers/pci/hotplug/acpiphp.h
drivers/pci/hotplug/acpiphp_glue.c