Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5750861img; Wed, 27 Mar 2019 14:39:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBXiPCzQv8e//pKAkUgKxSgoJ8Q9Y0uMaVvKPKc/oBv30+umflWa71Y4fCMhkO+LSgPEf6 X-Received: by 2002:a62:59cb:: with SMTP id k72mr38530872pfj.111.1553722778014; Wed, 27 Mar 2019 14:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553722778; cv=none; d=google.com; s=arc-20160816; b=YbI+itV81OEhYIZMG12I1eUjcUQ4VZ9iNTGQAGgfKfUmqTwmMxDXe0tf2Rs5O62CTJ YenOL5B7Lms/SBEkk2YMk9Ux7FIgLoqW1egDptijsvEBioeOTUKJ+JHfwbS6tZcAJQbW Z13ycd7AOgoekLxaAR97YDKVeYido8wBDu/cz+Co9CE8AixvBxPC2TDpL+qpQmZlxhlE uWb4yTjJ7eLlc3OZmyc/6cvtGSrHZ4CMRdRNXswZbJ3PPYruHbuS2EBs4pn5fGcjuLE6 ImOUa2wk1JqPh9e2CkZqoXHAxeLLWN/KzH6MRZErKgKcRKB10nkSz1pCPdoX9OlnnGcC fnqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:message-id:date:cc:to:from; bh=TkegfcYD1/Xgw1OslbsBJ/34KeXl4jh387LJ/XH82ds=; b=DHqBDbh19zbeSda4PipFpQmncCONUXP4GAsEkp1jRLeS6GIULwuIuEHgLd/4AX5FIP s8K5D4NnkOxzC2P190Q5Re5yLHSi/KxmZZNxFWAbJdkJO/Ky4SiKQeNgr3EqT4tCzNr4 rq2Ogmv8YtZYNN3EpL6TSrIMakLdWX9EQAEELDYGBYuqGKnMC5iq3M04PfaQNBivdAHF 1qC57IA2fNamGirqY1sP0CvklkjjdUhtGGMnjTg4k4HXVPCJic+r4XvX4Zsn54PWxbBO oyNvwUfEQpxqDDOhqz25IZ6svlmGJmGMg4M8/B+g0wMw9XLKYovB3dCtIQAHl4wxbprM lvdg== 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 o6si18136354pgk.470.2019.03.27.14.39.22; Wed, 27 Mar 2019 14:39:38 -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 S1730302AbfC0VhT (ORCPT + 99 others); Wed, 27 Mar 2019 17:37:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:58638 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfC0Vgt (ORCPT ); Wed, 27 Mar 2019 17:36:49 -0400 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 Cc: Stephen Bates , Palmer Dabbelt , Christoph Hellwig , Albert Ou , Logan Gunthorpe 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 Content-Transfer-Encoding: 8bit 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 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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