]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
PCI: Don't acquire ref on parent in pci_bridge_d3_update()
authorLukas Wunner <lukas@wunner.de>
Fri, 28 Oct 2016 08:52:06 +0000 (10:52 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 18 Nov 2016 00:43:49 +0000 (18:43 -0600)
commit738a7edbfc7b623e276686dead046c9f3aae6b2e
treee3abc850064b58a1c32682189ec34be25b8deefc
parentccdb6be9ec6580ef69f68949ebe26e0fb58a6fb0
PCI: Don't acquire ref on parent in pci_bridge_d3_update()

This function is always called with an existing pci_dev struct, which
holds a reference on the pci_bus struct it resides on, which in turn
holds a reference on pci_bus->bridge, which is the pci_dev's parent.

Hence there's no need to acquire an additional ref on the parent.

More specifically, the pci_dev exists until pci_destroy_dev() drops the
final reference on it, so all calls to pci_bridge_d3_update() must be
finished before that.  It is arguably the caller's responsibility to ensure
that it doesn't call pci_bridge_d3_update() with a pci_dev that might
suddenly disappear, but in any case the existing callers are all safe:

- The call in pci_destroy_dev() happens before the call to put_device().
- The call in pci_bus_add_device() is synchronized with pci_destroy_dev()
  using pci_lock_rescan_remove().
- The calls to pci_d3cold_disable() from the xhci and nouveau drivers
  are safe because a ref on the pci_dev is held as long as it's bound to
  a driver.
- The calls to pci_d3cold_enable() / pci_d3cold_disable() when modifying
  the sysfs "d3cold_allowed" entry are also safe because kernfs_drain()
  waits for existing sysfs users to finish before removing the entry,
  and pci_destroy_dev() is called way after that.

No functional change intended.

Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/pci/pci.c