Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3149863rdg; Tue, 17 Oct 2023 06:16:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsMnVGE44EjYnT2lFe3cQPz9WgqanzpDAOn5N1ux0j6lEfX4Z9ZWrBYioI1xy+nbX6n2dS X-Received: by 2002:a05:6359:318b:b0:166:d2ff:5c11 with SMTP id ri11-20020a056359318b00b00166d2ff5c11mr2288040rwb.29.1697548560650; Tue, 17 Oct 2023 06:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697548560; cv=none; d=google.com; s=arc-20160816; b=Mxd+5ILqhd4eR+3MvghUG55LyicL/+5SdJOzKgzQPXkFV7GsEIYcuZ6oo6bcUve/9n 4S4mhFsaKGBK20oCw7sAUip7fev4PiTP329E6/spZaXZbIARLIhoceMizAeML91mNzFC j6PKL0Jo08nYhooDp4oL9oqQj7rJaAebT470rjCpAXKPirlM1mgqYdm39yLS4WE2T2Vp YpdqGy8cIXjTvlndJK0YJXELZhE6HV3Fsre7aVNSNPIwEnXEgerNH6eUgZFH/bwSUyNu XxfoiSnoBWL4noKaehaQT+npglWlmKm2QPTi/9XLhcVXMZZFfqmRggWH1pBksNsPX891 8z+A== 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=gsST45qXCpXW6hXAZjZQAx82ZOViPLGcbU4pTeMM644=; fh=lvGFqwUxN+Dx1jonz8cRGrvjuKDcjMXylffmtrJGOYA=; b=d433CeDcAGy7DeugEPP/otHQ6hf3KFQ96jJ01qxXyrzIj0RGgXCwqBMk06dMmbqO5F e8LqoXXN03t0wd2KoT2REJ3bu26AXMA12PLzA900ygoJFLMzxMlEZtgtssYy/UJNFouQ X08hs0VhznlIE5tqj66OW2jYYygkR3Zf+eN6MAxwZIJxOlR0Uca+631cZu/e7hyStypM mkgjHZ63gHv/YhLjOOLj3Omm3AVbHWXdGA6s0fDHQR1k4lA3wbPNd65z7oYsO346KAPV 1YUFTQVCaEySGEFSxt7efrbJo9k9+ZJeEu9BdrO8gksvMFuHQ2K8g1wldlGlWEwvyzgl xcHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uyB2M5R+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s38-20020a056a0017a600b0068e4c3f3ac2si1637498pfg.245.2023.10.17.06.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=uyB2M5R+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C934D80CCDBC; Tue, 17 Oct 2023 06:15:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343820AbjJQNPf (ORCPT + 99 others); Tue, 17 Oct 2023 09:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbjJQNPb (ORCPT ); Tue, 17 Oct 2023 09:15:31 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8A2F7 for ; Tue, 17 Oct 2023 06:15:29 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-406aaccb41dso18299135e9.0 for ; Tue, 17 Oct 2023 06:15:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1697548528; x=1698153328; 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=gsST45qXCpXW6hXAZjZQAx82ZOViPLGcbU4pTeMM644=; b=uyB2M5R+DJ/rHyT6Pmb69lo81ITr7UvFocveAU7syQsTuFPZxtnivmU/7djjdH/e6y jqgjPATS5uES8wvBOPABCuOv4f/R+zRAN3MdNnMzTncivzd5IZH+DqPJjLzjIdcoe7Ba /oa7xLRjmNZHwV6KbrMMXEJFfO8mj1Qrikef9zh4o1Zwe0Dxxm28SpQXViBtQNm3S+sW H11nLtitzYJ9AuozwHdAWW7oC9/9zQWJXRRIkqj0iR+GscKQSF/kVuux8aCcvsdpeZvW yjHjr54HHK8XFYFurSGbMdcwOtOOTcWJly8QKti6dxieiw8Oo+GiIzxiAww27Rtnjbua EthA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697548528; x=1698153328; 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=gsST45qXCpXW6hXAZjZQAx82ZOViPLGcbU4pTeMM644=; b=GxXoJcMAWUSXWYkJP7ZoB+rbF4bJ/vCs5Ljd8Y40Ol3VpY2LRJnKD5g+8rLH+9wBjd fODJsUMJAysddRHt13MChC0M70VkkVtPP06ey/hIQpKe6Kl0TJFRgjnBSL50T+SXzjAP EYFgSRg8vfz7N2gW95LXThI2v9Uf275H9wVYAvUVf1z5YHYsHONEYnU5+FWYweMjpZWN s2upJGIY2G1OODiDLbWE3v/w6xijXtmxrUOY311r0HRnALFJkaDqrQaA8lj1fUDgphEZ W7ZCgfptxOO23hpUBrlNBfT8odhMVmgq9nl4EQ6tHYJGGrIZ4RWEhNuqe/v09i3e/huB +UKQ== X-Gm-Message-State: AOJu0Yzd2bbzARXZh9bIcSeNnMplq59b3XFybP5UUHP4m2oyuW3R314D jeDu4dKbU+tMceJMnM6+h3pRcko6gj4bVH3JGUjDuA== X-Received: by 2002:a05:600c:4f88:b0:405:3cc1:e115 with SMTP id n8-20020a05600c4f8800b004053cc1e115mr1603989wmq.3.1697548527550; Tue, 17 Oct 2023 06:15:27 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:96:820c:ecf7:a817]) by smtp.gmail.com with ESMTPSA id fj7-20020a05600c0c8700b0040772138bb7sm9873393wmb.2.2023.10.17.06.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 06:15:26 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Palmer Dabbelt , Paul Walmsley , Rob Herring , Krzysztof Kozlowski , Albert Ou , Jonathan Corbet , Andrew Jones , Evan Green , Conor Dooley , Samuel Ortiz Subject: [PATCH v2 01/19] riscv: hwprobe: factorize hwprobe ISA extension reporting Date: Tue, 17 Oct 2023 15:14:38 +0200 Message-ID: <20231017131456.2053396-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017131456.2053396-1-cleger@rivosinc.com> References: <20231017131456.2053396-1-cleger@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 06:15:55 -0700 (PDT) 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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c index 473159b5f303..e207874e686e 100644 --- a/arch/riscv/kernel/sys_riscv.c +++ b/arch/riscv/kernel/sys_riscv.c @@ -145,20 +145,24 @@ 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) + + /* + * Only use CHECK_ISA_EXT() for extensions which can be exposed + * to userspace, regardless of the kernel's configuration, as no + * other checks, besides presence in the hart_isa bitmap, are + * made. + */ + 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. */ -- 2.42.0