Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[S390] Fix enabled udelay for short delays.

When udelay() gets called with a delay that would expire before the
next clock event it reprograms the clock comparator.
When the interrupt happens the clock comparator won't be resetted
therefore the interrupt condition doesn't get cleared.
The result is an endless timer interrupt loop until the next clock
event would expire (stored in lowcore).
So udelay() usually would wait much longer for small delays than it
should.

Fix this by disabling the local tick which makes sure that the clock
comparator will be resetted when a timer interrupt happens.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Christian Borntraeger and committed by
Martin Schwidefsky
78d81f2f 102e835d

+9 -4
+9 -4
arch/s390/lib/delay.c
··· 49 49 static void __udelay_enabled(unsigned long usecs) 50 50 { 51 51 unsigned long mask; 52 - u64 end, time; 52 + u64 clock_saved; 53 + u64 end; 53 54 54 55 mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT | PSW_MASK_IO; 55 56 end = get_clock() + ((u64) usecs << 12); 56 57 do { 57 - time = end < S390_lowcore.clock_comparator ? 58 - end : S390_lowcore.clock_comparator; 59 - set_clock_comparator(time); 58 + clock_saved = 0; 59 + if (end < S390_lowcore.clock_comparator) { 60 + clock_saved = local_tick_disable(); 61 + set_clock_comparator(end); 62 + } 60 63 trace_hardirqs_on(); 61 64 __load_psw_mask(mask); 62 65 local_irq_disable(); 66 + if (clock_saved) 67 + local_tick_enable(clock_saved); 63 68 } while (get_clock() < end); 64 69 set_clock_comparator(S390_lowcore.clock_comparator); 65 70 }