x86/ioapic: Refactor the delay logic in timer_irq_works()
authorDou Liyang <douly.fnst@cn.fujitsu.com>
Wed, 13 Sep 2017 09:12:51 +0000 (17:12 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 13:03:16 +0000 (15:03 +0200)
commitca7c6076baed396737e31e33b87a637d70e9fc5f
tree3a9bc456de88d87a1f62fc7d58c2fec94ec3415e
parent0c759131ae568f2e620485662104ab8c1e770c81
x86/ioapic: Refactor the delay logic in timer_irq_works()

timer_irq_works() is used to detects the timer IRQs. It calls mdelay(10) to
delay ten ticks and check whether the timer IRQ work or not.

mdelay() depends on the loops_per_jiffy which is set up in
calibrate_delay(), but the delay calibration depends on a working timer
interrupt, which causes a chicken and egg problem.

The correct solution is to set up the interrupt mode and making sure that
the timer interrupt is delivered correctly before invoking calibrate_delay().
That means that mdelay() cannot be used in timer_irq_works().

Provide helper functions to make a rough delay estimate which is good enough
to prove that the timer interrupt is working. Either use TSC or a simple
delay loop and assume that 4GHz is the maximum CPU frequency to base the
delay calculation on.

Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-9-git-send-email-douly.fnst@cn.fujitsu.com
arch/x86/kernel/apic/io_apic.c