Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp141496rdb; Fri, 5 Jan 2024 05:31:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGljF7wco6GpezgxtamKSFf1CXdAVIK7WyyygoLOZqy/NLrJNLPRX+++BmLHha4ABGM1rnk X-Received: by 2002:a17:902:d501:b0:1d3:fa6a:fc88 with SMTP id b1-20020a170902d50100b001d3fa6afc88mr2222673plg.17.1704461511598; Fri, 05 Jan 2024 05:31:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704461511; cv=none; d=google.com; s=arc-20160816; b=NCpRE9BZS1nI6ddyffTNREjLNVrXPM5LzjZI5U/dnJvOAnDhkFTWoMuwbmZ6x7F52l lbG92JAsxusUfoJWf1uc4HFqJkw9PS9cxHJX9co8BpW8XjSznLpYrwn8+2SVGRe1AHWc ECmKo4p9Ujnwo5XQ7kd1p1aMb7jKwDcLnd4oCJcwLv7AgpN3D8y3aq/vjqURQe+6gvFA iwpfprwq81JU4WbmEvCo7XSInNTNrQvq5etG8VV4OJRxamPsotfymZJms4mhRv3q/h0v lptSJOo5MsHr0pSki2/ensPh60wxRwnu+5tW4H5jSCTJTAmvNvSD90wA+2pAGdTZK2/Q wjMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tgP+th0N7B9odu3YvrC1EGNYppOPseXtnsirIxKlnzQ=; fh=/SjJqYEpsgkEj/oMdV/GTXC92O3AZbetDF2apGIU0Jw=; b=bPBRQNt/5q/PEmELr7lS9JOFXJBv8SE66uA1v+EUDNnADfa1e+eQWJ4x9M8S5uBKhU V7yxBU8y8yNYnl/TTnTVIuH9ZUgSL7Qv9fUR2a/eLyhc7K6KREucPtSbSuFZQkJsPpc7 VfedjQRc0T9WU5G3SrEMTpif3FxK+jYjFpqZKrN+79hjGjDLU83yBz/bhSwASxCsOjeu Se2acykb6/GLs/cIddgFhKC0TJlu0EL6JgfjPrbRcWZqbMBWRAZqK6ExWu447ISUromm 5Q/IMtGF5aHTyvXRjcf3UAayurJLZh7IChTkiypeCEoxoor5FnrkO/1iqS64uuv6zjlW gciQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=T2rSBTry; spf=pass (google.com: domain of linux-kernel+bounces-17879-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17879-linux.lists.archive=gmail.com@vger.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 h1-20020a170902704100b001d408a4f5fdsi1188787plt.646.2024.01.05.05.31.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 05:31:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17879-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=@ventanamicro.com header.s=google header.b=T2rSBTry; spf=pass (google.com: domain of linux-kernel+bounces-17879-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17879-linux.lists.archive=gmail.com@vger.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 3D04CB20DBF for ; Fri, 5 Jan 2024 13:31:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F8482D638; Fri, 5 Jan 2024 13:31:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="T2rSBTry" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 517C72D609 for ; Fri, 5 Jan 2024 13:31:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a27cd5850d6so168528966b.1 for ; Fri, 05 Jan 2024 05:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1704461500; x=1705066300; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tgP+th0N7B9odu3YvrC1EGNYppOPseXtnsirIxKlnzQ=; b=T2rSBTry2/mDpiuajiNPPpZdKnz1lWBMk6CVmwc7+qH8meFgkwN8iCJXL1PlMwZVAf exSS/IxZ9wykmVhnQwuWPPToZAH9rLzDg3k84dek4peCydbieojVLpUy1GGJCgsX8uqY FlfYEunHeb99zbDVtFu65nXvUqJdJRfR0B+xzy/MoNtbWbgjBPC+3j7Q+R5M0oRjsaeI hfT79ZjnYxI3DJS3WpYCFeuET49xjqM0nqmTq2oFBVWaE87zaEWvSKLl61Y2xgnq+HPc zdUDVoWmL31am6eu91hO+S3kaUNR33L2dF48e7q/TpJVtGyYVMwHm7bT5pZZeY8A4cUM W4Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704461500; x=1705066300; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tgP+th0N7B9odu3YvrC1EGNYppOPseXtnsirIxKlnzQ=; b=M0iIjSEgQFpg8AQYerZC6pymzJZnR2RgHg1i4piBdfsL2SwNnoSG7R3E77gbXejGBU 2RGimbmx8QjlgJEaHKmjECvgo0qdzPY8HCr4YdRheyWHI2sERSlQM4qD39Ll00iVEH8F ZAv/SGcVK/sx+d+KgDppkhfHovPe/Wh/IH+doAHpQ2P4TUnJEeCJPvEIPCYFgAnDGxIP mqzNRFvHVGCAYh5MRjuEYE6fqNYCRmr8/gn26M6ZqV4GozLA79gi22hogXux2VT5qBjt QYqnp3uGP43iw+jbUX1UcEQ6qKCjLHOl3opRnPKZRU+3HKRU3/dJGvDf67QNFgMVhzqc 7ZqA== X-Gm-Message-State: AOJu0YywQGSEoISkvRxkPCLyrCC4C96kEzmdYreeYuuUmpexx85Ruozg 4FCg5B0S+iu13SDtOdIQ41iEqf454yf0wQ== X-Received: by 2002:a17:906:aad3:b0:a28:b21b:ee5 with SMTP id kt19-20020a170906aad300b00a28b21b0ee5mr1051218ejb.75.1704461500565; Fri, 05 Jan 2024 05:31:40 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id k27-20020a1709061c1b00b00a272de16f52sm885194ejg.112.2024.01.05.05.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 05:31:39 -0800 (PST) Date: Fri, 5 Jan 2024 14:31:39 +0100 From: Andrew Jones To: guoren@kernel.org Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, 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, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Guo Ren Subject: Re: Re: [PATCH V2 2/3] riscv: Add ARCH_HAS_PRETCHW support with Zibop Message-ID: <20240105-6dba80fb50413c0869b0beb3@orel> References: <20231231082955.16516-1-guoren@kernel.org> <20231231082955.16516-3-guoren@kernel.org> <20240102-7e62facbd8322db4dee4b0dd@orel> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240102-7e62facbd8322db4dee4b0dd@orel> On Tue, Jan 02, 2024 at 11:45:08AM +0100, Andrew Jones wrote: > > s/Zibop/Zicbop/ <<<$SUBJECT > > On Sun, Dec 31, 2023 at 03:29:52AM -0500, guoren@kernel.org wrote: > > From: Guo Ren > > > > Enable Linux prefetchw primitive with Zibop cpufeature, which preloads > > Also s/Zibop/Zicbop/ here > > > 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"); > > +} > > Shouldn't we create an interface which exposes the offset input of > the instruction, allowing a sequence of calls to be unrolled? But > I guess that could be put off until there's a need for it. If we did expose offset, then, because it must be constant and also must only have bits 5-11 set, then we could add a static assert. Something like #define prefetchw_offset(base, offset) \ ({ \ static_assert(__builtin_constant_p(offset) && !(offset & ~GENMASK(11, 5))); \ __asm__ __volatile__(PREFETCHW_ASM(%0, %1) : : "r" (x), "I" (offset) : "memory"); \ }) Probably overkill though... Thanks, drew