[S390] Fix enabled udelay for short delays.
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 6 Oct 2009 08:34:04 +0000 (10:34 +0200)
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>
Tue, 6 Oct 2009 08:35:08 +0000 (10:35 +0200)
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>
arch/s390/lib/delay.c

index 97c1eca83cc24274e796c491f60d5851252de150..2c3094342789489ed4aefc51e9ce89b3825948db 100644 (file)
@@ -49,17 +49,22 @@ static void __udelay_disabled(unsigned long usecs)
 static void __udelay_enabled(unsigned long usecs)
 {
        unsigned long mask;
-       u64 end, time;
+       u64 clock_saved;
+       u64 end;
 
        mask = psw_kernel_bits | PSW_MASK_WAIT | PSW_MASK_EXT | PSW_MASK_IO;
        end = get_clock() + ((u64) usecs << 12);
        do {
-               time = end < S390_lowcore.clock_comparator ?
-                       end : S390_lowcore.clock_comparator;
-               set_clock_comparator(time);
+               clock_saved = 0;
+               if (end < S390_lowcore.clock_comparator) {
+                       clock_saved = local_tick_disable();
+                       set_clock_comparator(end);
+               }
                trace_hardirqs_on();
                __load_psw_mask(mask);
                local_irq_disable();
+               if (clock_saved)
+                       local_tick_enable(clock_saved);
        } while (get_clock() < end);
        set_clock_comparator(S390_lowcore.clock_comparator);
 }
This page took 0.025559 seconds and 5 git commands to generate.