Re: [RFC PATCH v2 5/5] vfio/pci: add the support for PCI D3cold state

From: Jason Gunthorpe
Date: Fri Mar 11 2022 - 11:39:02 EST


On Wed, Mar 09, 2022 at 10:26:42AM -0700, Alex Williamson wrote:

> > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> > index c8695baf3b54..4ac3338c8fc7 100644
> > +++ b/drivers/vfio/pci/vfio_pci.c
> > @@ -153,7 +153,6 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> > ret = vfio_pci_core_register_device(vdev);
> > if (ret)
> > goto out_free;
> > - dev_set_drvdata(&pdev->dev, vdev);
>
> Relocating the setting of drvdata should be proposed separately rather
> than buried in this patch. The driver owns drvdata, the driver is the
> only consumer of drvdata, so pushing this into the core to impose a
> standard for drvdata across all vfio-pci variants doesn't seem like a
> good idea to me.

I've been wanting to do this for another reason - there is a few
places in the core vfio-pci that converts a struct device to a
vfio_device the slow way when the drvdata is the right way to do it.

So either have the core code set it or require drivers to set it to the
vfio_pci_core_device pointer seems necessary.

But yes, it should be a seperated patch

Jason