Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4963513imu; Tue, 15 Jan 2019 08:52:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7zqqqo2tIelvoNkGoneh0HvIA+AQI+kP2iHSnZbvoeeTZdz5qzXTobXGxFO6S/MgSLnycn X-Received: by 2002:a65:610d:: with SMTP id z13mr4647917pgu.427.1547571122706; Tue, 15 Jan 2019 08:52:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547571122; cv=none; d=google.com; s=arc-20160816; b=Qf++35onqrjfbJadjT3kXCM1zpZWfj608A1noko6y49qYSwBmKDKhTf5Dfh4vpHkYV X6sI7JCHUT13NDB7Kvrcx5/y3v0i1csV1LIr6xDg/h6yEFVWv5ZFXM0ShXYC9A5tliuj u8wHZc+vgdDyypvLqkTGWQsPGxGeobaDjqt7CgMLRdNayUsd/ZRKKwLxf0q0fOzfCgkc ub26R8XZXXbwKlmSaODS+tNNHWGTDgF/RaeOVf4jBpompAMBi19Kq2lBWeT7VpFGJBki jZvVwXQKG2qPlNt73I+t3pS72KcChqJ34pVFqnNPztqG58n78CKArwbIgASgGn8wmm0L 3VIQ== 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=GH7bb7p7BzHRz228ccENUVA30SccQyo33ZoN1r3BKLY=; b=ABSTMGquATkpAOGWvjna2VFYG27txlLCxjhnt3ZvnYUSG4AlGG1QuXDeFgQ6loMYT1 aEiQMmJ+k1Fb5peJ+tFl6r0JfeMRddrbHNbkHJuqrmFR6o0S0c/1X/qiQWV97WbxSzIH iYgPQ0MmtaFQkzvHOIgOk5vEe8ii4ozGrqtS5xk6AL9Baq42j1FAS1Sv2eE8xHShdYGo P2z5+UF1Ac7Mf4AVIehYpps+haeY9pL0dNsTgRcEkkImCAZ00NSzxy6TMDLbPd6RpWES iB1rb8Fxq//fnNc0qbz2M2ftnObi068MqXvqCSc3Njw7eHwifGlKxIOee8qJk0DyaFEL LY8g== 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 j21si3789555pfn.277.2019.01.15.08.51.43; Tue, 15 Jan 2019 08:52:02 -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 S1729693AbfAONXQ (ORCPT + 99 others); Tue, 15 Jan 2019 08:23:16 -0500 Received: from 8bytes.org ([81.169.241.247]:57788 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729323AbfAONXC (ORCPT ); Tue, 15 Jan 2019 08:23:02 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 989C844A; Tue, 15 Jan 2019 14:23:00 +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 3/3] virtio-blk: Consider dma_max_mapping_size() for maximum segment size Date: Tue, 15 Jan 2019 14:22:57 +0100 Message-Id: <20190115132257.6426-4-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115132257.6426-1-joro@8bytes.org> References: <20190115132257.6426-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..6193962a7fec 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 = dma_max_mapping_size(&vdev->dev); + /* 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