> -----Original Message----- > From: Alex Williamson <[email protected]> > Sent: Tuesday, September 22, 2026 7:45 AM > To: Manish Honap <[email protected]> > Cc: [email protected]; Ankit Agrawal <[email protected]>; [email protected]; > [email protected]; [email protected]; Srirangan > Madhavan <[email protected]>; [email protected]; > [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; [email protected]; Yishai > Hadas <[email protected]>; Shameer Kolothum Thodi > <[email protected]>; [email protected]; [email protected]; > [email protected]; [email protected]; [email protected]; Neo Jia > <[email protected]>; Krishnakant Jaju <[email protected]>; Vikram Sethi > <[email protected]>; Zhi Wang <[email protected]>; linux- > [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; linux- > [email protected]; [email protected]; > [email protected]; Simon Song (SW-GPU) <[email protected]> > Subject: Re: [PATCH v5 13/27] vfio/pci: Bracket PCI resets with the CXL reset > hooks > > External email: Use caution opening links or attachments > > > On Thu, 17 Sep 2026 00:05:26 +0530 > <[email protected]> wrote: > > > From: Manish Honap <[email protected]> > > > > A CXL Type-2 device must quiesce its coherent link before any reset > > and restore its HDM decoder state afterward, or a reset can leave the > > device mastering the bus over decoders that are no longer valid. This > > has to happen around every reset the PCI core drives for the device, > > not only the ones VFIO issues directly. > > > > Add reset_prepare and reset_done to the CXL ops and register the > > matching pci_error_handlers callbacks. > > > > Assisted-by: LLM > > Signed-off-by: Manish Honap <[email protected]> > > --- > > drivers/vfio/pci/vfio_pci_core.c | 18 ++++++++++++++++++ > > include/linux/vfio_pci_core.h | 2 ++ > > 2 files changed, 20 insertions(+) > > > > diff --git a/drivers/vfio/pci/vfio_pci_core.c > > b/drivers/vfio/pci/vfio_pci_core.c > > index 2f593b2721a1..a91e07181847 100644 > > --- a/drivers/vfio/pci/vfio_pci_core.c > > +++ b/drivers/vfio/pci/vfio_pci_core.c > > @@ -2794,8 +2794,26 @@ int vfio_pci_core_sriov_configure(struct > > vfio_pci_core_device *vdev, } > > EXPORT_SYMBOL_GPL(vfio_pci_core_sriov_configure); > > > > +static void vfio_pci_core_reset_prepare(struct pci_dev *pdev) { > > + struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); > > + > > + if (vdev->cxl_ops) > > + vdev->cxl_ops->reset_prepare(vdev); > > +} > > + > > +static void vfio_pci_core_reset_done(struct pci_dev *pdev) { > > + struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); > > + > > + if (vdev->cxl_ops) > > + vdev->cxl_ops->reset_done(vdev); } > > Flagging this because it's introducing one more vfio-pci-core use of the > convention of storing the vfio_pci_core_device in drvdata that's a barrier > for a > Rust-based variant driver. Likely this needs to be added to the per-variant > boilerplate or macro so variants provide the vfio_pci_core_device pointer > rather than expecting it in drvdata. > Thanks, > > Alex Understood. In v6 the hooks will take the device: vfio_pci_core_reset_prepare() and vfio_pci_core_reset_done() are exported with a struct vfio_pci_core_device argument, and vfio-pci calls them from its own pci_error_handlers in vfio_pci.c, which already owns the drvdata. vfio-pci-core will not add dev_get_drvdata() call, and a variant that binds CXL devices will call the same two above mentioned helpers from its own handlers. I am leaving vfio_pci_core_aer_err_detected() as it is in this series. > > > + > > const struct pci_error_handlers vfio_pci_core_err_handlers = { > > .error_detected = vfio_pci_core_aer_err_detected, > > + .reset_prepare = vfio_pci_core_reset_prepare, > > + .reset_done = vfio_pci_core_reset_done, > > }; > > EXPORT_SYMBOL_GPL(vfio_pci_core_err_handlers); > > > > diff --git a/include/linux/vfio_pci_core.h > > b/include/linux/vfio_pci_core.h index 643f32c2141f..6ebf9a26275e > > 100644 > > --- a/include/linux/vfio_pci_core.h > > +++ b/include/linux/vfio_pci_core.h > > @@ -72,6 +72,8 @@ struct vfio_cxl_ops { > > void (*release)(struct vfio_pci_core_device *vdev); > > int (*open_device)(struct vfio_pci_core_device *vdev); > > void (*close_device)(struct vfio_pci_core_device *vdev); > > + void (*reset_prepare)(struct vfio_pci_core_device *vdev); > > + void (*reset_done)(struct vfio_pci_core_device *vdev); > > /* Pinned per bound CXL device so vfio-cxl cannot unload under usage > > */ > > struct module *owner; > > };

