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>
Cc: Jens Axboe <axboe@kernel.dk>,
virtualization@lists.linux-foundation.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org, jfehlig@suse.com,
jon.grimm@amd.com, brijesh.singh@amd.com, hch@lst.de,
Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 3/3] virtio-blk: Consider virtio_max_dma_size() for maximum segment size
Date: Thu, 10 Jan 2019 14:44:33 +0100 [thread overview]
Message-ID: <20190110134433.15672-4-joro@8bytes.org> (raw)
In-Reply-To: <20190110134433.15672-1-joro@8bytes.org>
From: Joerg Roedel <jroedel@suse.de>
Segments can't be larger than the maximum DMA allocation
size supported by virtio on the platform. Take that into
account when setting the maximum segment size for a block
device.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/block/virtio_blk.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index b16a887bbd02..6062faa8d213 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -723,7 +723,7 @@ static int virtblk_probe(struct virtio_device *vdev)
struct request_queue *q;
int err, index;
- u32 v, blk_size, sg_elems, opt_io_size;
+ u32 v, blk_size, seg_size, sg_elems, opt_io_size;
u16 min_io_size;
u8 physical_block_exp, alignment_offset;
@@ -826,14 +826,16 @@ static int virtblk_probe(struct virtio_device *vdev)
/* No real sector limit. */
blk_queue_max_hw_sectors(q, -1U);
+ seg_size = virtio_max_dma_size(vdev);
+
/* Host can optionally specify maximum segment size and number of
* segments. */
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX,
struct virtio_blk_config, size_max, &v);
if (!err)
- blk_queue_max_segment_size(q, v);
- else
- blk_queue_max_segment_size(q, -1U);
+ seg_size = min(v, seg_size);
+
+ blk_queue_max_segment_size(q, seg_size);
/* Host can optionally specify the block size of the device */
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
--
2.17.1
next prev parent reply other threads:[~2019-01-10 13:44 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 13:44 [PATCH 0/3] Fix virtio-blk issue with SWIOTLB Joerg Roedel
2019-01-10 13:44 ` Joerg Roedel
2019-01-10 13:44 ` [PATCH 1/3] swiotlb: Export maximum allocation size Joerg Roedel
2019-01-10 13:44 ` Joerg Roedel
2019-01-10 17:02 ` Konrad Rzeszutek Wilk
2019-01-10 17:02 ` Konrad Rzeszutek Wilk
2019-01-10 17:02 ` Konrad Rzeszutek Wilk
2019-01-11 9:12 ` Joerg Roedel
2019-01-14 20:49 ` Konrad Rzeszutek Wilk
2019-01-14 20:49 ` Konrad Rzeszutek Wilk
2019-01-14 21:59 ` Michael S. Tsirkin
2019-01-15 13:05 ` Christoph Hellwig
2019-01-15 13:05 ` Christoph Hellwig
2019-01-14 21:59 ` Michael S. Tsirkin
2019-01-11 9:12 ` Joerg Roedel
2019-01-10 13:44 ` Joerg Roedel
2019-01-10 13:44 ` [PATCH 2/3] virtio: Introduce virtio_max_dma_size() Joerg Roedel
2019-01-10 13:44 ` Joerg Roedel
2019-01-10 13:44 ` [PATCH 3/3] virtio-blk: Consider virtio_max_dma_size() for maximum segment size Joerg Roedel
2019-01-10 13:44 ` Joerg Roedel [this message]
2019-01-10 13:59 ` [PATCH 0/3] Fix virtio-blk issue with SWIOTLB Christoph Hellwig
2019-01-10 14:26 ` Joerg Roedel
2019-01-10 14:26 ` Joerg Roedel
2019-01-10 13:59 ` Christoph Hellwig
2019-01-11 3:29 ` Jason Wang
2019-01-11 9:15 ` Joerg Roedel
2019-01-11 9:15 ` Joerg Roedel
2019-01-14 9:41 ` Jason Wang
2019-01-14 9:50 ` Christoph Hellwig
2019-01-14 9:50 ` Christoph Hellwig
2019-01-14 12:41 ` Jason Wang
2019-01-14 12:41 ` Jason Wang
2019-01-14 18:20 ` Michael S. Tsirkin
2019-01-14 18:20 ` Michael S. Tsirkin
2019-01-14 19:09 ` Singh, Brijesh
2019-01-14 19:12 ` Robin Murphy
2019-01-14 19:12 ` Robin Murphy
2019-01-14 20:22 ` Christoph Hellwig
2019-01-14 20:22 ` Christoph Hellwig
2019-01-14 20:29 ` Michael S. Tsirkin
2019-01-14 20:29 ` Michael S. Tsirkin
2019-01-14 20:19 ` Christoph Hellwig
2019-01-14 20:19 ` Christoph Hellwig
2019-01-14 20:48 ` Michael S. Tsirkin
2019-01-15 13:09 ` Christoph Hellwig
2019-01-15 13:09 ` Christoph Hellwig
2019-01-14 20:48 ` Michael S. Tsirkin
2019-01-15 8:37 ` Joerg Roedel
2019-01-15 13:20 ` Christoph Hellwig
2019-01-16 14:16 ` Michael S. Tsirkin
2019-01-16 14:16 ` Michael S. Tsirkin
2019-01-15 13:20 ` Christoph Hellwig
2019-01-15 8:37 ` Joerg Roedel
2019-01-14 9:41 ` Jason Wang
2019-01-11 3:29 ` Jason Wang
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=20190110134433.15672-4-joro@8bytes.org \
--to=joro@8bytes.org \
--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.