Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1176308imu; Wed, 16 Jan 2019 14:11:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7/uKHVRnu4RTwxFP6Ty5uGFZcoZd3y6DVzNFuRMgxAwMwvhN6lZESCTxnXJ+C8qJ/EysGo X-Received: by 2002:a63:e545:: with SMTP id z5mr10971242pgj.195.1547676662512; Wed, 16 Jan 2019 14:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547676662; cv=none; d=google.com; s=arc-20160816; b=O70XEgOASeheh72KA5DhMx3JOFaRWSyHUG9frRK27coUR+kSdJEN8deuTvpCbXrFjG ja2MEF7HT3YaVthTVKFhcilsKuCwSE3t18GqWBKF6VF+1khV9+r4Y+ugQ4M8xwN4LfJ7 0yKFleusbjvlCPFtwmrs+/1Xb+Qp3VWdQ20Se1D1aeUDFr5riYPeYbsTa/N74jQ57nRx Yoe3znEx9s+wkUPzlplUs/lebwYVUdoXyFF5Z3oD7cQeE+C2ZdtERC+1lXTtR+jyUltu 6lJkMIxphxLjIfJ3+ICWlJ1tNQkXW+jM4lIWABB4RcwTciB9nE7rkyAY47z1gdDPaeNc aBFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jVrQqN7hn9LLvtOleRAK/WuLmnAuCgfGyUDAiQckh90=; b=Ei6hpcqCEg4/+BkY6VdWuNjJETfLURq2H/jTVa7+YJ6EwVqvwcN+CKljGaQKpAFsAv ca16MOnbW2zdI8iYGVFp8i6lxb4g2Y8qozmevobfzLLDu0YbddAN1dUV3QuFQVmoulA6 BUlOtoBAyuIZLV6Ma6UAZcttKa8GP7JOIklK3YGyrCpgYx8P4QDbMCagGkkyL2rUN0xG oA7VQaIvoEztgOpLX+SHGoGvtV/uco393vx4Xqm3P3tnA2jVOpkzilEI2DCq/wa4G1h/ l2fUcMfuKRkd61ZmXZnB3+0mKW7mZVIy6p05YlgMOe3tQAHe8d45rTSWn4/E5DkQUPt2 TYlA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t75si7545455pfa.170.2019.01.16.14.10.43; Wed, 16 Jan 2019 14:11: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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390954AbfAPOFs (ORCPT + 99 others); Wed, 16 Jan 2019 09:05:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51885 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390192AbfAPOFr (ORCPT ); Wed, 16 Jan 2019 09:05:47 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA7455C9; Wed, 16 Jan 2019 14:05:46 +0000 (UTC) Received: from redhat.com (ovpn-120-67.rdu2.redhat.com [10.10.120.67]) by smtp.corp.redhat.com (Postfix) with SMTP id A8A1B1C934; Wed, 16 Jan 2019 14:05:40 +0000 (UTC) Date: Wed, 16 Jan 2019 09:05:40 -0500 From: "Michael S. Tsirkin" To: Joerg Roedel Cc: Jason Wang , Konrad Rzeszutek Wilk , Christoph Hellwig , 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, jroedel@suse.de Subject: Re: [PATCH 3/3] virtio-blk: Consider dma_max_mapping_size() for maximum segment size Message-ID: <20190116090355-mutt-send-email-mst@kernel.org> References: <20190115132257.6426-1-joro@8bytes.org> <20190115132257.6426-4-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115132257.6426-4-joro@8bytes.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 16 Jan 2019 14:05:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 02:22:57PM +0100, Joerg Roedel wrote: > 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); > + Should this be limited to ACCESS_PLATFORM? I see no reason to limit this without as guest can access any memory. I'd like a bit of time to consider this point. > /* 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