From patchwork Sun Nov 12 06:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13453283 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 7C8ACC4167B for ; Sun, 12 Nov 2023 06:17:59 +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=aVqFx79qhs4SUASdCbVPlgjhGhyPSWtzS2eDbVK3hDo=; b=jqkQwxDjBvpt0i y5EsoOxp9uwxV5jNlc58RSMdrNUGcbjSPVZ//YhGqeVs36b5hvepTAfgHFWSJFelxNC32hoPxXkxs JqQuSvJG2hYFJuknewTi1VTQJVBIqX+r2FQEa9q21ZO+K2RAwDmXOepPivSsKbY7/9nef2zXyAYpW U4CWlx/MJzhjGiviwgfBhUqpnndULdMDE0uCnrrFyDN/VVuNL/qxMsmK3uRWUKdT/N2Gq+GKjUM3z fXl5JQYz9Lx83Y3vkglvGnFyqIxcUOoERZWdyUa8GEXq5R/zyGyyP6Qe6wTqaukSo2POXkaskFm4O XIjtnoL6kIFbZeAotGSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r23n9-00BkTc-20; Sun, 12 Nov 2023 06:17:55 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r23n4-00BkOD-0v for linux-riscv@lists.infradead.org; Sun, 12 Nov 2023 06:17:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A31ABCE0D85; Sun, 12 Nov 2023 06:17:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5A01C433D9; Sun, 12 Nov 2023 06:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699769867; bh=DJd0JPnD4tdXPL2F5/pVMn7+3pGHc/BdFV5e1StNJ0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3mYKvvVcCXgok8Svx8v4kF7mGHdEIkfptFpvN3AkwLdtO3ntnvI1tFetv8IzkGud QsqcEzsuLOpPvYOMq//OcMmUt1bX8nDoBgAPmTAQ3RWqjuHAZ6Dde0eSs6C2/y+VxI PDCLedfjiu12dGTFD/L2dYd544DJHkuziYtfgdvNe+TXgj8RPvV5f8jK6eJT4fAhxf aqzzh/LVK8k8ktL94w2cpBMh0gvgCZ0CJTHTeQQHWNyUaWzvHLESSAINDdDCvDxL1V uaLDgFyGRBaolDP18QX6VtyYB/IDSyturZGmHAbMRjanSPG5ujOcv/4DT0ZxwCN0zU kKb1zgIB6qstA== From: guoren@kernel.org To: arnd@arndb.de, guoren@kernel.org, palmer@rivosinc.com, tglx@linutronix.de, conor.dooley@microchip.com, heiko@sntech.de, apatel@ventanamicro.com, atishp@atishpatra.org, bjorn@kernel.org, paul.walmsley@sifive.com, anup@brainfault.org, jiawei@iscas.ac.cn, liweiwei@iscas.ac.cn, wefu@redhat.com, U2FsdGVkX1@gmail.com, wangjunqiang@iscas.ac.cn, kito.cheng@sifive.com, andy.chiu@sifive.com, vincent.chen@sifive.com, greentime.hu@sifive.com, wuwei2016@iscas.ac.cn, jrtc27@jrtc27.com, luto@kernel.org, fweimer@redhat.com, catalin.marinas@arm.com, hjl.tools@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Guo Ren Subject: [RFC PATCH V2 23/38] riscv: s64ilp32: Enable native atomic64 Date: Sun, 12 Nov 2023 01:14:59 -0500 Message-Id: <20231112061514.2306187-24-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20231112061514.2306187-1-guoren@kernel.org> References: <20231112061514.2306187-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231111_221750_500180_1BF052C5 X-CRM114-Status: UNSURE ( 8.42 ) 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 From: Guo Ren The traditional rv32 Linux (s32ilp32) uses a generic version of the lib/atomic64.c, which are inaccurate atomic64 primitives and couldn't co-work with READ_ONCE/WRITE_ONCE, atomic_8/16/32. The s64ilp32 could use native AMO instructions to implement accurate atomic64 primitives. Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/Kconfig | 2 +- arch/riscv/include/asm/atomic.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index f364d2436b1d..0fc03aa076e6 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -65,7 +65,7 @@ config RISCV select CPU_PM if CPU_IDLE || HIBERNATION select EDAC_SUPPORT select GENERIC_ARCH_TOPOLOGY - select GENERIC_ATOMIC64 if !64BIT + select GENERIC_ATOMIC64 if ARCH_RV32I select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY diff --git a/arch/riscv/include/asm/atomic.h b/arch/riscv/include/asm/atomic.h index f5dfef6c2153..8f6579b33ecc 100644 --- a/arch/riscv/include/asm/atomic.h +++ b/arch/riscv/include/asm/atomic.h @@ -16,6 +16,12 @@ # endif #endif +#ifdef CONFIG_ARCH_RV64ILP32 +typedef struct { + s64 counter; +} atomic64_t; +#endif + #include #include