Skip to content

Commit a13a806

Browse files
Merge patch series "Support Andes PMU extension"
Yu Chien Peter Lin <peterlin@andestech.com> says: This patch series introduces the Andes PMU extension, which serves the same purpose as Sscofpmf and Smcntrpmf. Its non-standard local interrupt is assigned to bit 18 in the custom S-mode local interrupt enable and pending registers (slie/slip), while the interrupt cause is (256 + 18). * b4-shazam-merge: riscv: andes: Support specifying symbolic firmware and hardware raw events riscv: dts: renesas: Add Andes PMU extension for r9a07g043f dt-bindings: riscv: Add Andes PMU extension description perf: RISC-V: Introduce Andes PMU to support perf event sampling perf: RISC-V: Eliminate redundant interrupt enable/disable operations riscv: dts: renesas: r9a07g043f: Update compatible string to use Andes INTC dt-bindings: riscv: Add Andes interrupt controller compatible string riscv: errata: Rename defines for Andes Link: https://lore.kernel.org/r/20240222083946.3977135-1-peterlin@andestech.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 parents b8e00bd + f5102e3 commit a13a806

File tree

16 files changed

+401
-26
lines changed

16 files changed

+401
-26
lines changed

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ properties:
106106
const: 1
107107

108108
compatible:
109-
const: riscv,cpu-intc
109+
oneOf:
110+
- items:
111+
- const: andestech,cpu-intc
112+
- const: riscv,cpu-intc
113+
- const: riscv,cpu-intc
110114

111115
interrupt-controller: true
112116

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,12 @@ properties:
477477
latency, as ratified in commit 56ed795 ("Update
478478
riscv-crypto-spec-vector.adoc") of riscv-crypto.
479479

480+
- const: xandespmu
481+
description:
482+
The Andes Technology performance monitor extension for counter overflow
483+
and privilege mode filtering. For more details, see Counter Related
484+
Registers in the AX45MP datasheet.
485+
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
486+
480487
additionalProperties: true
481488
...

arch/riscv/boot/dts/renesas/r9a07g043f.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
riscv,isa-base = "rv64i";
2828
riscv,isa-extensions = "i", "m", "a", "f", "d", "c",
2929
"zicntr", "zicsr", "zifencei",
30-
"zihpm";
30+
"zihpm", "xandespmu";
3131
mmu-type = "riscv,sv39";
3232
i-cache-size = <0x8000>;
3333
i-cache-line-size = <0x40>;
@@ -39,7 +39,7 @@
3939

4040
cpu0_intc: interrupt-controller {
4141
#interrupt-cells = <1>;
42-
compatible = "riscv,cpu-intc";
42+
compatible = "andestech,cpu-intc", "riscv,cpu-intc";
4343
interrupt-controller;
4444
};
4545
};

arch/riscv/errata/andes/errata.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include <asm/sbi.h>
1919
#include <asm/vendorid_list.h>
2020

21-
#define ANDESTECH_AX45MP_MARCHID 0x8000000000008a45UL
22-
#define ANDESTECH_AX45MP_MIMPID 0x500UL
23-
#define ANDESTECH_SBI_EXT_ANDES 0x0900031E
21+
#define ANDES_AX45MP_MARCHID 0x8000000000008a45UL
22+
#define ANDES_AX45MP_MIMPID 0x500UL
23+
#define ANDES_SBI_EXT_ANDES 0x0900031E
2424

2525
#define ANDES_SBI_EXT_IOCP_SW_WORKAROUND 1
2626

@@ -32,7 +32,7 @@ static long ax45mp_iocp_sw_workaround(void)
3232
* ANDES_SBI_EXT_IOCP_SW_WORKAROUND SBI EXT checks if the IOCP is missing and
3333
* cache is controllable only then CMO will be applied to the platform.
3434
*/
35-
ret = sbi_ecall(ANDESTECH_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
35+
ret = sbi_ecall(ANDES_SBI_EXT_ANDES, ANDES_SBI_EXT_IOCP_SW_WORKAROUND,
3636
0, 0, 0, 0, 0, 0);
3737

3838
return ret.error ? 0 : ret.value;
@@ -50,7 +50,7 @@ static void errata_probe_iocp(unsigned int stage, unsigned long arch_id, unsigne
5050

5151
done = true;
5252

53-
if (arch_id != ANDESTECH_AX45MP_MARCHID || impid != ANDESTECH_AX45MP_MIMPID)
53+
if (arch_id != ANDES_AX45MP_MARCHID || impid != ANDES_AX45MP_MIMPID)
5454
return;
5555

5656
if (!ax45mp_iocp_sw_workaround())

arch/riscv/include/asm/errata_list.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#include <asm/vendorid_list.h>
1313

1414
#ifdef CONFIG_ERRATA_ANDES
15-
#define ERRATA_ANDESTECH_NO_IOCP 0
16-
#define ERRATA_ANDESTECH_NUMBER 1
15+
#define ERRATA_ANDES_NO_IOCP 0
16+
#define ERRATA_ANDES_NUMBER 1
1717
#endif
1818

1919
#ifdef CONFIG_ERRATA_SIFIVE
@@ -112,15 +112,6 @@ asm volatile(ALTERNATIVE( \
112112
#define THEAD_C9XX_RV_IRQ_PMU 17
113113
#define THEAD_C9XX_CSR_SCOUNTEROF 0x5c5
114114

115-
#define ALT_SBI_PMU_OVERFLOW(__ovl) \
116-
asm volatile(ALTERNATIVE( \
117-
"csrr %0, " __stringify(CSR_SSCOUNTOVF), \
118-
"csrr %0, " __stringify(THEAD_C9XX_CSR_SCOUNTEROF), \
119-
THEAD_VENDOR_ID, ERRATA_THEAD_PMU, \
120-
CONFIG_ERRATA_THEAD_PMU) \
121-
: "=r" (__ovl) : \
122-
: "memory")
123-
124115
#endif /* __ASSEMBLY__ */
125116

126117
#endif

arch/riscv/include/asm/hwcap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
#define RISCV_ISA_EXT_ZFA 71
8181
#define RISCV_ISA_EXT_ZTSO 72
8282
#define RISCV_ISA_EXT_ZACAS 73
83+
#define RISCV_ISA_EXT_XANDESPMU 74
8384

8485
#define RISCV_ISA_EXT_MAX 128
8586
#define RISCV_ISA_EXT_INVALID U32_MAX

arch/riscv/include/asm/vendorid_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef ASM_VENDOR_LIST_H
66
#define ASM_VENDOR_LIST_H
77

8-
#define ANDESTECH_VENDOR_ID 0x31e
8+
#define ANDES_VENDOR_ID 0x31e
99
#define SIFIVE_VENDOR_ID 0x489
1010
#define THEAD_VENDOR_ID 0x5b7
1111

arch/riscv/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void riscv_fill_cpu_mfr_info(struct cpu_manufacturer_info_t *cpu_mfr_info
4343

4444
switch (cpu_mfr_info->vendor_id) {
4545
#ifdef CONFIG_ERRATA_ANDES
46-
case ANDESTECH_VENDOR_ID:
46+
case ANDES_VENDOR_ID:
4747
cpu_mfr_info->patch_func = andes_errata_patch_func;
4848
break;
4949
#endif

arch/riscv/kernel/cpufeature.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
307307
__RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL),
308308
__RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT),
309309
__RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT),
310+
__RISCV_ISA_EXT_DATA(xandespmu, RISCV_ISA_EXT_XANDESPMU),
310311
};
311312

312313
const size_t riscv_isa_ext_count = ARRAY_SIZE(riscv_isa_ext);

drivers/perf/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ config RISCV_PMU_SBI
8686
full perf feature support i.e. counter overflow, privilege mode
8787
filtering, counter configuration.
8888

89+
config ANDES_CUSTOM_PMU
90+
bool "Andes custom PMU support"
91+
depends on ARCH_RENESAS && RISCV_ALTERNATIVE && RISCV_PMU_SBI
92+
default y
93+
help
94+
The Andes cores implement the PMU overflow extension very
95+
similar to the standard Sscofpmf and Smcntrpmf extension.
96+
97+
This will patch the overflow and pending CSRs and handle the
98+
non-standard behaviour via the regular SBI PMU driver and
99+
interface.
100+
101+
If you don't know what to do here, say "Y".
102+
89103
config ARM_PMU_ACPI
90104
depends on ARM_PMU && ACPI
91105
def_bool y

0 commit comments

Comments
 (0)