Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp959879imu; Wed, 23 Jan 2019 08:32:39 -0800 (PST) X-Google-Smtp-Source: ALg8bN7gjV7fnUm6mGUQEqWscEBk3n37sHrh8Ybh0jbwE5njRiEvXDLo8TspTbsCtduvUbYaSxKw X-Received: by 2002:a63:7d06:: with SMTP id y6mr2509114pgc.171.1548261159008; Wed, 23 Jan 2019 08:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548261158; cv=none; d=google.com; s=arc-20160816; b=pwQfsPe/hPbNuioda4DXEnQXbdparVF8j7ds0IC91fKw51fotqvycD/kKUg0vf3U0D i2r/z3GzkVrwEj+8M51Usb3YU+HD2pTpOfuw36o1FSwdM8baMrp9xbLFGz/FGHiWEtMX 9gMWNVaV3gpjxZ/+0IcakaZ+Uq8uazR0yPAanJAIVOpAQA4U/pNFWkUWEl7ytM1TXPym 7vK+rCat/GqLl1/pELEWomqVaTB2KlrwEhqG+jWqu9Qk9pCQ8rKiTCooQmvipEbo3JEl Oo46A8BrbuGCAvz8JoLEXbfv1UfL7Fc0BGWklwZ/YNU2VTwZc32SBg9C/w/My8wRZCh+ ob8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=/JwKH45Afs2OJCURcZc8kdiml/lpUkiMSVJuekTAHUk=; b=j5rF8gtQG79PKgRTxiOOqLlLsO9MFnwgKzvfWKv7A1ssA8wM4mvYcOVZiwnYchbHsX duVubomIswMXuYGE0HftJNf7QyJkBNlf1daOi6jbMlNnIZdvEGHk1ljwNREih7L3eYwD YS02gtlFF3WNeAHMoruDMe7+9Vm31XAzMV26kF+2W5bRbsoCz1VF9frBnb9ViPshMOmJ Sg9ON5LMf2zc+EDZN37LSs9vUgAaHHthVqigoTLjdiiNL7EpMsaxDLC4mkoyiMhwVVxX vE7MSD5LkyKS4yZUorzl8Ks09QVzCUEdaIEnRMtHROcWnemT1ZuF1IJxz+Gw0tJUlGX0 l4EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si19242711plm.431.2019.01.23.08.32.22; Wed, 23 Jan 2019 08:32:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726790AbfAWQa6 (ORCPT + 99 others); Wed, 23 Jan 2019 11:30:58 -0500 Received: from 8bytes.org ([81.169.241.247]:59262 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726398AbfAWQay (ORCPT ); Wed, 23 Jan 2019 11:30:54 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id F317946A; Wed, 23 Jan 2019 17:30:51 +0100 (CET) From: Joerg Roedel To: "Michael S . Tsirkin" , Jason Wang , Konrad Rzeszutek Wilk , Christoph Hellwig Cc: Jens Axboe , 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, joro@8bytes.org, jroedel@suse.de Subject: [PATCH 5/5] virtio-blk: Consider virtio_max_dma_size() for maximum segment size Date: Wed, 23 Jan 2019 17:30:49 +0100 Message-Id: <20190123163049.24863-6-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190123163049.24863-1-joro@8bytes.org> References: <20190123163049.24863-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel 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. Signed-off-by: Joerg Roedel --- 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..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) 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, -- 2.17.1