Merge branch 'pci/yinghai-revert-pci_find_bus-and-remove-cleanup' into next
* pci/yinghai-revert-pci_find_bus-and-remove-cleanup: PCI: Stop all children first, before removing all children Revert "PCI: Use hotplug-safe pci_get_domain_bus_and_slot()"
This commit is contained in:
commit
168ae6a08a
2 changed files with 45 additions and 22 deletions
|
@ -152,11 +152,15 @@ failed1:
|
||||||
static void virtfn_remove(struct pci_dev *dev, int id, int reset)
|
static void virtfn_remove(struct pci_dev *dev, int id, int reset)
|
||||||
{
|
{
|
||||||
char buf[VIRTFN_ID_LEN];
|
char buf[VIRTFN_ID_LEN];
|
||||||
|
struct pci_bus *bus;
|
||||||
struct pci_dev *virtfn;
|
struct pci_dev *virtfn;
|
||||||
struct pci_sriov *iov = dev->sriov;
|
struct pci_sriov *iov = dev->sriov;
|
||||||
|
|
||||||
virtfn = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus),
|
bus = pci_find_bus(pci_domain_nr(dev->bus), virtfn_bus(dev, id));
|
||||||
virtfn_bus(dev, id), virtfn_devfn(dev, id));
|
if (!bus)
|
||||||
|
return;
|
||||||
|
|
||||||
|
virtfn = pci_get_slot(bus, virtfn_devfn(dev, id));
|
||||||
if (!virtfn)
|
if (!virtfn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,43 @@ void pci_remove_bus(struct pci_bus *bus)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pci_remove_bus);
|
EXPORT_SYMBOL(pci_remove_bus);
|
||||||
|
|
||||||
|
static void pci_stop_bus_device(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
struct pci_bus *bus = dev->subordinate;
|
||||||
|
struct pci_dev *child, *tmp;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Stopping an SR-IOV PF device removes all the associated VFs,
|
||||||
|
* which will update the bus->devices list and confuse the
|
||||||
|
* iterator. Therefore, iterate in reverse so we remove the VFs
|
||||||
|
* first, then the PF.
|
||||||
|
*/
|
||||||
|
if (bus) {
|
||||||
|
list_for_each_entry_safe_reverse(child, tmp,
|
||||||
|
&bus->devices, bus_list)
|
||||||
|
pci_stop_bus_device(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
pci_stop_dev(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pci_remove_bus_device(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
struct pci_bus *bus = dev->subordinate;
|
||||||
|
struct pci_dev *child, *tmp;
|
||||||
|
|
||||||
|
if (bus) {
|
||||||
|
list_for_each_entry_safe(child, tmp,
|
||||||
|
&bus->devices, bus_list)
|
||||||
|
pci_remove_bus_device(child);
|
||||||
|
|
||||||
|
pci_remove_bus(bus);
|
||||||
|
dev->subordinate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pci_destroy_dev(dev);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_stop_and_remove_bus_device - remove a PCI device and any children
|
* pci_stop_and_remove_bus_device - remove a PCI device and any children
|
||||||
* @dev: the device to remove
|
* @dev: the device to remove
|
||||||
|
@ -70,25 +107,7 @@ EXPORT_SYMBOL(pci_remove_bus);
|
||||||
*/
|
*/
|
||||||
void pci_stop_and_remove_bus_device(struct pci_dev *dev)
|
void pci_stop_and_remove_bus_device(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
struct pci_bus *bus = dev->subordinate;
|
pci_stop_bus_device(dev);
|
||||||
struct pci_dev *child, *tmp;
|
pci_remove_bus_device(dev);
|
||||||
|
|
||||||
/*
|
|
||||||
* Removing an SR-IOV PF device removes all the associated VFs,
|
|
||||||
* which will update the bus->devices list and confuse the
|
|
||||||
* iterator. Therefore, iterate in reverse so we remove the VFs
|
|
||||||
* first, then the PF.
|
|
||||||
*/
|
|
||||||
if (bus) {
|
|
||||||
list_for_each_entry_safe_reverse(child, tmp,
|
|
||||||
&bus->devices, bus_list)
|
|
||||||
pci_stop_and_remove_bus_device(child);
|
|
||||||
|
|
||||||
pci_remove_bus(bus);
|
|
||||||
dev->subordinate = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_stop_dev(dev);
|
|
||||||
pci_destroy_dev(dev);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
|
EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
|
||||||
|
|
Loading…
Add table
Reference in a new issue