From patchwork Tue Nov 14 17:08:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10057937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2CB8601D3 for ; Tue, 14 Nov 2017 17:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE374288DB for ; Tue, 14 Nov 2017 17:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B320F28F41; Tue, 14 Nov 2017 17:09:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 552E3288DB for ; Tue, 14 Nov 2017 17:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756023AbdKNRIb (ORCPT ); Tue, 14 Nov 2017 12:08:31 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57659 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756005AbdKNRIZ (ORCPT ); Tue, 14 Nov 2017 12:08:25 -0500 Received: from w540.lan (unknown [IPv6:2001:b07:6442:1ac4:14ce:9944:dde6:26cb]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CE1C817209B; Tue, 14 Nov 2017 18:08:20 +0100 (CET) From: Jacopo Mondi To: ysato@users.sourceforge.jp, dalias@libc.org, laurent.pinchart@ideasonboard.com, geert@linux-m68k.org Cc: Jacopo Mondi , linux-sh@vger.kernel.org, linux-renesas-soc@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC v2 2/2] base: dma-mapping: Postpone page_to_pfn() on mmap() Date: Tue, 14 Nov 2017 18:08:06 +0100 Message-Id: <1510679286-6988-3-git-send-email-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510679286-6988-1-git-send-email-jacopo+renesas@jmondi.org> References: <1510679286-6988-1-git-send-email-jacopo+renesas@jmondi.org> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Suggested-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- drivers/base/dma-mapping.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,