Re: [PATCH v13 vfio 3/7] vfio/pds: register with the pds_core PF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/4/2023 3:42 PM, Jason Gunthorpe wrote:
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


On Fri, Aug 04, 2023 at 12:21:21PM -0700, Brett Creeley wrote:
+int pds_vfio_register_client_cmd(struct pds_vfio_pci_device *pds_vfio)
+{
+     struct pci_dev *pdev = pds_vfio_to_pci_dev(pds_vfio);
+     char devname[PDS_DEVNAME_LEN];
+     int ci;
+
+     snprintf(devname, sizeof(devname), "%s.%d-%u",
PDS_VFIO_LM_DEV_NAME,
+              pci_domain_nr(pdev->bus),
+              PCI_DEVID(pdev->bus->number, pdev->devfn));
+
+     ci = pds_client_register(pci_physfn(pdev), devname);
+     if (ci < 0)
+             return ci;

This is not the right way to get the drvdata of a PCI PF from a VF,
you must call pci_iov_get_pf_drvdata().

Jason

Okay, I will look at this and fix it up on the next version.

After taking another look this was intentional. I'm getting the PF pci_dev,
not the PF's drvdata.

pds_client_register() gets the drvdata from the passed PCI function,
you have to use pci_iov_get_pf_drvdata() to do this. You can't
shortcut it like this.

This is all nonsensical, the existing callers start with aa pdsc:

int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf)

Then they call

         client_id = pds_client_register(pf->pdev, devname);

Which then does

         struct pdsc *pf;
         pf = pci_get_drvdata(pf_pdev);

Just pass in the pdsc you already had

Add another wrapper to get the pdsc from a VF using
pci_iov_get_pf_drvdata() like you are supposed to.

Jason

Yeah this makes sense. Thanks for pointing this out. We will rework this in pds_core and I will add another small patch to the series that handles this. Then I can rework this patch to align. Good catch. I should have a v14 out later today with this update and other pending review comments.

Thanks for the review,

Brett



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux