aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/virtio_blk.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index b16a887bbd02..4bc083b7c9b5 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)
723 struct request_queue *q; 723 struct request_queue *q;
724 int err, index; 724 int err, index;
725 725
726 u32 v, blk_size, sg_elems, opt_io_size; 726 u32 v, blk_size, max_size, sg_elems, opt_io_size;
727 u16 min_io_size; 727 u16 min_io_size;
728 u8 physical_block_exp, alignment_offset; 728 u8 physical_block_exp, alignment_offset;
729 729
@@ -826,14 +826,16 @@ static int virtblk_probe(struct virtio_device *vdev)
826 /* No real sector limit. */ 826 /* No real sector limit. */
827 blk_queue_max_hw_sectors(q, -1U); 827 blk_queue_max_hw_sectors(q, -1U);
828 828
829 max_size = virtio_max_dma_size(vdev);
830
829 /* Host can optionally specify maximum segment size and number of 831 /* Host can optionally specify maximum segment size and number of
830 * segments. */ 832 * segments. */
831 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX, 833 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX,
832 struct virtio_blk_config, size_max, &v); 834 struct virtio_blk_config, size_max, &v);
833 if (!err) 835 if (!err)
834 blk_queue_max_segment_size(q, v); 836 max_size = min(max_size, v);
835 else 837
836 blk_queue_max_segment_size(q, -1U); 838 blk_queue_max_segment_size(q, max_size);
837 839
838 /* Host can optionally specify the block size of the device */ 840 /* Host can optionally specify the block size of the device */
839 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE, 841 err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,