On Tue, Jul 14, 2026 at 10:59:13AM +0800, weimin xiong wrote:
> From: Xiong Weimin <[email protected]>
> 
> The event virtqueue callback retrieves the driver state through
> vq->vdev->priv. viommu_probe() currently initializes that pointer only
> after virtio_device_ready() and after the event queue is populated.
> 
> Store the driver data before creating the virtqueues so callbacks always
> see initialized driver state once the device is made ready. Clear the
> pointer again on probe failure.
> 
> Signed-off-by: Xiong Weimin <[email protected]>
> ---
>  drivers/iommu/virtio-iommu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
> index 9118377d7..4c91a82d2 100644
> --- a/drivers/iommu/virtio-iommu.c
> +++ b/drivers/iommu/virtio-iommu.c
> @@ -1173,11 +1173,12 @@ static int viommu_probe(struct virtio_device *vdev)
>       ida_init(&viommu->domain_ids);
>       viommu->dev = dev;
>       viommu->vdev = vdev;
> +     vdev->priv = viommu;
>       INIT_LIST_HEAD(&viommu->requests);
>  
>       ret = viommu_init_vqs(viommu);
>       if (ret)
> -             return ret;
> +             goto err_clear_priv;

I guess it would make sense to pass the 'vdev' instead of the 'viommu'
pointer to viommu_init_vqs(), now that you have linked them together.

Will

Reply via email to