Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1792382imu; Thu, 24 Jan 2019 01:53:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN5OFJgdjedoi0irdCPQ43aISqcn5GGtF8R2EEt6jY4Y0F38zDgCDiQZd8mY4InrkSYgFgEn X-Received: by 2002:a17:902:1008:: with SMTP id b8mr5685149pla.252.1548323628294; Thu, 24 Jan 2019 01:53:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548323628; cv=none; d=google.com; s=arc-20160816; b=ZJb/eWWTddOftLr5pNp39+leOzhgkVA8MU2o820EL8ier/M+eOwxVjr4GAEbkjoTs2 mDqoUaKoecfC09tAccaLo16p+vmyRQ55RxYODd9BBUZx5n20pVym4E3VgpdjGLBfBdBF UXhcgd+du0M4aStj9asb1e5otOJmPEpwy4eYD4x3GHIyHbdXgK2k1j0mCs/abaXSkt5e jfdl9TGiC+YtTKPGPAkFOB4pjrhoBFUm7SuT79eud4kJ2+DSVSm+PxTsmc6+VxpsHQCV HFIXIO2Blhf9420f8r+rqtMXHwNm1ukoIHiq0SthAX7rmwx9eXB0eHhnq7Lq0+sQhNm6 qGWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=s+aCZjDd828NEzHvDv0LFblGKihbk0XbrmmxIhpIPP8=; b=B29NkTOfs6fUSH01LZcuJtAf/yXO/kjRTrukmmdx0kDttgQFwEnXaKmoMPYhJ284Ai IS2rEBj0x6KtlK4rghiT4BM/Qp+X1fplBdMYUpuOlfHvf0h2n9AAbuxM/FI/2tcSkhH1 1MhEHjhf5x+c6Xb/4ofJ/3GT7NM4s7QMaXqCGSN9wDnF3zJ3J9U1V8KuNhkDJlxixtBB MSTunfDjMbQbmEdKeiH2c1nZn6PuCndLchSc4c1gea61XaIjdrIBIQ5AAATy8TxkOkAO pcgQ+LibDWxqZTx4qSciFgVhoQaazTkAstNHyqGQ8f9pyQR80ftt7D5OmPpNcJnr+nFN zlZQ== 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 g184si15807628pfb.288.2019.01.24.01.53.33; Thu, 24 Jan 2019 01:53:48 -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 S1727409AbfAXJvx (ORCPT + 99 others); Thu, 24 Jan 2019 04:51:53 -0500 Received: from 8bytes.org ([81.169.241.247]:59494 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbfAXJvx (ORCPT ); Thu, 24 Jan 2019 04:51:53 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 276D048C; Thu, 24 Jan 2019 10:51:51 +0100 (CET) Date: Thu, 24 Jan 2019 10:51:51 +0100 From: Joerg Roedel To: Christoph Hellwig Cc: "Michael S . Tsirkin" , Jason Wang , Konrad Rzeszutek Wilk , 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 5/5] virtio-blk: Consider virtio_max_dma_size() for maximum segment size Message-ID: <20190124095150.GL32526@8bytes.org> References: <20190123163049.24863-1-joro@8bytes.org> <20190123163049.24863-6-joro@8bytes.org> <20190123213139.GD9032@lst.de> <20190124084011.GJ32526@8bytes.org> <20190124084221.GB19441@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190124084221.GB19441@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 09:42:21AM +0100, Christoph Hellwig wrote: > Yes. But more importantly it would fix the limit for all other block > drivers that set large segment sizes when running over swiotlb. True, so it would be something like the diff below? I havn't worked on the block layer, so I don't know if that needs additional checks for ->dev or anything. diff --git a/block/blk-settings.c b/block/blk-settings.c index 3e7038e475ee..9a927280c904 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -1,6 +1,7 @@ /* * Functions related to setting various queue properties from drivers */ +#include #include #include #include @@ -303,13 +304,17 @@ EXPORT_SYMBOL_GPL(blk_queue_max_discard_segments); **/ void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size) { + unsigned int dma_max_size; + if (max_size < PAGE_SIZE) { max_size = PAGE_SIZE; printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_size); } - q->limits.max_segment_size = max_size; + dma_max_size = dma_max_mapping_size(q->backing_dev_info->dev); + + q->limits.max_segment_size = min(max_size, dma_max_size); } EXPORT_SYMBOL(blk_queue_max_segment_size);