-tip/apic merging one more series
cover -tip/apic merging one more series
Simple changes mostly. The only patch which should be considered
with more attention is
[PATCH 9/9] x86: apic - generic_processor_info
where I suspect the bug was - we had set phys_cpu_present_map but it could happen we warn about processor number limit after and exit havin this bit set.
Please review - any comments are welcome!
(new week are almost started so my patch flow will decrease
'cause of other duties)
- Cyrill -
PATCH 1/9 x86: apic - rearrange maxcpu definition
--- arch/x86/kernel/apic_32.c | 4 ++-- arch/x86/kernel/apic_64.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/apic_32.c +2 -2
@@ -114,6 +114,8 @@ static DEFINE_PER_CPU(struct clock_event_device, lapic_events);static int enabled_via_apicbase;static unsigned long apic_phys; +unsigned int __cpuinitdata maxcpus =NR_CPUS ; +/* * Get the LAPIC version
@@ -1459,8 +1461,6 @@ void disconnect_bsp_APIC(int virt_wire_setup) } } -unsigned int __cpuinitdata maxcpus =NR_CPUS ; -void __cpuinit generic_processor_info (int apicid,int version) {int cpu;
arch/x86/kernel/apic_64.c +1 -1
@@ -98,10 +98,10 @@ static struct clock_event_device lapic_clockevent = { static DEFINE_PER_CPU(struct clock_event_device, lapic_events);static unsigned long apic_phys; +unsigned int __cpuinitdata maxcpus =NR_CPUS ;unsigned long mp_lapic_addr; -unsigned int __cpuinitdata maxcpus =NR_CPUS ;/* * Get the LAPIC version */
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 2/9 x86: apic - unify setup_boot_APIC_clock
In reply to Cyrill Gorcunov--- arch/x86/kernel/apic_32.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/apic_32.c +1 -0
@@ -612,6 +612,7 @@ void __init setup_boot_APIC_clock(void)* broadcast mechanism is used. On UP systems simply ignore it. */ if (disable_apic_timer) { +printk (KERN_INFO "Disabling APIC timer\n" );/* No broadcast on UP ! */ if (num_possible_cpus () >1 ) { lapic_clockevent.mult =1 ;
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 3/9 x86: apic - unify disable_local_APIC
In reply to Cyrill Gorcunov--- arch/x86/kernel/apic_32.c | 4 +++- arch/x86/kernel/apic_64.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-)
arch/x86/kernel/apic_32.c +3 -1
@@ -796,7 +796,7 @@ void clear_local_APIC(void)*/ void disable_local_APIC (void ) { -unsigned long value; +unsigned int value;clear_local_APIC ();
@@ -808,6 +808,7 @@ void disable_local_APIC(void) value &= ~APIC_SPIV_APIC_ENABLED ;apic_write (APIC_SPIV , value); +#ifdef CONFIG_X86_32 /* * When LAPIC was disabled by the BIOS and enabled by the kernel, * restore the disabled state.
@@ -819,6 +820,7 @@ void disable_local_APIC(void) l &= ~MSR_IA32_APICBASE_ENABLE ; wrmsr(MSR_IA32_APICBASE, l, h); } +#endif }/*
arch/x86/kernel/apic_64.c +14 -0
@@ -691,6 +691,20 @@ void disable_local_APIC(void) value =apic_read (APIC_SPIV ); value &= ~APIC_SPIV_APIC_ENABLED ;apic_write (APIC_SPIV , value); + +#ifdef CONFIG_X86_32 +/* +* When LAPIC was disabled by the BIOS and enabled by the kernel, +* restore the disabled state. +*/ +if (enabled_via_apicbase) { +unsigned int l, h; + +rdmsr (MSR_IA32_APICBASE , l, h); + l &= ~MSR_IA32_APICBASE_ENABLE ; +wrmsr (MSR_IA32_APICBASE , l, h); + } +#endif }void lapic_shutdown (void )
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 4/9 x86: apic - unify disable_local_APIC
In reply to Cyrill Gorcunov--- arch/x86/kernel/apic_32.c | 9 ++++++--- arch/x86/kernel/apic_64.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-)
arch/x86/kernel/apic_32.c +6 -3
@@ -838,10 +838,13 @@ void lapic_shutdown(void)local_irq_save (flags); -if (enabled_via_apicbase) -disable_local_APIC (); -else +#ifdef CONFIG_X86_32 +if (!enabled_via_apicbase)clear_local_APIC (); + else +#endif +disable_local_APIC (); +local_irq_restore (flags); }
arch/x86/kernel/apic_64.c +13 -1
@@ -707,6 +707,12 @@ void disable_local_APIC(void)#endif } +/* +* If Linux enabled the LAPIC against the BIOS default disable it down before +* re-entering the BIOS on shutdown. Otherwise the BIOS may get confused and +* not power-off. Additionally clear all LVT entries before disable_local_APIC +* for the case where Linux didn't enable the LAPIC. +*/ void lapic_shutdown (void ) {unsigned long flags;
@@ -716,7 +722,13 @@ void lapic_shutdown(void)local_irq_save (flags); -disable_local_APIC (); +#ifdef CONFIG_X86_32 +if (!enabled_via_apicbase) +clear_local_APIC (); + else +#endif +disable_local_APIC (); +local_irq_restore (flags); }
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 5/9 x86: apic - unify connect_bsp_APIC
In reply to Cyrill Gorcunov--- arch/x86/kernel/apic_32.c | 2 ++ arch/x86/kernel/apic_64.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-)
arch/x86/kernel/apic_32.c +2 -0
@@ -1387,6 +1387,7 @@ void smp_error_interrupt(struct pt_regs *regs)*/ void __init connect_bsp_APIC (void ) { +#ifdef CONFIG_X86_32 if (pic_mode) {/* * Do not trust the local APIC being empty at bootup.
@@ -1401,6 +1402,7 @@ void __init connect_bsp_APIC(void)outb (0x70 ,0x22 ); outb(0x01, 0x23); } +#endif enable_apic_mode (); }
arch/x86/kernel/apic_64.c +18 -2
@@ -1285,10 +1285,26 @@ asmlinkage void smp_error_interrupt(void) }/** -* * connect_bsp_APIC - attach the APIC to the interrupt system -* */ +* connect_bsp_APIC - attach the APIC to the interrupt system +*/ void __init connect_bsp_APIC (void ) { +#ifdef CONFIG_X86_32 +if (pic_mode) { +/* +* Do not trust the local APIC being empty at bootup. +*/ +clear_local_APIC (); +/* +* PIC mode, enable APIC mode in the IMCR, i.e. connect BSP's +* local APIC to INT and NMI lines. +*/ +apic_printk (APIC_VERBOSE ,"leaving PIC mode, " +"enabling APIC mode.\n" ); +outb (0x70 ,0x22 ); +outb (0x01 ,0x23 ); + } +#endif enable_apic_mode (); }
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 6/9 x86: apic - unify lapic_setup_esr
In reply to Cyrill GorcunovWe use 32bit code former for 64bit
mode since it's much better implementation
and easier to merge.
--- arch/x86/kernel/apic_32.c | 21 +++++++++-------- arch/x86/kernel/apic_64.c | 51 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 22 deletions(-)
arch/x86/kernel/apic_32.c +11 -10
@@ -983,6 +983,16 @@ static void __cpuinit lapic_setup_esr(void) {unsigned long oldvalue, value, maxlvt;if (lapic_is_integrated () && !esr_disable) { +if (esr_disable) { +/* +* Something untraceable is creating bad interrupts on +* secondary quads ... for the moment, just leave the +* ESR disabled - we can't do anything useful with the +* errors anyway - mbligh +*/ +printk (KERN_INFO "Leaving ESR disabled.\n" ); +return ; + }/* !82489DX */ maxlvt =lapic_get_maxlvt ();if (maxlvt >3 )/* Due to the Pentium erratum 3AP. */
@@ -1003,16 +1013,7 @@ static void __cpuinit lapic_setup_esr(void)"vector: 0x%08lx after: 0x%08lx\n" , oldvalue, value); }else { -if (esr_disable) -/* -* Something untraceable is creating bad interrupts on -* secondary quads ... for the moment, just leave the -* ESR disabled - we can't do anything useful with the -* errors anyway - mbligh -*/ -printk (KERN_INFO "Leaving ESR disabled.\n" ); -else -printk (KERN_INFO "No ESR for 82489DX.\n" ); +printk (KERN_INFO "No ESR for 82489DX.\n" ); } }
arch/x86/kernel/apic_64.c +39 -12
63 lines not on this page · raw message
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 7/9 x86: apic - unify __setup_APIC_LVTT
In reply to Cyrill Gorcunov--- arch/x86/kernel/apic_32.c | 10 +++++++--- arch/x86/kernel/apic_64.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-)
arch/x86/kernel/apic_32.c +7 -3
@@ -248,8 +248,12 @@ int lapic_get_maxlvt(void)* Local APIC timer */ -/* Clock divisor is set to 16 */ +/* Clock divisor */ +#ifdef CONFG_X86_64 +#define APIC_DIVISOR 1 +#else #define APIC_DIVISOR 16 +#endif /* * This function sets up the local APIC timer, with a timeout of
@@ -281,8 +285,8 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)*/ tmp_value =apic_read (APIC_TDCR );apic_write (APIC_TDCR , - (tmp_value & ~(APIC_TDR_DIV_1 |APIC_TDR_DIV_TMBASE )) | -APIC_TDR_DIV_16 ); + (tmp_value & ~(APIC_TDR_DIV_1 |APIC_TDR_DIV_TMBASE )) | +APIC_TDR_DIV_16 );if (!oneshot)apic_write (APIC_TMICT , clocks /APIC_DIVISOR );
arch/x86/kernel/apic_64.c +8 -4
@@ -259,8 +259,12 @@ int lapic_get_maxlvt(void)* Local APIC timer */ -/* Clock divisor is set to 1 */ +/* Clock divisor */ +#ifdef CONFG_X86_64 #define APIC_DIVISOR 1 +#else +#define APIC_DIVISOR 16 +#endif /* * This function sets up the local APIC timer, with a timeout of
@@ -291,9 +295,9 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)* Divide PICLK by 16 */ tmp_value =apic_read (APIC_TDCR ); -apic_write (APIC_TDCR , (tmp_value - & ~(APIC_TDR_DIV_1 |APIC_TDR_DIV_TMBASE )) - |APIC_TDR_DIV_16 ); +apic_write (APIC_TDCR , + (tmp_value & ~(APIC_TDR_DIV_1 |APIC_TDR_DIV_TMBASE )) | +APIC_TDR_DIV_16 );if (!oneshot)apic_write (APIC_TMICT , clocks /APIC_DIVISOR );
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 8/9 x86: apic - unify disconnect_bsp_APIC
In reply to Cyrill Gorcunov- just #ifdef added
--- arch/x86/kernel/apic_32.c | 66 +++++++++++++++++++++++--------------------- arch/x86/kernel/apic_64.c | 23 ++++++++++++++- 2 files changed, 55 insertions(+), 34 deletions(-)
arch/x86/kernel/apic_32.c +34 -32
@@ -1420,6 +1420,7 @@ void __init connect_bsp_APIC(void)*/ void disconnect_bsp_APIC (int virt_wire_setup) { +#ifdef CONFIG_X86_32 if (pic_mode) {/* * Put the board back into PIC mode (has an effect only on
@@ -1431,47 +1432,48 @@ void disconnect_bsp_APIC(int virt_wire_setup) "entering PIC mode.\n");outb (0x70 ,0x22 );outb (0x00 ,0x23 ); - }else { -/* Go back to Virtual Wire compatibility mode */ -unsigned long value; +return ; + } +#endif -/* For the spurious interrupt use vector F, and enable it */ - value =apic_read (APIC_SPIV ); - value &= ~APIC_VECTOR_MASK ; - value |=APIC_SPIV_APIC_ENABLED ; - value |=0xf ; -apic_write (APIC_SPIV , value); +/* Go back to Virtual Wire compatibility mode */ +unsigned int value; -if (!virt_wire_setup) { -/* -* For LVT0 make it edge triggered, active high, -* external and enabled -*/ - value =apic_read (APIC_LVT0 ); - value &= ~(APIC_MODE_MASK |APIC_SEND_PENDING | -APIC_INPUT_POLARITY |APIC_LVT_REMOTE_IRR | -APIC_LVT_LEVEL_TRIGGER |APIC_LVT_MASKED ); - value |=APIC_LVT_REMOTE_IRR |APIC_SEND_PENDING ; - value =SET_APIC_DELIVERY_MODE (value,APIC_MODE_EXTINT ); -apic_write (APIC_LVT0 , value); - }else { -/* Disable LVT0 */ -apic_write (APIC_LVT0 ,APIC_LVT_MASKED ); - } +/* For the spurious interrupt use vector F, and enable it */ + value =apic_read (APIC_SPIV ); + value &= ~APIC_VECTOR_MASK ; + value |=APIC_SPIV_APIC_ENABLED ; + value |=0xf ; +apic_write (APIC_SPIV , value); +if (!virt_wire_setup) {/* -* For LVT1 make it edge triggered, active high, nmi and -* enabled +* For LVT0 make it edge triggered, active high, +* external and enabled */ - value =apic_read (APIC_LVT1 ); - value &= ~( -APIC_MODE_MASK |APIC_SEND_PENDING | + value =apic_read (APIC_LVT0 ); + value &= ~(APIC_MODE_MASK |APIC_SEND_PENDING |APIC_INPUT_POLARITY |APIC_LVT_REMOTE_IRR |APIC_LVT_LEVEL_TRIGGER |APIC_LVT_MASKED ); value |=APIC_LVT_REMOTE_IRR |APIC_SEND_PENDING ; - value =SET_APIC_DELIVERY_MODE (value,APIC_MODE_NMI ); -apic_write (APIC_LVT1 , value); + value =SET_APIC_DELIVERY_MODE (value,APIC_MODE_EXTINT ); +apic_write (APIC_LVT0 , value); + }else { +/* Disable LVT0 */ +apic_write (APIC_LVT0 ,APIC_LVT_MASKED ); } + +/* +* For LVT1 make it edge triggered, active high, +* nmi and enabled +*/ + value =apic_read (APIC_LVT1 ); + value &= ~(APIC_MODE_MASK |APIC_SEND_PENDING | +APIC_INPUT_POLARITY |APIC_LVT_REMOTE_IRR | +APIC_LVT_LEVEL_TRIGGER |APIC_LVT_MASKED ); + value |=APIC_LVT_REMOTE_IRR |APIC_SEND_PENDING ; + value =SET_APIC_DELIVERY_MODE (value,APIC_MODE_NMI ); +apic_write (APIC_LVT1 , value); }void __cpuinit generic_processor_info (int apicid,int version)
arch/x86/kernel/apic_64.c +21 -2
@@ -1348,8 +1348,24 @@ void __init connect_bsp_APIC(void)*/ void disconnect_bsp_APIC (int virt_wire_setup) { +#ifdef CONFIG_X86_32 +if (pic_mode) { +/* +* Put the board back into PIC mode (has an effect only on +* certain older boards). Note that APIC interrupts, including +* IPIs, won't work beyond this point! The only exception are +* INIT IPIs. +*/ +apic_printk (APIC_VERBOSE ,"disabling APIC mode, " +"entering PIC mode.\n" ); +outb (0x70 ,0x22 ); +outb (0x00 ,0x23 ); +return ; + } +#endif +/* Go back to Virtual Wire compatibility mode */ -unsigned long value; +unsigned int value;/* For the spurious interrupt use vector F, and enable it */ value =apic_read (APIC_SPIV );
@@ -1375,7 +1391,10 @@ void disconnect_bsp_APIC(int virt_wire_setup)apic_write (APIC_LVT0 ,APIC_LVT_MASKED ); } -/* For LVT1 make it edge triggered, active high, nmi and enabled */ +/* +* For LVT1 make it edge triggered, active high, +* nmi and enabled +*/ value =apic_read (APIC_LVT1 ); value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING | APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
Signature · 1 line
1.6.0.rc1.34.g0fe8c
PATCH 9/9 x86: apic - generic_processor_info
In reply to Cyrill Gorcunov- use physid_set instead of phys_cpu and physids_or
- set phys_cpu_present_map bit AFTER check for allowed number of processors
- add checking for APIC valid version in 64bit mode (mostly not needed but added for merging purpose)
- add apic_version definition for 64bit mode which is used now
--- arch/x86/kernel/apic_32.c | 15 ++++++++------- arch/x86/kernel/apic_64.c | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 9 deletions(-)
arch/x86/kernel/apic_32.c +8 -7
@@ -1480,7 +1480,6 @@ void __cpuinit generic_processor_info(int apicid, int version) {int cpu;cpumask_t tmp_map; -physid_mask_t phys_cpu;/* * Validate version
@@ -1493,9 +1492,6 @@ void __cpuinit generic_processor_info(int apicid, int version) } apic_version[apicid] = version; - phys_cpu =apicid_to_cpu_present (apicid); -physids_or (phys_cpu_present_map, phys_cpu_present_map, phys_cpu); -if (num_processors >=NR_CPUS ) {printk (KERN_WARNING "WARNING: NR_CPUS limit of %i reached." " Processor ignored.\n" ,NR_CPUS );
@@ -1512,17 +1508,19 @@ void __cpuinit generic_processor_info(int apicid, int version)cpus_complement (tmp_map, cpu_present_map); cpu =first_cpu (tmp_map); -if (apicid == boot_cpu_physical_apicid) +physid_set (apicid, phys_cpu_present_map); +if (apicid == boot_cpu_physical_apicid) {/* * x86_bios_cpu_apicid is required to have processors listed * in same order as logical cpu numbers. Hence the first * entry is BSP, and so on. */ cpu =0 ; - + }if (apicid > max_physical_apicid) max_physical_apicid = apicid; +#ifdef CONFIG_X86_32 /* * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y * but we need to work other dependencies like SMP_SUSPEND etc
@@ -1542,7 +1540,9 @@ void __cpuinit generic_processor_info(int apicid, int version) def_to_bigsmp = 1; } } -#ifdef CONFIG_SMP +#endif + +#if defined(CONFIG_X86_SMP ) || defined(CONFIG_X86_64 )/* are we being called early in kernel startup? */ if (early_per_cpu_ptr (x86_cpu_to_apicid)) {u16 *cpu_to_apicid =early_per_cpu_ptr (x86_cpu_to_apicid);
@@ -1555,6 +1555,7 @@ void __cpuinit generic_processor_info(int apicid, int version) per_cpu(x86_bios_cpu_apicid, cpu) = apicid; }#endif +cpu_set (cpu, cpu_possible_map);cpu_set (cpu, cpu_present_map); }
arch/x86/kernel/apic_64.c +39 -2
72 lines not on this page · raw message
Signature · 1 line
1.6.0.rc1.34.g0fe8c
please check if you need { } otherwise you broke 64 bit
static int lapic_resume(struct sys_device *dev)
{
unsigned int l, h;
unsigned long flags;
int maxlvt;
if (!apic_pm_state.active)
return 0;
maxlvt = lapic_get_maxlvt();
local_irq_save(flags);#ifdef CONFIG_X86_64
if (x2apic)
enable_x2apic();
else
#endif
/*
* Make sure the APICBASE points to the right address
*
* FIXME! This will be wrong if we ever support suspend on
* SMP! We'll need to do this as part of the CPU restore!
*/
rdmsr(MSR_IA32_APICBASE, l, h);
l &= ~MSR_IA32_APICBASE_BASE;
l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr;
wrmsr(MSR_IA32_APICBASE, l, h);YH
Quoted 33 lines · Yinghai Lu
please check if you need { } otherwise you broke 64 bit
static int
lapic_resume(struct sys_device *dev){ unsigned int l, h; unsigned long flags; int maxlvt; if (!apic_pm_state.active) return 0; maxlvt = lapic_get_maxlvt(); local_irq_save(flags);#ifdef CONFIG_X86_64 if (x2apic) enable_x2apic(); else #endif /* * Make sure the APICBASE points to the right address * * FIXME! This will be wrong if we ever support suspend on * SMP! We'll need to do this as part of the CPU restore! */ rdmsr(MSR_IA32_APICBASE, l, h); l &= ~MSR_IA32_APICBASE_BASE; l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; wrmsr(MSR_IA32_APICBASE, l, h);
Quoted 2 lines
YH
Oh...indeed. Thanks Yinghai! - will fix it today evening. Ingo drop this patch please (if it was applied).
Quoted 34 lines · Cyrill Gorcunov
Quoted 33 lines · Yinghai Lu
please check if you need { } otherwise you broke 64 bit
static int
lapic_resume(struct sys_device *dev){ unsigned int l, h; unsigned long flags; int maxlvt; if (!apic_pm_state.active) return 0; maxlvt = lapic_get_maxlvt(); local_irq_save(flags);#ifdef CONFIG_X86_64 if (x2apic) enable_x2apic(); else #endif /* * Make sure the APICBASE points to the right address * * FIXME! This will be wrong if we ever support suspend on * SMP! We'll need to do this as part of the CPU restore! */ rdmsr(MSR_IA32_APICBASE, l, h); l &= ~MSR_IA32_APICBASE_BASE; l |= MSR_IA32_APICBASE_ENABLE | mp_lapic_addr; wrmsr(MSR_IA32_APICBASE, l, h);
Quoted 5 lines
Quoted 2 lines
YH
Oh...indeed. Thanks Yinghai! - will fix it today evening. Ingo drop this patch please (if it was applied).
hm, none of these patches has lapic_resume mentioned and current tip/master's version doesnt seem broken so there's nothing to drop.
plus 1/9 doesnt apply to tip/master. (nor tip/x86/apic, nor -git)
I'll wait for this to be sorted out.
Ingo
Quoted 5 lines · Ingo Molnar
Quoted 2 lines
Oh...indeed. Thanks Yinghai! - will fix it today evening. Ingo drop this patch please (if it was applied).
hm, none of these patches has
lapic_resumementioned and current tip/master's version doesnt seem broken so there's nothing to drop.
ah, i see Yinghai's fix. I'll apply that to tip/x86/apic.
Ingo
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Ingo Molnar
Quoted 2 lines
Oh...indeed. Thanks Yinghai! - will fix it today evening. Ingo drop this patch please (if it was applied).
Quoted 7 lines
Quoted 2 lines
hm, none of these patches has
lapic_resumementioned and current tip/master's version doesnt seem broken so there's nothing to drop.ah, i see Yinghai's fix. I'll apply that to tip/x86/apic.
Ingo
Thanks Ingo, I'll fetch tip/apic after my workaday complete then check what is applied what is not and rearrange pathes if needed and then resend. Ugh... :-)