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

firmware/dmi_scan: generalize for use by other archs

This patch makes a couple of changes to the SMBIOS/DMI scanning
code so it can be used on other archs (such as ARM and arm64):
(a) wrap the calls to ioremap()/iounmap(), this allows the use of a
flavor of ioremap() more suitable for random unaligned access;
(b) allow the non-EFI fallback probe into hardcoded physical address
0xF0000 to be disabled.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Grant Likely <grant.likely@linaro.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ard Biesheuvel and committed by
Linus Torvalds
cf074402 3e2a4c18

+24 -15
+1
arch/ia64/Kconfig
··· 104 104 config DMI 105 105 bool 106 106 default y 107 + select DMI_SCAN_MACHINE_NON_EFI_FALLBACK 107 108 108 109 config EFI 109 110 bool
+5 -3
arch/ia64/include/asm/dmi.h
··· 5 5 #include <asm/io.h> 6 6 7 7 /* Use normal IO mappings for DMI */ 8 - #define dmi_ioremap ioremap 9 - #define dmi_iounmap(x,l) iounmap(x) 10 - #define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) 8 + #define dmi_early_remap ioremap 9 + #define dmi_early_unmap(x, l) iounmap(x) 10 + #define dmi_remap ioremap 11 + #define dmi_unmap iounmap 12 + #define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) 11 13 12 14 #endif
+1
arch/x86/Kconfig
··· 731 731 # The code disables itself when not needed. 732 732 config DMI 733 733 default y 734 + select DMI_SCAN_MACHINE_NON_EFI_FALLBACK 734 735 bool "Enable DMI scanning" if EXPERT 735 736 ---help--- 736 737 Enabled scanning of DMI to identify machine quirks. Say Y
+4 -2
arch/x86/include/asm/dmi.h
··· 13 13 } 14 14 15 15 /* Use early IO mappings for DMI because it's initialized early */ 16 - #define dmi_ioremap early_ioremap 17 - #define dmi_iounmap early_iounmap 16 + #define dmi_early_remap early_ioremap 17 + #define dmi_early_unmap early_iounmap 18 + #define dmi_remap ioremap 19 + #define dmi_unmap iounmap 18 20 19 21 #endif /* _ASM_X86_DMI_H */
+3
drivers/firmware/Kconfig
··· 108 108 under /sys/firmware/dmi when this option is enabled and 109 109 loaded. 110 110 111 + config DMI_SCAN_MACHINE_NON_EFI_FALLBACK 112 + bool 113 + 111 114 config ISCSI_IBFT_FIND 112 115 bool "iSCSI Boot Firmware Table Attributes" 113 116 depends on X86
+10 -10
drivers/firmware/dmi_scan.c
··· 116 116 { 117 117 u8 *buf; 118 118 119 - buf = dmi_ioremap(dmi_base, dmi_len); 119 + buf = dmi_early_remap(dmi_base, dmi_len); 120 120 if (buf == NULL) 121 121 return -1; 122 122 ··· 124 124 125 125 add_device_randomness(buf, dmi_len); 126 126 127 - dmi_iounmap(buf, dmi_len); 127 + dmi_early_unmap(buf, dmi_len); 128 128 return 0; 129 129 } 130 130 ··· 527 527 * needed during early boot. This also means we can 528 528 * iounmap the space when we're done with it. 529 529 */ 530 - p = dmi_ioremap(efi.smbios, 32); 530 + p = dmi_early_remap(efi.smbios, 32); 531 531 if (p == NULL) 532 532 goto error; 533 533 memcpy_fromio(buf, p, 32); 534 - dmi_iounmap(p, 32); 534 + dmi_early_unmap(p, 32); 535 535 536 536 if (!dmi_present(buf)) { 537 537 dmi_available = 1; 538 538 goto out; 539 539 } 540 - } else { 541 - p = dmi_ioremap(0xF0000, 0x10000); 540 + } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { 541 + p = dmi_early_remap(0xF0000, 0x10000); 542 542 if (p == NULL) 543 543 goto error; 544 544 ··· 554 554 memcpy_fromio(buf + 16, q, 16); 555 555 if (!dmi_present(buf)) { 556 556 dmi_available = 1; 557 - dmi_iounmap(p, 0x10000); 557 + dmi_early_unmap(p, 0x10000); 558 558 goto out; 559 559 } 560 560 memcpy(buf, buf + 16, 16); 561 561 } 562 - dmi_iounmap(p, 0x10000); 562 + dmi_early_unmap(p, 0x10000); 563 563 } 564 564 error: 565 565 pr_info("DMI not present or invalid.\n"); ··· 831 831 if (!dmi_available) 832 832 return -1; 833 833 834 - buf = ioremap(dmi_base, dmi_len); 834 + buf = dmi_remap(dmi_base, dmi_len); 835 835 if (buf == NULL) 836 836 return -1; 837 837 838 838 dmi_table(buf, dmi_len, dmi_num, decode, private_data); 839 839 840 - iounmap(buf); 840 + dmi_unmap(buf); 841 841 return 0; 842 842 } 843 843 EXPORT_SYMBOL_GPL(dmi_walk);