Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5800631rdb; Sun, 31 Dec 2023 18:29:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOoO1f4Dxodoir11QC3QcCJFHpee4aN+HuGk4AhBj90WbKm3ikSvO2nvyEVA8PLsd5QX5Y X-Received: by 2002:a05:6870:2307:b0:203:f6b9:993e with SMTP id w7-20020a056870230700b00203f6b9993emr19421795oao.96.1704076181549; Sun, 31 Dec 2023 18:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704076181; cv=none; d=google.com; s=arc-20160816; b=joLWQSwkcTiZWBC7Nu9BmbMnYgXA/GbOfL9XJ7rfsOsUPtj52/tomR/EYwGDFt4BBK 3zweq4wnAGEM69WA6RVrAv3UJeysMUlHpdcWSy4K/WUx/n7WtN1ZT/emq3jVDmVa9tov rllv8Ohu8EVKLDnhF5WUo0LbNS24t6ZNOd9vlwqXm4C7+MxmI4z3VZ79DzYkXTdhBG6E jcW6Ew6x4/SnIy3I+3Tztnhq7crjAe2+UVwNb09a1H+5BYpZvfeaABYBHWNm+ms9lQFC nrlmVA7bZlsEfRM1S2VrBDK9K+DYW6qFV8UnFp//x1FBwG5Mr6S0mpNPmNbZtsaqhNBo x3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=x2aVX51lW+dvIO5nB9A/N93GfRhDbWP693EMwsqcYM4=; fh=8az2WX9seVnlqIwzdvRsfDVjT91R5QAYA+cOijWi0GY=; b=Ajra+dsczoqLIBQ8mvn4jd4cXHfzylhgjs41zb14vjaofene42iiiMx9FAeTHWaPgJ S7ibuUeD8Ocf6rZ/uelf6ho/4KeE0ImFJyoya/HFXqWNngyl99vBZon0aQoyA3vYRkyG hERny4Qt8naDsWGvp2mvMYHoWRuRoOBxJdrI9IJQifbGCYvVnEB4ojVamooQahE7xsMd FbycEBKEb9+snlIOqiFxFDVWAodhxBYDgUy2bYRvrIorf4Ip9uuc0RbSDTaWgUphVlQ/ 84aA2kOev8if0UxfSB6YUWdaGV/96h1gVyy6WsFM3+J2NHlKLUJdJKPpJU3YWkKUWV4N GjAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=deuTnnbh; spf=pass (google.com: domain of linux-kernel+bounces-13815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 1-20020a17090a0cc100b0028bc575e78csi17814630pjt.189.2023.12.31.18.29.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 18:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=deuTnnbh; spf=pass (google.com: domain of linux-kernel+bounces-13815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13815-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B970B282A3C for ; Mon, 1 Jan 2024 02:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072CA2595; Mon, 1 Jan 2024 02:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="deuTnnbh" 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 27840210B for ; Mon, 1 Jan 2024 02:29:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DA4BC433C9 for ; Mon, 1 Jan 2024 02:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704076174; bh=NxcQt/1WVdElhgcHVwYbzLY/6vPTKg2Mr7ScZIEVR7w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=deuTnnbhP22cVt2mKII+KMjMY/MdkNY5Tvkb/5RpiAWGhNn7wEPfvUzw1PybSQpwh vru6kbn9xK/daV/HLaPB9JDtK7e2/N/4H4jV4tNeL+N1nYP6a5hudu7CPKLYDp2jXO +15rND5Phz5X1ycirGD85UrH+LzdzO93K5WljP4mRSeIuv4BbMaD69LEKj7bpIWDla 4ausGfo+FDNdYsDEsaDIOhANCU0ywF1Au0WC/CKBjf43BQ9Xfb6pXnmVoJfM3Z6sIT Wzq40HjMvjxAV4nJCH53zj3MBKTaO40MRDQ13DmeYLwAVHLppyJ5C5+EMl7DsF+Grf eTT4b5/ocprvA== Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-55559e26ccfso4211518a12.3 for ; Sun, 31 Dec 2023 18:29:34 -0800 (PST) X-Gm-Message-State: AOJu0YxiY0Bj6wzZTuODEz0dr/MAm3RSAaK+nuezZKk9SUecQqXlRwnw MLd8+RsubReCZBl4a+rrisk13EMhbE6yga+zew4= X-Received: by 2002:a50:8e17:0:b0:54f:51cc:6570 with SMTP id 23-20020a508e17000000b0054f51cc6570mr6935713edw.63.1704076173099; Sun, 31 Dec 2023 18:29:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231231082955.16516-1-guoren@kernel.org> <20231231082955.16516-3-guoren@kernel.org> In-Reply-To: <20231231082955.16516-3-guoren@kernel.org> From: Guo Ren Date: Mon, 1 Jan 2024 10:29:21 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V2 2/3] riscv: Add ARCH_HAS_PRETCHW support with Zibop 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Dec 31, 2023 at 4:30=E2=80=AFPM wrote: > > 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(unsi= gned 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) The PREFETCHW_ASM(x) definition should be out of "ifdef CONFIG_RISCV_ISA_ZICBOP... #endif", because xchg_small may use this macro without 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 > --=20 Best Regards Guo Ren