mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 05:50:52 +07:00
virtio-blk: Consider virtio_max_dma_size() for maximum segment size
Segments can't be larger than the maximum DMA mapping size supported on the platform. Take that into account when setting the maximum segment size for a block device. 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>
This commit is contained in:
parent
e6d6dd6c87
commit
fd1068e186
@ -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, max_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);
|
||||
|
||||
max_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);
|
||||
max_size = min(max_size, v);
|
||||
|
||||
blk_queue_max_segment_size(q, max_size);
|
||||
|
||||
/* Host can optionally specify the block size of the device */
|
||||
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
|
||||
|
Loading…
Reference in New Issue
Block a user