Received: by 10.213.65.68 with SMTP id h4csp2288215imn; Mon, 9 Apr 2018 00:29:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/sohf+h9tInRHgR3fBAfXJgi4AJ72BVJsurox7maMVQ103CteX++L8+JQhUtcflwJnxyjt X-Received: by 10.98.103.69 with SMTP id b66mr28033869pfc.151.1523258969196; Mon, 09 Apr 2018 00:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523258969; cv=none; d=google.com; s=arc-20160816; b=Q8ppHdAFbBBsELfQdf4z6imarMY3JNrjt2ftVSg7dlTk6NRMQNam0rowMw6aOZbX2v JybfQ72okNbX+V7dH35a3YMKPvETAJwZDi1n9P9w1OHwfPTGbnId/J3OI/gnUQM76h20 jSfIJ/f7XQToWGnARu8LxVMXNVtlTQE18SPsJl7yZqSr3DAkBgxNy+/xrFxzOF0hWghY Xv9xzUPaMLHsWepBG3RggrEeuphGlh8Ea7JKHq0P6ZNxx1fA3G2zWIeY9B+A+Ysynqys OOA+wjp1oW0nKLp58buwmKgKb/G0PFGCprPR0fR5FG2TGO4P3yYdNScFzzJRH5uz9wKS ZhuQ== 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=IYcfudQTAukmssBtuMqQln6zohdwpsAZegEkJ0pJ0rE=; b=YFU8BBlbEXZdZ9kzen1acTKYJaC0Laf23V/uMnuxdoDf4pyqOn0xztxZ1k5j6sw5ri +QQp+mhbJlUgRxHkY16fvX3spRb/zhQDeTYmh2hFK0ja7JhWeOFUdBXLnsW7Amzhaaxk D2pQxNorY859BMCq8+QPondAoqswz+pKdjUz3V2fD4q2VjpkpUoxNIv0QxVarY2bEMAp 4JSwHlfnGJ4iv35hhQfHND/yhWGMy38lOuP/zUWGBiHc6cvcT+L9JEQus9NW6bJq92p8 /qe3gle7XMl0IhHbvCLe7LPR0aLo+n+AyHCDYX0UGdHb2Sa9EAflH3NjlRM0z2rdGThr EpYw== 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 o129si10804554pga.253.2018.04.09.00.28.52; Mon, 09 Apr 2018 00:29:29 -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 S1752091AbeDIHZ4 (ORCPT + 99 others); Mon, 9 Apr 2018 03:25:56 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46065 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751794AbeDIHZy (ORCPT ); Mon, 9 Apr 2018 03:25:54 -0400 X-Originating-IP: 158.255.198.50 Received: from w540 (unknown [158.255.198.50]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 7018360005; Mon, 9 Apr 2018 09:25:49 +0200 (CEST) Date: Mon, 9 Apr 2018 09:25:47 +0200 From: jacopo mondi To: Robin Murphy Cc: Jacopo Mondi , ysato@users.sourceforge.jp, dalias@libc.org, laurent.pinchart@ideasonboard.com, 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: <20180409072547.GU20945@w540> References: <1510679286-6988-1-git-send-email-jacopo+renesas@jmondi.org> <1510679286-6988-3-git-send-email-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8a48p4KKsB+A/3VY" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --8a48p4KKsB+A/3VY Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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? Thanks j > > Robin. > > >Suggested-by: Laurent Pinchart > >Signed-off-by: Jacopo Mondi > >--- > > drivers/base/dma-mapping.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > >diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c > >index e584edd..73d64d3 100644 > >--- a/drivers/base/dma-mapping.c > >+++ b/drivers/base/dma-mapping.c > >@@ -227,8 +227,8 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, > > #ifndef CONFIG_ARCH_NO_COHERENT_DMA_MMAP > > unsigned long user_count = vma_pages(vma); > > unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT; > >- unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr)); > > unsigned long off = vma->vm_pgoff; > >+ unsigned long pfn; > > > > vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > > > >@@ -236,6 +236,7 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, > > return ret; > > > > if (off < count && user_count <= (count - off)) { > >+ pfn = page_to_pfn(virt_to_page(cpu_addr)); > > ret = remap_pfn_range(vma, vma->vm_start, > > pfn + off, > > user_count << PAGE_SHIFT, > >-- > >2.7.4 > > > >_______________________________________________ > >iommu mailing list > >iommu@lists.linux-foundation.org > >https://lists.linuxfoundation.org/mailman/listinfo/iommu > > --8a48p4KKsB+A/3VY Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJayxV7AAoJEHI0Bo8WoVY8poQP/RLuihAmfxnsaF8Y5vpyWWQT GS7+W9OGNVGOn8IeMsp0Lq+GSpzqHVd8o18/06m1Cp+4KIzhgbGrOPpSHBZ4qMON oi98PJHrMWxIqzgSt/ejjXQ70USkEAOfv4tMZ8R8QnzFcOZ4Ka/ppoH2JuSzb0E5 XCKfgkqFu7VyT5cQCERb0+orAVmj5w4vpglIr6igE0UTh0XjubXqtIxFitH3qmdw cnboVo3SH7eTLTDzSWdOPUi0aPRditdbHOpencmWpwtKQRAwFx7xwtefWkrML+dT n8Ygl0VOk+B5zYlb1JMCmX1/btaxOl9P7wDI0IkUwuEY3S7ZWmpzoWnlw/Fzbnlb wWoEmTLuM514Qd9UTB98hDqpsZhe5D/Zo7kExHAU+peucxUyfZ6g2q1mwrDYwUY+ BP78VWaQc4lHQZ9xBGkHgaXzmVHjmEjXFWe+L/3z1iGmngYdR4/b5Dhfw1GXT6mt PHcliy3AbgHT/wr55WBCEB2+xdl7tChdv/Hl2x89kDqkRXFnS+uWsIJ4qd4U0DIy oDb/6g4TAbGV7j/k3gEQT4MkclRYrv/rlDVyYZrGIWn6oX8iDieVLoJSa2mNa59K sAWLR3Ca+vLaGI+WOn+8mvg0ZxW4Wywi5xwiru98RVPHI1CxGQGL1Hm3ayyK/K+F H2NKjX9Nm20Zg0HDf/oh =MB4Z -----END PGP SIGNATURE----- --8a48p4KKsB+A/3VY--