Re: [PATCH v2 2/2] powerpc: update pci_controller.refcount for PCI devices and buses
flat view
From: Andrew Donnellan <hidden>
Date: 2016-08-10 04:50:00
On 10/08/16 10:44, Mauricio Faria de Oliveira wrote:
This patch employs the refcount in struct pci_controller to track the references from PCI devices and buses (struct pci_dev/pci_bus). In order to do that without modifying any PCI scan/probe approach (e.g., PCI_PROBE_DEVTREE and PCI_PROBE_NORMAL), it leverages some of the PCI arch-specific callback: pci_(add|release)_device() and pci_(add|remove)_bus(). (a small change is required for PCI_PROBE_DEVTREE, which makes it consistent with PCI_PROBE_NORMAL - the pci_dev should inherit the parent pci_bus's phb pointer - see pci_setup_device() in probe.c) This also has the advantage that locking for kref_(get|put)() is satisfied by the 'pci_rescan_remove_lock' mutex, which is normal practice for usage of the PCI subsystem - thus already in place. More details added in comment on pcibios_release_device(). Signed-off-by: Mauricio Faria de Oliveira <redacted>
quoted hunk ↗ jump to hunk
void pcibios_release_device(struct pci_dev *dev) { struct pci_controller *phb = pci_bus_to_host(dev->bus); + pr_debug("PCI %s, pci_dev %p, phb %p\n", dev_name(&dev->dev), dev, phb); + eeh_remove_device(dev); if (phb->controller_ops.release_device) phb->controller_ops.release_device(dev); + + if (unlikely(!phb)) + pr_warn("%s: PCI device %s has null PHB; refcount bug!", + __func__, dev_name(&dev->dev)); /* WARN_ON ahead */
This should probably go before trying to dereference phb->controller_ops above? -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited