From patchwork Wed Oct 11 11:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 151304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp461842vqb; Wed, 11 Oct 2023 04:19:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSSKM2E4KkK9xtNJ72TPjxsGp/vFVoRI55iRk8lbJTHZPK5pygdqyz0zbr1ivI8Y9y7GQw X-Received: by 2002:a05:6a00:391c:b0:690:d0d4:6fb0 with SMTP id fh28-20020a056a00391c00b00690d0d46fb0mr22574142pfb.3.1697023194962; Wed, 11 Oct 2023 04:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697023194; cv=none; d=google.com; s=arc-20160816; b=un7gpQIQzi9W859F2N7Hnr2O2sKQx2MXZ8yZEbEzWjxUA+gqbnROkVE4ep0j2SQQin G2vH2vW3CsWsGchqNwkF9MmnRYdmgs9nvUAbdowIFm1ciNKfHHeJ1cY6YatJS5XNjXAm H033nYJs2qAIlExRjgTwLV8OlXxpRd/i+RuQHPolk8sT7S60nOiZ96gdm8U8no80TEq5 neKKod682s7l3m0c1j+XjrdyUn0fVBaFb+KvCZVi3GBAeOV5CT/Od6/4Di5srcWkSBwx 8dOZwYWPWjMdSXWQQYMknZUHAeEnY5dceqYo6o0roapAMM0uBOM5MXIvIS4px6uDXTvZ vZaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y5dECHie5t7w/LFj+hSn2EZYYIuSxKSWdwgSHs3GrYQ=; fh=YTBEzcO0MYpF5YfD8pS5vr0pvVavk2TCgoIFkI+x0fk=; b=qxFFQOQA9Jpo2YdCfWjkZNEXRL1ES+AeYtICHa40BlYnaqk2bwsgjTVBwYKVFWkXOF 2gXn1zCN1wgGh3OC2hT0fBGkrvHUaBLddm0HC2UfAQXNMxsRr/d/cf6bVLnpo8wnFhW4 CPxFvarDMQagx4bNmlyXzx9NNlGHhKZLnJ2XAHHfnNqc5lIddN0thZt1Hp96DKTO2Sym appa2p/P7pwhFOMx5Mj28vmUGCIaTprCdciq9/WOiqqt3YvGFE6UYkiZITvDsdzeFENw 71o/ID0KhhNoR5IALAe7wv51njhJmcVSYyj1WLyrdPcxwbCG+ePlA8oofHUFbA3Lxovv ZTqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=paOaubDp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bt21-20020a056a00439500b0068a52819fd2si11919973pfb.331.2023.10.11.04.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:19:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=paOaubDp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DE99D8134984; Wed, 11 Oct 2023 04:19:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346390AbjJKLTl (ORCPT + 18 others); Wed, 11 Oct 2023 07:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234658AbjJKLTS (ORCPT ); Wed, 11 Oct 2023 07:19:18 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37474B0 for ; Wed, 11 Oct 2023 04:19:16 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4053e6e8ca7so19944285e9.1 for ; Wed, 11 Oct 2023 04:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697023154; x=1697627954; darn=vger.kernel.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=Y5dECHie5t7w/LFj+hSn2EZYYIuSxKSWdwgSHs3GrYQ=; b=paOaubDpSR+Z2YXae5A3aOp7dykvVsDwwtVI3IXsqZ3yl+3b5Lejk7TeZKU9Bk7oRq 6mReQYe1T2S5mibvGYrut7fLqf9DhNtczvYVWS5OIVhxnSllWe4ogBwjHYvLsk8/V31a OrjKh3utE//AJQlQgDYtuT7l/GKkV78RTtmpMpCNTfmFMdGEGhuRZQwORPNJBv8RIZdR rsWGJhxBsQD5V+Kmi/WoI4CFMSeBDnAa28tBRxiVTnaCVwmY92nK4PDcUdcxLrHhlYOP 7q44ySqZs5hnRKxgt/bWrGdCUsT6y2+CDuSFGWO3UugQuRDj4DLWMIYrns6XKoDMZu5K niqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697023154; x=1697627954; 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=Y5dECHie5t7w/LFj+hSn2EZYYIuSxKSWdwgSHs3GrYQ=; b=gNPiiWnkMOkE6xgX7LGM3eqf/S62QSPEfwLVSK6GAM0i3TRFD2NTFqlkT0x9pnMAnK 189RWAUd7V+PtenDDN127/ktx7m+KiXYJRFCISoEISf851vzz1Vq8HRBsQYNe3Z7EY92 AHpIR4/8QYlkPUqIoALF3zJ5upHEWgvyRsNkAGQbbkYgewr6pCS7QmuX+1B5K6YOB231 b3/GZNheV8/20ht4rYvSAkjzXGRSs174wM0NvZIWZeJ4q4XQRNFz4+gUE2ut0QDjRFHA Ykgl50U7A49434BJpJnHJbWewtqNWof8k0/AU6XVSFgXeUAcLqd99Mz7vUTAnLmAuSnm igxQ== X-Gm-Message-State: AOJu0YwO1olfOwcQ+x/rZiQ+wxeW7kUK+uK2vrq64DGlfmhbGOhWx5H0 U4cDdIe+hSS4siE5pXx6oQidbMYx6aaFho52uqz9Kg== X-Received: by 2002:a05:600c:214f:b0:406:513d:738f with SMTP id v15-20020a05600c214f00b00406513d738fmr18787352wml.2.1697023154659; Wed, 11 Oct 2023 04:19:14 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:9134:b302:d8b:a200]) by smtp.gmail.com with ESMTPSA id a4-20020a05600c224400b003fe2b081661sm18945715wmm.30.2023.10.11.04.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 04:19:14 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Palmer Dabbelt , Paul Walmsley , Rob Herring , Krzysztof Kozlowski , Albert Ou , Jonathan Corbet , Andrew Jones , Evan Green , Conor Dooley Subject: [PATCH v1 01/13] riscv: fatorize hwprobe ISA extension reporting Date: Wed, 11 Oct 2023 13:14:26 +0200 Message-ID: <20231011111438.909552-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231011111438.909552-1-cleger@rivosinc.com> References: <20231011111438.909552-1-cleger@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 04:19:52 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779457793534002346 X-GMAIL-MSGID: 1779457793534002346 Factorize ISA extension reporting by using a macro rather than copy/pasting extension names. This will allow adding new extensions more easily. Signed-off-by: Clément Léger --- arch/riscv/kernel/sys_riscv.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c index 473159b5f303..5ce593ce07a4 100644 --- a/arch/riscv/kernel/sys_riscv.c +++ b/arch/riscv/kernel/sys_riscv.c @@ -145,20 +145,18 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, for_each_cpu(cpu, cpus) { struct riscv_isainfo *isainfo = &hart_isa[cpu]; - if (riscv_isa_extension_available(isainfo->isa, ZBA)) - pair->value |= RISCV_HWPROBE_EXT_ZBA; - else - missing |= RISCV_HWPROBE_EXT_ZBA; - - if (riscv_isa_extension_available(isainfo->isa, ZBB)) - pair->value |= RISCV_HWPROBE_EXT_ZBB; - else - missing |= RISCV_HWPROBE_EXT_ZBB; - - if (riscv_isa_extension_available(isainfo->isa, ZBS)) - pair->value |= RISCV_HWPROBE_EXT_ZBS; - else - missing |= RISCV_HWPROBE_EXT_ZBS; +#define CHECK_ISA_EXT(__ext) \ + do { \ + if (riscv_isa_extension_available(isainfo->isa, __ext)) \ + pair->value |= RISCV_HWPROBE_EXT_##__ext; \ + else \ + missing |= RISCV_HWPROBE_EXT_##__ext; \ + } while (false) \ + + CHECK_ISA_EXT(ZBA); + CHECK_ISA_EXT(ZBB); + CHECK_ISA_EXT(ZBS); +#undef CHECK_ISA_EXT } /* Now turn off reporting features if any CPU is missing it. */