Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp307127imu; Tue, 15 Jan 2019 22:29:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/0rezJmNU0E0C+kJBA4GgboluiJvfovlD/GVr3ScBoolqVZONJW4yYXpqN0WpJUlu4x3U X-Received: by 2002:a63:6d48:: with SMTP id i69mr7125050pgc.215.1547620199808; Tue, 15 Jan 2019 22:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547620199; cv=none; d=google.com; s=arc-20160816; b=0JrYisxB5ur2f3g998iTSeIOD5guJJCmB8NI2E6FUd/AmP6kPHAQJCRybEhoY6LSuR PJzu9tfkEWx4jZW1GYVuFsDKuRTGtyCLVbqrAUh89Yn8aIbCFemXYZ+5CHAhYlnICxzQ YC9NnrgNtc3f0QYf8/zAhg44SS0IPxIKW8vx5Hhtxqz/Xwz+sq0Aj730qY6EdFFYZF4l FkIzZ3tVsym8pYbtiv3bV5Kn2r6SfkJYH2J66nUff32bo91aZSq0tqeR0rd4Wtv14sy5 9OrDkR/Ax8ZjlWYDkSvPBiaVSLTKjXkzz/bTw2nCNCc4lDzkjl/uax9bU2S36yhY8XCP CSYA== 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=qhhWhyqXFLCH+03aGJ4+RxrJb78mSqcM8byRuQtLSQk=; b=R5gPldEYDIOrdI22c8IVwlzne3oayj3e0+EF2R28IZ7VNeETMfQ40/cqROBqd+JKoS sS1oHpa5Fz2G/NbwaNScjtEPW4dHf++ySo21mD82gY9QK51+B5JAZDfADw/m25XnCQpj K8YJ0UdvEoPClXHhvaly+OrwqjTq34FSzv/CcHe14n0qJdAZs5/I+OPESQOwftnIg79m vxll9uH12M2ERZXwyotBvjuqhLxn/bRnPARuMh3mpfAd43fyZNZFBfvvhP8xSSRiVwqf 5jPqMldXpebHwenP7/26QNtB2T6pi///6008bPR6OoWXqBvqEJ3YSEN3Mmyzx6J5pXc6 Ws/A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t64si790577pgd.202.2019.01.15.22.29.44; Tue, 15 Jan 2019 22:29:59 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388578AbfAORyU (ORCPT + 99 others); Tue, 15 Jan 2019 12:54:20 -0500 Received: from verein.lst.de ([213.95.11.211]:54554 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbfAORyU (ORCPT ); Tue, 15 Jan 2019 12:54:20 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 84A3467358; Tue, 15 Jan 2019 18:54:18 +0100 (CET) Date: Tue, 15 Jan 2019 18:54:18 +0100 From: Christoph Hellwig To: Joerg Roedel Cc: Christoph Hellwig , "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 2/3] dma: Introduce dma_max_mapping_size() Message-ID: <20190115175418.GA11402@lst.de> References: <20190115132257.6426-1-joro@8bytes.org> <20190115132257.6426-3-joro@8bytes.org> <20190115133754.GB29225@lst.de> <20190115162322.GA4681@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190115162322.GA4681@8bytes.org> User-Agent: Mutt/1.5.17 (2007-11-01) 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 05:23:22PM +0100, Joerg Roedel wrote: > Right, I thought about that too, but didn't find a generic way to check > for all the cases. There are various checks that could be done: > > 1) Check if SWIOTLB is initialized at all, if not, return > SIZE_MAX as the limit. This can't be checked from dma-direct > code right now, but could be easily implemented. Yes, this is the low hanging fruit. > 2) Check for swiotlb=force needs to be done. > > 3) Check whether the device can access all of available RAM. I > have no idea how to check that in an architecture independent > way. It also has to take memory hotplug into account as well > as the DMA mask of the device. > > An easy approximation could be to omit the limit if the > dma-mask covers all of the physical address bits available > on the platform. It would require to pass the dma-mask as an > additional parameter like it is done in dma_supported(). > > Any better ideas for how to implement 3)? And yeah, this is hard. So I'd just go for the low hanging fruit for now and only implement 1) with a comment mentioning that we are a little pessimistic.