From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 8EE4314C587 for ; Fri, 12 Apr 2024 17:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943789; cv=none; b=tMp2lhdFNCq/20LNqVLtGr73Bd9kBk45wnK218cgoA21rnbe3eo3HJZnSZdyYVQf+bgWwkoTYMhL4eiPueeMpgOo5rbSwFGJoSDnzxLMYBljobn5IOMLSW20gPe0evwCxESxF/ZeavpgnOHMF3FLpCqMOhG8h3XWnn8y16EoK0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712943789; c=relaxed/simple; bh=398UBf0wjuXyW1KRcz0N92ExG8gOAwZvnLb+5hA8430=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WkzTvLEtUELp2vvyX9zKBEltRsdk+qeJgtdebKbq6b/Y9VDs3SttbbQYdxRRmWdqC4zw+oqAgSpYnrTOcCr4r/Qyo/ZtxT6dg26G577j4WX3xkbRoXtxU8aKjXmmBeqYPRQ5HQvA0PSJxoyrjh1bf6pK05WSnB/ccIO2A3Zk/PQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=VREmx/I4; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="VREmx/I4" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1e5b6e8f662so5900935ad.0 for ; Fri, 12 Apr 2024 10:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712943786; x=1713548586; 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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=VREmx/I4Bl8fL+erIIvIEgsEoPlqugBORJ930NOMVQeeB8gjpQm0aFTE3G73Jvtrgx B1rAIbF3LXz5Mdnck0/OYdjc3aLIYWNlMq9S7+w8lXvp7DGbceXEfM47U0o1+4wQ6kuo rEB5HpjVvcbkb8hrDI4vcHc0CcMKQxvF8VGrgAZyHrC0zFs4BLnJ4xZNwHZWENg03/Sd lLPrOe7tstnqZZ8p3E0QTAaCoYg+5GlDjhoZr3on5BpjgnnZOru3nbH82Y6WaK/H3P/6 kdySzfhHxh8ZGab/OalYe9YkNBc6SdlT6XRz4xPlCBezUQ718IoXkN5Tkm4B/cFyuuzb hLdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712943786; x=1713548586; 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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=pgz4tQDi8Dbm586xrNPkvKQd8vZD5qeLv2ERWSNG8N+6c9h4uedrX/i0g0QAaM5NQB zCNZkjEb3MCp909i2QeLKzlSnleXPT89PDtwZ4GHBc5dfyB9ZisTfj26OPWQnFEn89a1 Vk267iauA7j+iHAqLUoLvXD5k1Hxoucgzph8NNi/3XbFYz13og765QoIuPSdYy57eS/B rZq8iJEzx6WOkq3+x6v7ZPN3SkCU2TsemNBhljZWocnY74yESFqzPbAHDWXWzlqDCDjR /aCbFM1aIGEH22kV4PxS9nW5ZjqO7ECFFPe/Kmi9ws7hhnzCRteSAD0Erw63UDkJ11rI oRIg== X-Forwarded-Encrypted: i=1; AJvYcCUjY/isTy823jp/cFhrJvyVETOliVe72ojPdVKoa0KAETRGXA0oAb6Tb3V8ZeDH2I6CtQ3yYr5ZcSaNVAGphYqc+kpBhpQ2Wvfx X-Gm-Message-State: AOJu0Yxy/kxcD1w0hw9U97XtsoyQv2sfvkXMKHF3tG8XBMII+PwgQ5U7 EFCiDFXhE3SD1Eese9nvfSHoaRzkbxhiQshjWCrOkQ92eDWzvUiwo/uybh71sQE= X-Google-Smtp-Source: AGHT+IE1KS+cgoHgP39ECdNzoJBDC8vTl8/0G5V7240HCpKQkDUzHJq76jMWfkj5KFoeGRTzjJqSZQ== X-Received: by 2002:a17:902:d303:b0:1e0:bae4:48f9 with SMTP id b3-20020a170902d30300b001e0bae448f9mr3205407plc.32.1712943785937; Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:121b:da6b:94f1:304]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f2c900b001e0e5722788sm3287804plc.17.2024.04.12.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Date: Fri, 12 Apr 2024 10:43:02 -0700 From: Charlie Jenkins To: Conor Dooley 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 , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 08/19] riscv: Introduce vendor variants of extension helpers Message-ID: 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> <20240412-dwarf-shower-5a7300fcd283@wendy> Precedence: bulk X-Mailing-List: linux-doc@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: <20240412-dwarf-shower-5a7300fcd283@wendy> On Fri, Apr 12, 2024 at 12:49:57PM +0100, Conor Dooley wrote: > 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. > > > > 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. It is not duplicating infrastructure. If we merge this into the existing infrastructure, we would be littering if (ext > RISCV_ISA_VENDOR_EXT_BASE) in __riscv_isa_extension_available. This is particularily important exactly because we have so few vendor extensions currently so this check would be irrelevant in the vast majority of cases. It is also unecessary to push off the refactoring until we have some "sufficient" amount of vendor extensions to deem changing the infrastructure when I already have the patch available here. This does not introduce any extra overhead to existing functions and will be able to support vendors into the future. - Charlie > > > > --- > > arch/riscv/include/asm/cpufeature.h | 54 +++++++++++++++++++++++++++++++++++++ > > arch/riscv/kernel/cpufeature.c | 34 ++++++++++++++++++++--- > > 2 files changed, 84 insertions(+), 4 deletions(-) > > > > 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 long *isa_bitmap, unsigned i > > #define riscv_isa_extension_available(isa_bitmap, ext) \ > > __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) > > > > +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 unsigned long ext) > > return true; > > } > > > > +/* 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); > > } > > > > +/* 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 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_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. From mboxrd@z Thu Jan 1 00:00:00 1970 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 F0A7CC4345F for ; Fri, 12 Apr 2024 17:43:17 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4FSbNHe6RJl19tRtsfFndKwPtYXMQEpzVXDW8b5c5Yc=; b=ftyMFL7JXaL0mG cZfCcoIZcVkGs8dv1skEN4nDksS+0cUbSdEPQBJWqqECxEcDV52YQGKR5YqnVcWf0lI75LJkBUpYX GEwPaBAegk0vsmupTbuBtaJaHce9IjIv9VQ8vLJhqWkW1dZ5XtvBCMowPBP0/kjy3La160lzaGaUr cBUOStXifUDQe0ZORbq6NVVgoV72EqeJZuMsGhpURGP+pU8+3iQrTQfEV8JEzTS9cSPSdCxKv2Mkf R1g2nkIlm+ZNZRIGVV+9LzD5EqKGF0GYxQub3a7EhzAFWyHaxPDSNhngpEv8pN+QSs2inRAT3B2vo LpJKrw4qq6k7M6hEdaIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKvg-00000000ias-1ddK; Fri, 12 Apr 2024 17:43:12 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKvc-00000000iZS-40ZC for linux-riscv@lists.infradead.org; Fri, 12 Apr 2024 17:43:10 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e4266673bbso10502835ad.2 for ; Fri, 12 Apr 2024 10:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712943786; x=1713548586; darn=lists.infradead.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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=jbpjdEmKBEWIbLneWFvix7/nL0LxC7Ee6RK5CpqanbCnVOcRSLiZJBtkkfjdF4TSnE yw+XjWa+dRt46JlF4JcS0/C/4D2KQ+ftnTiqFhWc5Kx/3jvhF3c8ziOJ2l14UJTHDTmT nCAfBE3ad0C3i0oHcH53YUeLVeUeBLSKcYbifnfwxew2G9ofqAeiZuYFHW1c/DJC7xN6 czbv32eD+J4Fr2+ZXbtelHuQGCWf9V3EkFU5p1VlIuJCET5OtXkdRkhN/Dr7MWsepEqx OURkKtMWr8xcGnY+bNaNwKPtyh2HyiHNJvhk/ZRNHlW9PNsMevwN+vvRt+DwsZdocMyL zMSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712943786; x=1713548586; 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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=EJcNUKKaXjHOU3U+Ft2hlUxFVVM/SE5UV9Z6/Ci1DnOqUCDHDcGkLsdy0LGnH96Qpf o/eUx+oStvX8s5dun/l7rsbUSx6vK4hxW0Spcp/OphiqNsUaU7puEo6aGiaLwjnpBwNB QXMEfVwDeH6Sd73ZhPjwsnvNuHAoAO6LTftaiBH6VnTblAK0cQrv3G7ihhNQ+5IGbjVa QzG0vGcJcNZgT/pnBWDMBQOXP69cVMekSP6KP5OdeK5qtdJTF+6msIJ6fmmJLL4XvBWo ekgQfEK0d58Qv6kn+9n6lrmbOj1by95rLX3/noT3yyj95MCICLhXkfcjqA89euHYQ/V2 /tHA== X-Forwarded-Encrypted: i=1; AJvYcCXmVlmwcNSkL9loXX5NewD1ABvu0XS9v+6OzT/gZxkWvNQk5df1kARk+0M+uV+p0DdAQzFwzDIqnEd86lmDjH8jWN2EsyT/BRPatisAa1fj X-Gm-Message-State: AOJu0YyRvxzaXnCpk7UTb5of6gewt3wYQ+kB8J4yenmoMMDcDznQNFsH 6JYAXcoYtl6V9IuvjikKKYb3O8msTRegYhUSiUk3X1kDymF5K8vdYfrfaG9zpx4= X-Google-Smtp-Source: AGHT+IE1KS+cgoHgP39ECdNzoJBDC8vTl8/0G5V7240HCpKQkDUzHJq76jMWfkj5KFoeGRTzjJqSZQ== X-Received: by 2002:a17:902:d303:b0:1e0:bae4:48f9 with SMTP id b3-20020a170902d30300b001e0bae448f9mr3205407plc.32.1712943785937; Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:121b:da6b:94f1:304]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f2c900b001e0e5722788sm3287804plc.17.2024.04.12.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Date: Fri, 12 Apr 2024 10:43:02 -0700 From: Charlie Jenkins To: Conor Dooley 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 , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 08/19] riscv: Introduce vendor variants of extension helpers Message-ID: 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> <20240412-dwarf-shower-5a7300fcd283@wendy> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412-dwarf-shower-5a7300fcd283@wendy> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_104309_024217_90B1733F X-CRM114-Status: GOOD ( 28.63 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Apr 12, 2024 at 12:49:57PM +0100, Conor Dooley wrote: > 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. > > > > 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. It is not duplicating infrastructure. If we merge this into the existing infrastructure, we would be littering if (ext > RISCV_ISA_VENDOR_EXT_BASE) in __riscv_isa_extension_available. This is particularily important exactly because we have so few vendor extensions currently so this check would be irrelevant in the vast majority of cases. It is also unecessary to push off the refactoring until we have some "sufficient" amount of vendor extensions to deem changing the infrastructure when I already have the patch available here. This does not introduce any extra overhead to existing functions and will be able to support vendors into the future. - Charlie > > > > --- > > arch/riscv/include/asm/cpufeature.h | 54 +++++++++++++++++++++++++++++++++++++ > > arch/riscv/kernel/cpufeature.c | 34 ++++++++++++++++++++--- > > 2 files changed, 84 insertions(+), 4 deletions(-) > > > > 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 long *isa_bitmap, unsigned i > > #define riscv_isa_extension_available(isa_bitmap, ext) \ > > __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) > > > > +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 unsigned long ext) > > return true; > > } > > > > +/* 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); > > } > > > > +/* 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 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_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. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 436D3C4345F for ; Fri, 12 Apr 2024 17:43:25 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+qvwb591wkq5u+rpyQKYAxUT/oDVSEk8YGyp0bfJAwY=; b=mx6XS8hTjQtG8p CCBI1O0rTGpCKZUbAE1wclXsAHooS+dNQ53+040H6/GejhDY0dzRyJArthRBS11iipGA7yAnBCrtT WJD1KHaTZUIxSU+FKhAmWWqsCZibThSVdJQgF7GUkZnehM2xbZZMz0ivzdwWDNnSUVndAgTp7OlWX c1P9fxskb6nyPxWLs7+75FZxCPeMVZQZCJFxGS8GOk7atomoME+Qv6y68FAdJ7lKMYubgrGmSlYod DAsmh+LL61sMFtDSoGK6uyAWHsYRpVwqFMV+3VCzT0rHdPdkZ5cROyrpfURxK0CCmoGiSqcOvssIY 013dBLDyACpE6BUTZiOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKvh-00000000ibS-17rP; Fri, 12 Apr 2024 17:43:13 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKvc-00000000iZR-3zqB for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 17:43:10 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e4266673bbso10502825ad.2 for ; Fri, 12 Apr 2024 10:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712943786; x=1713548586; darn=lists.infradead.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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=jbpjdEmKBEWIbLneWFvix7/nL0LxC7Ee6RK5CpqanbCnVOcRSLiZJBtkkfjdF4TSnE yw+XjWa+dRt46JlF4JcS0/C/4D2KQ+ftnTiqFhWc5Kx/3jvhF3c8ziOJ2l14UJTHDTmT nCAfBE3ad0C3i0oHcH53YUeLVeUeBLSKcYbifnfwxew2G9ofqAeiZuYFHW1c/DJC7xN6 czbv32eD+J4Fr2+ZXbtelHuQGCWf9V3EkFU5p1VlIuJCET5OtXkdRkhN/Dr7MWsepEqx OURkKtMWr8xcGnY+bNaNwKPtyh2HyiHNJvhk/ZRNHlW9PNsMevwN+vvRt+DwsZdocMyL zMSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712943786; x=1713548586; 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=8YRvEt+OTF00KrpCNHpUGlZ7toxHUQ85PqnBkH5iiOI=; b=XFCV1ur7jmqjSu1aK/3CwsFrj/cxjiLopRlhwELIE1BUW4rVxdNhyut8zFuw0ejgCt LD7jaC6gUZFFYlPJHHwwE6G+Z4foWufKVuNip78MsJTqDCTvtHpg/OQ4vC40dvYuj9nO I39q1U5Xqv8cJcECz17Qf/jywSpbF/8KuGjm3tLd123WLr6pPgmCD5s9p10oIZKYZ7yR CxlGJXmwo4V6d48g8XnvVbCXC4DAu9kLDITvY9B47938gOzDTKhmIfFjNyV5UqrxJRCA OGWGGvM1xu3RLlMs629uRyAz2LB/738uhZ3Oxq7U3gnwuNTo+W42MtG2hvB1K10Z+PG5 EAIQ== X-Forwarded-Encrypted: i=1; AJvYcCXi1PSUkQDQHuuGDW8Ky5SIwDwuHCpU9sk9dK9bDmTvqcIH3wOCn36gOeNe4MaD3Z2Q6Yr5od2u+Ea8imqHIM+qmbfdEslTbbpmC8AbitEL9fnKuPU= X-Gm-Message-State: AOJu0YxEuZSzNFJ9o79XJUd+uDjTC0VgxltL7vr8F2GdULu39O4aR4+N pABFjYI7XkpCZzpixuJIc514knqu2c8jCUw/i8sNG66Hyliggy/4lZsyMJtQzfY= X-Google-Smtp-Source: AGHT+IE1KS+cgoHgP39ECdNzoJBDC8vTl8/0G5V7240HCpKQkDUzHJq76jMWfkj5KFoeGRTzjJqSZQ== X-Received: by 2002:a17:902:d303:b0:1e0:bae4:48f9 with SMTP id b3-20020a170902d30300b001e0bae448f9mr3205407plc.32.1712943785937; Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:121b:da6b:94f1:304]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f2c900b001e0e5722788sm3287804plc.17.2024.04.12.10.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 10:43:05 -0700 (PDT) Date: Fri, 12 Apr 2024 10:43:02 -0700 From: Charlie Jenkins To: Conor Dooley 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 , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 08/19] riscv: Introduce vendor variants of extension helpers Message-ID: 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> <20240412-dwarf-shower-5a7300fcd283@wendy> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412-dwarf-shower-5a7300fcd283@wendy> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_104309_024870_7049DC2D X-CRM114-Status: GOOD ( 30.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 12, 2024 at 12:49:57PM +0100, Conor Dooley wrote: > 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. > > > > 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. It is not duplicating infrastructure. If we merge this into the existing infrastructure, we would be littering if (ext > RISCV_ISA_VENDOR_EXT_BASE) in __riscv_isa_extension_available. This is particularily important exactly because we have so few vendor extensions currently so this check would be irrelevant in the vast majority of cases. It is also unecessary to push off the refactoring until we have some "sufficient" amount of vendor extensions to deem changing the infrastructure when I already have the patch available here. This does not introduce any extra overhead to existing functions and will be able to support vendors into the future. - Charlie > > > > --- > > arch/riscv/include/asm/cpufeature.h | 54 +++++++++++++++++++++++++++++++++++++ > > arch/riscv/kernel/cpufeature.c | 34 ++++++++++++++++++++--- > > 2 files changed, 84 insertions(+), 4 deletions(-) > > > > 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 long *isa_bitmap, unsigned i > > #define riscv_isa_extension_available(isa_bitmap, ext) \ > > __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) > > > > +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 unsigned long ext) > > return true; > > } > > > > +/* 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); > > } > > > > +/* 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 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_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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel