From patchwork Wed Mar 27 21:36:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10873955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A27071708 for ; Wed, 27 Mar 2019 21:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E819289AD for ; Wed, 27 Mar 2019 21:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8322F28B5B; Wed, 27 Mar 2019 21:37:09 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 22FDF289AD for ; Wed, 27 Mar 2019 21:37:09 +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-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=L3+Gn57G8VZMVdv0FS24PGdT/t9Ssndh/J/DNRyOZJ8=; b=JJi+O+6iaN7ewE j0l+/4JY4JgVU0VXtKZcSxTP0+A0bxqJ/vtEAvmbOsQyRvKJgmeuOmVRPtT5Q2RnijFIEjoSyN0GN Mr+3lkyvH+GxX3FAWTJGT83EX9hTR8t76BlQpuQPX00aVMrmN3ZU/bp+YgbUfclPiyHNdyMmt8cAn 0xECNSdJynnKFlNUsWXL/WBtWm9DLSHwX9x9VR5sxdUiMWTGjlv8oj2A28v0vKyBwL4RqRwOLkzXn yudkc6tmiBnKsSVnj/OVey7BIh75matoQh+SB5le/ZjbOWLaxQ13Bq1pC8Bp8Q/lOPMUrMdcUoar5 mgM8lqP38nQxjrnaPxLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9GEM-0001NC-6u; Wed, 27 Mar 2019 21:37:06 +0000 Received: from ale.deltatee.com ([207.54.116.67]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9GEC-0001GM-OG for linux-riscv@lists.infradead.org; Wed, 27 Mar 2019 21:37:01 +0000 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h9GE3-0006DG-1s; Wed, 27 Mar 2019 15:36:47 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1h9GE1-0006CW-Pm; Wed, 27 Mar 2019 15:36:45 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Date: Wed, 27 Mar 2019 15:36:36 -0600 Message-Id: <20190327213643.23789-1-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, sbates@raithlin.com, palmer@sifive.com, hch@lst.de, aou@eecs.berkeley.edu, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 0/7] RISC-V: Sparsmem, Memory Hotplug and pte_devmap for P2P X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190327_143657_297693_D71AD0B9 X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Palmer Dabbelt , Logan Gunthorpe , Christoph Hellwig , Albert Ou , Stephen Bates Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, This patchset enables P2P on the RISC-V architecture. To do this on the current kernel, we only need to be able to back IO memory with struct pages using devm_memremap_pages(). This requires ARCH_HAS_ZONE_DEVICE, ARCH_ENABLE_MEMORY_HOTPLUG, and ARCH_ENABLE_MEMORY_HOTREMOVE; which in turn requires ARCH_SPARSEMEM_ENABLE. We also need to ensure that the IO memory regions in hardware can be covered by the linear region so that there is a linear relation ship between the virtual address and the struct page address in the vmemmap region. While our reason to do this work is for P2P, these features are all useful, more generally, and also enable other kernel features. The first patch in the series implements sparse mem. It was already submitted and reviewed last cycle, only forgotten. It has been rebased onto v5.1-rc2. Patches 2 through 4 rework the architecture's virtual address space mapping trying to get as much of the IO regions covered by the linear mapping. With Sv39, we do not have enough address space to cover all the typical hardware regions but we can get the majority of it. Patch 5 and 6 implement memory hotplug and remove. These are relatively straight forward additions similar to other arches. Patch 7 implements pte_devmap which allows us to set ARCH_HAS_ZONE_DEVICE. The patchset was tested in QEMU and on a HiFive Unleashed board. However, we were unable to actually test P2P transactions with this exact set because we have been unable to get PCI working with v5.1-rc2. We were able to get it running on a 4.19 era kernel (with a bunch of out-of-tree patches for PCI on a Microsemi PolarFire board). This series is based on v5.1-rc2 and a git tree is available here: https://github.com/sbates130272/linux-p2pmem riscv-p2p-v1 Thanks, Logan --- Logan Gunthorpe (7): RISC-V: Implement sparsemem RISC-V: doc: Add file describing the virtual memory map RISC-V: Rework kernel's virtual address space mapping RISC-V: Update page tables to cover the whole linear mapping RISC-V: Implement memory hotplug RISC-V: Implement memory hot remove RISC-V: Implement pte_devmap() Documentation/riscv/mm.txt | 24 +++ arch/riscv/Kconfig | 32 +++- arch/riscv/include/asm/page.h | 2 - arch/riscv/include/asm/pgtable-64.h | 2 + arch/riscv/include/asm/pgtable-bits.h | 8 +- arch/riscv/include/asm/pgtable.h | 45 ++++- arch/riscv/include/asm/sparsemem.h | 11 ++ arch/riscv/kernel/setup.c | 1 - arch/riscv/mm/init.c | 251 ++++++++++++++++++++++++-- 9 files changed, 354 insertions(+), 22 deletions(-) create mode 100644 Documentation/riscv/mm.txt create mode 100644 arch/riscv/include/asm/sparsemem.h -- 2.20.1