@@ -1506,32 +1506,41 @@ static void __init setup_ioapic_ids_from_mpc(void)
* - if this function detects that timer IRQs are defunct, then we fall
* back to ISA timer IRQs
*/
-static int __init timer_irq_works(void)
+static bool __init timer_irq_works(void)
{
unsigned long t1, flags;
+ /* Wait for maximum 10 ticks */
+ unsigned int msec = (10 * 1000) / HZ;
+ bool works = false;
if ( pit_irq_works )
- return 1;
+ return true;
t1 = ACCESS_ONCE(pit0_ticks);
local_save_flags(flags);
local_irq_enable();
- /* Let ten ticks pass... */
- mdelay((10 * 1000) / HZ);
- local_irq_restore(flags);
- /*
- * Expect a few ticks at least, to be sure some possible
- * glue logic does not lock up after one or two first
- * ticks in a non-ExtINT mode. Also the local APIC
- * might have cached one ExtINT interrupt. Finally, at
- * least one tick may be lost due to delays.
- */
- if ( (ACCESS_ONCE(pit0_ticks) - t1) > 4 )
- return 1;
+ while ( msec-- )
+ {
+ mdelay(1);
+ /*
+ * Expect a few ticks at least, to be sure some possible
+ * glue logic does not lock up after one or two first
+ * ticks in a non-ExtINT mode. Also the local APIC
+ * might have cached one ExtINT interrupt. Finally, at
+ * least one tick may be lost due to delays.
+ */
+ if ( (ACCESS_ONCE(pit0_ticks) - t1) <= 4 )
+ continue;
- return 0;
+ works = true;
+ break;
+ }
+
+ local_irq_restore(flags);
+
+ return works;
}
/*