From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: [PATCH RFC] pci: fix device presence detection for VFs
Date: Mon, 10 Oct 2022 13:12:15 -0400 [thread overview]
Message-ID: <20221009191835.4036-1-mst@redhat.com> (raw)
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. Result is device marked broken incorrectly. As
VFs are present if and only if PF is present, just return the value for
that device.
Reported-by: gongwei <gongwei833x@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Warning - compile tested only. gongwei could you help test and report
please?
drivers/pci/pci.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 95bc329e74c0..ba29b8e2f3c1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6462,6 +6462,9 @@ bool pci_device_is_present(struct pci_dev *pdev)
{
u32 v;
+ if (pdev->is_virtfn)
+ return pci_device_is_present(pdev->physfn);
+
if (pci_dev_is_disconnected(pdev))
return false;
return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
--
MST
next reply other threads:[~2022-10-10 17:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 17:12 Michael S. Tsirkin [this message]
2022-10-11 21:01 ` [PATCH RFC] pci: fix device presence detection for VFs Michael S. Tsirkin
2022-10-14 11:31 ` Wei Gong
2022-10-26 3:39 ` Wei Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221009191835.4036-1-mst@redhat.com \
--to=mst@redhat.com \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).