Skip to contentSkip to conversation

Support Andes PMU extension

PATCH Superseded Yu Chien Peter Lin 8 participants 49 messages Nov 22, 2023 – Dec 12, 2023

Subsystems (9)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v4 cover Support Andes PMU extension

Hi All,

This patch series introduces the Andes PMU extension, which serves the same purpose as Sscofpmf. To use FDT-based probing the hardware support of the PMU extension, instead of adding another CPU errata, we have converted T-Head's PMU alternative along with this series.

Its non-standard local interrupt is assigned to bit 18 in the custom S-mode local interrupt enable/pending registers (slie/slip), while the interrupt cause is (256 + 18).

The feature needs the PMU device registered in OpenSBI. The OpenSBI and Linux patches can be found on Andes Technology GitHub
- https://github.com/andestech/opensbi/commits/andes-pmu-support-v3
- https://github.com/andestech/linux/commits/andes-pmu-support-v4

The PMU device tree node used on AX45MP:
- https://github.com/andestech/opensbi/blob/andes-pmu-support-v3/docs/pmu_support.md#example-3

Tested hardware:
- ASUS Tinker-V (RZ/Five, AX45MP single core)
- Andes AE350 (AX45MP quad core)

Locus Wei-Han Chen (1):
riscv: andes: Support symbolic FW and HW raw events

Yu Chien Peter Lin (12):
riscv: errata: Rename defines for Andes irqchip/riscv-intc: Allow large non-standard interrupt number irqchip/riscv-intc: Introduce Andes hart-level interrupt controller
dt-bindings: riscv: Add Andes interrupt controller compatible string
riscv: dts: renesas: r9a07g043f: Update compatible string to use Andes
INTC
perf: RISC-V: Eliminate redundant interrupt enable/disable operations
RISC-V: Move T-Head PMU to CPU feature alternative framework
perf: RISC-V: Introduce Andes PMU for perf event sampling
dt-bindings: riscv: Add T-Head PMU extension description
dt-bindings: riscv: Add Andes PMU extension description
riscv: dts: allwinner: Add T-Head PMU extension
riscv: dts: renesas: Add Andes PMU extension

 .../devicetree/bindings/riscv/cpus.yaml       |   6 +-
 .../devicetree/bindings/riscv/extensions.yaml |  13 ++
 arch/riscv/Kconfig.errata                     |  13 --
 arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi |   2 +-
 arch/riscv/boot/dts/renesas/r9a07g043f.dtsi   |   4 +-
 arch/riscv/errata/andes/errata.c              |  10 +-
 arch/riscv/errata/thead/errata.c              |  19 ---
 arch/riscv/include/asm/errata_list.h          |  19 +--
 arch/riscv/include/asm/hwcap.h                |   2 +
 arch/riscv/include/asm/vendorid_list.h        |   2 +-
 arch/riscv/kernel/alternative.c               |   2 +-
 arch/riscv/kernel/cpufeature.c                |   2 +
 drivers/irqchip/irq-riscv-intc.c              |  61 +++++++--
 drivers/perf/Kconfig                          |  27 ++++
 drivers/perf/riscv_pmu_sbi.c                  |  47 +++++--
 include/linux/soc/andes/irq.h                 |  17 +++
 .../arch/riscv/andes/ax45/firmware.json       |  68 ++++++++++
 .../arch/riscv/andes/ax45/instructions.json   | 127 ++++++++++++++++++
 .../arch/riscv/andes/ax45/memory.json         |  57 ++++++++
 .../arch/riscv/andes/ax45/microarch.json      |  77 +++++++++++
 tools/perf/pmu-events/arch/riscv/mapfile.csv  |   1 +
 21 files changed, 495 insertions(+), 81 deletions(-)
 create mode 100644 include/linux/soc/andes/irq.h
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/instructions.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/memory.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/microarch.json
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#1 lore raw

PATCH v4 1/13 riscv: errata: Rename defines for Andes

Using "ANDES" rather than "ANDESTECH" to unify the naming convention with directory, file names, Kconfig options and other definitions.

---
Changes v1 -> v2:
- No change
Changes v2 -> v3:
- Rewrote commit message (suggested by Conor)
Changes v3 -> v4:
- Include Conor's Acked-by tag

---
 arch/riscv/errata/andes/errata.c       | 10 +++++-----
 arch/riscv/include/asm/errata_list.h   |  4 ++--
 arch/riscv/include/asm/vendorid_list.h |  2 +-
 arch/riscv/kernel/alternative.c        |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)
arch/riscv/errata/andes/errata.c +5 -5
index 197db68cc8da..d2e1abcac967 100644
@@ -18,9 +18,9 @@
 #include <asm/sbi.h>
 #include <asm/vendorid_list.h>
 
-#define ANDESTECH_AX45MP_MARCHID	0x8000000000008a45UL
-#define ANDESTECH_AX45MP_MIMPID		0x500UL
-#define ANDESTECH_SBI_EXT_ANDES		0x0900031E
+#define ANDES_AX45MP_MARCHID		0x8000000000008a45UL
+#define ANDES_AX45MP_MIMPID		0x500UL
+#define ANDES_SBI_EXT_ANDES		0x0900031E
 
 #define ANDES_SBI_EXT_IOCP_SW_WORKAROUND	1
 
@@ -32,7 +32,7 @@ static long ax45mp_iocp_sw_workaround(void)
 	 * ANDES_SBI_EXT_IOCP_SW_WORKAROUND SBI EXT checks if the IOCP is missing and
 	 * cache is controllable only then CMO will be applied to the platform.
 	 */
-	ret = sbi_ecall(ANDESTECH_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
+	ret = sbi_ecall(ANDES_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
 			0, 0, 0, 0, 0, 0);
 
 	return ret.error ? 0 : ret.value;
@@ -43,7 +43,7 @@ static bool errata_probe_iocp(unsigned int stage, unsigned long arch_id, unsigne
 	if (!IS_ENABLED(CONFIG_ERRATA_ANDES_CMO))
 		return false;
 
-	if (arch_id != ANDESTECH_AX45MP_MARCHID || impid != ANDESTECH_AX45MP_MIMPID)
+	if (arch_id != ANDES_AX45MP_MARCHID || impid != ANDES_AX45MP_MIMPID)
 		return false;
 
 	if (!ax45mp_iocp_sw_workaround())
arch/riscv/include/asm/errata_list.h +2 -2
index 83ed25e43553..4ed21a62158c 100644
@@ -12,8 +12,8 @@
 #include <asm/vendorid_list.h>
 
 #ifdef CONFIG_ERRATA_ANDES
-#define ERRATA_ANDESTECH_NO_IOCP	0
-#define ERRATA_ANDESTECH_NUMBER		1
+#define ERRATA_ANDES_NO_IOCP 0
+#define ERRATA_ANDES_NUMBER 1
 #endif
 
 #ifdef CONFIG_ERRATA_SIFIVE
arch/riscv/include/asm/vendorid_list.h +1 -1
index e55407ace0c3..2f2bb0c84f9a 100644
@@ -5,7 +5,7 @@
 #ifndef ASM_VENDOR_LIST_H
 #define ASM_VENDOR_LIST_H
 
-#define ANDESTECH_VENDOR_ID	0x31e
+#define ANDES_VENDOR_ID		0x31e
 #define SIFIVE_VENDOR_ID	0x489
 #define THEAD_VENDOR_ID		0x5b7
 
arch/riscv/kernel/alternative.c +1 -1
index 319a1da0358b..0128b161bfda 100644
@@ -43,7 +43,7 @@ static void riscv_fill_cpu_mfr_info(struct cpu_manufacturer_info_t *cpu_mfr_info
 
 	switch (cpu_mfr_info->vendor_id) {
 #ifdef CONFIG_ERRATA_ANDES
-	case ANDESTECH_VENDOR_ID:
+	case ANDES_VENDOR_ID:
 		cpu_mfr_info->patch_func = andes_errata_patch_func;
 		break;
 #endif
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by Lad Prabhakar on v4 1/13
#2 lore raw

Re: [PATCH v4 01/13] riscv: errata: Rename defines for Andes

Quoted 16 lines · Yu Chien Peter Lin

Using "ANDES" rather than "ANDESTECH" to unify the naming convention with directory, file names, Kconfig options and other definitions.

---
Changes v1 -> v2:
- No change
Changes v2 -> v3:
- Rewrote commit message (suggested by Conor)
Changes v3 -> v4:
- Include Conor's Acked-by tag

Quoted 7 lines
---
 arch/riscv/errata/andes/errata.c       | 10 +++++-----
 arch/riscv/include/asm/errata_list.h   |  4 ++--
 arch/riscv/include/asm/vendorid_list.h |  2 +-
 arch/riscv/kernel/alternative.c        |  2 +-
 4 files changed, 9 insertions(+), 9 deletions(-)

Cheers,
Prabhakar

Quoted 80 lines
arch/riscv/errata/andes/errata.c +5 -5
index 197db68cc8da..d2e1abcac967 100644
@@ -18,9 +18,9 @@
 #include <asm/sbi.h>
 #include <asm/vendorid_list.h>
 
-#define ANDESTECH_AX45MP_MARCHID       0x8000000000008a45UL
-#define ANDESTECH_AX45MP_MIMPID                0x500UL
-#define ANDESTECH_SBI_EXT_ANDES                0x0900031E
+#define ANDES_AX45MP_MARCHID           0x8000000000008a45UL
+#define ANDES_AX45MP_MIMPID            0x500UL
+#define ANDES_SBI_EXT_ANDES            0x0900031E
 
 #define ANDES_SBI_EXT_IOCP_SW_WORKAROUND       1
 
@@ -32,7 +32,7 @@ static long ax45mp_iocp_sw_workaround(void)
         * ANDES_SBI_EXT_IOCP_SW_WORKAROUND SBI EXT checks if the IOCP is missing and
         * cache is controllable only then CMO will be applied to the platform.
         */
-       ret = sbi_ecall(ANDESTECH_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
+       ret = sbi_ecall(ANDES_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
                        0, 0, 0, 0, 0, 0);
 
        return ret.error ? 0 : ret.value;
@@ -43,7 +43,7 @@ static bool errata_probe_iocp(unsigned int stage, unsigned long arch_id, unsigne
        if (!IS_ENABLED(CONFIG_ERRATA_ANDES_CMO))
                return false;
 
-       if (arch_id != ANDESTECH_AX45MP_MARCHID || impid != ANDESTECH_AX45MP_MIMPID)
+       if (arch_id != ANDES_AX45MP_MARCHID || impid != ANDES_AX45MP_MIMPID)
                return false;
 
        if (!ax45mp_iocp_sw_workaround())
arch/riscv/include/asm/errata_list.h +2 -2
index 83ed25e43553..4ed21a62158c 100644
@@ -12,8 +12,8 @@
 #include <asm/vendorid_list.h>
 
 #ifdef CONFIG_ERRATA_ANDES
-#define ERRATA_ANDESTECH_NO_IOCP       0
-#define ERRATA_ANDESTECH_NUMBER                1
+#define ERRATA_ANDES_NO_IOCP 0
+#define ERRATA_ANDES_NUMBER 1
 #endif
 
 #ifdef CONFIG_ERRATA_SIFIVE
arch/riscv/include/asm/vendorid_list.h +1 -1
index e55407ace0c3..2f2bb0c84f9a 100644
@@ -5,7 +5,7 @@
 #ifndef ASM_VENDOR_LIST_H
 #define ASM_VENDOR_LIST_H
 
-#define ANDESTECH_VENDOR_ID    0x31e
+#define ANDES_VENDOR_ID                0x31e
 #define SIFIVE_VENDOR_ID       0x489
 #define THEAD_VENDOR_ID                0x5b7
 
arch/riscv/kernel/alternative.c +1 -2
index 319a1da0358b..0128b161bfda 100644
@@ -43,7 +43,7 @@ static void riscv_fill_cpu_mfr_info(struct cpu_manufacturer_info_t *cpu_mfr_info
 
        switch (cpu_mfr_info->vendor_id) {
 #ifdef CONFIG_ERRATA_ANDES
-       case ANDESTECH_VENDOR_ID:
+       case ANDES_VENDOR_ID:
                cpu_mfr_info->patch_func = andes_errata_patch_func;
                break;
 #endif
--

2.34.1

#3 lore raw

PATCH v4 2/13 irqchip/riscv-intc: Allow large non-standard interrupt number

In reply to Yu Chien Peter Lin

Currently, the implementation of the RISC-V INTC driver uses the interrupt cause as hwirq and has a limitation of supporting a maximum of 64 hwirqs. However, according to the privileged spec, interrupt causes >= 16 are defined for platform use.

This limitation prevents us from fully utilizing the available local interrupt sources. Additionally, the hwirqs used on RISC-V are sparse, with only interrupt numbers 1, 5 and 9 (plus Sscofpmf or T-Head's PMU irq) being currently used for supervisor mode.

Switch to using irq_domain_create_tree() to create the radix tree map, so a larger number of hardware interrupts can be handled.

---
Changes v1 -> v2:
- Fixed irq mapping failure checking (suggested by Clément and Anup)
Changes v2 -> v3:
- No change
Changes v3 -> v4: (Suggested by Thomas [1])
- Use pr_warn_ratelimited instead
- Fix coding style and commit message

[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/#25573085

---
 drivers/irqchip/irq-riscv-intc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/irqchip/irq-riscv-intc.c +4 -8
index e8d01b14ccdd..2fdd40f2a791 100644
@@ -24,10 +24,9 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs)
 {
 	unsigned long cause = regs->cause & ~CAUSE_IRQ_FLAG;
 
-	if (unlikely(cause >= BITS_PER_LONG))
-		panic("unexpected interrupt cause");
-
-	generic_handle_domain_irq(intc_domain, cause);
+	if (generic_handle_domain_irq(intc_domain, cause))
+		pr_warn_ratelimited("Failed to handle interrupt (cause: %ld)\n",
+				    cause);
 }
 
 /*
@@ -117,8 +116,7 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn)
 {
 	int rc;
 
-	intc_domain = irq_domain_create_linear(fn, BITS_PER_LONG,
-					       &riscv_intc_domain_ops, NULL);
+	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, NULL);
 	if (!intc_domain) {
 		pr_err("unable to add IRQ domain\n");
 		return -ENXIO;
@@ -132,8 +130,6 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn)
 
 	riscv_set_intc_hwnode_fn(riscv_intc_hwnode);
 
-	pr_info("%d local interrupts mapped\n", BITS_PER_LONG);
-
 	return 0;
 }
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#4 lore raw

Re: [PATCH v4 02/13] irqchip/riscv-intc: Allow large non-standard interrupt number

Quoted 2 lines · Yu Chien Peter Lin

Currently, the implementation of the RISC-V INTC driver uses the interrupt cause as hwirq and has a limitation of supporting a

s/hwirq/hardware interrupt/

Please spell things out. We are not on Xitter here.

Quoted 4 lines

maximum of 64 hwirqs. However, according to the privileged spec, interrupt causes >= 16 are defined for platform use.

This limitation prevents us from fully utilizing the available

This limitation prevents to fully utilize the ...

Quoted 6 lines

local interrupt sources. Additionally, the hwirqs used on RISC-V are sparse, with only interrupt numbers 1, 5 and 9 (plus Sscofpmf or T-Head's PMU irq) being currently used for supervisor mode.

Switch to using irq_domain_create_tree() to create the radix tree map, so a larger number of hardware interrupts can be handled.

#5 lore raw

Re: [PATCH v4 02/13] irqchip/riscv-intc: Allow large non-standard interrupt number

Hi Thomas,

Quoted 6 lines · Thomas Gleixner
Quoted 2 lines · Yu Chien Peter Lin

Currently, the implementation of the RISC-V INTC driver uses the interrupt cause as hwirq and has a limitation of supporting a

s/hwirq/hardware interrupt/

Quoted 8 lines

Please spell things out. We are not on Xitter here.

Quoted 4 lines

maximum of 64 hwirqs. However, according to the privileged spec, interrupt causes >= 16 are defined for platform use.

This limitation prevents us from fully utilizing the available

This limitation prevents to fully utilize the ...

Okay, will fix.

Thanks,
Peter Lin

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#6 lore raw

PATCH v4 3/13 irqchip/riscv-intc: Introduce Andes hart-level interrupt controller

In reply to Yu Chien Peter Lin

Add support for the Andes hart-level interrupt controller. This controller provides interrupt mask/unmask functions to access the custom register (SLIE) where the non-standard S-mode local interrupt enable bits are located.

To share the riscv_intc_domain_map() with the generic RISC-V INTC and ACPI, we add a chip parameter to riscv_intc_init_common(), so it can be passed to the irq_domain_set_info() as private data.

Andes hart-level interrupt controller requires the "andestech,cpu-intc" compatible string to be present in interrupt-controller of cpu node. e.g.,

  cpu0: cpu@0 {
      compatible = "andestech,ax45mp", "riscv";
      ...
      cpu0-intc: interrupt-controller {
          #interrupt-cells = <0x01>;
          compatible = "andestech,cpu-intc", "riscv,cpu-intc";
          interrupt-controller;
      };
  };

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Return -ENXIO if no valid compatible INTC found
- Allow falling back to generic RISC-V INTC
Changes v3 -> v4: (Suggested by Thomas [1])
- Add comment to andes irq chip function
- Refine code flow to share with generic RISC-V INTC and ACPI
- Move Andes specific definitions to include/linux/soc/andes/irq.h

[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/

---
 drivers/irqchip/irq-riscv-intc.c | 51 ++++++++++++++++++++++++++++----
 include/linux/soc/andes/irq.h    | 17 +++++++++++
 2 files changed, 63 insertions(+), 5 deletions(-)
 create mode 100644 include/linux/soc/andes/irq.h
drivers/irqchip/irq-riscv-intc.c +46 -5
index 2fdd40f2a791..30f0036c8978 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/soc/andes/irq.h>
 
 static struct irq_domain *intc_domain;
 
@@ -46,6 +47,31 @@ static void riscv_intc_irq_unmask(struct irq_data *d)
 	csr_set(CSR_IE, BIT(d->hwirq));
 }
 
+static void andes_intc_irq_mask(struct irq_data *d)
+{
+	/*
+	 * Andes specific S-mode local interrupt causes (hwirq)
+	 * are defined as (256 + n) and controlled by n-th bit
+	 * of SLIE.
+	 */
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);
+
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_clear(CSR_IE, mask);
+	else
+		csr_clear(ANDES_CSR_SLIE, mask);
+}
+
+static void andes_intc_irq_unmask(struct irq_data *d)
+{
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);
+
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_set(CSR_IE, mask);
+	else
+		csr_set(ANDES_CSR_SLIE, mask);
+}
+
 static void riscv_intc_irq_eoi(struct irq_data *d)
 {
 	/*
@@ -69,11 +95,20 @@ static struct irq_chip riscv_intc_chip = {
 	.irq_eoi = riscv_intc_irq_eoi,
 };
 
+static struct irq_chip andes_intc_chip = {
+	.name       = "RISC-V INTC",
+	.irq_mask   = andes_intc_irq_mask,
+	.irq_unmask = andes_intc_irq_unmask,
+	.irq_eoi    = riscv_intc_irq_eoi,
+};
+
 static int riscv_intc_domain_map(struct irq_domain *d, unsigned int irq,
 				 irq_hw_number_t hwirq)
 {
+	struct irq_chip *chip = d->host_data;
+
 	irq_set_percpu_devid(irq);
-	irq_domain_set_info(d, irq, hwirq, &riscv_intc_chip, d->host_data,
+	irq_domain_set_info(d, irq, hwirq, chip, d->host_data,
 			    handle_percpu_devid_irq, NULL, NULL);
 
 	return 0;
@@ -112,11 +147,12 @@ static struct fwnode_handle *riscv_intc_hwnode(void)
 	return intc_domain->fwnode;
 }
 
-static int __init riscv_intc_init_common(struct fwnode_handle *fn)
+static int __init riscv_intc_init_common(struct fwnode_handle *fn,
+					 struct irq_chip *chip)
 {
 	int rc;
 
-	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, NULL);
+	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, chip);
 	if (!intc_domain) {
 		pr_err("unable to add IRQ domain\n");
 		return -ENXIO;
@@ -138,6 +174,7 @@ static int __init riscv_intc_init(struct device_node *node,
 {
 	int rc;
 	unsigned long hartid;
+	struct irq_chip *chip = &riscv_intc_chip;
 
 	rc = riscv_of_parent_hartid(node, &hartid);
 	if (rc < 0) {
@@ -162,10 +199,14 @@ static int __init riscv_intc_init(struct device_node *node,
 		return 0;
 	}
 
-	return riscv_intc_init_common(of_node_to_fwnode(node));
+	if (of_device_is_compatible(node, "andestech,cpu-intc"))
+		chip = &andes_intc_chip;
+
+	return riscv_intc_init_common(of_node_to_fwnode(node), chip);
 }
 
 IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init);
+IRQCHIP_DECLARE(andes, "andestech,cpu-intc", riscv_intc_init);
 
 #ifdef CONFIG_ACPI
 
@@ -192,7 +233,7 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,
 		return -ENOMEM;
 	}
 
-	return riscv_intc_init_common(fn);
+	return riscv_intc_init_common(fn, &riscv_intc_chip);
 }
 
 IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL,
include/linux/soc/andes/irq.h new file +17 -0
new file mode 100644
index 000000000000..f03e68fea261
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2023 Andes Technology Corporation
+ */
+#ifndef __ANDES_IRQ_H
+#define __ANDES_IRQ_H
+
+/* Andes PMU irq number */
+#define ANDES_RV_IRQ_PMU		18
+#define ANDES_SLI_CAUSE_BASE		256
+
+/* Andes PMU related registers */
+#define ANDES_CSR_SLIE			0x9c4
+#define ANDES_CSR_SLIP			0x9c5
+#define ANDES_CSR_SCOUNTEROF		0x9d4
+
+#endif /* __ANDES_IRQ_H */
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#7 lore raw

Re: [PATCH v4 03/13] irqchip/riscv-intc: Introduce Andes hart-level interrupt controller

Quoted 2 lines · Yu Chien Peter Lin

To share the riscv_intc_domain_map() with the generic RISC-V INTC and ACPI, we add a chip parameter to riscv_intc_init_common(), so it can be

s/we//

See: Documentation/process/

Quoted 15 lines

passed to the irq_domain_set_info() as private data.

drivers/irqchip/irq-riscv-intc.c +1 -0
index 2fdd40f2a791..30f0036c8978 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/soc/andes/irq.h>
 
 static struct irq_domain *intc_domain;
 
@@ -46,6 +47,31 @@ static void riscv_intc_irq_unmask(struct irq_data *d)
 	csr_set(CSR_IE, BIT(d->hwirq));

drivers/irqchip/irq-riscv-intc.c static void riscv_intc_irq_unmask(struct irq_data *d) · line 57

Quoted 10 lines
drivers/irqchip/irq-riscv-intc.c +8 -0
 }
 
+static void andes_intc_irq_mask(struct irq_data *d)
+{
+	/*
+	 * Andes specific S-mode local interrupt causes (hwirq)
+	 * are defined as (256 + n) and controlled by n-th bit
+	 * of SLIE.
+	 */
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);

How is this supposed to be correct with BITS_PER_LONG == 64?

drivers/irqchip/irq-riscv-intc.c static void riscv_intc_irq_unmask(struct irq_data *d) · line 67

Quoted 10 lines
drivers/irqchip/irq-riscv-intc.c +10 -0
+
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_clear(CSR_IE, mask);
+	else
+		csr_clear(ANDES_CSR_SLIE, mask);
+}
+
+static void andes_intc_irq_unmask(struct irq_data *d)
+{
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);

Ditto.

Quoted 4 lines
drivers/irqchip/irq-riscv-intc.c +4 -0
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_set(CSR_IE, mask);
+	else
+		csr_set(ANDES_CSR_SLIE, mask);

drivers/irqchip/irq-riscv-intc.c static struct irq_chip riscv_intc_chip = { · line 111

Quoted 10 lines
drivers/irqchip/irq-riscv-intc.c +4 -1
+}
 
 static int riscv_intc_domain_map(struct irq_domain *d, unsigned int irq,
 				 irq_hw_number_t hwirq)
 {
+	struct irq_chip *chip = d->host_data;
+
 	irq_set_percpu_devid(irq);
-	irq_domain_set_info(d, irq, hwirq, &riscv_intc_chip, d->host_data,
+	irq_domain_set_info(d, irq, hwirq, chip, d->host_data,

So this sets 'chip_data' to the chip itself. What's the point? Just set it to NULL as the chip obviously does not need chip_data at all.

Quoted 19 lines
drivers/irqchip/irq-riscv-intc.c +3 -2
 			    handle_percpu_devid_irq, NULL, NULL);
 
 	return 0;
@@ -112,11 +147,12 @@ static struct fwnode_handle *riscv_intc_hwnode(void)
 	return intc_domain->fwnode;
 }
 
-static int __init riscv_intc_init_common(struct fwnode_handle *fn)
+static int __init riscv_intc_init_common(struct fwnode_handle *fn,
+					 struct irq_chip *chip)
 {
 	int rc;
 
-	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, NULL);
+	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, chip);
 	if (!intc_domain) {
 		pr_err("unable to add IRQ domain\n");
 		return -ENXIO;

drivers/irqchip/irq-riscv-intc.c static int __init riscv_intc_init(struct device_node *node, · line 177

Quoted 4 lines
drivers/irqchip/irq-riscv-intc.c +1 -0
@@ -138,6 +174,7 @@ static int __init riscv_intc_init(struct device_node *node,
 {
 	int rc;
 	unsigned long hartid;
+	struct irq_chip *chip = &riscv_intc_chip;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

Thanks

tglx

#8 lore raw

Re: [PATCH v4 03/13] irqchip/riscv-intc: Introduce Andes hart-level interrupt controller

Hi Thomas,

Quoted 25 lines · Thomas Gleixner
Quoted 2 lines · Yu Chien Peter Lin

To share the riscv_intc_domain_map() with the generic RISC-V INTC and ACPI, we add a chip parameter to riscv_intc_init_common(), so it can be

s/we//

See: Documentation/process/

Quoted 17 lines

passed to the irq_domain_set_info() as private data.

drivers/irqchip/irq-riscv-intc.c +1 -0
index 2fdd40f2a791..30f0036c8978 100644
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/smp.h>
+#include <linux/soc/andes/irq.h>
 
 static struct irq_domain *intc_domain;
 
@@ -46,6 +47,31 @@ static void riscv_intc_irq_unmask(struct irq_data *d)
 	csr_set(CSR_IE, BIT(d->hwirq));
 }
 
Quoted 10 lines

drivers/irqchip/irq-riscv-intc.c static void riscv_intc_irq_unmask(struct irq_data *d) · line 57

Quoted 8 lines
drivers/irqchip/irq-riscv-intc.c +8 -0
+static void andes_intc_irq_mask(struct irq_data *d)
+{
+	/*
+	 * Andes specific S-mode local interrupt causes (hwirq)
+	 * are defined as (256 + n) and controlled by n-th bit
+	 * of SLIE.
+	 */
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);

How is this supposed to be correct with BITS_PER_LONG == 64?

Yes, I should subtract ANDES_SLI_CAUSE_BASE directly here.

Quoted 19 lines

drivers/irqchip/irq-riscv-intc.c static void riscv_intc_irq_unmask(struct irq_data *d) · line 67

Quoted 10 lines
drivers/irqchip/irq-riscv-intc.c +10 -0
+
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_clear(CSR_IE, mask);
+	else
+		csr_clear(ANDES_CSR_SLIE, mask);
+}
+
+static void andes_intc_irq_unmask(struct irq_data *d)
+{
+	unsigned int mask = BIT(d->hwirq % BITS_PER_LONG);

Ditto.

Quoted 5 lines
drivers/irqchip/irq-riscv-intc.c +5 -0
+	if (d->hwirq < ANDES_SLI_CAUSE_BASE)
+		csr_set(CSR_IE, mask);
+	else
+		csr_set(ANDES_CSR_SLIE, mask);
+}
Quoted 11 lines

drivers/irqchip/irq-riscv-intc.c static struct irq_chip riscv_intc_chip = { · line 111

Quoted 8 lines
drivers/irqchip/irq-riscv-intc.c +2 -0
 static int riscv_intc_domain_map(struct irq_domain *d, unsigned int irq,
 				 irq_hw_number_t hwirq)
 {
+	struct irq_chip *chip = d->host_data;
+
drivers/irqchip/irq-riscv-intc.c +1 -1
 	irq_set_percpu_devid(irq);
-	irq_domain_set_info(d, irq, hwirq, &riscv_intc_chip, d->host_data,
+	irq_domain_set_info(d, irq, hwirq, chip, d->host_data,

So this sets 'chip_data' to the chip itself. What's the point? Just set it to NULL as the chip obviously does not need chip_data at all.

Will fix. Thanks.

Best regards,
Peter Lin

Quoted 29 lines
Quoted 19 lines
drivers/irqchip/irq-riscv-intc.c +3 -2
 			    handle_percpu_devid_irq, NULL, NULL);
 
 	return 0;
@@ -112,11 +147,12 @@ static struct fwnode_handle *riscv_intc_hwnode(void)
 	return intc_domain->fwnode;
 }
 
-static int __init riscv_intc_init_common(struct fwnode_handle *fn)
+static int __init riscv_intc_init_common(struct fwnode_handle *fn,
+					 struct irq_chip *chip)
 {
 	int rc;
 
-	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, NULL);
+	intc_domain = irq_domain_create_tree(fn, &riscv_intc_domain_ops, chip);
 	if (!intc_domain) {
 		pr_err("unable to add IRQ domain\n");
 		return -ENXIO;

drivers/irqchip/irq-riscv-intc.c static int __init riscv_intc_init(struct device_node *node, · line 177

Quoted 4 lines
drivers/irqchip/irq-riscv-intc.c +1 -0
@@ -138,6 +174,7 @@ static int __init riscv_intc_init(struct device_node *node,
 {
 	int rc;
 	unsigned long hartid;
+	struct irq_chip *chip = &riscv_intc_chip;

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

Thanks

tglx

#9 lore raw

PATCH v4 4/13 dt-bindings: riscv: Add Andes interrupt controller compatible string

In reply to Yu Chien Peter Lin

Add "andestech,cpu-intc" compatible string to indicate that Andes specific local interrupt is supported on the core, e.g. AX45MP cores have 3 types of non-standard local interrupt can be handled in supervisor mode:

- Slave port ECC error interrupt
- Bus write transaction error interrupt
- Performance monitor overflow interrupt

These interrupts are enabled/disabled via a custom register SLIE instead of the standard interrupt enable register SIE.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Updated commit message
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- Add const entry instead of enum (Suggested by Conor)

---
 Documentation/devicetree/bindings/riscv/cpus.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/riscv/cpus.yaml +5 -1
index f392e367d673..50307554478f 100644
@@ -100,7 +100,11 @@ properties:
         const: 1
 
       compatible:
-        const: riscv,cpu-intc
+        oneOf:
+          - items:
+              - const: andestech,cpu-intc
+              - const: riscv,cpu-intc
+          - const: riscv,cpu-intc
 
       interrupt-controller: true
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Acked-by on v4 4/13
#10 lore raw

Re: [PATCH v4 04/13] dt-bindings: riscv: Add Andes interrupt controller compatible string

Quoted 5 lines · Yu Chien Peter Lin

Add "andestech,cpu-intc" compatible string to indicate that Andes specific local interrupt is supported on the core, e.g. AX45MP cores have 3 types of non-standard local interrupt can be handled in supervisor mode:

Quoted 8 lines

- Slave port ECC error interrupt
- Bus write transaction error interrupt
- Performance monitor overflow interrupt

These interrupts are enabled/disabled via a custom register SLIE instead of the standard interrupt enable register SIE.

Cheers,
Conor.

Quoted 32 lines

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Updated commit message
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- Add const entry instead of enum (Suggested by Conor)

---
 Documentation/devicetree/bindings/riscv/cpus.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/riscv/cpus.yaml +5 -1
index f392e367d673..50307554478f 100644
@@ -100,7 +100,11 @@ properties:
         const: 1
 
       compatible:
-        const: riscv,cpu-intc
+        oneOf:
+          - items:
+              - const: andestech,cpu-intc
+              - const: riscv,cpu-intc
+          - const: riscv,cpu-intc
 
       interrupt-controller: true
 
Signature · 1 line
2.34.1
Reviewed-by Lad Prabhakar on v4 4/13
#11 lore raw

Re: [PATCH v4 04/13] dt-bindings: riscv: Add Andes interrupt controller compatible string

In reply to Yu Chien Peter Lin
Quoted 31 lines · Yu Chien Peter Lin

Add "andestech,cpu-intc" compatible string to indicate that Andes specific local interrupt is supported on the core, e.g. AX45MP cores have 3 types of non-standard local interrupt can be handled in supervisor mode:

- Slave port ECC error interrupt
- Bus write transaction error interrupt
- Performance monitor overflow interrupt

These interrupts are enabled/disabled via a custom register SLIE instead of the standard interrupt enable register SIE.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Updated commit message
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- Add const entry instead of enum (Suggested by Conor)

---
 Documentation/devicetree/bindings/riscv/cpus.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
index f392e367d673..50307554478f 100644

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 105

Quoted 7 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +3 -1
@@ -100,7 +100,11 @@ properties:
         const: 1
 
       compatible:
-        const: riscv,cpu-intc
+        oneOf:
+          - items:
+              - const: andestech,cpu-intc

given that the first patch renames andestech -> andes, do you want to follow the same here?

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 110

Quoted 5 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +2 -0
+              - const: riscv,cpu-intc
+          - const: riscv,cpu-intc
 
       interrupt-controller: true
 

Cheers,
Prabhakar

Quoted 4 lines

--
2.34.1

#12 lore raw

Re: [PATCH v4 04/13] dt-bindings: riscv: Add Andes interrupt controller compatible string

Quoted 35 lines · Prabhakar
Quoted 33 lines · Yu Chien Peter Lin

Add "andestech,cpu-intc" compatible string to indicate that Andes specific local interrupt is supported on the core, e.g. AX45MP cores have 3 types of non-standard local interrupt can be handled in supervisor mode:

- Slave port ECC error interrupt
- Bus write transaction error interrupt
- Performance monitor overflow interrupt

These interrupts are enabled/disabled via a custom register SLIE instead of the standard interrupt enable register SIE.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Updated commit message
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- Add const entry instead of enum (Suggested by Conor)

---
 Documentation/devicetree/bindings/riscv/cpus.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
index f392e367d673..50307554478f 100644
@@ -100,7 +100,11 @@ properties:
         const: 1
 
Quoted 7 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 105

Quoted 5 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +3 -1
       compatible:
-        const: riscv,cpu-intc
+        oneOf:
+          - items:
+              - const: andestech,cpu-intc

given that the first patch renames andestech -> andes, do you want to follow the same here?

No, that's their vendor prefix, they're stuck with it.

#13 lore raw

Re: [PATCH v4 04/13] dt-bindings: riscv: Add Andes interrupt controller compatible string

In reply to Lad, Prabhakar

Hi Prabhakar,

Quoted 35 lines · Prabhakar
Quoted 33 lines · Yu Chien Peter Lin

Add "andestech,cpu-intc" compatible string to indicate that Andes specific local interrupt is supported on the core, e.g. AX45MP cores have 3 types of non-standard local interrupt can be handled in supervisor mode:

- Slave port ECC error interrupt
- Bus write transaction error interrupt
- Performance monitor overflow interrupt

These interrupts are enabled/disabled via a custom register SLIE instead of the standard interrupt enable register SIE.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Updated commit message
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- Add const entry instead of enum (Suggested by Conor)

---
 Documentation/devicetree/bindings/riscv/cpus.yaml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/riscv/cpus.yaml +0 -0
index f392e367d673..50307554478f 100644
@@ -100,7 +100,11 @@ properties:
         const: 1
 
Quoted 7 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 105

Quoted 5 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +3 -1
       compatible:
-        const: riscv,cpu-intc
+        oneOf:
+          - items:
+              - const: andestech,cpu-intc

given that the first patch renames andestech -> andes, do you want to follow the same here?

Thanks for pointing this out.
We would like to use "andestech" for compatible string.

Documentation/devicetree/bindings/vendor-prefixes.yaml 118: "^andestech,.*":
119- description: Andes Technology Corporation

Quoted 6 lines

Documentation/devicetree/bindings/riscv/cpus.yaml properties: · line 110

Quoted 5 lines
Documentation/devicetree/bindings/riscv/cpus.yaml +2 -0
+              - const: riscv,cpu-intc
+          - const: riscv,cpu-intc
 
       interrupt-controller: true
 

Thanks for the review!

Best regards,
Peter Lin

Quoted 7 lines

Cheers,
Prabhakar

Quoted 4 lines

--
2.34.1

#14 lore raw

PATCH v4 5/13 riscv: dts: renesas: r9a07g043f: Update compatible string to use Andes INTC

In reply to Yu Chien Peter Lin

The Andes hart-level interrupt controller (Andes INTC) allows AX45MP cores to handle custom local interrupts, such as the performance counter overflow interrupt.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- No change

---
 arch/riscv/boot/dts/renesas/r9a07g043f.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/renesas/r9a07g043f.dtsi +1 -1
index eb301d8eb2b0..78072e80793d 100644
@@ -38,7 +38,7 @@ cpu0: cpu@0 {
 
 			cpu0_intc: interrupt-controller {
 				#interrupt-cells = <1>;
-				compatible = "riscv,cpu-intc";
+				compatible = "andestech,cpu-intc", "riscv,cpu-intc";
 				interrupt-controller;
 			};
 		};
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v4 5/13
#15 lore raw

Re: [PATCH v4 05/13] riscv: dts: renesas: r9a07g043f: Update compatible string to use Andes INTC

Quoted 5 lines · Yu Chien Peter Lin

The Andes hart-level interrupt controller (Andes INTC) allows AX45MP cores to handle custom local interrupts, such as the performance counter overflow interrupt.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Reviewed-by Lad Prabhakar Tested-by Lad Prabhakar on v4 5/13
#16 lore raw

Re: [PATCH v4 05/13] riscv: dts: renesas: r9a07g043f: Update compatible string to use Andes INTC

In reply to Yu Chien Peter Lin
Quoted 13 lines · Yu Chien Peter Lin

The Andes hart-level interrupt controller (Andes INTC) allows AX45MP cores to handle custom local interrupts, such as the performance counter overflow interrupt.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Fixed possible compatibles for Andes INTC
Changes v3 -> v4:
- No change

Quoted 4 lines
---
 arch/riscv/boot/dts/renesas/r9a07g043f.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Cheers,
Prabhakar

Quoted 17 lines
arch/riscv/boot/dts/renesas/r9a07g043f.dtsi +1 -2
index eb301d8eb2b0..78072e80793d 100644
@@ -38,7 +38,7 @@ cpu0: cpu@0 {
 
                        cpu0_intc: interrupt-controller {
                                #interrupt-cells = <1>;
-                               compatible = "riscv,cpu-intc";
+                               compatible = "andestech,cpu-intc", "riscv,cpu-intc";
                                interrupt-controller;
                        };
                };
--

2.34.1

#17 lore raw

PATCH v4 6/13 perf: RISC-V: Eliminate redundant interrupt enable/disable operations

In reply to Yu Chien Peter Lin

The interrupt enable/disable operations are already performed by the IRQ chip functions riscv_intc_irq_unmask()/riscv_intc_irq_mask() during enable_percpu_irq()/disable_percpu_irq(). We can just do it once.

---
This patch allows us to drop unnecessary ALT_SBI_PMU_OVF_{DISABLE,ENABLE} in the last PATCH3 [1].

[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/

Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- No change
Changes v3 -> v4:
- No change

---
 drivers/perf/riscv_pmu_sbi.c | 2 --
 1 file changed, 2 deletions(-)
drivers/perf/riscv_pmu_sbi.c +0 -2
index 16acd4dcdb96..2edbc37abadf 100644
@@ -781,7 +781,6 @@ static int pmu_sbi_starting_cpu(unsigned int cpu, struct hlist_node *node)
 	if (riscv_pmu_use_irq) {
 		cpu_hw_evt->irq = riscv_pmu_irq;
 		csr_clear(CSR_IP, BIT(riscv_pmu_irq_num));
-		csr_set(CSR_IE, BIT(riscv_pmu_irq_num));
 		enable_percpu_irq(riscv_pmu_irq, IRQ_TYPE_NONE);
 	}
 
@@ -792,7 +791,6 @@ static int pmu_sbi_dying_cpu(unsigned int cpu, struct hlist_node *node)
 {
 	if (riscv_pmu_use_irq) {
 		disable_percpu_irq(riscv_pmu_irq);
-		csr_clear(CSR_IE, BIT(riscv_pmu_irq_num));
 	}
 
 	/* Disable all counters access for user mode now */
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#18 lore raw

PATCH v4 7/13 RISC-V: Move T-Head PMU to CPU feature alternative framework

In reply to Yu Chien Peter Lin

The custom PMU extension aims to support perf event sampling prior to the ratification of Sscofpmf. Instead of diverting the bits and register reserved for future standard, a set of custom registers is added. Hence, we may consider it as a CPU feature rather than an erratum.

T-Head cores need to append "xtheadpmu" to the riscv,isa-extensions for each cpu node in device tree, and enable CONFIG_THEAD_CUSTOM_PMU for proper functioning as of this commit.

---
Hi All,

This is in preparation for introducing other PMU alternative. We follow Conor's suggestion [1][2] to use cpu feature alternative framework rather than errata, I'm happy to drop the patch if someone is willing to take care of this for T-Head's platforms (or sticking with CPU errata alternative?)

[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/#25503860
[2] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/#25565650

Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Removed m{vendor/arch/imp}id checks in pmu_sbi_setup_irqs()
Changes v3 -> v4:
- No change

---
 arch/riscv/Kconfig.errata            | 13 -------------
 arch/riscv/errata/thead/errata.c     | 19 -------------------
 arch/riscv/include/asm/errata_list.h | 15 +--------------
 arch/riscv/include/asm/hwcap.h       |  1 +
 arch/riscv/kernel/cpufeature.c       |  1 +
 drivers/perf/Kconfig                 | 13 +++++++++++++
 drivers/perf/riscv_pmu_sbi.c         | 19 ++++++++++++++-----
 7 files changed, 30 insertions(+), 51 deletions(-)
arch/riscv/Kconfig.errata +0 -13
index e2c731cfed8c..0d19f47d1018 100644
@@ -86,17 +86,4 @@ config ERRATA_THEAD_CMO
 
 	  If you don't know what to do here, say "Y".
 
-config ERRATA_THEAD_PMU
-	bool "Apply T-Head PMU errata"
-	depends on ERRATA_THEAD && RISCV_PMU_SBI
-	default y
-	help
-	  The T-Head C9xx cores implement a PMU overflow extension very
-	  similar to the core SSCOFPMF extension.
-
-	  This will apply the overflow errata to handle the non-standard
-	  behaviour via the regular SBI PMU driver and interface.
-
-	  If you don't know what to do here, say "Y".
-
 endmenu # "CPU errata selection"
arch/riscv/errata/thead/errata.c +0 -19
index 0554ed4bf087..5de5f7209132 100644
@@ -53,22 +53,6 @@ static bool errata_probe_cmo(unsigned int stage,
 	return true;
 }
 
-static bool errata_probe_pmu(unsigned int stage,
-			     unsigned long arch_id, unsigned long impid)
-{
-	if (!IS_ENABLED(CONFIG_ERRATA_THEAD_PMU))
-		return false;
-
-	/* target-c9xx cores report arch_id and impid as 0 */
-	if (arch_id != 0 || impid != 0)
-		return false;
-
-	if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
-		return false;
-
-	return true;
-}
-
 static u32 thead_errata_probe(unsigned int stage,
 			      unsigned long archid, unsigned long impid)
 {
@@ -80,9 +64,6 @@ static u32 thead_errata_probe(unsigned int stage,
 	if (errata_probe_cmo(stage, archid, impid))
 		cpu_req_errata |= BIT(ERRATA_THEAD_CMO);
 
-	if (errata_probe_pmu(stage, archid, impid))
-		cpu_req_errata |= BIT(ERRATA_THEAD_PMU);
-
 	return cpu_req_errata;
 }
 
arch/riscv/include/asm/errata_list.h +1 -14
index 4ed21a62158c..9bccc2ba0eb5 100644
@@ -25,8 +25,7 @@
 #ifdef CONFIG_ERRATA_THEAD
 #define	ERRATA_THEAD_PBMT 0
 #define	ERRATA_THEAD_CMO 1
-#define	ERRATA_THEAD_PMU 2
-#define	ERRATA_THEAD_NUMBER 3
+#define	ERRATA_THEAD_NUMBER 2
 #endif
 
 #ifdef __ASSEMBLY__
@@ -147,18 +146,6 @@ asm volatile(ALTERNATIVE_2(						\
 	    "r"((unsigned long)(_start) + (_size))			\
 	: "a0")
 
-#define THEAD_C9XX_RV_IRQ_PMU			17
-#define THEAD_C9XX_CSR_SCOUNTEROF		0x5c5
-
-#define ALT_SBI_PMU_OVERFLOW(__ovl)					\
-asm volatile(ALTERNATIVE(						\
-	"csrr %0, " __stringify(CSR_SSCOUNTOVF),			\
-	"csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),		\
-		THEAD_VENDOR_ID, ERRATA_THEAD_PMU,			\
-		CONFIG_ERRATA_THEAD_PMU)				\
-	: "=r" (__ovl) :						\
-	: "memory")
-
 #endif /* __ASSEMBLY__ */
 
 #endif
arch/riscv/include/asm/hwcap.h +1 -0
index 06d30526ef3b..c85ee34c78d9 100644
@@ -57,6 +57,7 @@
 #define RISCV_ISA_EXT_ZIHPM		42
 #define RISCV_ISA_EXT_SMSTATEEN		43
 #define RISCV_ISA_EXT_ZICOND		44
+#define RISCV_ISA_EXT_XTHEADPMU		45
 
 #define RISCV_ISA_EXT_MAX		64
 
arch/riscv/kernel/cpufeature.c +1 -0
index b3785ffc1570..e606f588d366 100644
@@ -185,6 +185,7 @@ 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(xtheadpmu, RISCV_ISA_EXT_XTHEADPMU),
 };
 
 const size_t riscv_isa_ext_count = ARRAY_SIZE(riscv_isa_ext);
drivers/perf/Kconfig +13 -0
index 273d67ecf6d2..c71b6f16bdfa 100644
@@ -86,6 +86,19 @@ config RISCV_PMU_SBI
 	  full perf feature support i.e. counter overflow, privilege mode
 	  filtering, counter configuration.
 
+config THEAD_CUSTOM_PMU
+	bool "T-Head custom PMU support"
+	depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
+	default y
+	help
+	  The T-Head C9xx cores implement a PMU overflow extension very
+	  similar to the core SSCOFPMF extension.
+
+	  This will patch the overflow CSR and handle the non-standard
+	  behaviour via the regular SBI PMU driver and interface.
+
+	  If you don't know what to do here, say "Y".
+
 config ARM_PMU_ACPI
 	depends on ARM_PMU && ACPI
 	def_bool y
drivers/perf/riscv_pmu_sbi.c +14 -5
index 2edbc37abadf..31ca79846399 100644
@@ -20,10 +20,21 @@
 #include <linux/cpu_pm.h>
 #include <linux/sched/clock.h>
 
-#include <asm/errata_list.h>
 #include <asm/sbi.h>
 #include <asm/cpufeature.h>
 
+#define THEAD_C9XX_RV_IRQ_PMU		17
+#define THEAD_C9XX_CSR_SCOUNTEROF	0x5c5
+
+#define ALT_SBI_PMU_OVERFLOW(__ovl)					\
+asm volatile(ALTERNATIVE(						\
+	"csrr %0, " __stringify(CSR_SSCOUNTOVF),			\
+	"csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),		\
+		0, RISCV_ISA_EXT_XTHEADPMU,				\
+		CONFIG_THEAD_CUSTOM_PMU)				\
+	: "=r" (__ovl) :						\
+	: "memory")
+
 #define SYSCTL_NO_USER_ACCESS	0
 #define SYSCTL_USER_ACCESS	1
 #define SYSCTL_LEGACY		2
@@ -808,10 +819,8 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 	if (riscv_isa_extension_available(NULL, SSCOFPMF)) {
 		riscv_pmu_irq_num = RV_IRQ_PMU;
 		riscv_pmu_use_irq = true;
-	} else if (IS_ENABLED(CONFIG_ERRATA_THEAD_PMU) &&
-		   riscv_cached_mvendorid(0) == THEAD_VENDOR_ID &&
-		   riscv_cached_marchid(0) == 0 &&
-		   riscv_cached_mimpid(0) == 0) {
+	} else if (riscv_isa_extension_available(NULL, XTHEADPMU) &&
+		   IS_ENABLED(CONFIG_THEAD_CUSTOM_PMU)) {
 		riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU;
 		riscv_pmu_use_irq = true;
 	}
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v4 7/13
#19 lore raw

Re: [PATCH v4 07/13] RISC-V: Move T-Head PMU to CPU feature alternative framework

Quoted 221 lines · Yu Chien Peter Lin

The custom PMU extension aims to support perf event sampling prior to the ratification of Sscofpmf. Instead of diverting the bits and register reserved for future standard, a set of custom registers is added. Hence, we may consider it as a CPU feature rather than an erratum.

T-Head cores need to append "xtheadpmu" to the riscv,isa-extensions for each cpu node in device tree, and enable CONFIG_THEAD_CUSTOM_PMU for proper functioning as of this commit.

---
Hi All,

This is in preparation for introducing other PMU alternative. We follow Conor's suggestion [1][2] to use cpu feature alternative framework rather than errata, I'm happy to drop the patch if someone is willing to take care of this for T-Head's platforms (or sticking with CPU errata alternative?)

[1] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/#25503860
[2] https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/#25565650

Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Removed m{vendor/arch/imp}id checks in pmu_sbi_setup_irqs()
Changes v3 -> v4:
- No change

---
 arch/riscv/Kconfig.errata            | 13 -------------
 arch/riscv/errata/thead/errata.c     | 19 -------------------
 arch/riscv/include/asm/errata_list.h | 15 +--------------
 arch/riscv/include/asm/hwcap.h       |  1 +
 arch/riscv/kernel/cpufeature.c       |  1 +
 drivers/perf/Kconfig                 | 13 +++++++++++++
 drivers/perf/riscv_pmu_sbi.c         | 19 ++++++++++++++-----
 7 files changed, 30 insertions(+), 51 deletions(-)
arch/riscv/Kconfig.errata +0 -13
index e2c731cfed8c..0d19f47d1018 100644
@@ -86,17 +86,4 @@ config ERRATA_THEAD_CMO
 
          If you don't know what to do here, say "Y".
 
-config ERRATA_THEAD_PMU
-       bool "Apply T-Head PMU errata"
-       depends on ERRATA_THEAD && RISCV_PMU_SBI
-       default y
-       help
-         The T-Head C9xx cores implement a PMU overflow extension very
-         similar to the core SSCOFPMF extension.
-
-         This will apply the overflow errata to handle the non-standard
-         behaviour via the regular SBI PMU driver and interface.
-
-         If you don't know what to do here, say "Y".
-
 endmenu # "CPU errata selection"
arch/riscv/errata/thead/errata.c +0 -19
index 0554ed4bf087..5de5f7209132 100644
@@ -53,22 +53,6 @@ static bool errata_probe_cmo(unsigned int stage,
        return true;
 }
 
-static bool errata_probe_pmu(unsigned int stage,
-                            unsigned long arch_id, unsigned long impid)
-{
-       if (!IS_ENABLED(CONFIG_ERRATA_THEAD_PMU))
-               return false;
-
-       /* target-c9xx cores report arch_id and impid as 0 */
-       if (arch_id != 0 || impid != 0)
-               return false;
-
-       if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
-               return false;
-
-       return true;
-}
-
 static u32 thead_errata_probe(unsigned int stage,
                              unsigned long archid, unsigned long impid)
 {
@@ -80,9 +64,6 @@ static u32 thead_errata_probe(unsigned int stage,
        if (errata_probe_cmo(stage, archid, impid))
                cpu_req_errata |= BIT(ERRATA_THEAD_CMO);
 
-       if (errata_probe_pmu(stage, archid, impid))
-               cpu_req_errata |= BIT(ERRATA_THEAD_PMU);
-
        return cpu_req_errata;
 }
 
arch/riscv/include/asm/errata_list.h +1 -14
index 4ed21a62158c..9bccc2ba0eb5 100644
@@ -25,8 +25,7 @@
 #ifdef CONFIG_ERRATA_THEAD
 #define        ERRATA_THEAD_PBMT 0
 #define        ERRATA_THEAD_CMO 1
-#define        ERRATA_THEAD_PMU 2
-#define        ERRATA_THEAD_NUMBER 3
+#define        ERRATA_THEAD_NUMBER 2
 #endif
 
 #ifdef __ASSEMBLY__
@@ -147,18 +146,6 @@ asm volatile(ALTERNATIVE_2(                                                \
            "r"((unsigned long)(_start) + (_size))                      \
        : "a0")
 
-#define THEAD_C9XX_RV_IRQ_PMU                  17
-#define THEAD_C9XX_CSR_SCOUNTEROF              0x5c5
-
-#define ALT_SBI_PMU_OVERFLOW(__ovl)                                    \
-asm volatile(ALTERNATIVE(                                              \
-       "csrr %0, " __stringify(CSR_SSCOUNTOVF),                        \
-       "csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),             \
-               THEAD_VENDOR_ID, ERRATA_THEAD_PMU,                      \
-               CONFIG_ERRATA_THEAD_PMU)                                \
-       : "=r" (__ovl) :                                                \
-       : "memory")
-
 #endif /* __ASSEMBLY__ */
 
 #endif
arch/riscv/include/asm/hwcap.h +1 -0
index 06d30526ef3b..c85ee34c78d9 100644
@@ -57,6 +57,7 @@
 #define RISCV_ISA_EXT_ZIHPM            42
 #define RISCV_ISA_EXT_SMSTATEEN                43
 #define RISCV_ISA_EXT_ZICOND           44
+#define RISCV_ISA_EXT_XTHEADPMU                45
 
 #define RISCV_ISA_EXT_MAX              64
 
arch/riscv/kernel/cpufeature.c +1 -0
index b3785ffc1570..e606f588d366 100644
@@ -185,6 +185,7 @@ 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(xtheadpmu, RISCV_ISA_EXT_XTHEADPMU),
 };
 
 const size_t riscv_isa_ext_count = ARRAY_SIZE(riscv_isa_ext);
drivers/perf/Kconfig +13 -0
index 273d67ecf6d2..c71b6f16bdfa 100644
@@ -86,6 +86,19 @@ config RISCV_PMU_SBI
          full perf feature support i.e. counter overflow, privilege mode
          filtering, counter configuration.
 
+config THEAD_CUSTOM_PMU
+       bool "T-Head custom PMU support"
+       depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
+       default y
+       help
+         The T-Head C9xx cores implement a PMU overflow extension very
+         similar to the core SSCOFPMF extension.
+
+         This will patch the overflow CSR and handle the non-standard
+         behaviour via the regular SBI PMU driver and interface.
+
+         If you don't know what to do here, say "Y".
+
 config ARM_PMU_ACPI
        depends on ARM_PMU && ACPI
        def_bool y
drivers/perf/riscv_pmu_sbi.c +14 -6
index 2edbc37abadf..31ca79846399 100644
@@ -20,10 +20,21 @@
 #include <linux/cpu_pm.h>
 #include <linux/sched/clock.h>
 
-#include <asm/errata_list.h>
 #include <asm/sbi.h>
 #include <asm/cpufeature.h>
 
+#define THEAD_C9XX_RV_IRQ_PMU          17
+#define THEAD_C9XX_CSR_SCOUNTEROF      0x5c5
+
+#define ALT_SBI_PMU_OVERFLOW(__ovl)                                    \
+asm volatile(ALTERNATIVE(                                              \
+       "csrr %0, " __stringify(CSR_SSCOUNTOVF),                        \
+       "csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),             \
+               0, RISCV_ISA_EXT_XTHEADPMU,                             \
+               CONFIG_THEAD_CUSTOM_PMU)                                \
+       : "=r" (__ovl) :                                                \
+       : "memory")
+
 #define SYSCTL_NO_USER_ACCESS  0
 #define SYSCTL_USER_ACCESS     1
 #define SYSCTL_LEGACY          2
@@ -808,10 +819,8 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
        if (riscv_isa_extension_available(NULL, SSCOFPMF)) {
                riscv_pmu_irq_num = RV_IRQ_PMU;
                riscv_pmu_use_irq = true;
-       } else if (IS_ENABLED(CONFIG_ERRATA_THEAD_PMU) &&
-                  riscv_cached_mvendorid(0) == THEAD_VENDOR_ID &&
-                  riscv_cached_marchid(0) == 0 &&
-                  riscv_cached_mimpid(0) == 0) {
+       } else if (riscv_isa_extension_available(NULL, XTHEADPMU) &&
+                  IS_ENABLED(CONFIG_THEAD_CUSTOM_PMU)) {
                riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU;
                riscv_pmu_use_irq = true;
        }
--
Quoted 2 lines

2.34.1

Signature · 2 lines
Best Regards
 Guo Ren
#20 lore raw

Re: [PATCH v4 07/13] RISC-V: Move T-Head PMU to CPU feature alternative framework

In reply to Yu Chien Peter Lin
Quoted 5 lines
 drivers/perf/riscv_pmu_sbi.c         | 19 ++++++++++++++-----
drivers/perf/Kconfig +2 -0
+config THEAD_CUSTOM_PMU
+	bool "T-Head custom PMU support"

drivers/perf/Kconfig config RISCV_PMU_SBI · line 100

Quoted 10 lines
drivers/perf/Kconfig +10 -0
+	depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
+	default y
+	help
+	  The T-Head C9xx cores implement a PMU overflow extension very
+	  similar to the core SSCOFPMF extension.
+
+	  This will patch the overflow CSR and handle the non-standard
+	  behaviour via the regular SBI PMU driver and interface.
+
+	  If you don't know what to do here, say "Y".

This is a < 20 line diff to the pmu driver, is it really worth adding having config options for these two non standard PMU implementations?

#21 lore raw

PATCH v4 8/13 perf: RISC-V: Introduce Andes PMU for perf event sampling

In reply to Yu Chien Peter Lin

The Andes PMU extension provides the same mechanism as Sscofpmf, allowing us to reuse the SBI PMU driver to support event sampling and mode filtering.

To make use of this custom PMU extension, "xandespmu" needs to be appended to the riscv,isa-extensions for each cpu node in device-tree, and enable CONFIG_ANDES_CUSTOM_PMU.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Reordered list in riscv_isa_ext[]
- Removed mvendorid check in pmu_sbi_setup_irqs()
Changes v3 -> v4:
- No change

---
 arch/riscv/include/asm/hwcap.h |  1 +
 arch/riscv/kernel/cpufeature.c |  1 +
 drivers/perf/Kconfig           | 14 ++++++++++++++
 drivers/perf/riscv_pmu_sbi.c   | 30 +++++++++++++++++++++++++-----
 4 files changed, 41 insertions(+), 5 deletions(-)
arch/riscv/include/asm/hwcap.h +1 -0
index c85ee34c78d9..cbfbc3505d2c 100644
@@ -58,6 +58,7 @@
 #define RISCV_ISA_EXT_SMSTATEEN		43
 #define RISCV_ISA_EXT_ZICOND		44
 #define RISCV_ISA_EXT_XTHEADPMU		45
+#define RISCV_ISA_EXT_XANDESPMU		46
 
 #define RISCV_ISA_EXT_MAX		64
 
arch/riscv/kernel/cpufeature.c +1 -0
index e606f588d366..42fda134c4a3 100644
@@ -185,6 +185,7 @@ 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),
 	__RISCV_ISA_EXT_DATA(xtheadpmu, RISCV_ISA_EXT_XTHEADPMU),
 };
 
drivers/perf/Kconfig +14 -0
index c71b6f16bdfa..c1a490829d15 100644
@@ -86,6 +86,20 @@ config RISCV_PMU_SBI
 	  full perf feature support i.e. counter overflow, privilege mode
 	  filtering, counter configuration.
 
+config ANDES_CUSTOM_PMU
+	bool "Andes custom PMU support"
+	depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
+	default y
+	help
+	  The Andes cores implement a PMU overflow extension very
+	  similar to the core SSCOFPMF extension.
+
+	  This will patch the overflow/pending CSR and handle the
+	  non-standard behaviour via the regular SBI PMU driver and
+	  interface.
+
+	  If you don't know what to do here, say "Y".
+
 config THEAD_CUSTOM_PMU
 	bool "T-Head custom PMU support"
 	depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
drivers/perf/riscv_pmu_sbi.c +25 -5
index 31ca79846399..1e0c709efbfc 100644
@@ -19,6 +19,7 @@
 #include <linux/of.h>
 #include <linux/cpu_pm.h>
 #include <linux/sched/clock.h>
+#include <linux/soc/andes/irq.h>
 
 #include <asm/sbi.h>
 #include <asm/cpufeature.h>
@@ -27,14 +28,26 @@
 #define THEAD_C9XX_CSR_SCOUNTEROF	0x5c5
 
 #define ALT_SBI_PMU_OVERFLOW(__ovl)					\
-asm volatile(ALTERNATIVE(						\
+asm volatile(ALTERNATIVE_2(						\
 	"csrr %0, " __stringify(CSR_SSCOUNTOVF),			\
 	"csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),		\
 		0, RISCV_ISA_EXT_XTHEADPMU,				\
-		CONFIG_THEAD_CUSTOM_PMU)				\
+		CONFIG_THEAD_CUSTOM_PMU,				\
+	"csrr %0, " __stringify(ANDES_CSR_SCOUNTEROF),			\
+		0, RISCV_ISA_EXT_XANDESPMU,		\
+		CONFIG_ANDES_CUSTOM_PMU)				\
 	: "=r" (__ovl) :						\
 	: "memory")
 
+#define ALT_SBI_PMU_OVF_CLEAR_PENDING(__irq_mask)			\
+asm volatile(ALTERNATIVE(						\
+	"csrc " __stringify(CSR_IP) ", %0\n\t",				\
+	"csrc " __stringify(ANDES_CSR_SLIP) ", %0\n\t",			\
+		0, RISCV_ISA_EXT_XANDESPMU,				\
+		CONFIG_ANDES_CUSTOM_PMU)				\
+	: : "r"(__irq_mask)						\
+	: "memory")
+
 #define SYSCTL_NO_USER_ACCESS	0
 #define SYSCTL_USER_ACCESS	1
 #define SYSCTL_LEGACY		2
@@ -72,6 +85,7 @@ static int sysctl_perf_user_access __read_mostly = SYSCTL_USER_ACCESS;
 static union sbi_pmu_ctr_info *pmu_ctr_list;
 static bool riscv_pmu_use_irq;
 static unsigned int riscv_pmu_irq_num;
+static unsigned int riscv_pmu_irq_mask;
 static unsigned int riscv_pmu_irq;
 
 /* Cache the available counters in a bitmask */
@@ -705,7 +719,7 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
 
 	event = cpu_hw_evt->events[fidx];
 	if (!event) {
-		csr_clear(CSR_SIP, BIT(riscv_pmu_irq_num));
+		ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
 		return IRQ_NONE;
 	}
 
@@ -719,7 +733,7 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
 	 * Overflow interrupt pending bit should only be cleared after stopping
 	 * all the counters to avoid any race condition.
 	 */
-	csr_clear(CSR_SIP, BIT(riscv_pmu_irq_num));
+	ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
 
 	/* No overflow bit is set */
 	if (!overflow)
@@ -791,7 +805,7 @@ static int pmu_sbi_starting_cpu(unsigned int cpu, struct hlist_node *node)
 
 	if (riscv_pmu_use_irq) {
 		cpu_hw_evt->irq = riscv_pmu_irq;
-		csr_clear(CSR_IP, BIT(riscv_pmu_irq_num));
+		ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
 		enable_percpu_irq(riscv_pmu_irq, IRQ_TYPE_NONE);
 	}
 
@@ -823,8 +837,14 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 		   IS_ENABLED(CONFIG_THEAD_CUSTOM_PMU)) {
 		riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU;
 		riscv_pmu_use_irq = true;
+	} else if (riscv_isa_extension_available(NULL, XANDESPMU) &&
+		   IS_ENABLED(CONFIG_ANDES_CUSTOM_PMU)) {
+		riscv_pmu_irq_num = ANDES_SLI_CAUSE_BASE + ANDES_RV_IRQ_PMU;
+		riscv_pmu_use_irq = true;
 	}
 
+	riscv_pmu_irq_mask = BIT(riscv_pmu_irq_num % BITS_PER_LONG);
+
 	if (!riscv_pmu_use_irq)
 		return -EOPNOTSUPP;
 
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by Lad Prabhakar Tested-by Lad Prabhakar on v4 8/13
#22 lore raw

Re: [PATCH v4 08/13] perf: RISC-V: Introduce Andes PMU for perf event sampling

Quoted 22 lines · Yu Chien Peter Lin

The Andes PMU extension provides the same mechanism as Sscofpmf, allowing us to reuse the SBI PMU driver to support event sampling and mode filtering.

To make use of this custom PMU extension, "xandespmu" needs to be appended to the riscv,isa-extensions for each cpu node in device-tree, and enable CONFIG_ANDES_CUSTOM_PMU.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- Reordered list in riscv_isa_ext[]
- Removed mvendorid check in pmu_sbi_setup_irqs()
Changes v3 -> v4:
- No change

Quoted 7 lines
---
 arch/riscv/include/asm/hwcap.h |  1 +
 arch/riscv/kernel/cpufeature.c |  1 +
 drivers/perf/Kconfig           | 14 ++++++++++++++
 drivers/perf/riscv_pmu_sbi.c   | 30 +++++++++++++++++++++++++-----
 4 files changed, 41 insertions(+), 5 deletions(-)

Cheers,
Prabhakar

Quoted 144 lines
arch/riscv/include/asm/hwcap.h +1 -0
index c85ee34c78d9..cbfbc3505d2c 100644
@@ -58,6 +58,7 @@
 #define RISCV_ISA_EXT_SMSTATEEN                43
 #define RISCV_ISA_EXT_ZICOND           44
 #define RISCV_ISA_EXT_XTHEADPMU                45
+#define RISCV_ISA_EXT_XANDESPMU                46
 
 #define RISCV_ISA_EXT_MAX              64
 
arch/riscv/kernel/cpufeature.c +1 -0
index e606f588d366..42fda134c4a3 100644
@@ -185,6 +185,7 @@ 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),
        __RISCV_ISA_EXT_DATA(xtheadpmu, RISCV_ISA_EXT_XTHEADPMU),
 };
 
drivers/perf/Kconfig +14 -0
index c71b6f16bdfa..c1a490829d15 100644
@@ -86,6 +86,20 @@ config RISCV_PMU_SBI
          full perf feature support i.e. counter overflow, privilege mode
          filtering, counter configuration.
 
+config ANDES_CUSTOM_PMU
+       bool "Andes custom PMU support"
+       depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
+       default y
+       help
+         The Andes cores implement a PMU overflow extension very
+         similar to the core SSCOFPMF extension.
+
+         This will patch the overflow/pending CSR and handle the
+         non-standard behaviour via the regular SBI PMU driver and
+         interface.
+
+         If you don't know what to do here, say "Y".
+
 config THEAD_CUSTOM_PMU
        bool "T-Head custom PMU support"
        depends on RISCV_ALTERNATIVE && RISCV_PMU_SBI
drivers/perf/riscv_pmu_sbi.c +25 -6
index 31ca79846399..1e0c709efbfc 100644
@@ -19,6 +19,7 @@
 #include <linux/of.h>
 #include <linux/cpu_pm.h>
 #include <linux/sched/clock.h>
+#include <linux/soc/andes/irq.h>
 
 #include <asm/sbi.h>
 #include <asm/cpufeature.h>
@@ -27,14 +28,26 @@
 #define THEAD_C9XX_CSR_SCOUNTEROF      0x5c5
 
 #define ALT_SBI_PMU_OVERFLOW(__ovl)                                    \
-asm volatile(ALTERNATIVE(                                              \
+asm volatile(ALTERNATIVE_2(                                            \
        "csrr %0, " __stringify(CSR_SSCOUNTOVF),                        \
        "csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF),             \
                0, RISCV_ISA_EXT_XTHEADPMU,                             \
-               CONFIG_THEAD_CUSTOM_PMU)                                \
+               CONFIG_THEAD_CUSTOM_PMU,                                \
+       "csrr %0, " __stringify(ANDES_CSR_SCOUNTEROF),                  \
+               0, RISCV_ISA_EXT_XANDESPMU,             \
+               CONFIG_ANDES_CUSTOM_PMU)                                \
        : "=r" (__ovl) :                                                \
        : "memory")
 
+#define ALT_SBI_PMU_OVF_CLEAR_PENDING(__irq_mask)                      \
+asm volatile(ALTERNATIVE(                                              \
+       "csrc " __stringify(CSR_IP) ", %0\n\t",                         \
+       "csrc " __stringify(ANDES_CSR_SLIP) ", %0\n\t",                 \
+               0, RISCV_ISA_EXT_XANDESPMU,                             \
+               CONFIG_ANDES_CUSTOM_PMU)                                \
+       : : "r"(__irq_mask)                                             \
+       : "memory")
+
 #define SYSCTL_NO_USER_ACCESS  0
 #define SYSCTL_USER_ACCESS     1
 #define SYSCTL_LEGACY          2
@@ -72,6 +85,7 @@ static int sysctl_perf_user_access __read_mostly = SYSCTL_USER_ACCESS;
 static union sbi_pmu_ctr_info *pmu_ctr_list;
 static bool riscv_pmu_use_irq;
 static unsigned int riscv_pmu_irq_num;
+static unsigned int riscv_pmu_irq_mask;
 static unsigned int riscv_pmu_irq;
 
 /* Cache the available counters in a bitmask */
@@ -705,7 +719,7 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
 
        event = cpu_hw_evt->events[fidx];
        if (!event) {
-               csr_clear(CSR_SIP, BIT(riscv_pmu_irq_num));
+               ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
                return IRQ_NONE;
        }
 
@@ -719,7 +733,7 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
         * Overflow interrupt pending bit should only be cleared after stopping
         * all the counters to avoid any race condition.
         */
-       csr_clear(CSR_SIP, BIT(riscv_pmu_irq_num));
+       ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
 
        /* No overflow bit is set */
        if (!overflow)
@@ -791,7 +805,7 @@ static int pmu_sbi_starting_cpu(unsigned int cpu, struct hlist_node *node)
 
        if (riscv_pmu_use_irq) {
                cpu_hw_evt->irq = riscv_pmu_irq;
-               csr_clear(CSR_IP, BIT(riscv_pmu_irq_num));
+               ALT_SBI_PMU_OVF_CLEAR_PENDING(riscv_pmu_irq_mask);
                enable_percpu_irq(riscv_pmu_irq, IRQ_TYPE_NONE);
        }
 
@@ -823,8 +837,14 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
                   IS_ENABLED(CONFIG_THEAD_CUSTOM_PMU)) {
                riscv_pmu_irq_num = THEAD_C9XX_RV_IRQ_PMU;
                riscv_pmu_use_irq = true;
+       } else if (riscv_isa_extension_available(NULL, XANDESPMU) &&
+                  IS_ENABLED(CONFIG_ANDES_CUSTOM_PMU)) {
+               riscv_pmu_irq_num = ANDES_SLI_CAUSE_BASE + ANDES_RV_IRQ_PMU;
+               riscv_pmu_use_irq = true;
        }
 
+       riscv_pmu_irq_mask = BIT(riscv_pmu_irq_num % BITS_PER_LONG);
+
        if (!riscv_pmu_use_irq)
                return -EOPNOTSUPP;
 
--

2.34.1

#23 lore raw

PATCH v4 9/13 dt-bindings: riscv: Add T-Head PMU extension description

In reply to Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
 ...
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v4 9/13
#24 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 31 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--
Quoted 2 lines

2.34.1

Signature · 2 lines
Best Regards
 Guo Ren
#25 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Thanks for the review.
Would you share document about T-Head PMU?

Best regards,
Peter Lin

Quoted 3 lines
Signature · 2 lines
Best Regards
 Guo Ren
#26 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Best regards,
Inochi

#27 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

Best regards,
Peter Lin

Quoted 2 lines

Best regards,
Inochi

#28 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 66 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

Quoted 8 lines

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

I suggest using perf event json as event description. The jsons provide more detailed explanation for these events than the user manual.

Quoted 6 lines

Best regards,
Peter Lin

Quoted 2 lines

Best regards,
Inochi

#29 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 72 lines · Inochi Amaoto
Quoted 72 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Quoted 5 lines
Quoted 2 lines

Is it OK with you?

I suggest using perf event json as event description. The jsons provide more detailed explanation for these events than the user manual.

Does the "perf event json" describe the registers and interrupt behaviour?

#30 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 74 lines · Inochi Amaoto
Quoted 72 lines
Quoted 72 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Is it OK with you?

I suggest using perf event json as event description. The jsons provide more detailed explanation for these events than the user manual.

Does the "perf event json" describe the registers and interrupt behaviour?

It does not. IIRC, the linux just uses SBI as perf driver backend. So the registers and interrupt behaviour is primarily for SBI developer.

For registers and interrup detail, just reference the openc910 doc url
(https://github.com/T-head-Semi/openc910/tree/main/doc) and the T-HEAD PMU driver in OpenSBI.

#31 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 77 lines · Inochi Amaoto
Quoted 77 lines · Inochi Amaoto
Quoted 75 lines
Quoted 74 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I suggest using perf event json as event description. The jsons provide more detailed explanation for these events than the user manual.

Does the "perf event json" describe the registers and interrupt behaviour?

It does not. IIRC, the linux just uses SBI as perf driver backend. So the registers and interrupt behaviour is primarily for SBI developer.

Interrupts and registers are the reason that this patch (and the rest of the patchset) exists :)

Quoted 3 lines

For registers and interrup detail, just reference the openc910 doc url
(https://github.com/T-head-Semi/openc910/tree/main/doc) and the T-HEAD PMU driver in OpenSBI.

The former, sure. But I will not accept driver implementations as the reference in this context.

Thanks,
Conor.

#32 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 82 lines · Inochi Amaoto
Quoted 80 lines
Quoted 80 lines · Inochi Amaoto
Quoted 77 lines
Quoted 66 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

Quoted 8 lines

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

I suggest using perf event json as event description. The jsons provide more detailed explanation for these events than the user manual.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Does the "perf event json" describe the registers and interrupt behaviour?

It does not. IIRC, the linux just uses SBI as perf driver backend. So the registers and interrupt behaviour is primarily for SBI developer.

Interrupts and registers are the reason that this patch (and the rest of the patchset) exists :)

Thanks, it seems I misunderstood something.

Quoted 7 lines
Quoted 3 lines

For registers and interrup detail, just reference the openc910 doc url
(https://github.com/T-head-Semi/openc910/tree/main/doc) and the T-HEAD PMU driver in OpenSBI.

The former, sure. But I will not accept driver implementations as the reference in this context.

OK, Let's drop it and left the document only.

Quoted 4 lines

Thanks,
Conor.

Reviewed-by
#33 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

In reply to Yu-Chien Peter Lin
Quoted 66 lines

Hi Inochi,

Quoted 51 lines · Inochi Amaoto
Quoted 41 lines

Hi Guo Ren,

Quoted 24 lines · Guo Ren
Quoted 22 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +6 -1
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc
+
 additionalProperties: true
...
--

2.34.1

Quoted 3 lines

Thanks for the review.
Would you share document about T-Head PMU?

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

Quoted 8 lines

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

Please indicate chapter 12 and chapter 13.5 of the manual related to the PMU. And changed openc906 manual to openc910 manual because it is more updated.

If modified:

Quoted 6 lines

Best regards,
Peter Lin

Quoted 2 lines

Best regards,
Inochi

#34 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

On Fri, Dec 01, 2023 at 09:14:00AM +0800, Inochi Amaoto wrote:
<...>

Quoted 27 lines
Quoted 18 lines
Quoted 7 lines

Hi, Peter Lin:

You can use the following two document to get all events:
https://github.com/T-head-Semi/openc906/tree/main/doc
https://github.com/T-head-Semi/openc910/tree/main/doc

Quoted 7 lines

There are also some RTL code can describe these events:
https://github.com/T-head-Semi/openc910/blob/e0c4ad8ec7f8c70f649d826ebd6c949086453272/C910_RTL_FACTORY/gen_rtl/pmu/rtl/ct_hpcp_top.v#L1123
https://github.com/T-head-Semi/openc906/blob/af5614d72de7e5a4b8609c427d2e20af1deb21c4/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v#L543

The perf events json can also be used as document, this is already applied (with more detailed explanation):
https://lore.kernel.org/all/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.com/

Thanks for reaching out!
The updated description will be:

Quoted 8 lines

- const: xtheadpmu
description:
The T-Head performance monitor extension for counter overflow, as ratified in commit bd9206 ("Initial commit") of Xuantie C906 user manual.
https://github.com/T-head-Semi/openc906/tree/main/doc

Is it OK with you?

Quoted 7 lines

Please indicate chapter 12 and chapter 13.5 of the manual related to the PMU. And changed openc906 manual to openc910 manual because it is more updated.

If modified:

Got it! Thanks for the information.

Regards,
Peter Lin

#35 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

In reply to Yu Chien Peter Lin
Quoted 18 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 265

Quoted 8 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +5 -0
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc

I'm pretty sure that I asked on the previous revision for you to identify a specific revision of this document.

Cheers,
Conor.

#36 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Hi Conor,

Quoted 22 lines · Conor Dooley
Quoted 21 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 8 lines

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 265

Quoted 5 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +5 -0
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc

I'm pretty sure that I asked on the previous revision for you to identify a specific revision of this document.

Sorry, I'm still searching for it.

Regards,
Peter Lin

Quoted 2 lines

Cheers,
Conor.

#37 lore raw

Re: [PATCH v4 09/13] dt-bindings: riscv: Add T-Head PMU extension description

Quoted 34 lines · Yu-Chien Peter Lin

Hi Conor,

Quoted 22 lines · Conor Dooley
Quoted 21 lines · Yu Chien Peter Lin

Document the ISA string for T-Head performance monitor extension which provides counter overflow interrupt mechanism.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +0 -0
index c91ab0e46648..694efaea8fce 100644
@@ -258,5 +258,11 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
Quoted 8 lines

Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 265

Quoted 5 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +5 -0
+        - const: xtheadpmu
+          description:
+            The T-Head performance monitor extension for counter overflow. For more
+            details, see the chapter 12 in the Xuantie C906 user manual.
+            https://github.com/T-head-Semi/openc906/tree/main/doc

I'm pretty sure that I asked on the previous revision for you to identify a specific revision of this document.

Quoted 1 line

Sorry, I'm still searching for it.

Identifying a specific commit from that repo as the revision would be okay. Follow the format used elsewhere for the standard extensions.

Cheers,
Conor.

#38 lore raw

PATCH v4 10/13 dt-bindings: riscv: Add Andes PMU extension description

In reply to Yu Chien Peter Lin

Document the ISA string for Andes Technology performance monitor extension which provides counter overflow interrupt and mode filtering mechanisms.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- Include Conor's Acked-by

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +7 -0
index 694efaea8fce..4e0066afc848 100644
@@ -258,6 +258,13 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
+        - const: xandespmu
+          description:
+            The Andes Technology performance monitor extension for counter overflow
+            and privilege mode filtering. For more details, see Counter Related
+            Registers in the AX45MP datasheet.
+            https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
+
         - const: xtheadpmu
           description:
             The T-Head performance monitor extension for counter overflow. For more
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by Lad Prabhakar on v4 10/13
#39 lore raw

Re: [PATCH v4 10/13] dt-bindings: riscv: Add Andes PMU extension description

Quoted 7 lines · Yu Chien Peter Lin

Document the ISA string for Andes Technology performance monitor extension which provides counter overflow interrupt and mode filtering mechanisms.

Quoted 9 lines

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- Include Conor's Acked-by

---
 Documentation/devicetree/bindings/riscv/extensions.yaml | 7 +++++++
 1 file changed, 7 insertions(+)

Cheers,
Prabhakar

Quoted 22 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +7 -1
index 694efaea8fce..4e0066afc848 100644
@@ -258,6 +258,13 @@ properties:
             in commit 2e5236 ("Ztso is now ratified.") of the
             riscv-isa-manual.
 
+        - const: xandespmu
+          description:
+            The Andes Technology performance monitor extension for counter overflow
+            and privilege mode filtering. For more details, see Counter Related
+            Registers in the AX45MP datasheet.
+            https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
+
         - const: xtheadpmu
           description:
             The T-Head performance monitor extension for counter overflow. For more
--

2.34.1

#40 lore raw

PATCH v4 11/13 riscv: dts: allwinner: Add T-Head PMU extension

In reply to Yu Chien Peter Lin

xtheadpmu stands for T-Head Performance Monitor Unit extension. Based on the added T-Head PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi +1 -1
index 64c3c2e6cbe0..7dcba86cfdd0 100644
@@ -27,7 +27,7 @@ cpu0: cpu@0 {
 			riscv,isa = "rv64imafdc";
 			riscv,isa-base = "rv64i";
 			riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
-					       "zifencei", "zihpm";
+					       "zifencei", "zihpm", "xtheadpmu";
 			#cooling-cells = <2>;
 
 			cpu0_intc: interrupt-controller {
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v4 11/13
#41 lore raw

Re: [PATCH v4 11/13] riscv: dts: allwinner: Add T-Head PMU extension

Quoted 20 lines · Yu Chien Peter Lin

xtheadpmu stands for T-Head Performance Monitor Unit extension. Based on the added T-Head PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

---
Changes v2 -> v3:
- New patch
Changes v3 -> v4:
- No change

---
 arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi +0 -0
index 64c3c2e6cbe0..7dcba86cfdd0 100644

arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi cpu0: cpu@0 { · line 30

Quoted 5 lines
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi +1 -1
@@ -27,7 +27,7 @@ cpu0: cpu@0 {
                        riscv,isa = "rv64imafdc";
                        riscv,isa-base = "rv64i";
                        riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
-                                              "zifencei", "zihpm";
+                                              "zifencei", "zihpm", "xtheadpmu";
Quoted 6 lines
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi +0 -1
                        #cooling-cells = <2>;
 
                        cpu0_intc: interrupt-controller {
--

2.34.1

Signature · 2 lines
Best Regards
 Guo Ren
#42 lore raw

Re: [PATCH v4 11/13] riscv: dts: allwinner: Add T-Head PMU extension

In reply to Yu Chien Peter Lin
Quoted 3 lines · Yu Chien Peter Lin

xtheadpmu stands for T-Head Performance Monitor Unit extension. Based on the added T-Head PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

Allwinner aren't the only ones using T-Head CPUs that the previous m*id pmu detection code would have matched on. I think the first three files below will also need to be updated:

rg -l "thead,c[0-9]*\b[^-]" arch/riscv/boot/dts/
arch/riscv/boot/dts/sophgo/sg2042-cpus.dtsi
arch/riscv/boot/dts/sophgo/cv1800b.dtsi
arch/riscv/boot/dts/thead/th1520.dtsi
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi

Cheers,
Conor.

#43 lore raw

Re: [PATCH v4 11/13] riscv: dts: allwinner: Add T-Head PMU extension

Hi Conor,

Quoted 9 lines · Conor Dooley
Quoted 3 lines · Yu Chien Peter Lin

xtheadpmu stands for T-Head Performance Monitor Unit extension. Based on the added T-Head PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

Allwinner aren't the only ones using T-Head CPUs that the previous m*id pmu detection code would have matched on. I think the first three files below will also need to be updated:

Quoted 5 lines

rg -l "thead,c[0-9]*\b[^-]" arch/riscv/boot/dts/
arch/riscv/boot/dts/sophgo/sg2042-cpus.dtsi
arch/riscv/boot/dts/sophgo/cv1800b.dtsi
arch/riscv/boot/dts/thead/th1520.dtsi
arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi

That's really helpful, I'll add these .dtsi files in the patchset v5.

Thanks,
Peter Lin

Quoted 2 lines

Cheers,
Conor.

#44 lore raw

PATCH v4 12/13 riscv: dts: renesas: Add Andes PMU extension

In reply to Yu Chien Peter Lin

xandespmu stands for Andes Performance Monitor Unit extension. Based on the added Andes PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- No change
Changes v3 -> v4:
- No change

---
 arch/riscv/boot/dts/renesas/r9a07g043f.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/boot/dts/renesas/r9a07g043f.dtsi +1 -1
index 78072e80793d..5f2f2181638a 100644
@@ -26,7 +26,7 @@ cpu0: cpu@0 {
 			riscv,isa = "rv64imafdc";
 			riscv,isa-base = "rv64i";
 			riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
-					       "zifencei", "zihpm";
+					       "zifencei", "zihpm", "xandespmu";
 			mmu-type = "riscv,sv39";
 			i-cache-size = <0x8000>;
 			i-cache-line-size = <0x40>;
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Reviewed-by on v4 12/13
#45 lore raw

Re: [PATCH v4 12/13] riscv: dts: renesas: Add Andes PMU extension

Quoted 5 lines · Yu Chien Peter Lin

xandespmu stands for Andes Performance Monitor Unit extension. Based on the added Andes PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Reviewed-by Lad Prabhakar Tested-by Lad Prabhakar on v4 12/13
#46 lore raw

Re: [PATCH v4 12/13] riscv: dts: renesas: Add Andes PMU extension

In reply to Yu Chien Peter Lin
Quoted 13 lines · Yu Chien Peter Lin

xandespmu stands for Andes Performance Monitor Unit extension. Based on the added Andes PMU ISA string, the SBI PMU driver will make use of the non-standard irq source.

---
Changes v1 -> v2:
- New patch
Changes v2 -> v3:
- No change
Changes v3 -> v4:
- No change

Quoted 4 lines
---
 arch/riscv/boot/dts/renesas/r9a07g043f.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Cheers,
Prabhakar

Quoted 17 lines
arch/riscv/boot/dts/renesas/r9a07g043f.dtsi +1 -2
index 78072e80793d..5f2f2181638a 100644
@@ -26,7 +26,7 @@ cpu0: cpu@0 {
                        riscv,isa = "rv64imafdc";
                        riscv,isa-base = "rv64i";
                        riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
-                                              "zifencei", "zihpm";
+                                              "zifencei", "zihpm", "xandespmu";
                        mmu-type = "riscv,sv39";
                        i-cache-size = <0x8000>;
                        i-cache-line-size = <0x40>;
--

2.34.1

#47 lore raw

PATCH v4 13/13 riscv: andes: Support symbolic FW and HW raw events

In reply to Yu Chien Peter Lin

From: Locus Wei-Han Chen <[email protected]>

This patch adds the Andes AX45 JSON files in the perf tool, allowing perf to be used with symbolic event names.

---
Changes v1 -> v2:
- No change
Changes v2 -> v3:
- No change
Changes v3 -> v4:
- No change

---
 .../arch/riscv/andes/ax45/firmware.json       |  68 ++++++++++
 .../arch/riscv/andes/ax45/instructions.json   | 127 ++++++++++++++++++
 .../arch/riscv/andes/ax45/memory.json         |  57 ++++++++
 .../arch/riscv/andes/ax45/microarch.json      |  77 +++++++++++
 tools/perf/pmu-events/arch/riscv/mapfile.csv  |   1 +
 5 files changed, 330 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/instructions.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/memory.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/microarch.json
tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json new file +68 -0
new file mode 100644
index 000000000000..9b4a032186a7
@@ -0,0 +1,68 @@
+[
+  {
+    "ArchStdEvent": "FW_MISALIGNED_LOAD"
+  },
+  {
+    "ArchStdEvent": "FW_MISALIGNED_STORE"
+  },
+  {
+    "ArchStdEvent": "FW_ACCESS_LOAD"
+  },
+  {
+    "ArchStdEvent": "FW_ACCESS_STORE"
+  },
+  {
+    "ArchStdEvent": "FW_ILLEGAL_INSN"
+  },
+  {
+    "ArchStdEvent": "FW_SET_TIMER"
+  },
+  {
+    "ArchStdEvent": "FW_IPI_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_IPI_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_FENCE_I_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_FENCE_I_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_VMID_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_VMID_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_ASID_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_ASID_RECEIVED"
+  }
+]
tools/perf/pmu-events/arch/riscv/andes/ax45/instructions.json new file +127 -0

127 lines not on this page · raw message

tools/perf/pmu-events/arch/riscv/andes/ax45/memory.json new file +57 -0

57 lines not on this page · raw message

tools/perf/pmu-events/arch/riscv/andes/ax45/microarch.json new file +77 -0

77 lines not on this page · raw message

tools/perf/pmu-events/arch/riscv/mapfile.csv +1 -0
index c61b3d6ef616..5bf09af14c1b 100644
@@ -15,3 +15,4 @@
 #
 #MVENDORID-MARCHID-MIMPID,Version,Filename,EventType
 0x489-0x8000000000000007-0x[[:xdigit:]]+,v1,sifive/u74,core
+0x31e-0x8000000000008a45-0x[[:xdigit:]]+,v1,andes/ax45,core
Signature · 7 lines
2.34.1


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Tested-by Lad Prabhakar on v4 13/13
#48 lore raw

Re: [PATCH v4 13/13] riscv: andes: Support symbolic FW and HW raw events

Quoted 17 lines · Yu Chien Peter Lin

From: Locus Wei-Han Chen <[email protected]>

This patch adds the Andes AX45 JSON files in the perf tool, allowing perf to be used with symbolic event names.

---
Changes v1 -> v2:
- No change
Changes v2 -> v3:
- No change
Changes v3 -> v4:
- No change

Quoted 12 lines
---
 .../arch/riscv/andes/ax45/firmware.json       |  68 ++++++++++
 .../arch/riscv/andes/ax45/instructions.json   | 127 ++++++++++++++++++
 .../arch/riscv/andes/ax45/memory.json         |  57 ++++++++
 .../arch/riscv/andes/ax45/microarch.json      |  77 +++++++++++
 tools/perf/pmu-events/arch/riscv/mapfile.csv  |   1 +
 5 files changed, 330 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/instructions.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/memory.json
 create mode 100644 tools/perf/pmu-events/arch/riscv/andes/ax45/microarch.json

Cheers,
Prabhakar

Quoted 366 lines
tools/perf/pmu-events/arch/riscv/andes/ax45/firmware.json new file +68 -0
new file mode 100644
index 000000000000..9b4a032186a7
@@ -0,0 +1,68 @@
+[
+  {
+    "ArchStdEvent": "FW_MISALIGNED_LOAD"
+  },
+  {
+    "ArchStdEvent": "FW_MISALIGNED_STORE"
+  },
+  {
+    "ArchStdEvent": "FW_ACCESS_LOAD"
+  },
+  {
+    "ArchStdEvent": "FW_ACCESS_STORE"
+  },
+  {
+    "ArchStdEvent": "FW_ILLEGAL_INSN"
+  },
+  {
+    "ArchStdEvent": "FW_SET_TIMER"
+  },
+  {
+    "ArchStdEvent": "FW_IPI_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_IPI_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_FENCE_I_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_FENCE_I_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_SFENCE_VMA_ASID_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_VMID_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_GVMA_VMID_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_RECEIVED"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_ASID_SENT"
+  },
+  {
+    "ArchStdEvent": "FW_HFENCE_VVMA_ASID_RECEIVED"
+  }
+]
tools/perf/pmu-events/arch/riscv/andes/ax45/instructions.json new file +127 -0
new file mode 100644
index 000000000000..713a08c1a40f
@@ -0,0 +1,127 @@
+[
+       {
+               "EventCode": "0x10",
+               "EventName": "cycle_count",
+               "BriefDescription": "Cycle count"
+       },
+       {
+               "EventCode": "0x20",
+               "EventName": "inst_count",
+               "BriefDescription": "Retired instruction count"
+       },
+       {
+               "EventCode": "0x30",
+               "EventName": "int_load_inst",
+               "BriefDescription": "Integer load instruction count"
+       },
+       {
+               "EventCode": "0x40",
+               "EventName": "int_store_inst",
+               "BriefDescription": "Integer store instruction count"
+       },
+       {
+               "EventCode": "0x50",
+               "EventName": "atomic_inst",
+               "BriefDescription": "Atomic instruction count"
+       },
+       {
+               "EventCode": "0x60",
+               "EventName": "sys_inst",
+               "BriefDescription": "System instruction count"
+       },
+       {
+               "EventCode": "0x70",
+               "EventName": "int_compute_inst",
+               "BriefDescription": "Integer computational instruction count"
+       },
+       {
+               "EventCode": "0x80",
+               "EventName": "condition_br",
+               "BriefDescription": "Conditional branch instruction count"
+       },
+       {
+               "EventCode": "0x90",
+               "EventName": "taken_condition_br",
+               "BriefDescription": "Taken conditional branch instruction count"
+       },
+       {
+               "EventCode": "0xA0",
+               "EventName": "jal_inst",
+               "BriefDescription": "JAL instruction count"
+       },
+       {
+               "EventCode": "0xB0",
+               "EventName": "jalr_inst",
+               "BriefDescription": "JALR instruction count"
+       },
+       {
+               "EventCode": "0xC0",
+               "EventName": "ret_inst",
+               "BriefDescription": "Return instruction count"
+       },
+       {
+               "EventCode": "0xD0",
+               "EventName": "control_trans_inst",
+               "BriefDescription": "Control transfer instruction count"
+       },
+       {
+               "EventCode": "0xE0",
+               "EventName": "ex9_inst",
+               "BriefDescription": "EXEC.IT instruction count"
+       },
+       {
+               "EventCode": "0xF0",
+               "EventName": "int_mul_inst",
+               "BriefDescription": "Integer multiplication instruction count"
+       },
+       {
+               "EventCode": "0x100",
+               "EventName": "int_div_rem_inst",
+               "BriefDescription": "Integer division/remainder instruction count"
+       },
+       {
+               "EventCode": "0x110",
+               "EventName": "float_load_inst",
+               "BriefDescription": "Floating-point load instruction count"
+       },
+       {
+               "EventCode": "0x120",
+               "EventName": "float_store_inst",
+               "BriefDescription": "Floating-point store instruction count"
+       },
+       {
+               "EventCode": "0x130",
+               "EventName": "float_add_sub_inst",
+               "BriefDescription": "Floating-point addition/subtraction instruction count"
+       },
+       {
+               "EventCode": "0x140",
+               "EventName": "float_mul_inst",
+               "BriefDescription": "Floating-point multiplication instruction count"
+       },
+       {
+               "EventCode": "0x150",
+               "EventName": "float_fused_muladd_inst",
+               "BriefDescription": "Floating-point fused multiply-add instruction count"
+       },
+       {
+               "EventCode": "0x160",
+               "EventName": "float_div_sqrt_inst",
+               "BriefDescription": "Floating-point division or square-root instruction count"
+       },
+       {
+               "EventCode": "0x170",
+               "EventName": "other_float_inst",
+               "BriefDescription": "Other floating-point instruction count"
+       },
+       {
+               "EventCode": "0x180",
+               "EventName": "int_mul_add_sub_inst",
+               "BriefDescription": "Integer multiplication and add/sub instruction count"
+       },
+       {
+               "EventCode": "0x190",
+               "EventName": "retired_ops",
+               "BriefDescription": "Retired operation count"
+       }
+]
tools/perf/pmu-events/arch/riscv/andes/ax45/memory.json new file +57 -0
new file mode 100644
index 000000000000..c7401b526c77
@@ -0,0 +1,57 @@
+[
+       {
+               "EventCode": "0x01",
+               "EventName": "ilm_access",
+               "BriefDescription": "ILM access"
+       },
+       {
+               "EventCode": "0x11",
+               "EventName": "dlm_access",
+               "BriefDescription": "DLM access"
+       },
+       {
+               "EventCode": "0x21",
+               "EventName": "icache_access",
+               "BriefDescription": "ICACHE access"
+       },
+       {
+               "EventCode": "0x31",
+               "EventName": "icache_miss",
+               "BriefDescription": "ICACHE miss"
+       },
+       {
+               "EventCode": "0x41",
+               "EventName": "dcache_access",
+               "BriefDescription": "DCACHE access"
+       },
+       {
+               "EventCode": "0x51",
+               "EventName": "dcache_miss",
+               "BriefDescription": "DCACHE miss"
+       },
+       {
+               "EventCode": "0x61",
+               "EventName": "dcache_load_access",
+               "BriefDescription": "DCACHE load access"
+       },
+       {
+               "EventCode": "0x71",
+               "EventName": "dcache_load_miss",
+               "BriefDescription": "DCACHE load miss"
+       },
+       {
+               "EventCode": "0x81",
+               "EventName": "dcache_store_access",
+               "BriefDescription": "DCACHE store access"
+       },
+       {
+               "EventCode": "0x91",
+               "EventName": "dcache_store_miss",
+               "BriefDescription": "DCACHE store miss"
+       },
+       {
+               "EventCode": "0xA1",
+               "EventName": "dcache_wb",
+               "BriefDescription": "DCACHE writeback"
+       }
+]
tools/perf/pmu-events/arch/riscv/andes/ax45/microarch.json new file +77 -0
new file mode 100644
index 000000000000..a6d378cbaa74
@@ -0,0 +1,77 @@
+[
+       {
+               "EventCode": "0xB1",
+               "EventName": "cycle_wait_icache_fill",
+               "BriefDescription": "Cycles waiting for ICACHE fill data"
+       },
+       {
+               "EventCode": "0xC1",
+               "EventName": "cycle_wait_dcache_fill",
+               "BriefDescription": "Cycles waiting for DCACHE fill data"
+       },
+       {
+               "EventCode": "0xD1",
+               "EventName": "uncached_ifetch_from_bus",
+               "BriefDescription": "Uncached ifetch data access from bus"
+       },
+       {
+               "EventCode": "0xE1",
+               "EventName": "uncached_load_from_bus",
+               "BriefDescription": "Uncached load data access from bus"
+       },
+       {
+               "EventCode": "0xF1",
+               "EventName": "cycle_wait_uncached_ifetch",
+               "BriefDescription": "Cycles waiting for uncached ifetch data from bus"
+       },
+       {
+               "EventCode": "0x101",
+               "EventName": "cycle_wait_uncached_load",
+               "BriefDescription": "Cycles waiting for uncached load data from bus"
+       },
+       {
+               "EventCode": "0x111",
+               "EventName": "main_itlb_access",
+               "BriefDescription": "Main ITLB access"
+       },
+       {
+               "EventCode": "0x121",
+               "EventName": "main_itlb_miss",
+               "BriefDescription": "Main ITLB miss"
+       },
+       {
+               "EventCode": "0x131",
+               "EventName": "main_dtlb_access",
+               "BriefDescription": "Main DTLB access"
+       },
+       {
+               "EventCode": "0x141",
+               "EventName": "main_dtlb_miss",
+               "BriefDescription": "Main DTLB miss"
+       },
+       {
+               "EventCode": "0x151",
+               "EventName": "cycle_wait_itlb_fill",
+               "BriefDescription": "Cycles waiting for Main ITLB fill data"
+       },
+       {
+               "EventCode": "0x161",
+               "EventName": "pipe_stall_cycle_dtlb_miss",
+               "BriefDescription": "Pipeline stall cycles caused by Main DTLB miss"
+       },
+       {
+               "EventCode": "0x02",
+               "EventName": "mispredict_condition_br",
+               "BriefDescription": "Misprediction of conditional branches"
+       },
+       {
+               "EventCode": "0x12",
+               "EventName": "mispredict_take_condition_br",
+               "BriefDescription": "Misprediction of taken conditional branches"
+       },
+       {
+               "EventCode": "0x22",
+               "EventName": "mispredict_target_ret_inst",
+               "BriefDescription": "Misprediction of targets of Return instructions"
+       }
+]
tools/perf/pmu-events/arch/riscv/mapfile.csv +1 -1
index c61b3d6ef616..5bf09af14c1b 100644
@@ -15,3 +15,4 @@
 #
 #MVENDORID-MARCHID-MIMPID,Version,Filename,EventType
 0x489-0x8000000000000007-0x[[:xdigit:]]+,v1,sifive/u74,core
+0x31e-0x8000000000008a45-0x[[:xdigit:]]+,v1,andes/ax45,core
--

2.34.1