Re: [PATCH] drm/virtio: Pass correct device to dma_sync_sgtable_for_device()

From: Dmitry Osipenko
Date: Sun Feb 26 2023 - 18:50:44 EST


On 2/25/23 17:55, Dmitry Osipenko wrote:
> On 2/24/23 18:34, Oleksandr Tyshchenko wrote:
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>>
>> The "vdev->dev.parent" should be used instead of "vdev->dev" as a device
>> for which to perform the DMA operation in both
>> virtio_gpu_cmd_transfer_to_host_2d(3d).
>>
>> Because the virtio-gpu device "vdev->dev" doesn't really have DMA OPS
>> assigned to it, but parent (virtio-pci or virtio-mmio) device
>> "vdev->dev.parent" has. The more, the sgtable in question the code is
>> trying to sync here was mapped for the parent device (by using its DMA OPS)
>> previously at:
>> virtio_gpu_object_shmem_init()->drm_gem_shmem_get_pages_sgt()->
>> dma_map_sgtable(), so should be synced here for the same parent device.
>>
>> Fixes: b5c9ed70d1a9 ("drm/virtio: Improve DMA API usage for shmem BOs")
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>> ---
...
> Indeed, it's only the vgpu drm device that was moved to use the pci
> parent device. On x86 the vdev always has dma-ops, also
> virtio_has_dma_quirk=true for modern Qemu. So I didn't test this code
> path and apparently it's only testable on Xen, which is good to know.
>
> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>

Applied to misc-fixes

--
Best regards,
Dmitry