Skip to content

Commit 7c64de1

Browse files
committed
lkl: relax cpu during __ndelay()
__ndelay() spins until the timeout occurs. If interrupts come concurrently from another host thread, an irq_status bit will be set, but the handler will not be called during the spin. This behavior is unreasonable. At least, it differs from that of real Linux running on a bare-mental machine. A driver may expect the device to raise an IRQ within a few microseconds, so it tries to spin and wait for it. This does not work without the commit. Calling cpu_relax() explicitly can cause the handlers to fire. This is also a valid use of cpu_relax() because the CPU is spinning. Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
1 parent 9c51103 commit 7c64de1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/lkl/kernel/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void __ndelay(unsigned long nsecs)
1414
unsigned long long start = lkl_ops->time();
1515

1616
while (lkl_ops->time() < start + nsecs)
17-
;
17+
cpu_relax();
1818
}
1919

2020
void __udelay(unsigned long usecs)

0 commit comments

Comments
 (0)