diff options
author | Joerg Roedel <jroedel@suse.de> | 2019-02-07 12:59:16 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-03-06 11:19:15 -0500 |
commit | e6d6dd6c875eb3c9b69bb640419405726e6e0bbe (patch) | |
tree | 0392d073aef16f875c6772cdda08554d8798a45a /drivers/virtio | |
parent | 133d624b1cee16906134e92d5befb843b58bcf31 (diff) | |
download | linux-e6d6dd6c875eb3c9b69bb640419405726e6e0bbe.tar.bz2 |
virtio: Introduce virtio_max_dma_size()
This function returns the maximum segment size for a single
dma transaction of a virtio device. The possible limit comes
from the SWIOTLB implementation in the Linux kernel, that
has an upper limit of (currently) 256kb of contiguous
memory it can map. Other DMA-API implementations might also
have limits.
Use the new dma_max_mapping_size() function to determine the
maximum mapping size when DMA-API is in use for virtio.
Cc: stable@vger.kernel.org
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index a0b07c331255..18846afb39da 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -271,6 +271,17 @@ static bool vring_use_dma_api(struct virtio_device *vdev) return false; } +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); + + return max_segment_size; +} +EXPORT_SYMBOL_GPL(virtio_max_dma_size); + static void *vring_alloc_queue(struct virtio_device *vdev, size_t size, dma_addr_t *dma_handle, gfp_t flag) { |