Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5501578ybe; Tue, 10 Sep 2019 04:52:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVqkkkBDvEn6V4NNUAbgyPUhqyVdq/Y8oReLyqze6zFe3NF9wOjD98xwXK8j5pQKJm14z+ X-Received: by 2002:a17:906:4f04:: with SMTP id t4mr24508080eju.190.1568116355569; Tue, 10 Sep 2019 04:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568116355; cv=none; d=google.com; s=arc-20160816; b=Dv9op1Bn7ruIffgEOrLRoYcei5BjBJKOJtRqP4LFOl6GequWfSF6zYtu4EVSc0Ly6k vRi1/xZZ919FSAUYbXc8P2RGBu+O28ep+jojav1jNsXPfb+F1s8sUWvdZELW0hcZW62S 2H4iUAry+auBcbUhM8LeM6Ce4csbtrpQ7zTnoy6M4DoEg/nzrEPrXKPzPIGGFczzqoib AqAPcmLZycTiJPF6WYv1sJ3Dt9nBCpLkIwVflf5zO6HCWDOBWDUblGRt7/tzSo7/BGVV dswaPW0Nn1nDxJJbz5PNDKM0RyHDpXkSH+GjwmDPnKvS+0Eoj5TantyZf4crX++M8tHY LWVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=lwsvKpUPrADyejgxRJPfxHy0BqESi/C+njX2RLDAR9U=; b=vdsRzb3xTQXrxfjlZ4WQvD/rpxj5HTpljJfBuXuZF/MJqrP7nZyUOz96WS9TonrXIW I+oylpDoKIvk9Tj1Nge+hpupNNhXv+2x34VJtnxj0Mw8bLnrnq8OEXr0gwUKxJ9+Ieze T5Q5f56wUTekZ7/Ho6P4OAM6e9y9qOQJnX3ZhGZicy+hFx3yzmSYJFOftExltFefn/mC WuIraqP4D23om4flzOlNKi0l3eNJZ7vYJFuI+gbVJiHhFE2ndpaYsbHyGceEG68pLTB8 m0Z4gZTQ7vgSFIFB5fmNzY1l+G5FRgpaYmmWT2XlZSHAf3mzAuLutVWDNNzm/5FtLUCF ugYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=RbgKb2UY; 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 v57si11472775edc.171.2019.09.10.04.52.11; Tue, 10 Sep 2019 04:52:35 -0700 (PDT) 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; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=RbgKb2UY; 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 S1728367AbfIJIhZ (ORCPT + 99 others); Tue, 10 Sep 2019 04:37:25 -0400 Received: from pio-pvt-msa2.bahnhof.se ([79.136.2.41]:60792 "EHLO pio-pvt-msa2.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfIJIhY (ORCPT ); Tue, 10 Sep 2019 04:37:24 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 67BB13F63C; Tue, 10 Sep 2019 10:37:20 +0200 (CEST) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=RbgKb2UY; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7X0L3ZDda6NP; Tue, 10 Sep 2019 10:37:19 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 8976F3F5F5; Tue, 10 Sep 2019 10:37:18 +0200 (CEST) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id BF7C1360195; Tue, 10 Sep 2019 10:37:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1568104635; bh=Exy62JteIIiFDqg9sDFhMjGz8fW5liamcWBqhMgS7H4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=RbgKb2UYsm52plgagsbzNnxLaOFs/XpgtVEtv3poLUqni6TZimS9f1juiS4q34dsf CdfdckLJrfqwlxGT52303uayAfk70Lh6kDC39W+CuA2pxVcZpl+9/Dk20Dm/ePcP65 5so/uC8HxRDvD7xziLyXIwl0jW/n4o0/AJx3uOsM= Subject: Re: dma_mmap_fault discussion To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, "pv-drivers@vmware.com" , Thomas Hellstrom , Dave Hansen , =?UTF-8?Q?Christian_K=c3=b6nig?= References: <20190905103541.4161-1-thomas_os@shipmail.org> <20190905103541.4161-2-thomas_os@shipmail.org> <608bbec6-448e-f9d5-b29a-1984225eb078@intel.com> <20190905152438.GA18286@infradead.org> <20190906063203.GA25415@infradead.org> <20190906072037.GA29459@infradead.org> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= Organization: VMware Inc. Message-ID: <611166e3-bb9a-d42c-fb98-18846dfefb8f@shipmail.org> Date: Tue, 10 Sep 2019 10:37:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190906072037.GA29459@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/6/19 9:20 AM, Christoph Hellwig wrote: > On Fri, Sep 06, 2019 at 09:10:08AM +0200, Thomas Hellström (VMware) wrote: >> It's definitely possible. I was just wondering whether it was necessary, but >> it seems like it. > Yepp. > > I've pushed a new version out (even hotter off the press) that doesn't > require the region for dma_mmap_prepare, and also uses PAGE_SIZE units > for the offset / length in dma_mmap_fault, which simplifies a few > things. Hi, Christoph, I've been looking into this a bit, and while it's possible to make it work for fault, (and for single page kmaps of course, since we have the kernel virtual address already), I run into problems with vmaps, since we basically need to vmap a set of consecutive coherent allocations obtained from the coherent pool. Also, at mmap time, we need in theory to call dma_mmap_prepare() and save the page_prot for all attrs we might be using at fault time... I did some thinking into whether we could perhaps cover all or at least the vast majority of architectures and awkward devices more generally with a  page prot and a set of pfns. So I looked at how remap_pfn_range() and io_remap_pfn_range() was implemented across architectures, and it turns out that all archs implementing a special io_remap_pfn_range() (sparc and mips) end up calling remap_pfn_range(), and that should mean that any arch that's currently capable of doing fault() should in principle be capable of using vmf_insert_pfn_prot() with a suitable pfn that in most (if not all) cases should be obtainable from the kernel virtual address. So do you think a way forward could perhaps be to have a dma_common_get_pfn_sgtable() and add a generic vmap_pfn_prot()? Thanks, Thomas