From patchwork Wed Mar 15 20:42:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 9626649 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 50B52604A9 for ; Wed, 15 Mar 2017 20:42:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42D5C2808F for ; Wed, 15 Mar 2017 20:42:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 379C2284CB; Wed, 15 Mar 2017 20:42:33 +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 DCA722808F for ; Wed, 15 Mar 2017 20:42:32 +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=L2iye92W7ez0XxTvwTxvOCKXEVbQ5dBzKpPeB9FVfEc=; b=KA2 SK8rZ9vSwy2eDoN9zVqhjkh4fHIWxgMIrnnwCBO9ATXGk70TZmHcYFc/wh8JbvAOe1EyCzWan4srS ZI6ilQt1NwQI3zVrl8XVlkZ3ppELQ56v/4vMgsnKCKYykzhf7spnnZXJTKV0FoCqw4MjvCqnakbZ8 tuf4VjWzDupT/g0tPSFqR54zUrEwL4GfnpRcUbn6Cukd1xduQgYTcfATef1qdRlc+GjzFuE0KDDid dBIL/roZ4gaQwgAIOa2xYq93nwMXbLD91rkIS1UWqr0ZTTPdioz90XLw7gzlFhTL/aqFq8rrXRnUr A6piVA0Ztd4VnG5JTfelAe07I5f5yTA==; 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 1coFkX-0000rn-5R; Wed, 15 Mar 2017 20:42:25 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1coFkV-0000rN-1m for linux-arm-kernel@bombadil.infradead.org; Wed, 15 Mar 2017 20:42:23 +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=3rnSg01r89g3OhcgIwaKkjYVC8Rv3hex/V1Quf+drtw=; b=fD4GXtBqhzolHNS0vFpvzo7jwK EwMydvUkls8vc9gN0B+qsGcDxyxKfsjKjfHEVdFsvMIhtQUAx5R+vqneoBM7w1PcSvdyqpgooUB59 Hu+ZhRa1E7EkyIHCxURfTIEtkqq3hafal9ig9t/XeffGP4R4IJlO/yeu4yHnRIrrJ1c9YHd4a4nCN bL3BcGtIuT45cpaf74ertcbdJCTargYnIJsfZyXhSWNjxuFBgt1ud74enJGw/QC3kpD4a5RKWpdBk gTkhDTPVnRHYvGfh8MC8dOmFceMl6GC9CvpUfnwkhq4vZfrUhv8JD7xgs5HYei0mqWkzIeaF65gg/ E3YXH/tQ==; Received: from i7.infradead.org ([90.155.92.213]) by casper.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1coFkT-0003nn-38; Wed, 15 Mar 2017 20:42:21 +0000 Message-ID: <1489610540.86622.19.camel@infradead.org> Subject: [PATCH v2 1/4] 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 20:42:20 +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: Mark Rutland , 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() must be implemented and HAVE_PCI_MMAP defined. This support was absent for arm64. [dwmw2: Add WC support] Reviewed-by: Erik Quanstrom Reviewed-by: Anthony Liguori Signed-off-by: Brijesh Singh Signed-off-by: David Woodhouse --- v2: s/pgprot_uncached/pgprot_device/ 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..9a87b2a 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_device(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; +}