Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1a98b69 authored by Tiejun Chen's avatar Tiejun Chen Committed by Jesse Barnes
Browse files

PCI: enumerate the PCI device only removed out PCI hieratchy of OS when re-scanning PCI



When hot-plugging a root bridge, we always prevent assigning a bus number
that already exists. This makes sure we don't step over an existing bus.
But sometimes we only remove PCI device in PCI hieratchy of OS, i,e.

echo 1 > /sys/bus/pci/devices/.../remove

but actually don't hotplug this device out the platform, so in this case
we still should re-scan this bus to enumerate this device when re-scanning
PCI again.

Signed-off-by: default avatarTiejun Chen <tiejun.chen@windriver.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 0918472c
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -724,12 +724,14 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
		pci_write_config_word(dev, PCI_STATUS, 0xffff);
		pci_write_config_word(dev, PCI_STATUS, 0xffff);


		/* Prevent assigning a bus number that already exists.
		/* Prevent assigning a bus number that already exists.
		 * This can happen when a bridge is hot-plugged */
		 * This can happen when a bridge is hot-plugged, so in
		if (pci_find_bus(pci_domain_nr(bus), max+1))
		 * this case we only re-scan this bus. */
			goto out;
		child = pci_find_bus(pci_domain_nr(bus), max+1);
		if (!child) {
			child = pci_add_new_bus(bus, dev, ++max);
			child = pci_add_new_bus(bus, dev, ++max);
			if (!child)
			if (!child)
				goto out;
				goto out;
		}
		buses = (buses & 0xff000000)
		buses = (buses & 0xff000000)
		      | ((unsigned int)(child->primary)     <<  0)
		      | ((unsigned int)(child->primary)     <<  0)
		      | ((unsigned int)(child->secondary)   <<  8)
		      | ((unsigned int)(child->secondary)   <<  8)