All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_vring: Fix maximum DMA mapping size computation
@ 2021-12-03 12:16 ` Suzuki K Poulose
  0 siblings, 0 replies; 6+ messages in thread
From: Suzuki K Poulose @ 2021-12-03 12:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arm-kernel, will, maz, jasowang, virtualization,
	Suzuki K Poulose, Joerg Roedel, Konrad Rzeszutek Wilk,
	Christoph Hellwig, Michael S . Tsirkin, Robin Murphy,
	Steven Price

The virtio vring is a bit messy about the DMA allocations. We
use the parent device for any DMA alloc/free. However, we use the
child device for calculating the maximum size mapped by the DMA API
for the device. This leads to issues where the max size is set to
SIZE_MAX, and if the virtio device (e.g, virtio-blk) is bound to
swiotlb (e.g., via restricted-dma pool), we end up trying to allocate
larger chunks of memory, which are never satisfied by the swiotlb and
eventually fails.

Fix this by using the parent device (just like all the other
DMA API calls) for the max mapping size.

Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max_dma_size()")
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/virtio/virtio_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 6d2614e34470..028b05d44546 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -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;
 }
-- 
2.25.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-03 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-03 12:16 [PATCH] virtio_vring: Fix maximum DMA mapping size computation Suzuki K Poulose
2021-12-03 12:16 ` Suzuki K Poulose
2021-12-03 12:26 ` Marc Zyngier
2021-12-03 12:26   ` Marc Zyngier
2021-12-03 14:32   ` Suzuki K Poulose
2021-12-03 14:32     ` Suzuki K Poulose

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.