Re: [PATCH v2 1/1] vfio/pci: Remove the core dependency on driver data
From: Simon Song
Date: Fri Oct 02 2026 - 16:26:14 EST
On 9/30/2026 1:40 PM, Danilo Krummrich wrote:
> On Wed Sep 30, 2026 at 4:36 PM CEST, Simon Song wrote:
>> vfio-pci-core currently has runtime functions that interpret pci
>> driver_data as a pointer to vfio_pci_core_device, and enforce vfio
>> variant drivers must set vfio_pci_core_device to their pci driver_data.
>> This constrains variant drivers' private-data layout, including the
>> typed driver data used by the Rust PCI infrastructure.
>>
>> Added VFIO_PCI_CORE_DEFINE_CALLBACKS marcos to generate wrapper code for
>> each vfio variant driver, update vfio variant drivers to store their
>> private strctures in driver_data and use generated wrapper to pass the
>> vfio core device to helpers.
>>
>> Select the vga decode callback during vfio_pci_vga_init based on if
>> vfio_vga_disabled, the callback only use pci_dev and does not require
>> driver_data
>>
>> Assisted-by: LLM
>> Link: https://lore.kernel.org/all/DLFD2ZDSK9YQ.3A4R66G8UJMD8@xxxxxxxxxx/
>> Co-developed-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
>> Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
>> Signed-off-by: Simon Song <xinmengs@xxxxxxxxxx>
>
> I like that this moves the PM ops to static initialization. One nit below, but
> either way:
>
> Reviewed-by: Danilo Krummrich <dakr@xxxxxxxxxx>
>
>> @@ -2332,10 +2324,9 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev)
>> }
>> EXPORT_SYMBOL_GPL(vfio_pci_core_unregister_device);
>>
>> -pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,
>> +pci_ers_result_t vfio_pci_core_aer_err_detected(struct vfio_pci_core_device *vdev,
>> pci_channel_state_t state)
>
> The state argument is unused. Since this is not installed as a direct PCI
> callback anymore it technically doesn't need to retain its signature.
Thanks for the review! Agreed, I'll drop the unused state argument from vfio_pci_core_aer_err_detected() in v3.
Simon