Skip to contentSkip to conversation

Bug fixes and IPSR.PMIP support

PATCH Applied Jay Chang 2 participants 4 messages Mar 25 – Mar 30 RISC-V

lore
Share & tools
lore

Jay Chang

author
#0 lore raw

v2 cover Bug fixes and IPSR.PMIP support

This series contains two fixes for the RISC-V IOMMU implementation:

1. Fix a bug in the HPM (Hardware Performance Monitor) timer setup where irq_overflow_left was not properly reset, causing stale values from previous timer setups to affect new timer behavior.

2. Add proper RW1C (Read/Write 1 to Clear) support for the IPSR.PMIP (Performance Monitor Interrupt Pending) bit, which was missing from the IPSR register implementation.

---
Change in V2
Add commit message

Jay Chang (2):
hw/riscv/riscv-iommu-hpm: Fix irq_overflow_left residual value bug hw/riscv/riscv-iommu: Add IPSR.PMIP RW1C support

 hw/riscv/riscv-iommu-bits.h | 1 +
 hw/riscv/riscv-iommu-hpm.c  | 1 +
 hw/riscv/riscv-iommu.c      | 4 ++++
 3 files changed, 6 insertions(+)
Signature · 1 line
2.48.1
author
#1 lore raw

PATCH v2 1/2 hw/riscv/riscv-iommu-hpm: Fix irq_overflow_left residual value bug

Reset irq_overflow_left to 0 before setting up a new timer. Without this fix, a stale irq_overflow_left value from a previous timer setup could cause incorrect timer behavior.

---
 hw/riscv/riscv-iommu-hpm.c | 1 +
 1 file changed, 1 insertion(+)
hw/riscv/riscv-iommu-hpm.c +1 -0
index c5034bff79..e8d284ac8b 100644
@@ -228,6 +228,7 @@ static void hpm_setup_timer(RISCVIOMMUState *s, uint64_t value)
     }
 
     overflow_at = (uint64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + overflow_ns;
+    s->irq_overflow_left = 0;
 
     if (overflow_at > INT64_MAX) {
         s->irq_overflow_left = overflow_at - INT64_MAX;
Signature · 1 line
2.48.1
author
#2 lore raw

PATCH v2 2/2 hw/riscv/riscv-iommu: Add IPSR.PMIP RW1C support

In reply to Jay Chang

Add proper RW1C (Read/Write 1 to Clear) support for the IPSR.PMIP (Performance Monitor Interrupt Pending) bit, which was missing from the IPSR register implementation.

---
 hw/riscv/riscv-iommu-bits.h | 1 +
 hw/riscv/riscv-iommu.c      | 4 ++++
 2 files changed, 5 insertions(+)
hw/riscv/riscv-iommu-bits.h +1 -0
index 47fe01bee5..a938fd3eb4 100644
@@ -189,6 +189,7 @@ enum riscv_iommu_ddtp_modes {
 #define RISCV_IOMMU_REG_IPSR            0x0054
 #define RISCV_IOMMU_IPSR_CIP            BIT(0)
 #define RISCV_IOMMU_IPSR_FIP            BIT(1)
+#define RISCV_IOMMU_IPSR_PMIP           BIT(2)
 #define RISCV_IOMMU_IPSR_PIP            BIT(3)
 
 enum {
hw/riscv/riscv-iommu.c +4 -0
index 225394ea83..f8b5187328 100644
@@ -2153,6 +2153,10 @@ static void riscv_iommu_update_ipsr(RISCVIOMMUState *s, uint64_t data)
         ipsr_clr |= RISCV_IOMMU_IPSR_FIP;
     }
 
+    if (!(data & RISCV_IOMMU_IPSR_PMIP)) {
+        ipsr_clr |= RISCV_IOMMU_IPSR_PMIP;
+    }
+
     if (data & RISCV_IOMMU_IPSR_PIP) {
         pqcsr = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_PQCSR);
 
Signature · 1 line
2.48.1
#3 lore raw
In reply to Jay Chang
Quoted 10 lines · Jay Chang

This series contains two fixes for the RISC-V IOMMU implementation:

1. Fix a bug in the HPM (Hardware Performance Monitor) timer setup where irq_overflow_left was not properly reset, causing stale values from previous timer setups to affect new timer behavior.

2. Add proper RW1C (Read/Write 1 to Clear) support for the IPSR.PMIP (Performance Monitor Interrupt Pending) bit, which was missing from the IPSR register implementation.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 18 lines

---
Change in V2
Add commit message

Jay Chang (2):
hw/riscv/riscv-iommu-hpm: Fix irq_overflow_left residual value bug hw/riscv/riscv-iommu: Add IPSR.PMIP RW1C support

 hw/riscv/riscv-iommu-bits.h | 1 +
 hw/riscv/riscv-iommu-hpm.c  | 1 +
 hw/riscv/riscv-iommu.c      | 4 ++++
 3 files changed, 6 insertions(+)

--
2.48.1