From patchwork Wed Mar 15 17:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 9626263 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 1DD10604A9 for ; Wed, 15 Mar 2017 17:17:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0843E28602 for ; Wed, 15 Mar 2017 17:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED8F528641; Wed, 15 Mar 2017 17:17:52 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D2E028602 for ; Wed, 15 Mar 2017 17:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Mime-Version:Date:To:From:Subject:Message-ID:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=9T0feufuzlMxXZA5P/9DVeh2Gw9QG9ym+/RXQaFxOsA=; b=M2Z H9tkei/KzGoFtssQuogAZiEdbKyALYEHnBnzlQlfPJFel1rdxgbl3PZTe+Cm0Xi+2rkJyw7Zavb37 gLp1Fb7KgfRBOmN0QYGPvqx0QkCDMn11FFUuk3D6CklQH8up7c2SLfsQUX+7jBfuzMQ3y2EQjkS7g KJsS5CenRfWneHv742Zrq6fx/QvQoR+TkCXkBngQhwVXnP1Gzbf9Wtsz7rL+98U5A7fjmWO5EaAKX QrHfJIV+inp/QBrBtrRvuyLSfp0JJOkWQV3gf7ethRcsJrgI5ugfj1owqNFMLudcQ5lQ0ojD7Ux8m k2281etVu69sQUFVMO9uX+ow3m12gxQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1coCYa-0002M6-6S; Wed, 15 Mar 2017 17:17:52 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1coCYX-0002LR-3h for linux-arm-kernel@bombadil.infradead.org; Wed, 15 Mar 2017 17:17:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Mime-Version:Content-Type:Date:Cc:To: From:Subject:Message-ID:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PWnXdBZYZeV+KSNu0CkMb/zCA1pyqrXa/QfXYwPecH4=; b=cw8EmBWC4ZwN0LZ4imypPAtwLc I+x9o+dlFNc6V/Zu0qZwxi4KAWuaUaZrpevekf6y1cJlIMhzIV9lGdu+cMJhxvT1+qgFVJjmwPkDz De7ah4TpyjmzhOpoHBnNnwQDip1snF0jlx24HUSWe2t1Jz5Hh35ebDogciAXA4TIbPsZJCEpbD4oE +rq1+nTW3CVwY+PDQfi+rGwdGO1CyDetsHjAAqQegXa55rj58fvVN2uYiSholruyqyYH8USKqkrlv a1CoYnhP5zP+bvyZiU6R818R1rvtEEv+O4krHOko47+5ECTzKM+RGk5NoYKf7+eMP6+LyV7c95ZpV STNLP9iA==; Received: from i7.infradead.org ([90.155.92.213]) by casper.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1coCYU-0003Od-Ss; Wed, 15 Mar 2017 17:17:46 +0000 Message-ID: <1489598266.86622.12.camel@infradead.org> Subject: [PATCH 1/3] arm64: enable pci resource mapping using sysfs From: David Woodhouse To: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Wed, 15 Mar 2017 17:17:46 +0000 X-Mailer: Evolution 3.22.4 (3.22.4-2.fc25) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Catalin Marinas , Will Deacon Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Brijesh Singh To support pci resource mapping from userspace, pci_mmap_page_range implementation must be done for that platform. This support was broken for arm64. This patch copies existing implementation from arm to enable sysfs mmap. [dwmw2: Add WC support] Reviewed-by: Erik Quanstrom Reviewed-by: Anthony Liguori Signed-off-by: Brijesh Singh Signed-off-by: David Woodhouse --- arch/arm64/include/asm/pci.h | 4 ++++ arch/arm64/kernel/pci.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h index b9a7ba9..f73734f 100644 --- a/arch/arm64/include/asm/pci.h +++ b/arch/arm64/include/asm/pci.h @@ -37,5 +37,9 @@ static inline int pci_proc_domain(struct pci_bus *bus) } #endif /* CONFIG_PCI */ +#define HAVE_PCI_MMAP +extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine); + #endif /* __KERNEL__ */ #endif /* __ASM_PCI_H */ diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 4f0e3eb..a9b6542 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -228,3 +228,22 @@ void pcibios_remove_bus(struct pci_bus *bus) } #endif + +int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, + enum pci_mmap_state mmap_state, int write_combine) +{ + if (mmap_state == pci_mmap_io) + return -EINVAL; + + if (write_combine) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) + return -EAGAIN; + + return 0; +}