Skip to contentSkip to conversation

target/riscv: fix invalid riscv,event-to-mhpmcounters entry

PATCH Applied Conor Dooley 2 participants 3 messages Apr 4, 2023 – Apr 5, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/riscv: fix invalid riscv,event-to-mhpmcounters entry

From: Conor Dooley <[email protected]>

dt-validate complains:

Quoted 4 lines

soc: pmu: {'riscv,event-to-mhpmcounters':
[[1, 1, 524281], [2, 2, 524284], [65561, 65561, 524280], [65563, 65563, 524280], [65569, 65569, 524280], [0, 0, 0], [0, 0]],
pmu: riscv,event-to-mhpmcounters:6: [0, 0] is too short

There are bogus 0 entries added at the end, of which one is of insufficient length. This happens because only 15 of fdt_event_ctr_map[]'s 20 elements are populated & qemu_fdt_setprop() is called using the size of the array.
Reduce the array to 15 elements to make the error go away.

---
I dunno if I am missing something intentional here, feel free to scream if so!

---
 target/riscv/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/pmu.c +1 -1
index b8e56d2b7b..fa1e1484c2 100644
@@ -35,7 +35,7 @@
  */
 void riscv_pmu_generate_fdt_node(void *fdt, int num_ctrs, char *pmu_name)
 {
-    uint32_t fdt_event_ctr_map[20] = {};
+    uint32_t fdt_event_ctr_map[15] = {};
     uint32_t cmask;
 
     /* All the programmable counters can map to any event */
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw

Re: [PATCH] target/riscv: fix invalid riscv, event-to-mhpmcounters entry

Quoted 9 lines · Conor Dooley

From: Conor Dooley <[email protected]>

dt-validate complains:

Quoted 4 lines

soc: pmu: {'riscv,event-to-mhpmcounters':
[[1, 1, 524281], [2, 2, 524284], [65561, 65561, 524280], [65563, 65563, 524280], [65569, 65569, 524280], [0, 0, 0], [0, 0]],
pmu: riscv,event-to-mhpmcounters:6: [0, 0] is too short

Quoted 7 lines

There are bogus 0 entries added at the end, of which one is of insufficient length. This happens because only 15 of fdt_event_ctr_map[]'s 20 elements are populated & qemu_fdt_setprop() is called using the size of the array.
Reduce the array to 15 elements to make the error go away.

Alistair

Quoted 24 lines

---
I dunno if I am missing something intentional here, feel free to scream if so!

---
 target/riscv/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/pmu.c +1 -2
index b8e56d2b7b..fa1e1484c2 100644
@@ -35,7 +35,7 @@
  */
 void riscv_pmu_generate_fdt_node(void *fdt, int num_ctrs, char *pmu_name)
 {
-    uint32_t fdt_event_ctr_map[20] = {};
+    uint32_t fdt_event_ctr_map[15] = {};
     uint32_t cmask;
 
     /* All the programmable counters can map to any event */
--

2.39.2

#2 lore raw

Re: [PATCH] target/riscv: fix invalid riscv, event-to-mhpmcounters entry

In reply to Conor Dooley
Quoted 9 lines · Conor Dooley

From: Conor Dooley <[email protected]>

dt-validate complains:

Quoted 4 lines

soc: pmu: {'riscv,event-to-mhpmcounters':
[[1, 1, 524281], [2, 2, 524284], [65561, 65561, 524280], [65563, 65563, 524280], [65569, 65569, 524280], [0, 0, 0], [0, 0]],
pmu: riscv,event-to-mhpmcounters:6: [0, 0] is too short

Quoted 7 lines

There are bogus 0 entries added at the end, of which one is of insufficient length. This happens because only 15 of fdt_event_ctr_map[]'s 20 elements are populated & qemu_fdt_setprop() is called using the size of the array.
Reduce the array to 15 elements to make the error go away.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 24 lines

---
I dunno if I am missing something intentional here, feel free to scream if so!

---
 target/riscv/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/pmu.c +1 -2
index b8e56d2b7b..fa1e1484c2 100644
@@ -35,7 +35,7 @@
  */
 void riscv_pmu_generate_fdt_node(void *fdt, int num_ctrs, char *pmu_name)
 {
-    uint32_t fdt_event_ctr_map[20] = {};
+    uint32_t fdt_event_ctr_map[15] = {};
     uint32_t cmask;
 
     /* All the programmable counters can map to any event */
--

2.39.2