Skip to content

Commit 1f78278

Browse files
committed
Revert "target: arc: timer: Misc fixes"
This reverts commit b46c4ec. That commit causes random stalls in QEMU when running linux. Eventually, QEMU will get out of the stalls after a minute or so without actually making the CPU spin. Mostly observed during "dhcp" activity and "poweroff". Chance of happening 25%. Mostly in arc64 target, but archs and arc32 are affected as well.
1 parent b46c4ec commit 1f78278

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

target/arc/timer.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void cpu_arc_timer_update(CPUARCState *env, uint32_t timer)
6969
delta = env->timer[timer].T_Limit - t_count;
7070

7171
#ifndef CONFIG_USER_ONLY
72-
timer_mod_anticipate_ns(env->cpu_timer[timer], now + CYCLES_TO_NS((uint64_t)delta));
72+
timer_mod_ns(env->cpu_timer[timer], now + CYCLES_TO_NS((uint64_t)delta));
7373
#endif
7474

7575
qemu_log_mask(LOG_UNIMP,
@@ -87,14 +87,10 @@ static void cpu_arc_timer_expire(CPUARCState *env, uint32_t timer)
8787
assert(timer == 1 || timer == 0);
8888
qemu_log_mask(LOG_UNIMP, "[TMR%d] Timer expired\n", timer);
8989

90-
uint32_t overflow = get_t_count(env, timer) >= env->timer[timer].T_Limit;
90+
uint32_t overflow = env->timer[timer].T_Cntrl & TMR_IP;
9191
/* Set the IP bit. */
9292

9393
bool unlocked = !qemu_mutex_iothread_locked();
94-
95-
if (!overflow)
96-
return;
97-
9894
if (unlocked) {
9995
qemu_mutex_lock_iothread();
10096
}
@@ -105,7 +101,7 @@ static void cpu_arc_timer_expire(CPUARCState *env, uint32_t timer)
105101
}
106102

107103
/* Raise an interrupt if enabled. */
108-
if (env->timer[timer].T_Cntrl & TMR_IE) {
104+
if ((env->timer[timer].T_Cntrl & TMR_IE) && !overflow) {
109105
qemu_log_mask(CPU_LOG_INT, "[TMR%d] Rising IRQ\n", timer);
110106
qemu_irq_raise(env->irq[TIMER0_IRQ + (timer & 0x01)]);
111107
}
@@ -241,7 +237,7 @@ static void cpu_arc_count_set(CPUARCState *env, uint32_t timer, uint32_t val)
241237
if (unlocked) {
242238
qemu_mutex_lock_iothread();
243239
}
244-
env->timer[timer].last_clk = get_ns(env) + CYCLES_TO_NS(val);
240+
env->timer[timer].last_clk = get_ns(env) - CYCLES_TO_NS(val);
245241
cpu_arc_timer_update(env, timer);
246242
if (unlocked) {
247243
qemu_mutex_unlock_iothread();

0 commit comments

Comments
 (0)