x86 DMI scan and UP_APIC fixes
RFC PATCH 1/1 x86 DMI scan and UP_APIC fixes
The x86 UP_APIC code breaks on some machines due to BIOS bugs, in particular on all recent Dell Inspiron and Latitude laptops. This is something the DMI scan could fix, but unfortunately the boot order is such that the DMI scan occurs long after much of the core hardware has been detected and initialised.
Moving DMI scan to setup_arch(), where it really belongs, would solve this. The problem is that the DMI scan relies on ioremap() and kmalloc(), and they don't work at that early point in the boot.
The patch below (against 2.4.17) contains a proposed fix:
- dmi_scan_machine() is called from setup_arch() instead of being a module_init() thing
- DMI scan now uses the new "bt_ioremap()": a restricted version of ioremap() which works early in the boot process. bt_ioremap() is implemented on top of the FIXMAP mechanism, which has been extended to permit temporary boot-time mappings
- dmi_scan.c and apic.c are augmented with workarounds for known broken machines: currently Dell laptops and Intel's AL440LX
- init_apic_mappings() is called from trap_init() instead of setup_arch(), i.e. after dmi_scan_machine() is done
I've been running this on several machines for the last 2 months, and it does seem to work as intended with no observed breakage.
Is having a boot-time clone of ioremap() a reasonable approach, or is there an easier solution I've overlooked?
Comments?
/Mikael
arch/i386/kernel/apic.c renamed from arch/i386/kernel/apic.c.~1~ +11 -0
@@ -571,12 +571,17 @@* Detect and enable local APICs on non-SMP boards. * Original code written by Keir Fraser. */ +int dont_enable_local_apic__initdata =0 ;static int __init detect_init_APIC (void ) {u32 h, l, features;extern void get_cpu_vendor (struct cpuinfo_x86 *); +/* Disabled by DMI scan or kernel option? */ +if (dont_enable_local_apic) +return -1 ; +/* Workaround for us being called before identify_cpu(). */ get_cpu_vendor (&boot_cpu_data);
@@ -894,8 +899,14 @@static unsigned int calibration_result; +int dont_use_local_apic_timer__initdata =0 ; +void __init setup_APIC_clocks (void ) { +/* Disabled by DMI scan or kernel option? */ +if (dont_use_local_apic_timer) +return ; +printk ("Using local APIC timer interrupts.\n" ); using_apic_timer =1 ;
arch/i386/kernel/dmi_scan.c renamed from arch/i386/kernel/dmi_scan.c.~1~ +61 -6
112 lines not on this page · raw message
arch/i386/kernel/setup.c renamed from arch/i386/kernel/setup.c.~1~ +1 -1
@@ -992,7 +992,6 @@*/ if (smp_found_config)get_smp_config (); -init_apic_mappings ();#endif
@@ -1044,6 +1043,7 @@ conswitchp = &dummy_con;#endif #endif +dmi_scan_machine (); }static int cachesize_override__initdata =-1 ;
arch/i386/kernel/traps.c renamed from arch/i386/kernel/traps.c.~1~ +4 -0
@@ -920,6 +920,10 @@ EISA_bus =1 ;#endif +#ifdef CONFIG_X86_LOCAL_APIC +init_apic_mappings (); +#endif +set_trap_gate (0 ,÷_error);set_trap_gate (1 ,&debug);set_intr_gate (2 ,&nmi);
arch/i386/mm/init.c renamed from arch/i386/mm/init.c.~1~ +2 -5
@@ -128,7 +128,6 @@static inline void set_pte_phys (unsigned long vaddr,unsigned long phys,pgprot_t flags) { -pgprot_t prot;pgd_t *pgd;pmd_t *pmd;pte_t *pte;
@@ -144,10 +143,8 @@return ; } pte =pte_offset (pmd, vaddr); -if (pte_val (*pte)) -pte_ERROR (*pte); -pgprot_val (prot) =pgprot_val (PAGE_KERNEL ) |pgprot_val (flags); -set_pte (pte,mk_pte_phys (phys, prot)); +/* <phys,flags> stored as-is, to permit clearing entries */ +set_pte (pte,mk_pte_phys (phys, flags));/* * It's enough to flush this one mapping.
arch/i386/mm/ioremap.c renamed from arch/i386/mm/ioremap.c.~1~ +66 -0
69 lines not on this page · raw message
include/asm-i386/fixmap.h renamed from include/asm-i386/fixmap.h.~1~ +7 -2
@@ -65,6 +65,11 @@FIX_KMAP_BEGIN ,/* reserved pte's for temporary kernel mappings */ FIX_KMAP_END =FIX_KMAP_BEGIN +(KM_TYPE_NR *NR_CPUS )-1 , #endif + __end_of_permanent_fixed_addresses, +/* temporary boot-time mappings, used before ioremap() is functional */ +#define NR_FIX_BTMAPS 16 +FIX_BTMAP_END = __end_of_permanent_fixed_addresses, +FIX_BTMAP_BEGIN =FIX_BTMAP_END +NR_FIX_BTMAPS -1 , __end_of_fixed_addresses };
@@ -86,8 +91,8 @@* at the top of mem.. */ #define FIXADDR_TOP (0xffffe000UL) -#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) -#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) +#define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) +#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)#define __fix_to_virt (x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
include/asm-i386/io.h renamed from include/asm-i386/io.h.~1~ +8 -0
@@ -98,6 +98,14 @@extern void iounmap (void *addr);/* +* bt_ioremap() and bt_iounmap() are for temporary early boot-time +* mappings, before the real ioremap() is functional. +* A boot-time mapping is currently limited to at most 16 pages. +*/ +extern void *bt_ioremap (unsigned long offset,unsigned long size); +extern void bt_iounmap (void *addr,unsigned long size); + +/* * IO bus memory addresses are also 1:1 with the physical address */ #define virt_to_bus virt_to_phys
Quoted 5 lines
The x86
UP_APICcode breaks on some machines due to BIOS bugs, in particular on all recent Dell Inspiron and Latitude laptops. This is something the DMI scan could fix, but unfortunately the boot order is such that the DMI scan occurs long after much of the core hardware has been detected and initialised.
Agreed. Also it would help for some of the intel 440GX junk where we need to force the UP APIC on to get the irq delivery working.