mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 13:43:55 +08:00
d36b49b910
The local apic timer calibration has two problem cases: 1. The calibration is based on readout of the PIT/HPET timer to detect the wrap of the periodic tick. It happens that a box gets stuck in the calibration loop due to a PIT with a broken readout function. 2. CoreDuo boxen show a sporadic PIT runs too slow defect, which results in a wrong lapic calibration. The PIT goes back to normal operation once the lapic timer is switched to periodic mode. Both are existing and unfixed problems in the current upstream kernel and prevent certain laptops and other systems from booting Linux. Rework the code to address both problems: - Make the calibration interrupt driven. This removes the wait_timer_tick magic hackery from lapic.c and time_hpet.c. The clockevents framework allows easy substitution of the global tick event handler for the calibration. This is more accurate than monitoring jiffies. At this point of the boot process, nothing disturbes the interrupt delivery, so the results are very accurate. - Verify the calibration against the PM timer, when available by using the early access function. When the measured calibration period is outside of an one percent window, then the lapic timer calibration is adjusted to the pm timer result. - Verify the calibration by running the lapic timer with the calibration handler. Disable lapic timer in case of deviation. This also removes the "synchronization" of the local apic timer to the global tick. This synchronization never worked, as there is no way to synchronize PIT(HPET) and local APIC timer. The synchronization by waiting for the tick just alignes the local APIC timer for the first events, but later the events drift away due to the different clocks. Removing the "sync" is just randomizing the asynchronous behaviour at setup time. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Zachary Amsden <zach@vmware.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Rohit Seth <rohitseth@google.com> Cc: Andi Kleen <ak@suse.de> Cc: john stultz <johnstul@us.ibm.com> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
127 lines
3.1 KiB
C
127 lines
3.1 KiB
C
#ifndef __ASM_APIC_H
|
|
#define __ASM_APIC_H
|
|
|
|
#include <linux/pm.h>
|
|
#include <asm/fixmap.h>
|
|
#include <asm/apicdef.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/system.h>
|
|
|
|
#define Dprintk(x...)
|
|
|
|
/*
|
|
* Debugging macros
|
|
*/
|
|
#define APIC_QUIET 0
|
|
#define APIC_VERBOSE 1
|
|
#define APIC_DEBUG 2
|
|
|
|
extern int apic_verbosity;
|
|
|
|
/*
|
|
* Define the default level of output to be very little
|
|
* This can be turned up by using apic=verbose for more
|
|
* information and apic=debug for _lots_ of information.
|
|
* apic_verbosity is defined in apic.c
|
|
*/
|
|
#define apic_printk(v, s, a...) do { \
|
|
if ((v) <= apic_verbosity) \
|
|
printk(s, ##a); \
|
|
} while (0)
|
|
|
|
|
|
extern void generic_apic_probe(void);
|
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
|
|
|
/*
|
|
* Basic functions accessing APICs.
|
|
*/
|
|
#ifdef CONFIG_PARAVIRT
|
|
#include <asm/paravirt.h>
|
|
#else
|
|
#define apic_write native_apic_write
|
|
#define apic_write_atomic native_apic_write_atomic
|
|
#define apic_read native_apic_read
|
|
#define setup_boot_clock setup_boot_APIC_clock
|
|
#define setup_secondary_clock setup_secondary_APIC_clock
|
|
#endif
|
|
|
|
static __inline fastcall void native_apic_write(unsigned long reg,
|
|
unsigned long v)
|
|
{
|
|
*((volatile unsigned long *)(APIC_BASE+reg)) = v;
|
|
}
|
|
|
|
static __inline fastcall void native_apic_write_atomic(unsigned long reg,
|
|
unsigned long v)
|
|
{
|
|
xchg((volatile unsigned long *)(APIC_BASE+reg), v);
|
|
}
|
|
|
|
static __inline fastcall unsigned long native_apic_read(unsigned long reg)
|
|
{
|
|
return *((volatile unsigned long *)(APIC_BASE+reg));
|
|
}
|
|
|
|
static __inline__ void apic_wait_icr_idle(void)
|
|
{
|
|
while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY )
|
|
cpu_relax();
|
|
}
|
|
|
|
int get_physical_broadcast(void);
|
|
|
|
#ifdef CONFIG_X86_GOOD_APIC
|
|
# define FORCE_READ_AROUND_WRITE 0
|
|
# define apic_read_around(x)
|
|
# define apic_write_around(x,y) apic_write((x),(y))
|
|
#else
|
|
# define FORCE_READ_AROUND_WRITE 1
|
|
# define apic_read_around(x) apic_read(x)
|
|
# define apic_write_around(x,y) apic_write_atomic((x),(y))
|
|
#endif
|
|
|
|
static inline void ack_APIC_irq(void)
|
|
{
|
|
/*
|
|
* ack_APIC_irq() actually gets compiled as a single instruction:
|
|
* - a single rmw on Pentium/82489DX
|
|
* - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
|
|
* ... yummie.
|
|
*/
|
|
|
|
/* Docs say use 0 for future compatibility */
|
|
apic_write_around(APIC_EOI, 0);
|
|
}
|
|
|
|
extern int lapic_get_maxlvt(void);
|
|
extern void clear_local_APIC(void);
|
|
extern void connect_bsp_APIC (void);
|
|
extern void disconnect_bsp_APIC (int virt_wire_setup);
|
|
extern void disable_local_APIC (void);
|
|
extern void lapic_shutdown (void);
|
|
extern int verify_local_APIC (void);
|
|
extern void cache_APIC_registers (void);
|
|
extern void sync_Arb_IDs (void);
|
|
extern void init_bsp_APIC (void);
|
|
extern void setup_local_APIC (void);
|
|
extern void init_apic_mappings (void);
|
|
extern void smp_local_timer_interrupt (void);
|
|
extern void setup_boot_APIC_clock (void);
|
|
extern void setup_secondary_APIC_clock (void);
|
|
extern int APIC_init_uniprocessor (void);
|
|
|
|
extern void enable_NMI_through_LVT0 (void * dummy);
|
|
|
|
#define ARCH_APICTIMER_STOPS_ON_C3 1
|
|
|
|
extern int timer_over_8254;
|
|
|
|
#else /* !CONFIG_X86_LOCAL_APIC */
|
|
static inline void lapic_shutdown(void) { }
|
|
|
|
#endif /* !CONFIG_X86_LOCAL_APIC */
|
|
|
|
#endif /* __ASM_APIC_H */
|