]> Git Repo - J-linux.git/commitdiff
virtio_ring: Fix querying of maximum DMA mapping size for virtio device
authorWill Deacon <[email protected]>
Wed, 1 Dec 2021 11:20:18 +0000 (11:20 +0000)
committerMichael S. Tsirkin <[email protected]>
Wed, 8 Dec 2021 20:04:06 +0000 (15:04 -0500)
virtio_max_dma_size() returns the maximum DMA mapping size of the virtio
device by querying dma_max_mapping_size() for the device when the DMA
API is in use for the vring. Unfortunately, the device passed is
initialised by register_virtio_device() and does not inherit the DMA
configuration from its parent, resulting in SWIOTLB errors when bouncing
is enabled and the default 256K mapping limit (IO_TLB_SEGSIZE) is not
respected:

  | virtio-pci 0000:00:01.0: swiotlb buffer is full (sz: 294912 bytes), total 1024 (slots), used 725 (slots)

Follow the pattern used elsewhere in the virtio_ring code when calling
into the DMA layer and pass the parent device to dma_max_mapping_size()
instead.

Cc: Marc Zyngier <[email protected]>
Cc: Quentin Perret <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Jason Wang <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Acked-by: Jason Wang <[email protected]>
Tested-by: Suzuki K Poulose <[email protected]>
Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max_dma_size()")
Cc: Joerg Roedel <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Robin Murphy <[email protected]>
Signed-off-by: Steven Price <[email protected]>
Signed-off-by: Suzuki K Poulose <[email protected]>
Cc: [email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
drivers/virtio/virtio_ring.c

index 6d2614e34470f463bb553e7e9e80f7bb0a0cef4a..028b05d4454604d5aee636895f8fcfee77a2b46a 100644 (file)
@@ -268,7 +268,7 @@ size_t virtio_max_dma_size(struct virtio_device *vdev)
        size_t max_segment_size = SIZE_MAX;
 
        if (vring_use_dma_api(vdev))
-               max_segment_size = dma_max_mapping_size(&vdev->dev);
+               max_segment_size = dma_max_mapping_size(vdev->dev.parent);
 
        return max_segment_size;
 }
This page took 0.059212 seconds and 4 git commands to generate.