]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/powernv/ioda: Fix ref count for devices with their own PE
authorFrederic Barrat <fbarrat@linux.ibm.com>
Thu, 21 Nov 2019 13:49:08 +0000 (14:49 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 23 Jan 2020 10:31:16 +0000 (21:31 +1100)
commit702e51ba65b65fa622d351e88ebc69fde5762c4e
treec2574700157172f9e6108c99bc8c24ac1d3b2c56
parent2784f73aa2a9bccaeeec3ed5aac72387ba239516
powerpc/powernv/ioda: Fix ref count for devices with their own PE

The pci_dn structure used to store a pointer to the struct pci_dev, so
taking a reference on the device was required. However, the pci_dev
pointer was later removed from the pci_dn structure, but the reference
was kept for the npu device.
See commit 3d399754c1ca ("powerpc/powernv/idoa: Remove unnecessary
pcidev from pci_dn").

We don't need to take a reference on the device when assigning the PE
as the struct pnv_ioda_pe is cleaned up at the same time as
the (physical) device is released. Doing so prevents the device from
being released, which is a problem for opencapi devices, since we want
to be able to remove them through PCI hotplug.

Now the ugly part: nvlink npu devices are not meant to be
released. Because of the above, we've always leaked a reference and
simply removing it now is dangerous and would likely require more
work. There's currently no release device callback for nvlink devices
for example. So to be safe, this patch leaks a reference on the npu
device, but only for nvlink and not opencapi.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20191121134918.7155-2-fbarrat@linux.ibm.com
arch/powerpc/platforms/powernv/pci-ioda.c