提交 e253aaf0 编写于 作者: Y Yinghai Lu 提交者: Bjorn Helgaas

PCI: Delay final fixups until resources are assigned

Commit 4f535093 "PCI: Put pci_dev in device tree as early as possible"
moved final fixups from pci_bus_add_device() to pci_device_add().  But
pci_device_add() happens before resource assignment, so BARs may not be
valid yet.

Typical flow for hot-add:

    pciehp_configure_device
      pci_scan_slot
        pci_scan_single_device
          pci_device_add
            pci_fixup_device(pci_fixup_final, dev)  # previous location
      # resource assignment happens here
      pci_bus_add_devices
        pci_bus_add_device
          pci_fixup_device(pci_fixup_final, dev)    # new location

[bhelgaas: changelog, move fixups to pci_bus_add_device()]
Reference: https://lkml.kernel.org/r/20130415182614.GB9224@xanatosReported-by: NDavid Bulkow <David.Bulkow@stratus.com>
Tested-by: NDavid Bulkow <David.Bulkow@stratus.com>
Signed-off-by: NYinghai Lu <yinghai@kernel.org>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org	# v3.9+
上级 dd72be99
...@@ -174,6 +174,7 @@ int pci_bus_add_device(struct pci_dev *dev) ...@@ -174,6 +174,7 @@ int pci_bus_add_device(struct pci_dev *dev)
* Can not put in pci_device_add yet because resources * Can not put in pci_device_add yet because resources
* are not assigned yet for some devices. * are not assigned yet for some devices.
*/ */
pci_fixup_device(pci_fixup_final, dev);
pci_create_sysfs_dev_files(dev); pci_create_sysfs_dev_files(dev);
dev->match_driver = true; dev->match_driver = true;
......
...@@ -1341,7 +1341,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) ...@@ -1341,7 +1341,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
list_add_tail(&dev->bus_list, &bus->devices); list_add_tail(&dev->bus_list, &bus->devices);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
pci_fixup_device(pci_fixup_final, dev);
ret = pcibios_add_device(dev); ret = pcibios_add_device(dev);
WARN_ON(ret < 0); WARN_ON(ret < 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册