Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1118547rwi; Wed, 19 Oct 2022 07:00:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vcYo/5qJ5WgSkaM7951RWxzZWTZw3tPui3l2+xXAoH3cvEfKTL1cFoM4K8pKrZeEUlpby X-Received: by 2002:a05:6402:2686:b0:45d:82c0:c2b6 with SMTP id w6-20020a056402268600b0045d82c0c2b6mr7411566edd.390.1666188004618; Wed, 19 Oct 2022 07:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666188004; cv=none; d=google.com; s=arc-20160816; b=pqZUSRyR0C91IwtE33HWcx3JViTJoy2uDvELIQa+810TBW7rYyr+veYkhB4/azHL5L GJ0WOmJ4x6um/wya5UnBX9l8psWvT5yzgzBrBHLZEPd2jTbIumG+McqWZ9XHIpat1vou d+s62RFrRApEIA9t6v6vyZQSA9Ca47Zl9hjt1+vqj8LnnTtlDyhUZVAILHEUOu7og/2l ggx+BGOiBnuAexmTOiJCpUCttWqp2h5BFfYPbK2HE3g4iAxVsrKbM9uhsWWRAzxBD+88 Y6uYzgda6i905g8PdWcE1o0AhK1aiXEzQzF4TzZCa9ipSUSSnamOkO/1rRT/6EAFxWLG qPzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VDJV4ZwRVQLzE0DQMb9i2tBKWni84XeHMbgigRoQK/0=; b=ewfYlsSL/sXy2W9nithJCaWrfuKM6Sr0qZMy5n1IINUaus9wqUBgPLchoiZSMuj8xk M1RyYtpQtyNbIArKWMQBOPe4aOMaCC7eWcvEGAqdN2H1kdR1trmtSs7mmdeKNjp5a06f jjN6gSIri/zP384aVBgsJwytvwUSXjVwOZILUYh9smeCugrMYffu6L6gCFluo6DuokkG m2lx2j+sZUBIlOn80Khw2qJ3FfYpnKGs6pUj3izZCj7EBrRkx8bgjntEokVtCiDWPSQR DlWlsBzrey9WLAI/qlUMe0J6AUydTVAkTch26rG88+LCpfXlY35i/GgG6fVvwP2hCTJn 1TYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=i5xDygA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020aa7d515000000b004548a74553esi11705219edq.445.2022.10.19.06.59.38; Wed, 19 Oct 2022 07:00:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=i5xDygA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233351AbiJSMnk (ORCPT + 99 others); Wed, 19 Oct 2022 08:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbiJSMnK (ORCPT ); Wed, 19 Oct 2022 08:43:10 -0400 Received: from mail-vs1-xe2e.google.com (mail-vs1-xe2e.google.com [IPv6:2607:f8b0:4864:20::e2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1643B1285E6 for ; Wed, 19 Oct 2022 05:26:05 -0700 (PDT) Received: by mail-vs1-xe2e.google.com with SMTP id k6so17534467vsc.8 for ; Wed, 19 Oct 2022 05:26:05 -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=i5xDygA39ZiL6V5jYRwye8A2LIvzetB63vHUYOWr2BWrbkVbpO3pkBYH3R4AefnCMx ZNbUX/VDSAHFyP+aJFUhp8kECTdCKL05yrdADc5Ot3y93ZCkWLi6bUz897yCaExJx4Bw GajHfhrg155GES2wMaGWRDyc7m7ypTIovOPmMj54xOBMiXif0M/CdtpVVIQUvLy/fn08 sPTvrps9V+qBJWKON+saGrBa1E6W9gfWpnCme7jlICvN4pZt1r5D2/f11wkyaTBxjgSt JMW+2bKAdpbDrP7biq9KESues6HlMcwwOi9yTdA+K09/XvqaJMkHNQDM7av9zvcdDaap HhTA== 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=RxF4KFqd9kn75HPDGO3vbOtnv+mr/BoG6ahbiUWM1tzxXzLDT+4a9hzEnM0xBCK5kv jQdRkqUeMsX1ess69ghILvRhqquh9STBNEOJ3aKQuVZxViiZSiaN9ESiuMDrKwYJ0m20 XNMQrd8oC+V7AYiHKJay0ElPWnhRNW2g9bEq31lJysPqMXlrMSQLdpsgXD+Pq6i8QeYQ t0EUci8E5JHZk3AijJG1ZmrzlBpwNXyB81u0UvMfUIoiifF2Ayq4nEe5w/QIYow81YSP UaXq1qVNzOlE8F9gWqojMzIahEuvcFTLz6HPHKKeyLw4k+NEv2vrYGgBchTrO13ac35H nSNg== X-Gm-Message-State: ACrzQf3+DODh8fk5+HPN6bA10xzVkhiJFmeVUgoUvGo2Hb3p3O9iEjZw 5MvtrtsJBwGdyqPuozNUrBkb82rhNKWSDQ== X-Received: by 2002:a17:902:f78b:b0:17f:9c94:b247 with SMTP id q11-20020a170902f78b00b0017f9c94b247mr7851355pln.137.1666181817710; Wed, 19 Oct 2022 05:16:57 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id x7-20020a170902a38700b0017e93c158d7sm10529824pla.214.2022.10.19.05.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 05:16:56 -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 v3 3/4] RISC-V: Implement arch specific PMEM APIs Date: Wed, 19 Oct 2022 17:46:21 +0530 Message-Id: <20221019121622.179024-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019121622.179024-1-apatel@ventanamicro.com> References: <20221019121622.179024-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.34.1