Skip to contentSkip to conversation

Fix interval interrupt of cadence ttc when timer is in decrement mode

PATCH In review Johannes Schlatow 3 participants 3 messages Jun 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix interval interrupt of cadence ttc when timer is in decrement mode

The interval interrupt is not set if the timer is in decrement mode. This is because x >=0 and x < interval after leaving the while-loop.

---
 hw/timer/cadence_ttc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/timer/cadence_ttc.c +4 -5
index d46db3c..35bc880 100644
@@ -208,15 +208,14 @@ static void cadence_timer_sync(CadenceTimerState *s)
             s->reg_intr |= (2 << i);
         }
     }
+    if ((x < 0) || (x >= interval)) {
+        s->reg_intr |= (s->reg_count & COUNTER_CTRL_INT) ?
+            COUNTER_INTR_IV : COUNTER_INTR_OV;
+    }
     while (x < 0) {
         x += interval;
     }
     s->reg_value = (uint32_t)(x % interval);
-
-    if (s->reg_value != x) {
-        s->reg_intr |= (s->reg_count & COUNTER_CTRL_INT) ?
-            COUNTER_INTR_IV : COUNTER_INTR_OV;
-    }
     cadence_timer_update(s);
 }
 
Signature · 1 line
2.4.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Johannes Schlatow

The interval interrupt is not set if the timer is in decrement mode. This is because x >=0 and x < interval after leaving the while-loop.

Can this go via target-arm for 2.4 (as a bugfix)?

Regards,
Peter

Quoted 32 lines
---
 hw/timer/cadence_ttc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/timer/cadence_ttc.c +4 -6
index d46db3c..35bc880 100644
@@ -208,15 +208,14 @@ static void cadence_timer_sync(CadenceTimerState *s)
             s->reg_intr |= (2 << i);
         }
     }
+    if ((x < 0) || (x >= interval)) {
+        s->reg_intr |= (s->reg_count & COUNTER_CTRL_INT) ?
+            COUNTER_INTR_IV : COUNTER_INTR_OV;
+    }
     while (x < 0) {
         x += interval;
     }
     s->reg_value = (uint32_t)(x % interval);
-
-    if (s->reg_value != x) {
-        s->reg_intr |= (s->reg_count & COUNTER_CTRL_INT) ?
-            COUNTER_INTR_IV : COUNTER_INTR_OV;
-    }
     cadence_timer_update(s);
 }
 
--

2.4.5