Skip to contentSkip to conversation

riscv: opentitan: fixup plic stride len

PATCH Superseded Alistair Francis 4 participants 7 messages Jan 10, 2022 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 riscv: opentitan: fixup plic stride len

From: Wilfred Mallawa <[email protected]>

The following change was made to rectify incorrectly set stride length on the PLIC. Where it should be 32bit and not 24bit (0x18). This was discovered whilst attempting to fix a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

---
 hw/riscv/opentitan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/opentitan.c +1 -1
index c531450b9f..5144845567 100644
@@ -160,7 +160,7 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
     qdev_prop_set_uint32(DEVICE(&s->plic), "priority-base", 0x00);
     qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000);
     qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000);
-    qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 0x18);
+    qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 32);
     qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200000);
     qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 8);
     qdev_prop_set_uint32(DEVICE(&s->plic), "aperture-size", memmap[IBEX_DEV_PLIC].size);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 hw: timer: ibex_timer: update/add reg address

From: Wilfred Mallawa <[email protected]>

The following changes:
1. Fixes the incorrectly set CTRL register address. As
per [1] https://docs.opentitan.org/hw/ip/rv_timer/doc/#register-table

The CTRL register is @ 0x04.

This was found when attempting to fixup a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

2. Adds ALERT_TEST register as documented on [1], adding repective switch cases to error handle and later implement functionality.

---
 hw/timer/ibex_timer.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
hw/timer/ibex_timer.c +10 -1
index 66e1f8e48c..096588ac8a 100644
@@ -34,7 +34,9 @@
 #include "target/riscv/cpu.h"
 #include "migration/vmstate.h"
 
-REG32(CTRL, 0x00)
+REG32(ALERT_TEST, 0x00)
+    FIELD(ALERT_TEST, FATAL_FAULT, 0, 1)
+REG32(CTRL, 0x04)
     FIELD(CTRL, ACTIVE, 0, 1)
 REG32(CFG0, 0x100)
     FIELD(CFG0, PRESCALE, 0, 12)
@@ -143,6 +145,10 @@ static uint64_t ibex_timer_read(void *opaque, hwaddr addr,
     uint64_t retvalue = 0;
 
     switch (addr >> 2) {
+    case R_ALERT_TEST:
+        qemu_log_mask(LOG_GUEST_ERROR,
+                        "Attempted to read ALERT_TEST, a write only register");
+        break;
     case R_CTRL:
         retvalue = s->timer_ctrl;
         break;
@@ -186,6 +192,9 @@ static void ibex_timer_write(void *opaque, hwaddr addr,
     uint32_t val = val64;
 
     switch (addr >> 2) {
+    case R_ALERT_TEST:
+        qemu_log_mask(LOG_UNIMP, "Alert triggering not supported");
+        break;
     case R_CTRL:
         s->timer_ctrl = val;
         break;
Signature · 1 line
2.34.1
Reviewed-by Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] hw: timer: ibex_timer: update/add reg address

Quoted 9 lines · Alistair Francis

From: Wilfred Mallawa <[email protected]>

The following changes:
1. Fixes the incorrectly set CTRL register address. As
per [1] https://docs.opentitan.org/hw/ip/rv_timer/doc/#register-table

The CTRL register is @ 0x04.

Quoted 7 lines

This was found when attempting to fixup a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

2. Adds ALERT_TEST register as documented on [1], adding repective switch cases to error handle and later implement functionality.

Alistair

Quoted 43 lines
---
 hw/timer/ibex_timer.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
hw/timer/ibex_timer.c +10 -2
index 66e1f8e48c..096588ac8a 100644
@@ -34,7 +34,9 @@
 #include "target/riscv/cpu.h"
 #include "migration/vmstate.h"
 
-REG32(CTRL, 0x00)
+REG32(ALERT_TEST, 0x00)
+    FIELD(ALERT_TEST, FATAL_FAULT, 0, 1)
+REG32(CTRL, 0x04)
     FIELD(CTRL, ACTIVE, 0, 1)
 REG32(CFG0, 0x100)
     FIELD(CFG0, PRESCALE, 0, 12)
@@ -143,6 +145,10 @@ static uint64_t ibex_timer_read(void *opaque, hwaddr addr,
     uint64_t retvalue = 0;
 
     switch (addr >> 2) {
+    case R_ALERT_TEST:
+        qemu_log_mask(LOG_GUEST_ERROR,
+                        "Attempted to read ALERT_TEST, a write only register");
+        break;
     case R_CTRL:
         retvalue = s->timer_ctrl;
         break;
@@ -186,6 +192,9 @@ static void ibex_timer_write(void *opaque, hwaddr addr,
     uint32_t val = val64;
 
     switch (addr >> 2) {
+    case R_ALERT_TEST:
+        qemu_log_mask(LOG_UNIMP, "Alert triggering not supported");
+        break;
     case R_CTRL:
         s->timer_ctrl = val;
         break;
--

2.34.1

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] hw: timer: ibex_timer: update/add reg address

In reply to Alistair Francis
Quoted 12 lines · Alistair Francis

From: Wilfred Mallawa <[email protected]>

The following changes:
1. Fixes the incorrectly set CTRL register address. As
per [1] https://docs.opentitan.org/hw/ip/rv_timer/doc/#register-table

The CTRL register is @ 0x04.

This was found when attempting to fixup a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

Quoted 8 lines

2. Adds ALERT_TEST register as documented on [1], adding repective switch cases to error handle and later implement functionality.

---
 hw/timer/ibex_timer.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Reviewed-by Tested-by on v1 1/2
#4 lore raw
In reply to Alistair Francis
Quoted 9 lines · Alistair Francis

From: Wilfred Mallawa <[email protected]>

The following change was made to rectify incorrectly set stride length on the PLIC. Where it should be 32bit and not 24bit (0x18). This was discovered whilst attempting to fix a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

Alistair

Quoted 20 lines
---
 hw/riscv/opentitan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/opentitan.c +1 -2
index c531450b9f..5144845567 100644
@@ -160,7 +160,7 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
     qdev_prop_set_uint32(DEVICE(&s->plic), "priority-base", 0x00);
     qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000);
     qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000);
-    qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 0x18);
+    qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 32);
     qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200000);
     qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 8);
     qdev_prop_set_uint32(DEVICE(&s->plic), "aperture-size", memmap[IBEX_DEV_PLIC].size);
--

2.34.1

Reviewed-by on v1 1/2
#5 lore raw
In reply to Alistair Francis
Quoted 5 lines · Alistair Francis

From: Wilfred Mallawa <[email protected]>

The following change was made to rectify incorrectly set stride length on the PLIC. Where it should be 32bit and not 24bit (0x18). This was

PLIC [1]

Quoted 3 lines

discovered whilst attempting to fix a bug where a timer_interrupt was not serviced on TockOS-OpenTitan.

[1] https://docs.opentitan.org/hw/top_earlgrey/ip_autogen/rv_plic/doc/

Quoted 5 lines
---
 hw/riscv/opentitan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#6 lore raw
Quoted 8 lines · Bin Meng

CAUTION: This email originated from outside of Western Digital. Do not click on links or open attachments unless you recognize the sender and know that the content is safe.

Quoted 1 line · Alistair Francis
Quoted 8 lines
Quoted 6 lines

From: Wilfred Mallawa <[email protected]>

The following change was made to rectify incorrectly set stride length
on the PLIC. Where it should be 32bit and not 24bit (0x18). This was

PLIC [1]

Thanks, will add this in.

Quoted 16 lines
Quoted 5 lines

discovered whilst attempting to fix a bug where a timer_interrupt was
not serviced on TockOS-OpenTitan.

[1]
https://docs.opentitan.org/hw/top_earlgrey/ip_autogen/rv_plic/doc/

Quoted 5 lines

---
 hw/riscv/opentitan.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)