Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp87673lql; Fri, 12 Apr 2024 04:51:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVV/Nm5xBS9AFZ8cDFXcKlXiij4Ajfz7t9IiFqC9OaZF01sg7fXaCgsjkdQPa0paq90OHfv/vHemaB9h2n1ISbCtsQZca3ETJQRdvR3cQ== X-Google-Smtp-Source: AGHT+IGB6toPWha4jju1z0aKsCkhB6X7jYm2SaBQX1Hv1H4tvMnatmmDsD/lQFeEJ0iFKpL/B+OE X-Received: by 2002:a17:902:c952:b0:1e4:12f0:d7c9 with SMTP id i18-20020a170902c95200b001e412f0d7c9mr3122967pla.11.1712922675045; Fri, 12 Apr 2024 04:51:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712922675; cv=pass; d=google.com; s=arc-20160816; b=vRvvKen5ZHQWHZPobodx3X52ttUaIr1N62D62k0CbdYGQc0HSt4yX/fDwK6wOzDsI6 FMTAOas7MX/X+s3klSsxirrFytdRuVO3I24fhMMC3aeiu6ergsAO3+xuse8mQDECkeQQ jUFruRDDb1fpU9l1y/XNV9Ab4tPy5ow/2QpdI1fCW/mcfBJml3f8Yg/wUoxIWcYvCI6J LV8r2mFAEdAmzUANu5GAFlGjNUvtuctRu2pfE/95fSKQ3SGJUpRe476+uz0Ar0IYxwLN gYAMgohrhU4eDY7p9GvI7IJRQFkPvNe9ejr4wOhIQNITlET80MVLZyYKrFypo9pZPR5V 1b9Q== ARC-Message-Signature: i=2; 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=cxFy+66rK3S1lNFzIHbHSBwi6xRf7UMtHVyHjcXZz6M=; fh=4jyGPlIgBC+cOBl2betKVRRu896Cfe1VEzAQNc3FCOU=; b=RM8LUbexfYZ2Sea/0infTZfP0G8XJlaopOIr/Tp7LtxiQiPsqK5CbZ1cbl+IU1+XTy M0UCWL5iR6vA0FUHGBUMViZXebGczwXkEhY94PRnFBBQ4cCmM1IeweRa+BqY/Q/DSqfJ fTxd+V8ANQw0GMRhGs9GhN4ENEvkwbSM7QKFUd7almHDh/4NnPPdgP12IbopUTq3y37X 2dZgblPUTNgwCz0KjKf52oTbxhxfl2jr0fGlEjto1+udJpuT5PPEvxaMigo+N9U4wv8b Dxx8DQhfLEf6wE+Lv4KcRADiBncNs/E3BQQzi/PuGXo6UNZF0oD3ecjLCcfkFojTrxad NG3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ceZLQ1C4; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-142612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u9-20020a170902e80900b001defa2d6abasi3143336plg.71.2024.04.12.04.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142612-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=@microchip.com header.s=mchp header.b=ceZLQ1C4; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-142612-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com 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 ACA1A284699 for ; Fri, 12 Apr 2024 11:51:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 850D154FB5; Fri, 12 Apr 2024 11:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="ceZLQ1C4" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 ECACF5490C; Fri, 12 Apr 2024 11:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712922658; cv=none; b=DJCSMRom9rmjzpdQYKiaYc9mbRfTm1ZrOg0rw26HUVfasfrZAmiPo1DMlqq2l7bN1llzchTPi9qC1jhlepLdSGQF8t1KbMabFa+4+YpcW2LtW3UA4dtjHzwFR696I7ecDUBag8kIJMHNrwSJWd8kxqfzAwTQQtudkA+JkR9PHU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712922658; c=relaxed/simple; bh=/MsWLEJD+g2lmJVxWXE9ihQ+XOiKAY5YDqrlImseWCM=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MkTOMCJ6nT0VWRGTTqrzdAubkjdpPqIgYxyy9ck1tHT0WPD2pN7B8VhkaDUQ7RSnmOjzLja4XawGDVOVvgWBHIPo0tLPLIKfJW7wmypAttHSl70OXqP4+3TJQeqXJYZSkvIMjtoi7Ml2RGTSSYaNDf0GVt0pjB58rlgvNp3DpEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=ceZLQ1C4; arc=none smtp.client-ip=68.232.153.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1712922657; x=1744458657; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/MsWLEJD+g2lmJVxWXE9ihQ+XOiKAY5YDqrlImseWCM=; b=ceZLQ1C4Zx2xp8ul0pxyDVnNHXuLPYZXqxO0nQ7I6XuPbC6nIRuA69kI eRdD6eR8USM7wblnUfazwkwHa9e4JNspHaofp3h+0Ss3OL2sSky0ZfO0O DCXtC+07GOaBn3mLOuibI4nEHAdCWjDxMZDD2l1/kM5yuLW336YEc8nte qBLfarCIN9lgWPZWGI/4Wx0kALQeIkh6bo4Td73sVdN2/6j/iGHac/fyH FsZTJqBqXQWE2ulUcYqbtnLTThq6Vb8wzbEDGvlfodEUd10K1CzD9/QUI 8uCnW0LyXswsfat1pUAKXZSRw4uEzoBIbuce0zXMuTDyRFnzCbCmVjmNp g==; X-CSE-ConnectionGUID: DbXRGJMARISTcHYzzFqcJQ== X-CSE-MsgGUID: r4WPBt/kRzewCEGLyzl6yw== X-IronPort-AV: E=Sophos;i="6.07,196,1708412400"; d="asc'?scan'208";a="20735309" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 12 Apr 2024 04:50:56 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 04:50:52 -0700 Received: from wendy (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 04:50:48 -0700 Date: Fri, 12 Apr 2024 12:49:57 +0100 From: Conor Dooley To: Charlie Jenkins CC: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Evan Green , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Jonathan Corbet , Shuah Khan , , , , Palmer Dabbelt , , , , Subject: Re: [PATCH 08/19] riscv: Introduce vendor variants of extension helpers Message-ID: <20240412-dwarf-shower-5a7300fcd283@wendy> References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> <20240411-dev-charlie-support_thead_vector_6_9-v1-8-4af9815ec746@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OxSigVsCwYUnQIoR" Content-Disposition: inline In-Reply-To: <20240411-dev-charlie-support_thead_vector_6_9-v1-8-4af9815ec746@rivosinc.com> --OxSigVsCwYUnQIoR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 11, 2024 at 09:11:14PM -0700, Charlie Jenkins wrote: > Create vendor variants of the existing extension helpers. If the > existing functions were instead modified to support vendor extensions, a > branch based on the ext value being greater than > RISCV_ISA_VENDOR_EXT_BASE would have to be introduced. This additional > branch would have an unnecessary performance impact. >=20 > Signed-off-by: Charlie Jenkins I've not looked at the "main" patch in the series that adds all of the probing and structures for representing this info yet beyond a cursory glance, but it feels like we're duplicating a bunch of infrastructure here before it is necessary. The IDs are all internal to Linux, so I'd rather we kept everything in the same structure until we have more than a handful of vendor extensions. With this patch (and the theadpmu stuff) we will have three vendor extensions which feels like a drop in the bucket compared to the standard ones. > --- > arch/riscv/include/asm/cpufeature.h | 54 +++++++++++++++++++++++++++++++= ++++++ > arch/riscv/kernel/cpufeature.c | 34 ++++++++++++++++++++--- > 2 files changed, 84 insertions(+), 4 deletions(-) >=20 > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm= /cpufeature.h > index db2ab037843a..8f19e3681b4f 100644 > --- a/arch/riscv/include/asm/cpufeature.h > +++ b/arch/riscv/include/asm/cpufeature.h > @@ -89,6 +89,10 @@ bool __riscv_isa_extension_available(const unsigned lo= ng *isa_bitmap, unsigned i > #define riscv_isa_extension_available(isa_bitmap, ext) \ > __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) > =20 > +bool __riscv_isa_vendor_extension_available(const unsigned long *vendor_= isa_bitmap, unsigned int bit); > +#define riscv_isa_vendor_extension_available(isa_bitmap, ext) \ > + __riscv_isa_vendor_extension_available(isa_bitmap, RISCV_ISA_VENDOR_EXT= _##ext) > + > static __always_inline bool > __riscv_has_extension_likely_alternatives(const unsigned long ext) > { > @@ -117,6 +121,8 @@ __riscv_has_extension_unlikely_alternatives(const uns= igned long ext) > return true; > } > =20 > +/* Standard extension helpers */ > + > static __always_inline bool > riscv_has_extension_likely(const unsigned long ext) > { > @@ -163,4 +169,52 @@ static __always_inline bool riscv_cpu_has_extension_= unlikely(int cpu, const unsi > return __riscv_isa_extension_available(hart_isa[cpu].isa, ext); > } > =20 > +/* Vendor extension helpers */ > + > +static __always_inline bool > +riscv_has_vendor_extension_likely(const unsigned long ext) > +{ > + compiletime_assert(ext < RISCV_ISA_VENDOR_EXT_MAX, > + "ext must be < RISCV_ISA_VENDOR_EXT_MAX"); > + > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) > + return __riscv_has_extension_likely_alternatives(ext); > + else > + return __riscv_isa_vendor_extension_available(NULL, ext); > +} > + > +static __always_inline bool > +riscv_has_vendor_extension_unlikely(const unsigned long ext) > +{ > + compiletime_assert(ext < RISCV_ISA_VENDOR_EXT_MAX, > + "ext must be < RISCV_ISA_VENDOR_EXT_MAX"); > + > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) > + return __riscv_has_extension_unlikely_alternatives(ext); > + else > + return __riscv_isa_vendor_extension_available(NULL, ext); > +} > + > +static __always_inline bool riscv_cpu_has_vendor_extension_likely(int cp= u, const unsigned long ext) > +{ > + compiletime_assert(ext < RISCV_ISA_VENDOR_EXT_MAX, > + "ext must be < RISCV_ISA_VENDOR_EXT_MAX"); > + > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) > + return __riscv_has_extension_likely_alternatives(ext); > + else > + return __riscv_isa_vendor_extension_available(hart_isa_vendor[cpu].isa= , ext); > +} > + > +static __always_inline bool riscv_cpu_has_vendor_extension_unlikely(int = cpu, const unsigned long ext) > +{ > + compiletime_assert(ext < RISCV_ISA_VENDOR_EXT_MAX, > + "ext must be < RISCV_ISA_VENDOR_EXT_MAX"); > + > + if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) > + return __riscv_has_extension_unlikely_alternatives(ext); > + else > + return __riscv_isa_vendor_extension_available(hart_isa_vendor[cpu].isa= , ext); > +} Same stuff about constant folding applies to these, I think these should just mirror the existing functions (if needed at all). Cheers, Conor. --OxSigVsCwYUnQIoR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZhkf5QAKCRB4tDGHoIJi 0t21AQDpXCNkKreoJcGsD1c3KhhnWrrt3e8Dua+btfF4IRjd5AD+OTlLyxva26D5 OHyd+dKNVKNYXjtuHGTu8h6vqaR8mw0= =H6/V -----END PGP SIGNATURE----- --OxSigVsCwYUnQIoR--