Skip to contentSkip to conversation

misc: zynq_slcr: Fix MMIO writes

PATCH Applied Peter Crosthwaite 3 participants 3 messages Oct 10, 2015 – Oct 13, 2015 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: zynq_slcr: Fix MMIO writes

The /4 for offset calculation in MMIO writes was happening twice giving wrong write offsets. Fix.

While touching the code, change the if-else to be a short returning if and convert the debug message to a GUEST_ERROR, which is more accurate for this condition.

---
 hw/misc/zynq_slcr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/misc/zynq_slcr.c +4 -4
index 964f253..3d78708 100644
@@ -393,12 +393,12 @@ static void zynq_slcr_write(void *opaque, hwaddr offset,
         return;
     }
 
-    if (!s->regs[LOCKSTA]) {
-        s->regs[offset / 4] = val;
-    } else {
-        DB_PRINT("SCLR registers are locked. Unlock them first\n");
+    if (s->regs[LOCKSTA]) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "SCLR registers are locked. Unlock them first\n");
         return;
     }
+    s->regs[offset] = val;
 
     switch (offset) {
     case PSS_RST_CTRL:
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Peter Crosthwaite

The /4 for offset calculation in MMIO writes was happening twice giving wrong write offsets. Fix.

While touching the code, change the if-else to be a short returning if and convert the debug message to a GUEST_ERROR, which is more accurate for this condition.

We actually already had the divide by four fix internally.

Thanks,

Alistair

Quoted 29 lines
---
 hw/misc/zynq_slcr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/misc/zynq_slcr.c +4 -5
index 964f253..3d78708 100644
@@ -393,12 +393,12 @@ static void zynq_slcr_write(void *opaque, hwaddr offset,
         return;
     }
 
-    if (!s->regs[LOCKSTA]) {
-        s->regs[offset / 4] = val;
-    } else {
-        DB_PRINT("SCLR registers are locked. Unlock them first\n");
+    if (s->regs[LOCKSTA]) {
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "SCLR registers are locked. Unlock them first\n");
         return;
     }
+    s->regs[offset] = val;
 
     switch (offset) {
     case PSS_RST_CTRL:
--

1.9.1

#2 lore raw
In reply to Peter Crosthwaite
Quoted 7 lines · Peter Crosthwaite

The /4 for offset calculation in MMIO writes was happening twice giving wrong write offsets. Fix.

While touching the code, change the if-else to be a short returning if and convert the debug message to a GUEST_ERROR, which is more accurate for this condition.

Quoted 6 lines
---
 hw/misc/zynq_slcr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied to target-arm.next, thanks.

-- PMM