lkml.org 
[lkml]   [2022]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] pci: fix device presence detection for VFs
On Wed, Oct 26, 2022 at 02:11:21AM -0400, Michael S. Tsirkin wrote:
> 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.

VFs are only present when the PF is present *and* the PF has VF Enable
set. Do you care about the possibility that VF Enable has been
cleared?

> 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
>

\
 
 \ /
  Last update: 2022-11-08 15:54    [W:0.113 / U:2.812 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site