s390/pci: fix zpci_bus_link_virtfn()
authorNiklas Schnelle <schnelle@linux.ibm.com>
Mon, 3 Aug 2020 07:33:29 +0000 (09:33 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 17 Aug 2020 11:17:18 +0000 (13:17 +0200)
commit3cddb79afc60bcdb5fd9dd7a1c64a8d03bdd460f
treef35d7d9c9648ca13278bcdb4ec05f63b36faaae7
parentfd78c59446b8d050ecf3e0897c5a486c7de7c595
s390/pci: fix zpci_bus_link_virtfn()

We were missing the pci_dev_put() for candidate PFs.  Furhtermore in
discussion with upstream it turns out that somewhat counterintuitively
some common code, in particular the vfio-pci driver, assumes that
pdev->is_virtfn always implies that pdev->physfn is set, i.e. that VFs
are always linked.
While POWER does seem to set pdev->is_virtfn even for unlinked functions
(see comments in arch/powerpc/kernel/eeh.c:eeh_debugfs_break_device())
for now just be safe and only set pdev->is_virtfn on linking.
Also make sure that we only search for parent PFs if the zbus is
multifunction and we thus know the devfn values supplied by firmware
come from the RID.

Fixes: e5794cf1a270 ("s390/pci: create links between PFs and VFs")
Cc: <stable@vger.kernel.org> # 5.8
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/pci/pci_bus.c