From patchwork Thu Mar 14 14:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Chiu X-Patchwork-Id: 13592495 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 D39D3C54E60 for ; Thu, 14 Mar 2024 14:26:32 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wMpmSKobOm2ran08LrL+Tv+yRdyFWZDDnCTGIJE0BRM=; b=plYxl0IuSFaAJa 3ERoWvH5lWCj+r+3jhlwwbraobh7zyt7q8atpzq55/uCy2zAC12R75rDow1kvy/yp3njiJTwbk09q ekmxY4vw12rU/qQbdZOZv2bUDkiutuHQCc04loXMZLWM3HEndC1yhKlp8JBqNDnc/Ac0290yxJwrT Kdp0d6+Udyi9br0AZAhFNBw5sdqjat3focVfBuj6UndWAYgeSeWL+GxGjhDex06i22lhv+XrnH+s0 Ixe+wBGIaJUpgD3Lg93XUUQDIXJkRGZPc7SePb87xQNqVoH6WuHfot/WJG9Itz1V6Fr1Flq3bE9Mf F095XRtCoUmkz+4Emq3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkm2O-0000000Ed2a-4BHI; Thu, 14 Mar 2024 14:26:29 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkm2L-0000000Eczu-2YF7 for linux-riscv@lists.infradead.org; Thu, 14 Mar 2024 14:26:27 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6e6ee9e3cffso284882b3a.1 for ; Thu, 14 Mar 2024 07:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1710426383; x=1711031183; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PNstRg6daczAXrALw7Zi6GYP2+HGLqW/5dmPLPDSUJY=; b=njTg6ZIZM30iuJNtCXreI0C47JhYACAv0vECvtKHDTeZ4MyYK0dLZWXJ8FS2dEyMiB b1Y1Qlc15aIn0N+6I0Mh9QYC+NEh6/OW9c3bgerBGauKZArmIE+53TQO6MqtaNCPTkLi NaZZoJktIPVPGHnAh5o53q0VM/TyrCzuZo8DwKmiuLjAEf4+TzM3bURNSCbxXw721g09 E5d2UMsqVpk1Q/KsxtLgFDcwbWNYDhAu2Wxx+eHRMgE5DQCZAqTZVn759ckBP96aArRv n3LaUWxW9MKEltTIIHw7HId0xiwOqMwqjX2YbpSI3Bv6TPfX+8jIlA3dsBecFtRRvtIH NSKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710426383; x=1711031183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PNstRg6daczAXrALw7Zi6GYP2+HGLqW/5dmPLPDSUJY=; b=DF7GHfVs4FLQHcJk+GaLsk1wWCCnvcitwlIa/Z6CYUgneMoTrWV5GGhFvw1eIAY/S1 GCbpUrGHf1uvbUVMXAYryp7HhGs6VdEhGp7n8wagANGZIMnTWtccoeo+5vo4AaAjITAI j/B6a7fH//CrDwm3u8vvyKwn1jRWxZTT8aIcTFoEtCdgvuqAGQ10iiV/21a6NaPItNxH Fep22wWoIcVeBqlywBypeLPkLvDeVvO5QzxckpPSLr5cPL16A5ENy6GVXHU0yyXoldpI xNVCGZveYZ4eILwH94N10Bga5Lkx6QjRUUA2Irm7qTB20AzzUwF8kVF8Y4WkpVrrdDLx y/lA== X-Gm-Message-State: AOJu0YypFb+EHvqrk4UmQ9dfwZhZl1JSmje3pMLz3jtAoBJh8UvOk37/ fEEw3JDYJ/nf3ex+KLhCuhKblaeMFCkg4E4YCjNs6jeD612uYAsx47pjWLQJkKBWwk4b8nzWIfQ aeTP+MacRjlCNW5FafnI/QR55Z1VanWve09TWeqyH1NvqD3Teo6OLMbe2zangYd7AtGK/ZlRqOo N0bwd8jr1+RH24We5Y1WWVuNI1AT2KvgkBBxjtUNbWGYyDZiE57fqr X-Google-Smtp-Source: AGHT+IHCOBS+cXi7w9ic2iD6x5GoItCXB4+H5HlhuhP/fax9v+yBM5aNMDIglPLe+3Txu8Gb4LL+kA== X-Received: by 2002:a05:6a00:3cc5:b0:6e6:30ef:b7e9 with SMTP id ln5-20020a056a003cc500b006e630efb7e9mr2995239pfb.16.1710426382983; Thu, 14 Mar 2024 07:26:22 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id y9-20020a62f249000000b006e6854d45afsm1556435pfl.97.2024.03.14.07.26.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:26:22 -0700 (PDT) From: Andy Chiu To: linux-riscv@lists.infradead.org, palmer@dabbelt.com Cc: greentime.hu@sifive.com, conor.dooley@microchip.com, guoren@linux.alibaba.com, bjorn@kernel.org, Andy Chiu , Paul Walmsley , Albert Ou , Andrew Jones , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Evan Green , Anup Patel , Xiao Wang , Charlie Jenkins , Yangyu Chen Subject: [v2, 4/7] riscv: cpufeature: add zve32[xf] and zve64[xfd] isa detection Date: Thu, 14 Mar 2024 22:25:39 +0800 Message-Id: <20240314142542.19957-5-andy.chiu@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240314142542.19957-1-andy.chiu@sifive.com> References: <20240314142542.19957-1-andy.chiu@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240314_072625_836138_0AB1717E X-CRM114-Status: GOOD ( 12.34 ) 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: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Multiple Vector subextensions are added. Also, the patch takes care of the dependencies of Vector subextensions by macro expansions. So, if some "embedded" platform only reports "zve64f" on the ISA string, the parser is able to expand it to zve32x zve32f zve64x and zve64f. Signed-off-by: Andy Chiu --- Changelog v2: - remove the extension itself from its isa_exts[] list (Clément) - use riscv_zve64d_exts for v's extension list (Samuel) --- arch/riscv/include/asm/hwcap.h | 5 +++++ arch/riscv/kernel/cpufeature.c | 36 +++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 5340f818746b..24efea44f1ab 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -80,6 +80,11 @@ #define RISCV_ISA_EXT_ZFA 71 #define RISCV_ISA_EXT_ZTSO 72 #define RISCV_ISA_EXT_ZACAS 73 +#define RISCV_ISA_EXT_ZVE32X 74 +#define RISCV_ISA_EXT_ZVE32F 75 +#define RISCV_ISA_EXT_ZVE64X 76 +#define RISCV_ISA_EXT_ZVE64F 77 +#define RISCV_ISA_EXT_ZVE64D 78 #define RISCV_ISA_EXT_MAX 128 #define RISCV_ISA_EXT_INVALID U32_MAX diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index d836241a1f11..ddac25a5fe3e 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -201,6 +201,35 @@ static const unsigned int riscv_zvbb_exts[] = { RISCV_ISA_EXT_ZVKB }; +#define RISCV_ISA_EXT_ZVE32F_IMPLY_LIST \ + RISCV_ISA_EXT_ZVE32X, + +#define RISCV_ISA_EXT_ZVE64F_IMPLY_LIST \ + RISCV_ISA_EXT_ZVE64X, \ + RISCV_ISA_EXT_ZVE32F, \ + RISCV_ISA_EXT_ZVE32F_IMPLY_LIST + +#define RISCV_ISA_EXT_ZVE64D_IMPLY_LIST \ + RISCV_ISA_EXT_ZVE64F, \ + RISCV_ISA_EXT_ZVE64F_IMPLY_LIST + +static const unsigned int riscv_zve32f_exts[] = { + RISCV_ISA_EXT_ZVE32F_IMPLY_LIST +}; + +static const unsigned int riscv_zve64f_exts[] = { + RISCV_ISA_EXT_ZVE64F_IMPLY_LIST +}; + +static const unsigned int riscv_zve64d_exts[] = { + RISCV_ISA_EXT_ZVE64D_IMPLY_LIST +}; + +static const unsigned int riscv_zve64x_exts[] = { + RISCV_ISA_EXT_ZVE32X, + RISCV_ISA_EXT_ZVE64X +}; + /* * The canonical order of ISA extension names in the ISA string is defined in * chapter 27 of the unprivileged specification. @@ -248,7 +277,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(d, RISCV_ISA_EXT_d), __RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q), __RISCV_ISA_EXT_DATA(c, RISCV_ISA_EXT_c), - __RISCV_ISA_EXT_DATA(v, RISCV_ISA_EXT_v), + __RISCV_ISA_EXT_SUPERSET(v, RISCV_ISA_EXT_v, riscv_zve64d_exts), __RISCV_ISA_EXT_DATA(h, RISCV_ISA_EXT_h), __RISCV_ISA_EXT_DATA(zicbom, RISCV_ISA_EXT_ZICBOM), __RISCV_ISA_EXT_DATA(zicboz, RISCV_ISA_EXT_ZICBOZ), @@ -283,6 +312,11 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(ztso, RISCV_ISA_EXT_ZTSO), __RISCV_ISA_EXT_SUPERSET(zvbb, RISCV_ISA_EXT_ZVBB, riscv_zvbb_exts), __RISCV_ISA_EXT_DATA(zvbc, RISCV_ISA_EXT_ZVBC), + __RISCV_ISA_EXT_SUPERSET(zve32f, RISCV_ISA_EXT_ZVE32F, riscv_zve32f_exts), + __RISCV_ISA_EXT_DATA(zve32x, RISCV_ISA_EXT_ZVE32X), + __RISCV_ISA_EXT_SUPERSET(zve64f, RISCV_ISA_EXT_ZVE64F, riscv_zve64f_exts), + __RISCV_ISA_EXT_SUPERSET(zve64d, RISCV_ISA_EXT_ZVE64D, riscv_zve64d_exts), + __RISCV_ISA_EXT_SUPERSET(zve64x, RISCV_ISA_EXT_ZVE64X, riscv_zve64x_exts), __RISCV_ISA_EXT_DATA(zvfh, RISCV_ISA_EXT_ZVFH), __RISCV_ISA_EXT_DATA(zvfhmin, RISCV_ISA_EXT_ZVFHMIN), __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),