From patchwork Tue Nov 7 10:55:37 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: 13448503 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 CED66C4332F for ; Tue, 7 Nov 2023 10:56:21 +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=bpv0xQ33BXt++08AXX/aBg6gsJ/I9d7xsB2AQvOkT9g=; b=4ErTpCNXhuHT8V G/batjZYq+L+Z/vhqJK8IXT+SAhoihbZeKeLSQGzf8x9rkHUsuVi7rvCYCncnX8eUANz3Ex5YWMxp g0W4SQU92zEzXFABxvQiAEugxS0XFzb0aJ/2p8EWC5u27eAV2qb9Jno6An7f1RC1q/95u6FsjMDiA zw6McMq1LpvSwcXU/Z8suoR59fRNcAd0p9MHX8osvWinLeH0wI3T25ixOuGtq3IdRF+fJafLwzoB0 mrAFfrMPDufPgh2Z6RLmqqKHjvLIM5Wc2wLEUyeMjhkdrvW7xwLUPHZqd9RwnAt2xdi/x2O52JbRk kJxAvh97hQ4O4LJsoc3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0Jkc-00197W-2Y; Tue, 07 Nov 2023 10:56:06 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0JkZ-00195q-3A for linux-riscv@lists.infradead.org; Tue, 07 Nov 2023 10:56:05 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32f8246103cso1245160f8f.1 for ; Tue, 07 Nov 2023 02:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1699354561; x=1699959361; 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=yWXszjrW0mqtPT5ge0XuiGQJ6aaCxrPofMKEXjPvYnQ=; b=xJSABzs6oJEQAH7Jzpr0F2T9a8FphyxO8kRU8392181+LlRCSXC/0nPVrchmtbQtpO lkhPGnQQKIZdlGyliRA6476yzWGIx+0w6oNJWCtX68zBY46j75OV3SdX4wtD9VSQPhoJ wApOLhyOfgur6njsRfC5NE+01wD9x8quOlThRZa6kT7b2uk+JV/RzmEd7btc3t9+2ZET qIHgIgl2GPrfrLA4/k0oo1ZCrim9yfOIawz1+XRpH/BlijMR6Ct7FLkqeOWNaQEhqqyT /TsWe/9ZCV0EOA48hk93l6enqrEOTMTKCTd9PTtBoLZ1X+19Rzjz90L24DXakWF+xIjh kQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699354561; x=1699959361; 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=yWXszjrW0mqtPT5ge0XuiGQJ6aaCxrPofMKEXjPvYnQ=; b=ep7XQtbu0m0AtYORNwhqiCzqKAeF5YRdj+ZSq8c7pnwsbNRroWP8IWiiVEPKNz78NL RkeBUcgXcWNSu1/Z+B7rWMmQpVdYTgT0arc8Y/FynzRZIm81LT8hB0SqGLNldhFjRGNa k2Y83W8sgL2UvgKXWXsXpS7ITUKs5AgYilrooLACtDuZ++6LObloMF/W28tcoz6fkbno FMGypX4HVr7YF41Jln3svAqhn0cKOGxADcc59sTR7q9PbDaxag+F8p7rvqAs5sMdUlED WATFgBeTEqJoHF18b2yoKTSy0/Py4VQtUwpjYJu9f0o9GBZV6PLIkGKkbW5hoCAtZa0Q ebzw== X-Gm-Message-State: AOJu0YyVre/zVLZ/7RRlMoxOFpOrtliXoZYZEOqHb9gkVZSqPRW9TFsP WuHP6Unx5j0lHQy5YSXmucsIxwpG1+2x5rz8BirXJg== X-Google-Smtp-Source: AGHT+IGuavTtsmwxI8/q0+XaTOH3JqZmAYfCgV3LA6iUJWNnV+0tLfzziM9Sx1y+OIsrf624uUG+Gg== X-Received: by 2002:a05:600c:418a:b0:3fe:d637:7b25 with SMTP id p10-20020a05600c418a00b003fed6377b25mr25010147wmh.0.1699354561462; Tue, 07 Nov 2023 02:56:01 -0800 (PST) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:7db3:bdd9:4cab:2ee3]) by smtp.gmail.com with ESMTPSA id n30-20020a05600c501e00b00405442edc69sm15396853wmr.14.2023.11.07.02.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 02:56:00 -0800 (PST) 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 , Samuel Ortiz Subject: [PATCH v3 01/20] riscv: hwprobe: factorize hwprobe ISA extension reporting Date: Tue, 7 Nov 2023 11:55:37 +0100 Message-ID: <20231107105556.517187-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107105556.517187-1-cleger@rivosinc.com> References: <20231107105556.517187-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231107_025604_024667_F933E384 X-CRM114-Status: GOOD ( 12.61 ) 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 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 Reviewed-by: Evan Green --- 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 b651ec698a91..49aa4e82797c 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 are usable by + * userspace with respect to the kernel current configuration. + * For instance, ISA extensions that use float operations + * should not be exposed when CONFIG_FPU is not enabled. + */ + 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. */