Skip to content

Commit daf3af4

Browse files
committed
x86/apic: Clarify i82489DX bit overlap in APIC_LVT0
Daniel stumbled over the bit overlap of the i82498DX external APIC and the TSC deadline timer configuration bit in modern APICs, which is neither documented in the code nor in the current SDM. Maciej provided links to the original i82489DX/486 documentation. See Link. Remove the i82489DX macro maze, use a i82489DX specific define in the apic code and document the overlap in a comment. Reported-by: Daniel Vacek <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Maciej W. Rozycki <[email protected]> Link: https://lore.kernel.org/r/87ee22f3ci.ffs@tglx
1 parent ce522ba commit daf3af4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

arch/x86/include/asm/apicdef.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@
9595
#define APIC_LVTTHMR 0x330
9696
#define APIC_LVTPC 0x340
9797
#define APIC_LVT0 0x350
98-
#define APIC_LVT_TIMER_BASE_MASK (0x3 << 18)
99-
#define GET_APIC_TIMER_BASE(x) (((x) >> 18) & 0x3)
100-
#define SET_APIC_TIMER_BASE(x) (((x) << 18))
101-
#define APIC_TIMER_BASE_CLKIN 0x0
102-
#define APIC_TIMER_BASE_TMBASE 0x1
103-
#define APIC_TIMER_BASE_DIV 0x2
10498
#define APIC_LVT_TIMER_ONESHOT (0 << 17)
10599
#define APIC_LVT_TIMER_PERIODIC (1 << 17)
106100
#define APIC_LVT_TIMER_TSCDEADLINE (2 << 17)

arch/x86/kernel/apic/apic.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ int lapic_get_maxlvt(void)
320320
#define APIC_DIVISOR 16
321321
#define TSC_DIVISOR 8
322322

323+
/* i82489DX specific */
324+
#define I82489DX_BASE_DIVIDER (((0x2) << 18))
325+
323326
/*
324327
* This function sets up the local APIC timer, with a timeout of
325328
* 'clocks' APIC bus clock. During calibration we actually call
@@ -340,8 +343,14 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
340343
else if (boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER))
341344
lvtt_value |= APIC_LVT_TIMER_TSCDEADLINE;
342345

346+
/*
347+
* The i82489DX APIC uses bit 18 and 19 for the base divider. This
348+
* overlaps with bit 18 on integrated APICs, but is not documented
349+
* in the SDM. No problem though. i82489DX equipped systems do not
350+
* have TSC deadline timer.
351+
*/
343352
if (!lapic_is_integrated())
344-
lvtt_value |= SET_APIC_TIMER_BASE(APIC_TIMER_BASE_DIV);
353+
lvtt_value |= I82489DX_BASE_DIVIDER;
345354

346355
if (!irqen)
347356
lvtt_value |= APIC_LVT_MASKED;

0 commit comments

Comments
 (0)