Skip to contentSkip to conversation

hw/riscv: riscv-iommu: Re-process command queue after clearing CMD_ILL

PATCH Superseded Jay Chang 3 participants 4 messages Jan 6 – May 18 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jay Chang

author
#0 lore raw

PATCH 1/1 hw/riscv: riscv-iommu: Re-process command queue after clearing CMD_ILL

When software clears CMD_ILL or CQMF error bits by writing 1 to CQCSR, the IOMMU should re-check the command queue and continue processing pending commands if head != tail.

Per RISC-V IOMMU specification, the software error recovery sequence:

1. Read the head pointer
2. Software has two options:
- Option 1: Set tail = head to re-start from an empty queue
- Option 2: Overwrite the illegal command with a valid one
3. Re-enable the command queue by writing 1 to cqcsr.cmd_ill

"At this point, IOMMU will start working on the first command
in the queue."

---
 hw/riscv/riscv-iommu.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/riscv/riscv-iommu.c +10 -0
index b46b337375..e89a262a63 100644
@@ -1992,6 +1992,16 @@ static void riscv_iommu_process_cq_control(RISCVIOMMUState *s)
     }
 
     riscv_iommu_reg_mod32(s, RISCV_IOMMU_REG_CQCSR, ctrl_set, ctrl_clr);
+
+    /*
+     * After clearing error bits (CMD_ILL, CQMF), if queue is still active,
+     * re-process pending command.
+     */
+    ctrl_set = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_CQCSR);
+    if ((ctrl_set & RISCV_IOMMU_CQCSR_CQON) &&
+        !(ctrl_set & (RISCV_IOMMU_CQCSR_CMD_ILL | RISCV_IOMMU_CQCSR_CQMF))) {
+        riscv_iommu_process_cq_tail(s);
+    }
 }
 
 static void riscv_iommu_process_fq_control(RISCVIOMMUState *s)
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Jay Chang

When software clears CMD_ILL or CQMF error bits by writing 1 to CQCSR, the IOMMU should re-check the command queue and continue processing pending commands if head != tail.

Per RISC-V IOMMU specification, the software error recovery sequence:

1. Read the head pointer
2. Software has two options:
- Option 1: Set tail = head to re-start from an empty queue
- Option 2: Overwrite the illegal command with a valid one
3. Re-enable the command queue by writing 1 to cqcsr.cmd_ill

Quoted 6 lines

"At this point, IOMMU will start working on the first command
in the queue."

---

Quoted 24 lines
  hw/riscv/riscv-iommu.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/riscv/riscv-iommu.c +10 -0
index b46b337375..e89a262a63 100644
@@ -1992,6 +1992,16 @@ static void riscv_iommu_process_cq_control(RISCVIOMMUState *s)
      }
 
      riscv_iommu_reg_mod32(s, RISCV_IOMMU_REG_CQCSR, ctrl_set, ctrl_clr);
+
+    /*
+     * After clearing error bits (CMD_ILL, CQMF), if queue is still active,
+     * re-process pending command.
+     */
+    ctrl_set = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_CQCSR);
+    if ((ctrl_set & RISCV_IOMMU_CQCSR_CQON) &&
+        !(ctrl_set & (RISCV_IOMMU_CQCSR_CMD_ILL | RISCV_IOMMU_CQCSR_CQMF))) {
+        riscv_iommu_process_cq_tail(s);
+    }
  }
 
  static void riscv_iommu_process_fq_control(RISCVIOMMUState *s)
author
#2 lore raw

Hi,

Gentle ping on this patch.

Thanks,
Jay Chang

Quoted 54 lines · Daniel Henrique Barboza
Quoted 12 lines · Jay Chang

When software clears CMD_ILL or CQMF error bits by writing 1 to CQCSR, the IOMMU should re-check the command queue and continue processing pending commands if head != tail.

Per RISC-V IOMMU specification, the software error recovery sequence:

1. Read the head pointer
2. Software has two options:
- Option 1: Set tail = head to re-start from an empty queue
- Option 2: Overwrite the illegal command with a valid one
3. Re-enable the command queue by writing 1 to cqcsr.cmd_ill

Quoted 6 lines

"At this point, IOMMU will start working on the first command
in the queue."

---

hw/riscv/riscv-iommu.c static void

Quoted 8 lines
  hw/riscv/riscv-iommu.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/riscv/riscv-iommu.c +0 -0
index b46b337375..e89a262a63 100644
@@ -1992,6 +1992,16 @@ static void

riscv_iommu_process_cq_control(RISCVIOMMUState *s)

hw/riscv/riscv-iommu.c static void · line 1994

Quoted 3 lines
hw/riscv/riscv-iommu.c +0 -0
      }
 
      riscv_iommu_reg_mod32(s, RISCV_IOMMU_REG_CQCSR, ctrl_set,

ctrl_clr);

hw/riscv/riscv-iommu.c static void riscv_iommu_process_cq_control(RISCVIOMMUState *s)

Quoted 3 lines
hw/riscv/riscv-iommu.c +3 -0
+
+    /*
+     * After clearing error bits (CMD_ILL, CQMF), if queue is still

active,

hw/riscv/riscv-iommu.c static void riscv_iommu_process_cq_control(RISCVIOMMUState *s)

Quoted 5 lines
hw/riscv/riscv-iommu.c +5 -0
+     * re-process pending command.
+     */
+    ctrl_set = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_CQCSR);
+    if ((ctrl_set & RISCV_IOMMU_CQCSR_CQON) &&
+        !(ctrl_set & (RISCV_IOMMU_CQCSR_CMD_ILL |

RISCV_IOMMU_CQCSR_CQMF))) {

Quoted 5 lines
hw/riscv/riscv-iommu.c +2 -0
+        riscv_iommu_process_cq_tail(s);
+    }
  }
 
  static void riscv_iommu_process_fq_control(RISCVIOMMUState *s)
#3 lore raw
Quoted 4 lines · Jay Chang

Hi,

Gentle ping on this patch.

Can you please resend the series, I lost this the first time around

Alistair

Quoted 55 lines

Thanks,
Jay Chang

Quoted 50 lines · Daniel Henrique Barboza
Quoted 12 lines · Jay Chang

When software clears CMD_ILL or CQMF error bits by writing 1 to CQCSR, the IOMMU should re-check the command queue and continue processing pending commands if head != tail.

Per RISC-V IOMMU specification, the software error recovery sequence:

1. Read the head pointer
2. Software has two options:
- Option 1: Set tail = head to re-start from an empty queue
- Option 2: Overwrite the illegal command with a valid one
3. Re-enable the command queue by writing 1 to cqcsr.cmd_ill

Quoted 6 lines

"At this point, IOMMU will start working on the first command
in the queue."

---

Quoted 24 lines
  hw/riscv/riscv-iommu.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
hw/riscv/riscv-iommu.c +10 -0
index b46b337375..e89a262a63 100644
@@ -1992,6 +1992,16 @@ static void riscv_iommu_process_cq_control(RISCVIOMMUState *s)
      }
 
      riscv_iommu_reg_mod32(s, RISCV_IOMMU_REG_CQCSR, ctrl_set, ctrl_clr);
+
+    /*
+     * After clearing error bits (CMD_ILL, CQMF), if queue is still active,
+     * re-process pending command.
+     */
+    ctrl_set = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_CQCSR);
+    if ((ctrl_set & RISCV_IOMMU_CQCSR_CQON) &&
+        !(ctrl_set & (RISCV_IOMMU_CQCSR_CMD_ILL | RISCV_IOMMU_CQCSR_CQMF))) {
+        riscv_iommu_process_cq_tail(s);
+    }
  }
 
  static void riscv_iommu_process_fq_control(RISCVIOMMUState *s)