From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EFCB3BBF6 for ; Tue, 16 Apr 2024 04:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713240736; cv=none; b=HEK/02pw7OObO88GlS37PHzFtf7YV8x3Fc7UXg5XbrXk+bTuTahS+1N6dCyZWPu3RAsgF2Is1j1YNPGaB21FUPcXJE/bPB5PJ1EQR20nMLk7jBDW11PbkxUgPAhDTX0uHZBNw7gKAHq8wKrZ7Vw7ilKxOo0UDGmhpKPAfE/BnPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713240736; c=relaxed/simple; bh=j7hOaHqP/gwoL4jD1U/UQdhE9yXcwGHiVrD2cYUclQM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KAzeXE6eJA6WKgWuQwk8MkHWtsyMZa3pC/HJ+WqqtcstZPzEWfJg7GOgwRYlUR3CpSPWEeSLqFbQ40VchW9CNAxdPIzWfkbSpsNB8OmNI+6gHWm4vrvxBCwQ8Dp5ECXZav8c78moYQ5mUowfu8gmbLitiNV+0/VV0JoFiELEhBU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=tyYXTK8j; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="tyYXTK8j" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6eb77e56b20so1652088a34.3 for ; Mon, 15 Apr 2024 21:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713240734; x=1713845534; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=RffB0o1A20UoURN50KRa9DaryhbtpvwRES2okh3bpYE=; b=tyYXTK8jfuXukektX0qQqknbP8WbyCPmD3yxNHBjdVM2LsDxkBcEJXCVjL9/Lez4ft ldJvkkgDw9aPCGGWgTmroXmViRwUZ+7guzKhAyat75WovoYt3zyUj8hn2H09/YxPbGry O6SN5sGA27pD085D7/l42RUarqXDqm3rbpC5mJzuWT+cXguBq3bUZdvLTsEj41b9wYie yYQwmyjJxB9KVdGkRWHF8ccSKiy5KD/UQrt/Z+FAcVOyjhtdWj0iIGUnZLzGdPuKWaAc 2Ps4GmqT+LZKdEbvicjH0U7gSFCeMWcQixyruZSrPAwQ2vDKMJ6MXSEclP60oDJWJ5uD rd1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713240734; x=1713845534; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RffB0o1A20UoURN50KRa9DaryhbtpvwRES2okh3bpYE=; b=XlEx+6Dzlf2aqbqLIor+djD9zY6O+oQnEYohYuBUJaVme8O6IHkQptygAcYt0xw1S2 +vyJwGF1MQv7qKPLdXdquAiaYzLQqKwRO5mdpjVnQ4ZF0eN3SkV1Sm84RVG2VRJyICyX Rv5cUC6U5oJyM3NKMxhwQcYC3Wp8N4k9knsfZ+rnVi99CaQrJnIcqmwpBDQhSaPxvLRi ZWQ5CpKYpUx6o5RuXj9lTvPN23cWTrc4PQSnZhA9kDN9xrqxvWfTTQ6M6dtFxobvjVoH 630CcDee5B9t53J5rcKiyNWUSkyqiv6H5rPfCps2Fpb50kP4HuGIsjwSfCWIbuGGEuQJ BGFw== X-Forwarded-Encrypted: i=1; AJvYcCVhessm7c1rbZ/2Sl9hHutdEZ99+T5UTyTcyUfcG9W2MMpqTquyd40nFti+A+qyKXjTz+yUgPtdk0plScOg3/iawgld4SDtNaeEoA== X-Gm-Message-State: AOJu0YwGgfJI/ErLi+fMUBC/sFxV2uV3vsot5q4piSAmtErldxhwzAp5 JBXbRNw4kM0iPONUuSP9NDsbHJZD9Y+HWTWWaVAp2EsMDxwmlwXFQkSJB31moo0= X-Google-Smtp-Source: AGHT+IHx670NU+TlR/f3v9B4Qzuah3bLLv9HaSlF62K+k8e99IHEN5iKr7nVeiVqlVhKiS267JiWCQ== X-Received: by 2002:a05:6808:199d:b0:3c7:2760:d52e with SMTP id bj29-20020a056808199d00b003c72760d52emr56390oib.52.1713240734403; Mon, 15 Apr 2024 21:12:14 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id z184-20020a6265c1000000b006ed4c430acesm8383149pfb.40.2024.04.15.21.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 21:12:13 -0700 (PDT) From: Charlie Jenkins Date: Mon, 15 Apr 2024 21:12:05 -0700 Subject: [PATCH v2 08/17] riscv: drivers: Convert xandespmu to use the vendor extension framework Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240415-dev-charlie-support_thead_vector_6_9-v2-8-c7d68c603268@rivosinc.com> References: <20240415-dev-charlie-support_thead_vector_6_9-v2-0-c7d68c603268@rivosinc.com> In-Reply-To: <20240415-dev-charlie-support_thead_vector_6_9-v2-0-c7d68c603268@rivosinc.com> To: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Conor Dooley , Evan Green , =?utf-8?q?Cl=C3=A9ment_L=C3=A9ger?= , Jonathan Corbet , Shuah Khan Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713240719; l=5822; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=j7hOaHqP/gwoL4jD1U/UQdhE9yXcwGHiVrD2cYUclQM=; b=0uoHwtzZ0HMjLFZ1Z0+67ZBZiFLnrjEiEVZz3A7YF2aFDJgj63u3xaTgyfzFXN4Mn1NQ/QS4Z dUA0C2swkhUANjDq2KpMi955RECXxD7uBiZof985lROPkNPq7hUBwOM X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= Migrate xandespmu out of riscv_isa_ext and into a new Andes-specific vendor namespace. Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/hwcap.h | 4 +++- arch/riscv/include/asm/vendor_extensions.h | 3 +++ arch/riscv/kernel/cpufeature.c | 1 - arch/riscv/kernel/vendor_extensions.c | 4 ++++ arch/riscv/kernel/vendor_extensions/Makefile | 1 + arch/riscv/kernel/vendor_extensions/andes_extensions.c | 13 +++++++++++++ drivers/perf/riscv_pmu_sbi.c | 7 ++++--- 7 files changed, 28 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 38157be5becd..4b986e4b56f2 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -80,7 +80,6 @@ #define RISCV_ISA_EXT_ZFA 71 #define RISCV_ISA_EXT_ZTSO 72 #define RISCV_ISA_EXT_ZACAS 73 -#define RISCV_ISA_EXT_XANDESPMU 74 #define RISCV_ISA_EXT_XLINUXENVCFG 127 @@ -103,6 +102,9 @@ */ #define RISCV_ISA_VENDOR_EXT_BASE 0x8000 +/* Andes Vendor Extensions */ +#define RISCV_ISA_VENDOR_EXT_XANDESPMU 0x8000 + /* THead Vendor Extensions */ #define RISCV_ISA_VENDOR_EXT_XTHEADVECTOR 0x8000 diff --git a/arch/riscv/include/asm/vendor_extensions.h b/arch/riscv/include/asm/vendor_extensions.h index 0a1955e1c900..33a430cc50cb 100644 --- a/arch/riscv/include/asm/vendor_extensions.h +++ b/arch/riscv/include/asm/vendor_extensions.h @@ -9,6 +9,9 @@ extern const struct riscv_isa_ext_data riscv_isa_vendor_ext_thead[]; extern const size_t riscv_isa_vendor_ext_count_thead; +extern const struct riscv_isa_ext_data riscv_isa_vendor_ext_andes[]; +extern const size_t riscv_isa_vendor_ext_count_andes; + bool get_isa_vendor_ext(unsigned long vendorid, const struct riscv_isa_ext_data **isa_vendor_ext, size_t *count); diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 799ec2d2e9e0..949c06970c4f 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -321,7 +321,6 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), - __RISCV_ISA_EXT_DATA(xandespmu, RISCV_ISA_EXT_XANDESPMU), }; const size_t riscv_isa_ext_count = ARRAY_SIZE(riscv_isa_ext); diff --git a/arch/riscv/kernel/vendor_extensions.c b/arch/riscv/kernel/vendor_extensions.c index 3a8a6c6dd34e..c5ca02ce1bb1 100644 --- a/arch/riscv/kernel/vendor_extensions.c +++ b/arch/riscv/kernel/vendor_extensions.c @@ -21,6 +21,10 @@ bool __init get_isa_vendor_ext(unsigned long vendorid, *isa_vendor_ext = riscv_isa_vendor_ext_thead; *count = riscv_isa_vendor_ext_count_thead; break; + case ANDES_VENDOR_ID: + *isa_vendor_ext = riscv_isa_vendor_ext_andes; + *count = riscv_isa_vendor_ext_count_andes; + break; default: *isa_vendor_ext = NULL; *count = 0; diff --git a/arch/riscv/kernel/vendor_extensions/Makefile b/arch/riscv/kernel/vendor_extensions/Makefile index dcf3de8d4658..8014594aafa1 100644 --- a/arch/riscv/kernel/vendor_extensions/Makefile +++ b/arch/riscv/kernel/vendor_extensions/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-y += andes_extensions.o obj-y += thead_extensions.o diff --git a/arch/riscv/kernel/vendor_extensions/andes_extensions.c b/arch/riscv/kernel/vendor_extensions/andes_extensions.c new file mode 100644 index 000000000000..b7450f99bfb5 --- /dev/null +++ b/arch/riscv/kernel/vendor_extensions/andes_extensions.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +#include + +const struct riscv_isa_ext_data riscv_isa_vendor_ext_andes[] = { + __RISCV_ISA_EXT_DATA(xandespmu, RISCV_ISA_VENDOR_EXT_XANDESPMU), +}; + +const size_t riscv_isa_vendor_ext_count_andes = ARRAY_SIZE(riscv_isa_vendor_ext_andes); diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 8cbe6e5f9c39..13e37296cb5f 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -24,6 +24,7 @@ #include #include #include +#include #define ALT_SBI_PMU_OVERFLOW(__ovl) \ asm volatile(ALTERNATIVE_2( \ @@ -32,7 +33,7 @@ asm volatile(ALTERNATIVE_2( \ THEAD_VENDOR_ID, ERRATA_THEAD_PMU, \ CONFIG_ERRATA_THEAD_PMU, \ "csrr %0, " __stringify(ANDES_CSR_SCOUNTEROF), \ - 0, RISCV_ISA_EXT_XANDESPMU, \ + ANDES_VENDOR_ID, RISCV_ISA_VENDOR_EXT_XANDESPMU, \ CONFIG_ANDES_CUSTOM_PMU) \ : "=r" (__ovl) : \ : "memory") @@ -41,7 +42,7 @@ asm volatile(ALTERNATIVE_2( \ asm volatile(ALTERNATIVE( \ "csrc " __stringify(CSR_IP) ", %0\n\t", \ "csrc " __stringify(ANDES_CSR_SLIP) ", %0\n\t", \ - 0, RISCV_ISA_EXT_XANDESPMU, \ + ANDES_VENDOR_ID, RISCV_ISA_VENDOR_EXT_XANDESPMU, \ CONFIG_ANDES_CUSTOM_PMU) \ : : "r"(__irq_mask) \ : "memory") @@ -837,7 +838,7 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde riscv_cached_mimpid(0) == 0) { riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU; riscv_pmu_use_irq = true; - } else if (riscv_isa_extension_available(NULL, XANDESPMU) && + } else if (riscv_isa_vendor_extension_available(NULL, XANDESPMU) && IS_ENABLED(CONFIG_ANDES_CUSTOM_PMU)) { riscv_pmu_irq_num = ANDES_SLI_CAUSE_BASE + ANDES_RV_IRQ_PMOVI; riscv_pmu_use_irq = true; -- 2.44.0