Received: by 10.213.65.68 with SMTP id h4csp2738097imn; Mon, 9 Apr 2018 08:16:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SX2REajlDsM5omhiwtIi9rXlKRbj5jVyBdkAA3wBcRzfmAZxHfRSwcnH0aUJPxKc1NP1J X-Received: by 10.99.122.70 with SMTP id j6mr1983588pgn.269.1523286960444; Mon, 09 Apr 2018 08:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523286960; cv=none; d=google.com; s=arc-20160816; b=ey8gKHRGT03h2I991IQJ8OW+6TOCYkjdidjosg48hUZAHyVXg7khmNm+6sXTxAPhWJ RGWPQKpY+DLqI9SRHBe8EWIBO3Or4oCVC3vKbxt+09RUcK76N1Bg3271w2GVsCqMZUgB uxHnIuXN5xOGwwIL2+AO46luQgqSPfVHL4UWMbVTnB/qoqACz/UIwDCYvkNzQRqUeN8J +YvDLKY8pOO9Jkqf8FBMBH69o7RNkmxTEvfcAO4SNubUAKVoC+pqLKA3J0XYFjoEvl3p 7AeFjW6x2Ujkyk9MfJldFn/8gJ7Qyy9wQ+PXNxkx2WDJSdW6iT/o7rltOr7hoCvknI62 nZcg== 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:arc-authentication-results; bh=BR20FCU3ScRI4yolBpqyBWNEl9m9tUk2l88n8ll8UkE=; b=ZkDN9R6IBJPlcOUXGDJu23lC9LwwfuEMiW47Tak3c0kkOmrfBXrLs7zJ8k49MrOKsp 8dW91weirpL1wHKASlwJRroGhWrCaF8dtFbFMKCtCaTcegYrXEjMusfnqPhnoa6w2nh4 NqUYvcLxbe5LOzmWAt1Qj3zNl7y6zn/NY491lCt6nTAHwT48OA3rXUCDyfs9U5ybqYpA XvQNeR79su6+jDtnitvWjQ1B1KotLgzXSCWGKmcVScDkvjPzVws8W0N0V+icSMXZohAt ZdiQ+2zt95QkITr8ui9P6bbcrfqDA7r9dnN/+mYW6yB6LhlaT4/lrPNSZEHU4qr2KweG vVyw== 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 k9-v6si487688pln.598.2018.04.09.08.15.21; Mon, 09 Apr 2018 08:16:00 -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; 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 S1752878AbeDIPLd (ORCPT + 99 others); Mon, 9 Apr 2018 11:11:33 -0400 Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:45862 "EHLO brightrain.aerifal.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752616AbeDIPLb (ORCPT ); Mon, 9 Apr 2018 11:11:31 -0400 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1f5YRt-0003wg-00; Mon, 09 Apr 2018 15:11:13 +0000 Date: Mon, 9 Apr 2018 11:11:13 -0400 From: Rich Felker To: Laurent Pinchart Cc: Robin Murphy , jacopo mondi , Jacopo Mondi , ysato@users.sourceforge.jp, geert@linux-m68k.org, linux-renesas-soc@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org Subject: Re: [RFC v2 2/2] base: dma-mapping: Postpone page_to_pfn() on mmap() Message-ID: <20180409151113.GD3094@brightrain.aerifal.cx> References: <1510679286-6988-1-git-send-email-jacopo+renesas@jmondi.org> <20180409072547.GU20945@w540> <7da3f31e-e4ad-7f1a-e66c-0d3e0fb8b27d@arm.com> <2555020.mSAUJ9kk90@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2555020.mSAUJ9kk90@avalon> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 09, 2018 at 04:06:15PM +0300, Laurent Pinchart wrote: > Hello, > > On Monday, 9 April 2018 14:11:22 EEST Robin Murphy wrote: > > On 09/04/18 08:25, jacopo mondi wrote: > > > Hi Robin, Laurent, > > > > > > a long time passed, sorry about this. > > > > > > On Wed, Nov 15, 2017 at 01:38:23PM +0000, Robin Murphy wrote: > > >> On 14/11/17 17:08, Jacopo Mondi wrote: > > >>> On SH4 architecture, with SPARSEMEM memory model, translating page to > > >>> pfn hangs the CPU. Post-pone translation to pfn after > > >>> dma_mmap_from_dev_coherent() function call as it succeeds and make page > > >>> translation not necessary. > > >>> > > >>> This patch was suggested by Laurent Pinchart and he's working to submit > > >>> a proper fix mainline. Not sending for inclusion at the moment. > > >> > > >> Y'know, I think this patch does have some merit by itself - until we know > > >> that cpu_addr *doesn't* represent some device-private memory which is not > > >> guaranteed to be backed by a struct page, calling virt_to_page() on it is > > >> arguably semantically incorrect, even if it might happen to be benign in > > >> most cases. > > > > > > I still need to carry this patch in my trees to have a working dma memory > > > mapping on SH4 platforms. My understanding from your comment is that > > > there may be a way forward for this patch, do you still think the same? > > > Have you got any suggestion on how to improve this eventually for > > > inclusion? > > > > As before, the change itself does seem reasonable; it might be worth > > rewording the commit message in more general terms rather than making it > > sound like an SH-specific workaround (which I really don't think it is), > > but otherwise I'd say just repost it as a non-RFC patch. > > I actually can't remember any better fix I would have in mind, so this looks > good to me :-) I agree with Robin, the commit message should be reworded. > Robin's explanation of why virt_to_page() should be postponed until we know > that cpu_addr represents memory that is guaranteed to be backed by a struct > page is a good starting point. You can mention SH4 as an example of an > architecture that will crash when calling virt_to_page() in such a case, but > the fix isn't specific to SH4. Just checking since I joined late -- is the consensus that this does not require any action/review specific to SH (in my role as maintainer way behind on maintenance)? Rich