Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] ia64: use i386 dmi_scan.c

Enable DMI table parsing on ia64.

Andi Kleen has a patch in his x86_64 tree which enables the use of i386
dmi_scan.c on x86_64. dmi_scan.c functions are being used by the
drivers/char/ipmi/ipmi_si_intf.c driver for autodetecting the ports or
memory spaces where the IPMI controllers may be found.

This patch adds equivalent changes for ia64 as to what is in the x86_64
tree. In addition, I reworked the DMI detection, such that on EFI-capable
systems, it uses the efi.smbios pointer to find the table, rather than
brute-force searching from 0xF0000. On non-EFI systems, it continues the
brute-force search.

My test system, an Intel S870BN4 'Tiger4', aka Dell PowerEdge 7250, with
latest BIOS, does not list the IPMI controller in the ACPI namespace, nor
does it have an ACPI SPMI table. Also note, currently shipping Dell x8xx
EM64T servers don't have these either, so DMI is the only method for
obtaining the address of the IPMI controller.

Signed-off-by: Matt Domsch <Matt_Domsch@dell.com>
Acked-by: "Luck, Tony" <tony.luck@intel.com>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Matt Domsch and committed by
Linus Torvalds
3ed3bce8 10dbe196

+80 -30
+55 -29
arch/i386/kernel/dmi_scan.c
··· 3 3 #include <linux/init.h> 4 4 #include <linux/module.h> 5 5 #include <linux/dmi.h> 6 + #include <linux/efi.h> 6 7 #include <linux/bootmem.h> 7 8 #include <linux/slab.h> 8 9 #include <asm/dmi.h> ··· 186 185 } 187 186 } 188 187 189 - void __init dmi_scan_machine(void) 188 + static int __init dmi_present(char __iomem *p) 190 189 { 191 190 u8 buf[15]; 191 + memcpy_fromio(buf, p, 15); 192 + if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { 193 + u16 num = (buf[13] << 8) | buf[12]; 194 + u16 len = (buf[7] << 8) | buf[6]; 195 + u32 base = (buf[11] << 24) | (buf[10] << 16) | 196 + (buf[9] << 8) | buf[8]; 197 + 198 + /* 199 + * DMI version 0.0 means that the real version is taken from 200 + * the SMBIOS version, which we don't know at this point. 201 + */ 202 + if (buf[14] != 0) 203 + printk(KERN_INFO "DMI %d.%d present.\n", 204 + buf[14] >> 4, buf[14] & 0xF); 205 + else 206 + printk(KERN_INFO "DMI present.\n"); 207 + if (dmi_table(base,len, num, dmi_decode) == 0) 208 + return 0; 209 + } 210 + return 1; 211 + } 212 + 213 + void __init dmi_scan_machine(void) 214 + { 192 215 char __iomem *p, *q; 216 + int rc; 193 217 194 - /* 195 - * no iounmap() for that ioremap(); it would be a no-op, but it's 196 - * so early in setup that sucker gets confused into doing what 197 - * it shouldn't if we actually call it. 198 - */ 199 - p = ioremap(0xF0000, 0x10000); 200 - if (p == NULL) 201 - goto out; 218 + if (efi_enabled) { 219 + if (!efi.smbios) 220 + goto out; 202 221 203 - for (q = p; q < p + 0x10000; q += 16) { 204 - memcpy_fromio(buf, q, 15); 205 - if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { 206 - u16 num = (buf[13] << 8) | buf[12]; 207 - u16 len = (buf[7] << 8) | buf[6]; 208 - u32 base = (buf[11] << 24) | (buf[10] << 16) | 209 - (buf[9] << 8) | buf[8]; 222 + /* This is called as a core_initcall() because it isn't 223 + * needed during early boot. This also means we can 224 + * iounmap the space when we're done with it. 225 + */ 226 + p = dmi_ioremap((unsigned long)efi.smbios, 0x10000); 227 + if (p == NULL) 228 + goto out; 210 229 211 - /* 212 - * DMI version 0.0 means that the real version is taken from 213 - * the SMBIOS version, which we don't know at this point. 214 - */ 215 - if (buf[14] != 0) 216 - printk(KERN_INFO "DMI %d.%d present.\n", 217 - buf[14] >> 4, buf[14] & 0xF); 218 - else 219 - printk(KERN_INFO "DMI present.\n"); 230 + rc = dmi_present(p + 0x10); /* offset of _DMI_ string */ 231 + iounmap(p); 232 + if (!rc) 233 + return; 234 + } 235 + else { 236 + /* 237 + * no iounmap() for that ioremap(); it would be a no-op, but 238 + * it's so early in setup that sucker gets confused into doing 239 + * what it shouldn't if we actually call it. 240 + */ 241 + p = dmi_ioremap(0xF0000, 0x10000); 242 + if (p == NULL) 243 + goto out; 220 244 221 - if (dmi_table(base,len, num, dmi_decode) == 0) 245 + for (q = p; q < p + 0x10000; q += 16) { 246 + rc = dmi_present(q); 247 + if (!rc) 222 248 return; 223 249 } 224 250 } 225 - 226 - out: printk(KERN_INFO "DMI not present or invalid.\n"); 251 + out: printk(KERN_INFO "DMI not present or invalid.\n"); 227 252 } 228 - 229 253 230 254 /** 231 255 * dmi_check_system - check system DMI data
+4
arch/ia64/Kconfig
··· 42 42 bool 43 43 default y 44 44 45 + config DMI 46 + bool 47 + default y 48 + 45 49 config EFI 46 50 bool 47 51 default y
+2 -1
arch/ia64/kernel/Makefile
··· 7 7 obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 8 8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 9 9 salinfo.o semaphore.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 10 - unwind.o mca.o mca_asm.o topology.o 10 + unwind.o mca.o mca_asm.o topology.o dmi_scan.o 11 11 12 12 obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 13 13 obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o ··· 30 30 obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o 31 31 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o 32 32 mca_recovery-y += mca_drv.o mca_drv_asm.o 33 + dmi_scan-y += ../../i386/kernel/dmi_scan.o 33 34 34 35 # The gate DSO image is built using a special linker script. 35 36 targets += gate.so gate-syms.o
+8
arch/ia64/kernel/setup.c
··· 37 37 #include <linux/string.h> 38 38 #include <linux/threads.h> 39 39 #include <linux/tty.h> 40 + #include <linux/dmi.h> 40 41 #include <linux/serial.h> 41 42 #include <linux/serial_core.h> 42 43 #include <linux/efi.h> ··· 888 887 ia64_patch_mckinley_e9((unsigned long) __start___mckinley_e9_bundles, 889 888 (unsigned long) __end___mckinley_e9_bundles); 890 889 } 890 + 891 + static int __init run_dmi_scan(void) 892 + { 893 + dmi_scan_machine(); 894 + return 0; 895 + } 896 + core_initcall(run_dmi_scan);
+6
include/asm-ia64/dmi.h
··· 1 + #ifndef _ASM_DMI_H 2 + #define _ASM_DMI_H 1 3 + 4 + #include <asm/io.h> 5 + 6 + #endif
+5
include/asm-ia64/io.h
··· 435 435 436 436 #define ioremap_nocache(o,s) ioremap(o,s) 437 437 438 + /* Use normal IO mappings for DMI */ 439 + #define dmi_ioremap ioremap 440 + #define dmi_iounmap(x,l) iounmap(x) 441 + #define dmi_alloc(l) kmalloc(l, GFP_ATOMIC) 442 + 438 443 # ifdef __KERNEL__ 439 444 440 445 /*