linux_dsm_epyc7002/arch/powerpc/platforms/powernv
Greg Kurz 02c5f53949 powerpc/powernv/npu: Fix reference leak
Since 902bdc5745, get_pci_dev() calls pci_get_domain_bus_and_slot(). This
has the effect of incrementing the reference count of the PCI device, as
explained in drivers/pci/search.c:

 * Given a PCI domain, bus, and slot/function number, the desired PCI
 * device is located in the list of PCI devices. If the device is
 * found, its reference count is increased and this function returns a
 * pointer to its data structure.  The caller must decrement the
 * reference count by calling pci_dev_put().  If no device is found,
 * %NULL is returned.

Nothing was done to call pci_dev_put() and the reference count of GPU and
NPU PCI devices rockets up.

A natural way to fix this would be to teach the callers about the change,
so that they call pci_dev_put() when done with the pointer. This turns
out to be quite intrusive, as it affects many paths in npu-dma.c,
pci-ioda.c and vfio_pci_nvlink2.c. Also, the issue appeared in 4.16 and
some affected code got moved around since then: it would be problematic
to backport the fix to stable releases.

All that code never cared for reference counting anyway. Call pci_dev_put()
from get_pci_dev() to revert to the previous behavior.

Fixes: 902bdc5745 ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn")
Cc: stable@vger.kernel.org # v4.16
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-06-02 19:39:36 +10:00
..
copy-paste.h powerpc/powernv: copy/paste - Mask SO bit in CR 2018-06-04 22:58:41 +10:00
eeh-powernv.c powerpc/powernv/eeh/npu: Fix uninitialized variables in opal_pci_eeh_freeze_status 2018-12-20 22:59:03 +11:00
idle.c powerpc/powernv/idle: Restore AMR/UAMOR/AMOR/IAMR after idle 2019-04-30 22:38:56 +10:00
Kconfig PCI: consolidate PCI config entry in drivers/pci 2018-11-23 11:45:34 +09:00
Makefile powerpc/powernv: move OPAL call wrapper tracing and interrupt handling to C 2019-02-26 23:55:09 +11:00
memtrace.c mm: replace all open encodings for NUMA_NO_NODE 2019-03-05 21:07:14 -08:00
npu-dma.c powerpc/powernv/npu: Fix reference leak 2019-06-02 19:39:36 +10:00
ocxl.c ocxl: Rename pnv_ocxl_spa_remove_pe to clarify it's action 2018-06-03 20:40:32 +10:00
opal-async.c powerpc/opal: Add opal_async_wait_response_interruptible() to opal-async 2017-11-06 20:39:28 +11:00
opal-call.c powerpc/hmi: Fix kernel hang when TB is in error state. 2019-05-03 02:54:57 +10:00
opal-dump.c powerpc/powernv/opal-dump : Use IRQ_HANDLED instead of numbers in interrupt handler 2018-07-24 22:03:24 +10:00
opal-elog.c powerpc: Use octal numbers for file permissions 2018-01-22 05:48:33 +11:00
opal-flash.c powerpc/powernv: Always stop secondaries before reboot/shutdown 2018-04-03 22:59:57 +10:00
opal-hmi.c powerpc/powernv: Show checkstop reason for NPU2 HMIs 2019-06-02 19:39:36 +10:00
opal-imc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 112 2019-05-24 17:39:01 +02:00
opal-irqchip.c powerpc/powernv/opal: Use standard interrupts property when available 2018-08-08 00:32:38 +10:00
opal-kmsg.c powerpc/powernv: Implement and use opal_flush_console 2018-07-24 22:09:56 +10:00
opal-lpc.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
opal-memory-errors.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
opal-msglog.c powerpc/powernv: Make opal log only readable by root 2019-02-27 22:11:31 +11:00
opal-nvram.c powerpc/powernv: Fix NVRAM sleep in invalid context when crashing 2018-05-18 00:23:07 +10:00
opal-power.c powerpc/powernv: Move opal_power_control_init() call in opal_init(). 2018-12-21 11:32:49 +11:00
opal-powercap.c powerpc: Convert to using %pOFn instead of device_node.name 2018-10-03 15:40:01 +10:00
opal-prd.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
opal-psr.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
opal-rtc.c powerpc: use time64_t in read_persistent_clock 2018-06-03 20:43:33 +10:00
opal-sensor-groups.c powerpc: Convert to using %pOFn instead of device_node.name 2018-10-03 15:40:01 +10:00
opal-sensor.c powernv: opal-sensor: Add support to read 64bit sensor values 2018-05-21 14:48:02 +10:00
opal-sysparam.c powerpc: Convert to using %pOFn instead of device_node.name 2018-10-03 15:40:01 +10:00
opal-tracepoints.c jump_label: move 'asm goto' support test to Kconfig 2019-01-06 09:46:51 +09:00
opal-wrappers.S powerpc/powernv: move OPAL call wrapper tracing and interrupt handling to C 2019-02-26 23:55:09 +11:00
opal-xscom.c powerpc: Use sizeof(*foo) rather than sizeof(struct foo) 2018-03-20 16:47:53 +11:00
opal.c powerpc/powernv: Update firmware archaeology around OPAL_HANDLE_HMI 2019-06-02 19:39:35 +10:00
pci-cxl.c Revert "powerpc/powernv: Add support for the cxl kernel api on the real phb" 2018-07-02 23:54:32 +10:00
pci-ioda-tce.c powerpc/powernv/ioda: Fix locked_vm counting for memory used by IOMMU tables 2019-02-28 11:50:02 +11:00
pci-ioda.c powerpc/powernv/ioda2: Add __printf format/argument verification 2019-05-03 02:54:58 +10:00
pci.c powerpc/powernv/sriov: Register IOMMU groups for VFs 2019-02-19 11:51:18 +11:00
pci.h powerpc/powernv/ioda2: Add __printf format/argument verification 2019-05-03 02:54:58 +10:00
powernv.h powerpc/powernv: process all OPAL event interrupts with kopald 2018-06-03 20:40:30 +10:00
rng.c powerpc: Convert to using %pOF instead of full_name 2017-08-23 22:27:04 +10:00
setup.c powerpc/hmi: Fix kernel hang when TB is in error state. 2019-05-03 02:54:57 +10:00
smp.c powerpc/powernv: Don't reprogram SLW image on every KVM guest entry/exit 2019-02-22 00:10:15 +11:00
subcore-asm.S powerpc/powernv: Add support for POWER8 split core on powernv 2014-05-28 13:35:37 +10:00
subcore.c powerpc/64s: Reimplement book3s idle code in C 2019-04-30 22:37:48 +10:00
subcore.h powernv/powerpc: Add winkle support for offline cpus 2014-12-15 10:46:41 +11:00
vas-debug.c powerpc/powernv/vas: Use DEFINE_SHOW_ATTRIBUTE macro 2018-11-25 17:11:22 +11:00
vas-trace.h powerpc/vas: Add a couple of trace points 2018-03-14 20:13:58 +11:00
vas-window.c ppc: Convert vas ID allocation to new IDA API 2018-08-21 23:54:19 -04:00
vas.c powerpc/vas: Fix cleanup when VAS is not configured 2018-03-14 20:11:37 +11:00
vas.h powerpc: clean the inclusion of stringify.h 2018-07-30 22:48:17 +10:00