Skip to contentSkip to conversation

target/imx: reload cmp timer outside of the reload ptimer transaction

PATCH In review ~axelheider 2 participants 3 messages Oct 21, 2022 – Oct 24, 2022 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/imx: reload cmp timer outside of the reload ptimer transaction

From: Axel Heider <[email protected]>

---
See https://gitlab.com/qemu-project/qemu/-/issues/1263
When running the seL4 tests
(https://docs.sel4.systems/projects/sel4test), on the sabrelight platform the timer test fails (and thus it's disabled by default). Investigation has shown that the arm/imx6 EPIT timer interrupt does not fire properly, instead of a second in can take up to a minute to finally see the interrupt.

 hw/timer/imx_epit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/timer/imx_epit.c +4 -1
index 2bf8c754b2..0b13c1eab0 100644
@@ -276,9 +276,12 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
             ptimer_set_count(s->timer_reload, s->lr);
         }
 
+        // commit s->timer_reload before imx_epit_reload_compare_timer
+        // as timer_reload is read in imx_epit_reload_compare_timer
+        ptimer_transaction_commit(s->timer_reload);
+
         imx_epit_reload_compare_timer(s);
         ptimer_transaction_commit(s->timer_cmp);
-        ptimer_transaction_commit(s->timer_reload);
         break;
 
     case 3: /* CMP */
Signature · 1 line
2.34.5
#1 lore raw
Quoted 21 lines · ~axelheider

From: Axel Heider <[email protected]>

---
See https://gitlab.com/qemu-project/qemu/-/issues/1263
When running the seL4 tests
(https://docs.sel4.systems/projects/sel4test), on the sabrelight platform the timer test fails (and thus it's disabled by default). Investigation has shown that the arm/imx6 EPIT timer interrupt does not fire properly, instead of a second in can take up to a minute to finally see the interrupt.

 hw/timer/imx_epit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/timer/imx_epit.c +0 -0
index 2bf8c754b2..0b13c1eab0 100644

hw/timer/imx_epit.c static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, · line 280

Quoted 5 lines
hw/timer/imx_epit.c +2 -0
@@ -276,9 +276,12 @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
             ptimer_set_count(s->timer_reload, s->lr);
         }
 
+        // commit s->timer_reload before imx_epit_reload_compare_timer
+        // as timer_reload is read in imx_epit_reload_compare_timer

QEMU coding style requires /* ... */ for comments, not // (with the /* and */ on lines of their own if it's a multiline comment.

hw/timer/imx_epit.c static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, · line 285

Quoted 6 lines
hw/timer/imx_epit.c +2 -1
+        ptimer_transaction_commit(s->timer_reload);
+
         imx_epit_reload_compare_timer(s);
         ptimer_transaction_commit(s->timer_cmp);
-        ptimer_transaction_commit(s->timer_reload);
         break;

Yes, I see what's happening here. It's OK to commit the timer_reload timer transaction first because that timer doesn't care about the timer_cmp timer.

Do we also need to change the other places that call imx_epit_reload_compare_timer() in the handling of CR register writes ? (Those are a little more tricky.)

thanks
-- PMM

#2 lore raw
Quoted 5 lines · Peter Maydell
Quoted 3 lines · ~axelheider

From: Axel Heider <[email protected]>

Quoted 9 lines
Quoted 9 lines

---
See https://gitlab.com/qemu-project/qemu/-/issues/1263
When running the seL4 tests
(https://docs.sel4.systems/projects/sel4test), on the sabrelight platform the timer test fails (and thus it's disabled by default). Investigation has shown that the arm/imx6 EPIT timer interrupt does not fire properly, instead of a second in can take up to a minute to finally see the interrupt.

Oh yes, this sort of information should ideally be in the commit message proper -- the commit message is the place to explain what you're changing and why. You can make the gitlab issue auto-close by putting a line

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1263

into the commit message.

thanks
-- PMM