Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5433907rdb; Sun, 31 Dec 2023 00:31:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyi8KlNlbaXMkF6nx9UzGZoriRZVMwOdu3BqRd8nXtJmuG3Z/CLc2zyzDEhll9oX1PmK5+ X-Received: by 2002:a05:6a20:7483:b0:196:df80:ab9d with SMTP id p3-20020a056a20748300b00196df80ab9dmr1034919pzd.76.1704011473399; Sun, 31 Dec 2023 00:31:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704011473; cv=none; d=google.com; s=arc-20160816; b=jyBvds1PU2Fnwg8g1yqYZyuXAy29apsE7bWECC3VSWpL30FcXpdf1n7Ih2pYWxI8fQ 4denWvWH9YKkJYYHS8HRxboBcrdUugJG4ozSaQMoB1wtsWoTmpczw5glY8n3LHvnhOgq 5imTbnUxtQ0DWhIfAi3Tv8BfpnWwSh/1E/movvZt2PcCP521COo4EGcRpYQj2872Oj68 avpuDKjuieTTwZPoKUEqEqVqgTTVPCLO0xzw5CPKE+XI4eELfYMSsl+dlBYHkOBKOs+I pt2uQ4g2RltKBcOeIdKkMnLlAdy05G6Ga8TdSKAMHktRKxHUXqk+RfbyR67NmrZb84Kw 7zGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Nz7CIG6pduiVe24ADMOGO4P+ttlMk1mFOo1jePLewb0=; fh=8az2WX9seVnlqIwzdvRsfDVjT91R5QAYA+cOijWi0GY=; b=BW8ZTNdketZZNGxwBijA/qr/JaMcrxA7SLzZQ5cnIbOIj255WS3NdjEEchB+1Mn8sg JD2mu0ab4P2Ct9kosVXEf6cq4C06yhZ7GDUKM5WCRbreQP0cDhVoDPJ6DFpz5W2eddPs RZacxt0yXjnWy+SfWxg3s3MZtuZ8yQDalrb/oFOFwy+CI2fNm0oDMDKEUj6gC/kRvcBl J7kZRgfjnVlPw60HHHDKgTfMu2w+9BmxFBAFFU41a4roNFlX5PHrVtIOc4ysewnhIPYZ d9brc2McAPCpe2UTuL2hJgQaAjfwo7yofjNhosFvxjdliyRMtzD/X0Sp3ASiRSkyz2yM LzMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pV/cfNnl"; spf=pass (google.com: domain of linux-kernel+bounces-13653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ck4-20020a056a02090400b005cd8367f8b7si14553834pgb.288.2023.12.31.00.31.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 00:31:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pV/cfNnl"; spf=pass (google.com: domain of linux-kernel+bounces-13653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 59102B21B88 for ; Sun, 31 Dec 2023 08:30:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D00E9CA49; Sun, 31 Dec 2023 08:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pV/cfNnl" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1388FC8D5 for ; Sun, 31 Dec 2023 08:30:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B8B8C433C7; Sun, 31 Dec 2023 08:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704011418; bh=D6VXuRwAKv9dO+mNmqMLcBG3Fo8hoXZOx0qi+4o2+wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pV/cfNnlutV5oJo3GVEF+qPX7SM5xqctJKNU2amJ7TJU4IOiq3JWRgdUT3zEA+zi6 yA+d+w+GWovK1mBnqsKKPAxRFaGoEXNANQwL9/HeB2MfY2USxVQhZJ8gxA11tPd/ue ATpwZ1PQR5TOJg2o5rIlKdnu3JGH35NPy7eQ+GPyknwR0xYo7c8BwjD5fehnihnKCX T02m2Cg1NosuM5VC+Kz+A4jl4He+Eq8Jc6iqdT4m572jiZKEeAE+S8eMqhezNpsHe8 dHtKfAfC7klMoG5W7b00l4uXr43yVa8nE9paBEU8WFl2azCTQsVJosZ64QKwWKcfAX iJLa9KiKs6u5w== From: guoren@kernel.org To: paul.walmsley@sifive.com, palmer@dabbelt.com, guoren@kernel.org, panqinglin2020@iscas.ac.cn, bjorn@rivosinc.com, conor.dooley@microchip.com, leobras@redhat.com, peterz@infradead.org, keescook@chromium.org, wuwei2016@iscas.ac.cn, xiaoguang.xing@sophgo.com, chao.wei@sophgo.com, unicorn_wang@outlook.com, uwu@icenowy.me, jszhang@kernel.org, wefu@redhat.com, atishp@atishpatra.org, ajones@ventanamicro.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren Subject: [PATCH V2 2/3] riscv: Add ARCH_HAS_PRETCHW support with Zibop Date: Sun, 31 Dec 2023 03:29:52 -0500 Message-Id: <20231231082955.16516-3-guoren@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231231082955.16516-1-guoren@kernel.org> References: <20231231082955.16516-1-guoren@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Guo Ren Enable Linux prefetchw primitive with Zibop cpufeature, which preloads cache line into L1 cache for the next write operation. Signed-off-by: Guo Ren Signed-off-by: Guo Ren --- arch/riscv/include/asm/processor.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index f19f861cda54..8d3a2ab37678 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -13,6 +13,9 @@ #include #include +#include +#include +#include #ifdef CONFIG_64BIT #define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1)) @@ -106,6 +109,19 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset, #define KSTK_EIP(tsk) (task_pt_regs(tsk)->epc) #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp) +#ifdef CONFIG_RISCV_ISA_ZICBOP +#define ARCH_HAS_PREFETCHW + +#define PREFETCHW_ASM(x) \ + ALTERNATIVE(__nops(1), CBO_PREFETCH_W(x, 0), 0, \ + RISCV_ISA_EXT_ZICBOP, CONFIG_RISCV_ISA_ZICBOP) + + +static inline void prefetchw(const void *x) +{ + __asm__ __volatile__(PREFETCHW_ASM(%0) : : "r" (x) : "memory"); +} +#endif /* CONFIG_RISCV_ISA_ZICBOP */ /* Do necessary setup to start up a newly executed thread. */ extern void start_thread(struct pt_regs *regs, -- 2.40.1