linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] pci: fix device presence detection for VFs
@ 2022-10-26  6:11 Michael S. Tsirkin
  2022-10-26 13:46 ` Wei Gong
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Michael S. Tsirkin @ 2022-10-26  6:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wei Gong, Bjorn Helgaas, linux-pci

virtio uses the same driver for VFs and PFs.  Accordingly,
pci_device_is_present is used to detect device presence. This function
isn't currently working properly for VFs since it attempts reading
device and vendor ID. As VFs are present if and only if PF is present,
just return the value for that device.

Reported-by: Wei Gong <gongwei833x@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Wei Gong, thanks for your testing of the RFC!
As I made a small change, would appreciate re-testing.

Thanks!

changes from RFC:
	use pci_physfn() wrapper to make the code build without PCI_IOV


 drivers/pci/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 2127aba3550b..899b3f52e84e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6445,8 +6445,13 @@ bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2)
 
 bool pci_device_is_present(struct pci_dev *pdev)
 {
+	struct pci_dev *physfn = pci_physfn(pdev);
 	u32 v;
 
+	/* Not a PF? Switch to the PF. */
+	if (physfn != pdev)
+		return pci_device_is_present(physfn);
+
 	if (pci_dev_is_disconnected(pdev))
 		return false;
 	return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
-- 
MST


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-12-19  8:22 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  6:11 [PATCH v2] pci: fix device presence detection for VFs Michael S. Tsirkin
2022-10-26 13:46 ` Wei Gong
2022-11-08  4:52 ` Wei Gong
2022-11-08  4:58   ` Michael S. Tsirkin
2022-11-08  5:06     ` Bjorn Helgaas
2022-11-10 19:35   ` Bjorn Helgaas
2022-11-10 20:15     ` Michael S. Tsirkin
2022-11-11 23:42       ` Bjorn Helgaas
2022-11-13  8:46         ` Michael S. Tsirkin
2022-11-15 16:24           ` Bjorn Helgaas
2022-11-16 11:16           ` Lukas Wunner
2022-11-17  5:36             ` Parav Pandit
2022-12-19  5:56               ` Michael S. Tsirkin
2022-12-19  8:22                 ` Lukas Wunner
2022-11-11  4:00     ` Wei Gong
2022-11-08 14:53 ` Bjorn Helgaas
2022-11-08 15:02   ` Bjorn Helgaas
2022-11-08 15:19     ` Michael S. Tsirkin
2022-11-08 17:58       ` Bjorn Helgaas
2022-11-08 18:02         ` Michael S. Tsirkin
2022-11-09  4:36           ` Wei Gong
2022-11-09  5:12             ` Bjorn Helgaas
2022-11-09  7:00               ` Wei Gong
2022-11-09  7:10               ` Michael S. Tsirkin
2022-11-09 17:30                 ` Bjorn Helgaas
2022-11-09 17:49                   ` Michael S. Tsirkin
2022-11-11 23:39 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).