All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: "Michael S . Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	Thomas.Lendacky@amd.com, jroedel@suse.de, brijesh.singh@amd.com,
	joro@8bytes.org, jon.grimm@amd.com, jfehlig@suse.com,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	iommu@lists.linux-foundation.org,
	virtualization@lists.linux-foundation.org
Subject: [PATCH 4/5] virtio: Introduce virtio_max_dma_size()
Date: Wed, 30 Jan 2019 17:40:06 +0100	[thread overview]
Message-ID: <20190130164007.26497-5-joro__44655.561148987$1548872733$gmane$org@8bytes.org> (raw)
In-Reply-To: <20190130164007.26497-1-joro@8bytes.org>

From: Joerg Roedel <jroedel@suse.de>

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.

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/virtio/virtio_ring.c | 11 +++++++++++
 include/linux/virtio.h       |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index cd7e755484e3..8a31c6862b2b 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -266,6 +266,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)
 {
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index fa1b5da2804e..673fe3ef3607 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -157,6 +157,8 @@ int virtio_device_freeze(struct virtio_device *dev);
 int virtio_device_restore(struct virtio_device *dev);
 #endif
 
+size_t virtio_max_dma_size(struct virtio_device *vdev);
+
 #define virtio_device_for_each_vq(vdev, vq) \
 	list_for_each_entry(vq, &vdev->vqs, list)
 
-- 
2.17.1

  parent reply	other threads:[~2019-01-30 16:40 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 16:40 [PATCH 0/5 v5] Fix virtio-blk issue with SWIOTLB Joerg Roedel
2019-01-30 16:40 ` [PATCH 1/5] swiotlb: Introduce swiotlb_max_mapping_size() Joerg Roedel
2019-01-30 16:40 ` Joerg Roedel
2019-01-30 16:40 ` [PATCH 2/5] swiotlb: Add is_swiotlb_active() function Joerg Roedel
2019-01-30 16:40 ` Joerg Roedel
2019-01-30 16:40 ` [PATCH 3/5] dma: Introduce dma_max_mapping_size() Joerg Roedel
2019-01-31 10:41   ` Christoph Hellwig
2019-01-31 10:41   ` Christoph Hellwig
2019-01-31 13:01     ` [PATCH] dma: Uninline dma_max_mapping_size() Joerg Roedel
2019-01-31 13:01       ` Joerg Roedel
2019-01-31 14:37       ` Christoph Hellwig
2019-01-31 14:43         ` Michael S. Tsirkin
2019-01-31 14:43         ` Michael S. Tsirkin
2019-01-31 16:34           ` Joerg Roedel
2019-01-31 16:34           ` Joerg Roedel
2019-01-31 14:37       ` Christoph Hellwig
2019-01-31 13:01     ` Joerg Roedel
2019-01-30 16:40 ` [PATCH 3/5] dma: Introduce dma_max_mapping_size() Joerg Roedel
2019-01-30 16:40 ` [PATCH 4/5] virtio: Introduce virtio_max_dma_size() Joerg Roedel
2019-01-30 16:40 ` Joerg Roedel [this message]
2019-01-30 16:40 ` [PATCH 5/5] virtio-blk: Consider virtio_max_dma_size() for maximum segment size Joerg Roedel
2019-01-30 16:40 ` Joerg Roedel
2019-01-30 18:11 ` [PATCH 0/5 v5] Fix virtio-blk issue with SWIOTLB Lendacky, Thomas
2019-01-30 18:11   ` Lendacky, Thomas
2019-01-30 18:11 ` Lendacky, Thomas
2019-01-30 18:35 ` Konrad Rzeszutek Wilk
2019-01-30 18:35 ` Konrad Rzeszutek Wilk
2019-01-30 21:59   ` Michael S. Tsirkin
2019-01-30 21:59   ` Michael S. Tsirkin
2019-01-30 21:59     ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2019-01-31 16:33 [PATCH 0/5 v6] " Joerg Roedel
2019-01-31 16:34 ` [PATCH 4/5] virtio: Introduce virtio_max_dma_size() Joerg Roedel
2019-01-31 16:34 ` Joerg Roedel
2019-01-29  8:43 [PATCH 0/5 v4] Fix virtio-blk issue with SWIOTLB Joerg Roedel
2019-01-29  8:43 ` [PATCH 4/5] virtio: Introduce virtio_max_dma_size() Joerg Roedel
2019-01-29  8:43 ` Joerg Roedel
2019-01-29 17:13   ` Christoph Hellwig
2019-01-29 17:13   ` Christoph Hellwig
2019-01-30 15:10   ` Lendacky, Thomas
2019-01-30 15:10   ` Lendacky, Thomas
2019-01-30 15:10     ` Lendacky, Thomas
2019-01-30 15:49     ` Joerg Roedel
2019-01-30 15:49     ` Joerg Roedel
2019-01-30 15:49       ` Joerg Roedel
2019-01-23 16:30 [PATCH 0/5 v3] Fix virtio-blk issue with SWIOTLB Joerg Roedel
2019-01-23 16:30 ` [PATCH 4/5] virtio: Introduce virtio_max_dma_size() Joerg Roedel
2019-01-23 16:30 ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20190130164007.26497-5-joro__44655.561148987$1548872733$gmane$org@8bytes.org' \
    --to=joro@8bytes.org \
    --cc=Thomas.Lendacky@amd.com \
    --cc=axboe@kernel.dk \
    --cc=brijesh.singh@amd.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jasowang@redhat.com \
    --cc=jfehlig@suse.com \
    --cc=jon.grimm@amd.com \
    --cc=jroedel@suse.de \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.