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 F0473C369CF for ; Fri, 18 Apr 2025 05:34:28 +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=rSRjCF+tZZdYQ9SGreH8SeWw+Jb6hYNfuZR3DyBaTuY=; b=w7EFet2h+NJJaz OiPRHgsQl28X+DR6hTKt+N1Kz/7pWXTtMEABhhc7E42vr9r0rG03yu+03FKaKvgnNVsHdT8IetWMc o/+v/+lGuFmaQM2MqVGV4yfHAOQRiylC8Wm3JolKj+/3aFVWjGCL6OgeubU5QvJ1l5aEid8WcnhV3 K3cifkf0I3lBvuiZkrtZkczKBg0zG9ijLopHLHwCqoYbTjd1Fmd5co6H3XhstZ+ZFsaLUTY4AV4mU g+nfBN/IGhzshB5tqnfuspvXzIrql48ShDM2v87ojkH0hgcgoLj1SMF63uOqLywNtyK2b3g4Z/jJC jN58HYDo72g25svh4hXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5eMq-0000000F9OJ-2aqN; Fri, 18 Apr 2025 05:34:24 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1u5eMo-0000000F9MG-0GuX for linux-riscv@lists.infradead.org; Fri, 18 Apr 2025 05:34:23 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7376dd56f60so1190236b3a.3 for ; Thu, 17 Apr 2025 22:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1744954461; x=1745559261; 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=1Vt4avVN1JMW1dLLTypBf6HyDWimdmGBTky31Gipgqs=; b=Tm14BAxfFv/mvQ6XS9TjMeWi9BIKMIwR0TuvzNh9jJNGHIpMWwM/AHhD5FzVu5dMOa 0AYtkQ72amDoHfDr9tEvGxj3eq6US7aDC3mKyC5IJ3IYwJVNJEa9OnV1UHNx9dkzsI+j ZclROL+aMeGvqnnlzobv8FMS8o4RG/fkO+CynDmW8kKvInR54jLqFzxf2NT9+ya8agNB b+N2rtCRCJoTgOX17CMO+PLWcxsZ6hzVuxWa8eMj3jkttUFcv2mSdAZvyYE/61JG9AmE h2G6qcxXwfHh6KJvf8q5ULxqbOlmwNhwQe/req182b00v6ByHuu/7yMtMsWLQiUHJwwY +P1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744954461; x=1745559261; 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=1Vt4avVN1JMW1dLLTypBf6HyDWimdmGBTky31Gipgqs=; b=sCufVGDP4ajLxjd13ZNcbygIIyLcP3YN5gFJHw6+dgBvrp+3MdFMMN4qV5ikw3bH0o bqNTgK+rKJ5w/iQFB0eBJ+TZPEA+Rb6KmLKFpbu8og44sm5cORHGDlvvSOCtSlh7eG0h bHuVIQ5VWN92mmrgAb/dj9VgzZ8YrHSNrDfMAYt6EDjIq7BMMtF5+qB9oUmkLLaWNJOo rig/BJ2UzRC144axKwS+4rbxscJRo1K365PmstiCMMO3QdBbwzfvo5czTq6h+8lV8RYa H4rXBLlOVHaHK6dLERfnAa6QA6wzOcFflQizePRjrxY59sIIF8sUCtNBPkhXcjb4kCjN DtIw== X-Forwarded-Encrypted: i=1; AJvYcCUhbv8u7V+Z32vzD+QbFy3GqrHQbO8E6JXe4tA68O7Kdd4xQB2Vdih5xKJhzQFv91EltYOdMyN3ULLeoQ==@lists.infradead.org X-Gm-Message-State: AOJu0YzkJ1b1Mvs0QdvfsPU3jPKsTTNgNvEQjwoWDogWkSsFwLRsfx5J b1cOEvzuC5ENAJJk1rkQcN7Cded4hz5/XItkMttg64kbAXvIV+BeMHoZp7oWO+s= X-Gm-Gg: ASbGncvB2+/cEXZiHtUkQwsxm9YWKIZXz9DSu48M6+Q1mr/GO6ThdcD2sqB/nvxo73Q p6wGWmSkKYZ1LgXLBeRJz1gkDkIHW1yBdb9CzI4qpZpTGVR7D+Hx2FVeJ3k5GXjcBTNzPXcGhyl GlGgQ0yg8CK3OStku8lpg/ZAPTk6Tt4R3lOYXQLl2hiC/K05XndgVU/NaLAZausrnVf5imXQ33h gorGX2ic7Ptt74t7CtM+styGK16nYDon0x4h4yt9ec5Jm9M7WVcbPxIgapqSfO64xcnYvf5D2Ce 16pnpT6WflpNW1kb8sm9JKfhXJzhlMv/Rt0cV679BFCOopePamyIQV4aVOifyxoAtHZmZdtwa/P V X-Google-Smtp-Source: AGHT+IH8oGcm9ULNBkRHJ+8ND/tHi2d1pyYFA/e6s/eR4NX5it1jIhKYwDK3JnyfigD7W5uIUOe5uA== X-Received: by 2002:a05:6a00:e05:b0:736:55ec:ea8b with SMTP id d2e1a72fcca58-73dc15cfb93mr2114304b3a.24.1744954461151; Thu, 17 Apr 2025 22:34:21 -0700 (PDT) Received: from cyan-mbp.internal.sifive.com ([136.226.240.168]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbfaed86csm834555b3a.180.2025.04.17.22.34.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 17 Apr 2025 22:34:20 -0700 (PDT) From: Cyan Yang To: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, samuel.holland@sifive.com Cc: linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Cyan Yang Subject: [PATCH 04/12] riscv: hwprobe: Add SiFive vendor extension support and probe for xsfqmaccdod and xsfqmaccqoq Date: Fri, 18 Apr 2025 13:32:31 +0800 Message-Id: <20250418053239.4351-5-cyan.yang@sifive.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20250418053239.4351-1-cyan.yang@sifive.com> References: <20250418053239.4351-1-cyan.yang@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250417_223422_103471_43672A6E X-CRM114-Status: GOOD ( 14.29 ) 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 Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0" which allows userspace to probe for the new vendor extensions from SiFive. Also, add new hwprobe for SiFive "xsfvqmaccdod" and "xsfvqmaccqoq" vendor extensions. Signed-off-by: Cyan Yang --- arch/riscv/include/asm/hwprobe.h | 1 + .../asm/vendor_extensions/sifive_hwprobe.h | 19 ++++++++++++++++++ arch/riscv/include/uapi/asm/vendor/sifive.h | 4 ++++ arch/riscv/kernel/sys_hwprobe.c | 5 +++++ arch/riscv/kernel/vendor_extensions/Makefile | 1 + .../kernel/vendor_extensions/sifive_hwprobe.c | 20 +++++++++++++++++++ 6 files changed, 50 insertions(+) create mode 100644 arch/riscv/include/asm/vendor_extensions/sifive_hwprobe.h create mode 100644 arch/riscv/include/uapi/asm/vendor/sifive.h create mode 100644 arch/riscv/kernel/vendor_extensions/sifive_hwprobe.c diff --git a/arch/riscv/include/asm/hwprobe.h b/arch/riscv/include/asm/hwprobe.h index 1c6977305776..7fe0a379474a 100644 --- a/arch/riscv/include/asm/hwprobe.h +++ b/arch/riscv/include/asm/hwprobe.h @@ -22,6 +22,7 @@ static inline bool hwprobe_key_is_bitmask(__s64 key) case RISCV_HWPROBE_KEY_IMA_EXT_0: case RISCV_HWPROBE_KEY_CPUPERF_0: case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0: + case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0: return true; } diff --git a/arch/riscv/include/asm/vendor_extensions/sifive_hwprobe.h b/arch/riscv/include/asm/vendor_extensions/sifive_hwprobe.h new file mode 100644 index 000000000000..90a61abd033c --- /dev/null +++ b/arch/riscv/include/asm/vendor_extensions/sifive_hwprobe.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_HWPROBE_H +#define _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_HWPROBE_H + +#include + +#include + +#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE +void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair, const struct cpumask *cpus); +#else +static inline void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair, + const struct cpumask *cpus) +{ + pair->value = 0; +} +#endif + +#endif diff --git a/arch/riscv/include/uapi/asm/vendor/sifive.h b/arch/riscv/include/uapi/asm/vendor/sifive.h new file mode 100644 index 000000000000..f25d8cf110d1 --- /dev/null +++ b/arch/riscv/include/uapi/asm/vendor/sifive.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#define RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD (1 << 0) +#define RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ (1 << 1) diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c index 249aec8594a9..138e74f05de7 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -300,6 +301,10 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair, pair->value = riscv_timebase; break; + case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0: + hwprobe_isa_vendor_ext_sifive_0(pair, cpus); + break; + case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0: hwprobe_isa_vendor_ext_thead_0(pair, cpus); break; diff --git a/arch/riscv/kernel/vendor_extensions/Makefile b/arch/riscv/kernel/vendor_extensions/Makefile index d5fdde0e863b..a4eca96d1c8a 100644 --- a/arch/riscv/kernel/vendor_extensions/Makefile +++ b/arch/riscv/kernel/vendor_extensions/Makefile @@ -2,5 +2,6 @@ obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive.o +obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive_hwprobe.o obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead.o obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead_hwprobe.o diff --git a/arch/riscv/kernel/vendor_extensions/sifive_hwprobe.c b/arch/riscv/kernel/vendor_extensions/sifive_hwprobe.c new file mode 100644 index 000000000000..461ce0f305ce --- /dev/null +++ b/arch/riscv/kernel/vendor_extensions/sifive_hwprobe.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +#include +#include + +#include +#include + +void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair, const struct cpumask *cpus) +{ + VENDOR_EXTENSION_SUPPORTED(pair, cpus, + riscv_isa_vendor_ext_list_sifive.per_hart_isa_bitmap, { + VENDOR_EXT_KEY(XSFVQMACCDOD); + VENDOR_EXT_KEY(XSFVQMACCQOQ); + }); +} -- 2.39.5 (Apple Git-154) _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv