From patchwork Wed Oct 19 13:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13011734 X-Patchwork-Delegate: palmer@dabbelt.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23C61C433FE for ; Wed, 19 Oct 2022 13:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2Q2Y0nIvGZMIYyBlQQxttuUcoO/KulKtt93DfaUDrRU=; b=PlE39DRwdvH9UO Afdszp8ASVLzDLzhUjjyA70j4mwY8Uxr5LlCuqxifbqk5S6S9LGi/ory0x4T6K9OpTdLpbHCPVK3L gvA1ss3IL96dbW7LBnb4HojmKbWYEVPIe12akJLR+uvY2OLA+vWrHae7KKCh+RxheXKylHDURff2Z in+em6C+0rYSmHh/Ms4C1/dTOEqy6ym9s8KMsazXLSI3IdZFBRQP6oueyxwqqVusAg2W/kLQkwsJu dj+tu6gnJnty52r8hcrEQflvGB+2G/Qgiu3yAts+KNWU+xEzKoXVcYu+LhUMrycjOyem04FNsp+v7 Ake8naAidbq35BUAIc9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rL-0023mU-DW; Wed, 19 Oct 2022 13:11:47 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rI-0023iz-3u for linux-riscv@lists.infradead.org; Wed, 19 Oct 2022 13:11:45 +0000 Received: by mail-pl1-x633.google.com with SMTP id l4so17198793plb.8 for ; Wed, 19 Oct 2022 06:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rh1RnpsntJfELASsE5PqiwcPYKRcDpF732XU4z7NxZA=; b=Wcyhp1LTucgrnH6f1PPH+sYeTNlqJGZ0rALt4DLvQwuGHO8D3wJ5CNzyJRYu7X9Ke/ MbTeah1+aXgUqp8DjaId+4YLIm1qTyJJwoP0gsjFnrHELrXE4VP18rsyQ42+siIw+Nic k+zMguu48+H+c6VfVVcl31JGio6i8qBgk67cNpJzvi3HPQKTTzr/zV0Ivi3drxqtYeyo xj5YK9j7ijzFamxSrgSlT11MEm+8b57VTmuhP03hBoOtKCc6/K1Mi4nHb1UnXqfVsytQ J0dCBVWqSEpKr/dh1D/5iLLtv9KzGZbaHUkcwPdiYZpsLO5kc/pl9I1r4/RekkVHkpDd L7TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rh1RnpsntJfELASsE5PqiwcPYKRcDpF732XU4z7NxZA=; b=rbv79J5Ae5Ci5dMe1kUg58BaDMOIHDDNPYcQqUn7Wr+GT6+Bo+2Oh4MkR8s49/hKKT KxNkF+8j7tEYjP1x3sjy6O/Om3TBLpYz0rLRy/396j3QgH0dcyqHf9NFe2zThsk0ctBE TNxKvl4YBwqpZl927LZ0VzRCi8+JXwaYDnQZF78LVtETErQzxuNyX5zHKVw0D8yJDmMM T5shfYS4UNqgxmCJHABD2scSPygnezSCRaHN6BIQy1m3crxEiDTl/u7Yj4x13L+uNKJ4 UH/oRXioG+y3FzWTIWcf7jt4esxaKlFdWWHjYFoMFwv4V3bsOQLCxAMxmpkXaCbkFwnX CXwQ== X-Gm-Message-State: ACrzQf36GTTVJ5IMtQINafpM8k2FdK2eiF2JFnEid2InzBE2IXk51F6E B4zjWPagqv0YKJDqv4DVR6yEkg== X-Google-Smtp-Source: AMsMyM5j2KNFBxA0GI0r4MduZGS0UbOsphNFcYq8wO1rsumCE/NJvbri3qEnJlmvINFPkEnW7CAh0A== X-Received: by 2002:a17:90b:128d:b0:20a:da54:788 with SMTP id fw13-20020a17090b128d00b0020ada540788mr9966123pjb.65.1666185101695; Wed, 19 Oct 2022 06:11:41 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b00172897952a0sm10934478plc.283.2022.10.19.06.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:11:41 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Jones , kernel test robot , Anup Patel , Conor Dooley Subject: [PATCH v4 1/4] RISC-V: Fix compilation without RISCV_ISA_ZICBOM Date: Wed, 19 Oct 2022 18:41:25 +0530 Message-Id: <20221019131128.237026-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019131128.237026-1-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_061144_192694_C40CFC1F X-CRM114-Status: GOOD ( 16.22 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Andrew Jones riscv_cbom_block_size and riscv_init_cbom_blocksize() should always be available and riscv_init_cbom_blocksize() should always be invoked, even when compiling without RISCV_ISA_ZICBOM enabled. This is because disabling RISCV_ISA_ZICBOM means "don't use zicbom instructions in the kernel" not "pretend there isn't zicbom, even when there is". When zicbom is available, whether the kernel enables its use with RISCV_ISA_ZICBOM or not, KVM will offer it to guests. Ensure we can build KVM and that the block size is initialized even when compiling without RISCV_ISA_ZICBOM. Fixes: 8f7e001e0325 ("RISC-V: Clean up the Zicbom block size probing") Reported-by: kernel test robot Signed-off-by: Andrew Jones Signed-off-by: Anup Patel Reviewed-by: Conor Dooley Reviewed-by: Heiko Stuebner Tested-by: Heiko Stuebner --- arch/riscv/include/asm/cacheflush.h | 8 ------ arch/riscv/mm/cacheflush.c | 38 ++++++++++++++++++++++++++ arch/riscv/mm/dma-noncoherent.c | 41 ----------------------------- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index 8a5c246b0a21..f6fbe7042f1c 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -42,16 +42,8 @@ void flush_icache_mm(struct mm_struct *mm, bool local); #endif /* CONFIG_SMP */ -/* - * The T-Head CMO errata internally probe the CBOM block size, but otherwise - * don't depend on Zicbom. - */ extern unsigned int riscv_cbom_block_size; -#ifdef CONFIG_RISCV_ISA_ZICBOM void riscv_init_cbom_blocksize(void); -#else -static inline void riscv_init_cbom_blocksize(void) { } -#endif #ifdef CONFIG_RISCV_DMA_NONCOHERENT void riscv_noncoherent_supported(void); diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 6cb7d96ad9c7..57b40a350420 100644 --- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -3,6 +3,7 @@ * Copyright (C) 2017 SiFive */ +#include #include #ifdef CONFIG_SMP @@ -86,3 +87,40 @@ void flush_icache_pte(pte_t pte) flush_icache_all(); } #endif /* CONFIG_MMU */ + +unsigned int riscv_cbom_block_size; +EXPORT_SYMBOL_GPL(riscv_cbom_block_size); + +void riscv_init_cbom_blocksize(void) +{ + struct device_node *node; + unsigned long cbom_hartid; + u32 val, probed_block_size; + int ret; + + probed_block_size = 0; + for_each_of_cpu_node(node) { + unsigned long hartid; + + ret = riscv_of_processor_hartid(node, &hartid); + if (ret) + continue; + + /* set block-size for cbom extension if available */ + ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); + if (ret) + continue; + + if (!probed_block_size) { + probed_block_size = val; + cbom_hartid = hartid; + } else { + if (probed_block_size != val) + pr_warn("cbom-block-size mismatched between harts %lu and %lu\n", + cbom_hartid, hartid); + } + } + + if (probed_block_size) + riscv_cbom_block_size = probed_block_size; +} diff --git a/arch/riscv/mm/dma-noncoherent.c b/arch/riscv/mm/dma-noncoherent.c index b0add983530a..d919efab6eba 100644 --- a/arch/riscv/mm/dma-noncoherent.c +++ b/arch/riscv/mm/dma-noncoherent.c @@ -8,13 +8,8 @@ #include #include #include -#include -#include #include -unsigned int riscv_cbom_block_size; -EXPORT_SYMBOL_GPL(riscv_cbom_block_size); - static bool noncoherent_supported; void arch_sync_dma_for_device(phys_addr_t paddr, size_t size, @@ -77,42 +72,6 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, dev->dma_coherent = coherent; } -#ifdef CONFIG_RISCV_ISA_ZICBOM -void riscv_init_cbom_blocksize(void) -{ - struct device_node *node; - unsigned long cbom_hartid; - u32 val, probed_block_size; - int ret; - - probed_block_size = 0; - for_each_of_cpu_node(node) { - unsigned long hartid; - - ret = riscv_of_processor_hartid(node, &hartid); - if (ret) - continue; - - /* set block-size for cbom extension if available */ - ret = of_property_read_u32(node, "riscv,cbom-block-size", &val); - if (ret) - continue; - - if (!probed_block_size) { - probed_block_size = val; - cbom_hartid = hartid; - } else { - if (probed_block_size != val) - pr_warn("cbom-block-size mismatched between harts %lu and %lu\n", - cbom_hartid, hartid); - } - } - - if (probed_block_size) - riscv_cbom_block_size = probed_block_size; -} -#endif - void riscv_noncoherent_supported(void) { WARN(!riscv_cbom_block_size, From patchwork Wed Oct 19 13:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13011738 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEE7CC433FE for ; Wed, 19 Oct 2022 13:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mJBy8ltRTTAUF7rWJXdDg0yQ1OeE385ToQCxiGUYfZ4=; b=lsytr6L7gOGGWd W1ydXaGIHafslZAvJWww8RCVOqZUIsJZ5krtBXcY1M2yOPYet7rEh5xDiR84Lm409w6nusnRObJP5 QQDhBc5j3MPh93bQpIMTHG0HPBdMK5EE9lGqCZWR4Ah/hdvCwJL+GW1czbrtrgYmi1fgUwTdIxNkq 4gtVHV+ZNeg0ROsrxf0wSX26AMhpfECM6rHwSizY88nv9KH4KetTzVJxLKPp/E2OP4/PA/+C5Wn2e v7Xix9wKBgRRNCCmyXkRDbtwwVebetgVtGdLokDvJqzMeDtuzuiWIBDAWahzOKKVCuQDV/EtXwE7K Q0rafrccktddGFX9L5qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rZ-0023uv-OZ; Wed, 19 Oct 2022 13:12:01 +0000 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rX-0023rX-CS for linux-riscv@lists.infradead.org; Wed, 19 Oct 2022 13:12:00 +0000 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1322fa1cf6fso20542372fac.6 for ; Wed, 19 Oct 2022 06:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vAvEVwdPVzOcq2kBtufcX9nitBNib2gQ4gtkOEEFeSI=; b=lxyzgM77oVhyr2xYFxJj6wgQvry6rw4Y/+zIvaG6JfmYtSzQ+X/1aPsePwBNrnegwI UrY3/A1/YLrrc1SIB0jp8+zD7aA98y9QtCArUpqYXnMw5Dl6VWnG3iDZuyf1BgGGohqT 1l9CyxXHnpqjwurbYuT9nD7l0kpliUcju0mwn+yFEAvwgXbH6lu8+EDbPW1ou1EWw4d0 i8arRfQLRw/k0jmr0IQml/LWHNUCdyXuEptr8wqAxovxLLP0t6dVC1zBEVwFmRU6HrPR foFXA9X8UDYRdXrxUc+XpDAQmh4P+zLMHzd7Q4Ct6xrxImFMYovLYXg9s6KdCxtlBdrg 3gMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vAvEVwdPVzOcq2kBtufcX9nitBNib2gQ4gtkOEEFeSI=; b=vfoecwq4MmItTgZrNoDgTIlHVKRijQORUkOP9gUWbxON/K3EMRzd/u8AXaNNUVBbgG n8eNom9mYkA+BSEt+kbsgGpGgrGTf2BAMr8ERxZlwgs8Koj+VdqWOsaeT7432WHQOvZP +lBKY7d6xEeB1BIZqQ0nrD0CxGxBs7ZCzaTCUztI3/29VTWPlHfTk+fUGJDR/d5wsfXQ Ad5TG6NeWAKLnc7xyIxJg0JPsB3qWUvwyMGi3LBRYFaLPuq8vGq18+d/IFI+HXszP5p/ VkwkHKczvHK7wCW5E+gc14T+ATbEO7/PZqqkHHOS4yt9uOY+rH8Jan/mxKozbToa9FK2 5JjQ== X-Gm-Message-State: ACrzQf1/eVcV841AjUQYZNz8Ym+yB2KMtBxTBocqm5cYOEBoVE0hWLnQ uykZTNaVq2gV1Lq5MHhQh0TSfa7ZKxMQCg== X-Google-Smtp-Source: AMsMyM6ea6y78yP7zvn7fmEDAEjq1F7za/6iBEos6YJxPN0ITU1VfQyHOKcpYsTQpoGZjSvFb+JmVQ== X-Received: by 2002:a17:90b:4c52:b0:20d:7917:4cb3 with SMTP id np18-20020a17090b4c5200b0020d79174cb3mr45614039pjb.6.1666185105397; Wed, 19 Oct 2022 06:11:45 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b00172897952a0sm10934478plc.283.2022.10.19.06.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:11:44 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Mayuresh Chitale Subject: [PATCH v4 2/4] RISC-V: Fix ioremap_cache() and ioremap_wc() for systems with Svpbmt Date: Wed, 19 Oct 2022 18:41:26 +0530 Message-Id: <20221019131128.237026-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019131128.237026-1-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_061159_431700_F3C65AE1 X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Currently, all flavors of ioremap_xyz() function maps to the generic ioremap() which means any ioremap_xyz() call will always map the target memory as IO using _PAGE_IOREMAP page attributes. This breaks ioremap_cache() and ioremap_wc() on systems with Svpbmt because memory remapped using ioremap_cache() and ioremap_wc() will use _PAGE_IOREMAP page attributes. To address above (just like other architectures), we implement RISC-V specific ioremap_cache() and ioremap_wc() which maps memory using page attributes as defined by the Svpbmt specification. Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support") Co-developed-by: Mayuresh Chitale Signed-off-by: Mayuresh Chitale Signed-off-by: Anup Patel Tested-by: Heiko Stuebner --- arch/riscv/include/asm/io.h | 10 ++++++++++ arch/riscv/include/asm/pgtable.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h index 92080a227937..92a31e543388 100644 --- a/arch/riscv/include/asm/io.h +++ b/arch/riscv/include/asm/io.h @@ -133,6 +133,16 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw()) #define outsq(addr, buffer, count) __outsq(PCI_IOBASE + (addr), buffer, count) #endif +#ifdef CONFIG_MMU +#define ioremap_wc(addr, size) \ + ioremap_prot((addr), (size), _PAGE_IOREMAP_WC) +#endif + #include +#ifdef CONFIG_MMU +#define ioremap_cache(addr, size) \ + ioremap_prot((addr), (size), _PAGE_KERNEL) +#endif + #endif /* _ASM_RISCV_IO_H */ diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 7ec936910a96..346b7c1a3eeb 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -182,6 +182,8 @@ extern struct pt_alloc_ops pt_ops __initdata; #define PAGE_TABLE __pgprot(_PAGE_TABLE) #define _PAGE_IOREMAP ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_IO) +#define _PAGE_IOREMAP_WC ((_PAGE_KERNEL & ~_PAGE_MTMASK) | \ + _PAGE_NOCACHE) #define PAGE_KERNEL_IO __pgprot(_PAGE_IOREMAP) extern pgd_t swapper_pg_dir[]; From patchwork Wed Oct 19 13:11:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13011736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D608BC43217 for ; Wed, 19 Oct 2022 13:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8R0n0GPtEX0PNmePzPYFBQOKR/X+TTGgyZNOfkcDrzU=; b=NjmVFbcUphPO3f nRSP7IukkPtaozAnmM+L/GoPviad7CHWfT9zMBhnDuvt1bqKodnMoTUfD2UeziVYRe+ne4HP1PJb9 nnHg0bNki7XovM/zTHbIMmFWUNTn+8tHREXbVfYnilE0f6/RYr7Uq/V0Zopfg5HCDej0vgxfcHhyR 6OjsUeAyr9SO/ngo6sWj1bc4Xcl4GB3EfqUbEfv4robLQYFOQLjkXNc5SWH+O+p3L8ZDho2HS/ybj Vq/TAM2CjmCuKkgUZP063EjC/vtIbHz33DIwbJGOT7YmYtc/8sY6b0godrV5DVhTwV8QUiEGVpzny bLthkV8MVGg3z9G41mBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rR-0023pj-Or; Wed, 19 Oct 2022 13:11:53 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rP-0023nG-3I for linux-riscv@lists.infradead.org; Wed, 19 Oct 2022 13:11:52 +0000 Received: by mail-pg1-x52f.google.com with SMTP id r18so16190615pgr.12 for ; Wed, 19 Oct 2022 06:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VDJV4ZwRVQLzE0DQMb9i2tBKWni84XeHMbgigRoQK/0=; b=HOkyp3/fLEtCt1yCpma/EVhFQK4FgiHrDx/1YMPDwT9KQrXtZ0+DK7VA6GhN48oRWA 4sG0ELlR4Xx5kFHMLD3IcKQgSiGxSCIYHNPRD6e781OBC4699iRbnlkAlAhprF0gqYki acC7BoHMX02nQX6Pt26dFyxXVI1LBAdKELJ09Ghl43yGZrR73a3ii+p3UpqdhnFHmDS3 0XiS8j+aXMQi6uBmUu0KnVCdN4N4RavsAQEqNU8PGVb2bh7fmWtfDPDtsrXzpGkESvGd aZAwD7ULTmeuMDJfShrg4v3kG6qvCUAGwnSOXlqQ+x8M/tR8DDnBRCjDLrLCFOns0lYR HzVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VDJV4ZwRVQLzE0DQMb9i2tBKWni84XeHMbgigRoQK/0=; b=M4DyANgnFbC/4gA1UNVl/Hv9qNMpMa+CGjLZYpOzBTXEodLMrc+VUbGilC/bjmt7/O /4z75DOc42MOmGw1V66vDXNucyuGMFMAwb9p+DmR/G4xu66hDaXj2nfGUeL0vhOGUDf7 vvWl2Mb+8klObzTq5gLailpChYFMd3aluzpxg++2N9kHwGhS7NpydQ6g3eRuAstgicb3 6JMbJQ+4vGvwPbtVitRA5q02vnRI/Jm3sDc8nYONozmsqDaI9TJ8XA75lP0n3EJRocfO 5LHjHWgkPk3WLIo3qPj2hu5Ln4zThWclOHbDC8nUI3QrsaYPg7WmyIOcI+kKHI3Hf/17 R7Zg== X-Gm-Message-State: ACrzQf3h+E+Gmh2Cp3hFfNy/8fSoicv6coFnNQD8J0BbCPdNo4M7rYhR 7fBS14pKqFzU7gDjW5RIyARQUQ== X-Google-Smtp-Source: AMsMyM798d6sCpUdCwQ/ecSIilfJZ6v86SVZw+SrASHeVBqUCbXn5DWhzpkIIEZcuJRhURHhRtRArA== X-Received: by 2002:a65:6b81:0:b0:461:4049:7df7 with SMTP id d1-20020a656b81000000b0046140497df7mr7235376pgw.593.1666185109034; Wed, 19 Oct 2022 06:11:49 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b00172897952a0sm10934478plc.283.2022.10.19.06.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:11:48 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Mayuresh Chitale Subject: [PATCH v4 3/4] RISC-V: Implement arch specific PMEM APIs Date: Wed, 19 Oct 2022 18:41:27 +0530 Message-Id: <20221019131128.237026-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019131128.237026-1-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_061151_149785_A3EC7CA7 X-CRM114-Status: GOOD ( 13.91 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The NVDIMM PMEM driver expects arch specific APIs for cache maintenance and if arch does not provide these APIs then NVDIMM PMEM driver will always use MEMREMAP_WT to map persistent memory which in-turn maps as UC memory type defined by the RISC-V Svpbmt specification. Now that the Svpbmt and Zicbom support is available in RISC-V kernel, we implement PMEM APIs using ALT_CMO_OP() macros so that the NVDIMM PMEM driver can use MEMREMAP_WB to map persistent memory. Co-developed-by: Mayuresh Chitale Signed-off-by: Mayuresh Chitale Signed-off-by: Anup Patel --- arch/riscv/Kconfig | 1 + arch/riscv/mm/Makefile | 1 + arch/riscv/mm/pmem.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 arch/riscv/mm/pmem.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6b48a3ae9843..025e2a1b1c60 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -25,6 +25,7 @@ config RISCV select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB + select ARCH_HAS_PMEM_API select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP if MMU select ARCH_HAS_SET_MEMORY if MMU diff --git a/arch/riscv/mm/Makefile b/arch/riscv/mm/Makefile index d76aabf4b94d..3b368e547f83 100644 --- a/arch/riscv/mm/Makefile +++ b/arch/riscv/mm/Makefile @@ -31,3 +31,4 @@ endif obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_RISCV_DMA_NONCOHERENT) += dma-noncoherent.o +obj-$(CONFIG_ARCH_HAS_PMEM_API) += pmem.o diff --git a/arch/riscv/mm/pmem.c b/arch/riscv/mm/pmem.c new file mode 100644 index 000000000000..089df92ae876 --- /dev/null +++ b/arch/riscv/mm/pmem.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#include +#include + +#include + +void arch_wb_cache_pmem(void *addr, size_t size) +{ + ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size); +} +EXPORT_SYMBOL_GPL(arch_wb_cache_pmem); + +void arch_invalidate_pmem(void *addr, size_t size) +{ + ALT_CMO_OP(inval, addr, size, riscv_cbom_block_size); +} +EXPORT_SYMBOL_GPL(arch_invalidate_pmem); From patchwork Wed Oct 19 13:11:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13011737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF06AC4332F for ; Wed, 19 Oct 2022 13:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VAG6PNjIYmLqTuGIeOwVsF8LbJffHJHY9dL/+kAaDEs=; b=NaG8/dOmhgk887 PAaF6d0TdZ77SdUJq9Y5q434tvx8EtlkYvhwlA+7uAzeZhGdrk/6oj5zrn+iumWxi56O+pG/8TWhz HvdLWNtzZWgydXEieJFdsoygarLCilrvmuLhpT5wgGPirbU6W1tvxHM1Mdf7VXulkGnaA4x147BA+ bKbJM5TjYWIlLUS6iXbprTMveHI8DiWzxucGLFkk+kOgUgnSUa4W0uXb9FxpISffHwUkKa8Qk1Vs9 yVumNG3uXVzM9TQWUzxM8t8qu+z+jWLaEidb3RmttAWOWucH0sr2QX0SaoUBgf4YO9rnaXH6pPb2J yo0yvUzuWPYE9j9reQBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rW-0023sh-7h; Wed, 19 Oct 2022 13:11:58 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ol8rT-0023pT-6i for linux-riscv@lists.infradead.org; Wed, 19 Oct 2022 13:11:56 +0000 Received: by mail-pj1-x1034.google.com with SMTP id o17-20020a17090aac1100b0020d98b0c0f4so18988719pjq.4 for ; Wed, 19 Oct 2022 06:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5TnLW0RVC/l/l6ZpSJGiQ9RS55Sh7Bww2u/zF6eZ2bY=; b=KVQYSnSwQFUiWWTDWziioJ8nATp3sFAA9sevKxCqCpQA/HkYqlZHsnoYXNx+Yg89JW ADG9MTT0eSgkBbdG4uNIHC0BxS6IlVAb0qXbDZVALJfkPpzjOxQ9HZImQWkLXn0lCImH B8I/RGkuYTGQ4oHXovOjUyfU12eWG8ApR2HNPlOZM+afMaQZxDgYdv2/eNG8XP0kg1WU MlmG+k+QdUIjiFsM8FlM0txbeRzB/ckeVWjS+nO3RKWD5gEtsLHS0uEnD+NYcTru45o/ 48Hwnn0X1r81gKz0TrPhcqp44nRpbh2ehIg6SW3Loxto5vQvZDkyKsNqMD+b3ZxODu76 9l9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5TnLW0RVC/l/l6ZpSJGiQ9RS55Sh7Bww2u/zF6eZ2bY=; b=cUUAm9P0cx+FT8/rIXNnzWdKpO74eoh9uqemQfI18cj0KVcMgpzBg2Gjw3TMH7kAiA wGGhUmoPnPLn/D/SycNzKOWVuTPrieHL5CUhlAqQtFFemXyKuwJArmNNgLEoeeHuMwrX eYujBD88P3GZWKxjZqmpQykW633v0o6nvDB8Ya4kE0ljPKOenMtFmO3QhTaNIEXHiGcy KrGiIX3nILBUzSj6fQJ+FGgdMJiFgqRM9jxRjja+Qns66OQKH3twrZdrwTQp35oT86Vh FMy2rc6py5Z+WzAMxFxQKC1zzQMwWw2rGsSfzaFvLbnTfKgAxyZxNXswZbWGGsvL2wLW 1dyw== X-Gm-Message-State: ACrzQf3Fh998tc9reTtuDurX4GEzwv9xNMoQEUjwVVEiAs7N6y7vgb1L 2/Os7aQt27ZEDxaCnTH/WogGHA== X-Google-Smtp-Source: AMsMyM4jEiN+8su71k6+cb/emSNBAIxNnD4Cx9I5sby2nXpdtW41N7UtPPhg792GaGcgy9DpernSOw== X-Received: by 2002:a17:903:41c3:b0:17f:8def:dc92 with SMTP id u3-20020a17090341c300b0017f8defdc92mr8326965ple.7.1666185112189; Wed, 19 Oct 2022 06:11:52 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id n12-20020a170902d2cc00b00172897952a0sm10934478plc.283.2022.10.19.06.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 06:11:51 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v4 4/4] RISC-V: Enable PMEM drivers Date: Wed, 19 Oct 2022 18:41:28 +0530 Message-Id: <20221019131128.237026-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019131128.237026-1-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_061155_252644_692B4D73 X-CRM114-Status: UNSURE ( 7.57 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We now have PMEM arch support available in RISC-V kernel so let us enable relevant drivers in defconfig. Signed-off-by: Anup Patel --- arch/riscv/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 05fd5fcf24f9..462da9f7410d 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -159,6 +159,7 @@ CONFIG_VIRTIO_MMIO=y CONFIG_RPMSG_CHAR=y CONFIG_RPMSG_CTRL=y CONFIG_RPMSG_VIRTIO=y +CONFIG_LIBNVDIMM=y CONFIG_EXT4_FS=y CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_EXT4_FS_SECURITY=y