[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cf353f24-6c18-7d2d-b797-d81646fd3bed@amd.com>
Date: Mon, 7 Aug 2023 10:28:57 -0700
From: Brett Creeley <bcreeley@....com>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: Brett Creeley <brett.creeley@....com>, kvm@...r.kernel.org,
netdev@...r.kernel.org, alex.williamson@...hat.com, yishaih@...dia.com,
shameerali.kolothum.thodi@...wei.com, kevin.tian@...el.com,
simon.horman@...igine.com, shannon.nelson@....com
Subject: Re: [PATCH v13 vfio 3/7] vfio/pds: register with the pds_core PF
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
Powered by blists - more mailing lists