Received: by 10.213.65.68 with SMTP id h4csp2746569imn; Mon, 9 Apr 2018 08:23:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OGeK9NvaDeSJeki61+QR6p40jwCLlZEAlT4J7BMFIYcwh6WeVfQqwMfsyHmkEdirok8a4 X-Received: by 10.98.33.154 with SMTP id o26mr29814016pfj.54.1523287421532; Mon, 09 Apr 2018 08:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523287421; cv=none; d=google.com; s=arc-20160816; b=dM8YkGauwwkhF9P5JgPSk+yXseboP/lmSjta8MgNJya/GJIxLSqMedwSvdZV/1kBaY i9kRPjp5gsEGCKBJ5Dx8N8MQgp9p2ckqyT1ZNhfyRWoBoe1sYsdksjShPoH5ed4I1OzD BATQnMJ8NuoxvfygJsPLg/Ndk4fh0uQB5+6pqSofJWIMjcDPpaCZXCR+m0e8hbJzCgPa NECGpaVSCRpEjf7gy/UDEXYJ/WJGHIdaq2LfUBnZeNflyjz8jeRENphZNXajV2LLYyW4 3z550iMgZGkM+kkFPpEibEWNryXuTchZxSTHTjl1AZRK2uwUCgtcGGcmWA8usY48YVzu J34w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=wc8vT1HsKiAgoa6k8i4j+vUdMpv2vCbqIYzCgJpbknk=; b=jB1zpU6ovbDUtY2zlrPnoIMg0nBElSZJE4knfC4TloYZRQ/w9bDc9DqbicyC+jSj56 qX850NAfuqyD9dTM/735Bz7ejWDzdzOt1NVhikgJ7WCtVm1DU0M4mdgUP4bAwEBPYB9y o1/3AT5wNOn9/cyygfL4OFjPU+6iDtYg9yxfZRQBmPtyeMGoqzyGVpGy2uRc0OZ5v8BY Wq4MPZxMwya8qtpnijV8AYWvMhbZpizvvVEZPeDXZEBWQ5TSam6R631Ejj3ZmtcwgcUI 22cyrlXX0YQK4Hws3EyvuIqupSf0iB+RzBz7cAJMhbO8v0zsV+ScTuTtCRkCrXl6g4Ll HSUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=jLj3DDKB; 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 p27si371240pgn.238.2018.04.09.08.23.03; Mon, 09 Apr 2018 08:23:41 -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=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=jLj3DDKB; 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 S1753189AbeDIPSY (ORCPT + 99 others); Mon, 9 Apr 2018 11:18:24 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:38467 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173AbeDIPSW (ORCPT ); Mon, 9 Apr 2018 11:18:22 -0400 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 3BB102038F; Mon, 9 Apr 2018 17:15:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1523286947; bh=RncUknWCBoBE0FNdOKdDgpbPSxBHHZ+FG18MWwuY2vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jLj3DDKBgkp15kgumdEwL7BZ6x+p368iZOVzzsswTHRVHBmdc35R1i+gsZiC9f0V9 gpHQ/qAQcE1QWBErCEBrb16C3P0JvNhRf5/OEgLYdCBCJ6thA/oUzrAw4gggJxwz/d TTUBpJJkrN+0KpesBgmdVkFO1w9WV5VfeEkkjekY= From: Laurent Pinchart To: Rich Felker 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() Date: Mon, 09 Apr 2018 18:18:23 +0300 Message-ID: <6024361.mOebchCzSY@avalon> Organization: Ideas on Board Oy In-Reply-To: <20180409151113.GD3094@brightrain.aerifal.cx> References: <1510679286-6988-1-git-send-email-jacopo+renesas@jmondi.org> <2555020.mSAUJ9kk90@avalon> <20180409151113.GD3094@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rich, On Monday, 9 April 2018 18:11:13 EEST Rich Felker wrote: > On Mon, Apr 09, 2018 at 04:06:15PM +0300, Laurent Pinchart wrote: > > 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)? I don't think it requires any action specific to SH. If you want to review the patch in the context of SH though, please feel free to do so :-) -- Regards, Laurent Pinchart