Skip to content

Commit 35bce38

Browse files
committed
fixed eclic bug, making the interrupt handler non-reentrant
1 parent d988524 commit 35bce38

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

hw/intc/nuclei_eclic.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,28 @@ static void nuclei_eclic_update_intip(NucLeiECLICState *eclic, int irq, int new_
335335

336336
int old_intip = eclic->clicintlist[irq].sig;
337337
int trigger = (eclic->clicintattr[irq] >> 1) & 0x3;
338-
if (((trigger == 0) && new_intip) ||
339-
((trigger == 1) && !old_intip && new_intip) ||
340-
((trigger == 3) && old_intip && !new_intip))
338+
if(old_intip == new_intip != 0)
341339
{
342-
eclic->clicintip[irq] = 1;
343-
eclic->clicintlist[irq].sig = new_intip;
344-
eclic_insert_pending_list(eclic, irq);
340+
345341
}
346342
else
347343
{
348-
if (eclic->clicintip[irq])
349-
eclic_remove_pending_list(eclic, irq);
350-
eclic->clicintip[irq] = 0;
351-
eclic->clicintlist[irq].sig = new_intip;
344+
if (((trigger == 0) && new_intip) ||
345+
((trigger == 1) && !old_intip && new_intip) ||
346+
((trigger == 3) && old_intip && !new_intip))
347+
{
348+
eclic->clicintip[irq] = 1;
349+
eclic->clicintlist[irq].sig = new_intip;
350+
eclic_insert_pending_list(eclic, irq);
351+
}
352+
else
353+
{
354+
if (eclic->clicintip[irq])
355+
eclic_remove_pending_list(eclic, irq);
356+
eclic->clicintip[irq] = 0;
357+
eclic->clicintlist[irq].sig = new_intip;
358+
}
359+
352360
}
353361

354362
nuclei_eclic_next_interrupt(eclic);

0 commit comments

Comments
 (0)