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

From: Jason Gunthorpe <[email-masked]>
Date: Fri, 4 Aug 2023 14:03:10 -0300

On Tue, Jul 25, 2023 at 02:40:21PM -0700, Brett Creeley wrote:

> diff --git a/drivers/vfio/pci/pds/cmds.c b/drivers/vfio/pci/pds/cmds.c
> new file mode 100644
> index 000000000000..198e8e2ed002
> --- /dev/null
> +++ b/drivers/vfio/pci/pds/cmds.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2023 Advanced Micro Devices, Inc. */
> +
> +#include <linux/io.h>
> +#include <linux/types.h>
> +
> +#include <linux/pds/pds_common.h>
> +#include <linux/pds/pds_core_if.h>
> +#include <linux/pds/pds_adminq.h>
> +
> +#include "vfio_dev.h"
> +#include "cmds.h"
> +
> +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