diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2014-01-23 18:54:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-23 19:36:57 -0500 |
commit | cf0744021c5d5de54d2c66e2020c6de2fe800264 (patch) | |
tree | 0d2032c3d04aabe53ac3d9a2963c41d8c0b331c1 | |
parent | 3e2a4c183ace8708c69f589505fb82bb63010ade (diff) |
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>
-rw-r--r-- | arch/ia64/Kconfig | 1 | ||||
-rw-r--r-- | arch/ia64/include/asm/dmi.h | 8 | ||||
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/dmi.h | 6 | ||||
-rw-r--r-- | drivers/firmware/Kconfig | 3 | ||||
-rw-r--r-- | drivers/firmware/dmi_scan.c | 20 |
6 files changed, 24 insertions, 15 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index a8c3a11dc5ab..c063b054294e 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
@@ -104,6 +104,7 @@ config HAVE_SETUP_PER_CPU_AREA | |||
104 | config DMI | 104 | config DMI |
105 | bool | 105 | bool |
106 | default y | 106 | default y |
107 | select DMI_SCAN_MACHINE_NON_EFI_FALLBACK | ||
107 | 108 | ||
108 | config EFI | 109 | config EFI |
109 | bool | 110 | bool |
diff --git a/arch/ia64/include/asm/dmi.h b/arch/ia64/include/asm/dmi.h index 185d3d18d0ec..f365a61f5c71 100644 --- a/arch/ia64/include/asm/dmi.h +++ b/arch/ia64/include/asm/dmi.h | |||
@@ -5,8 +5,10 @@ | |||
5 | #include <asm/io.h> | 5 | #include <asm/io.h> |
6 | 6 | ||
7 | /* Use normal IO mappings for DMI */ | 7 | /* Use normal IO mappings for DMI */ |
8 | #define dmi_ioremap ioremap | 8 | #define dmi_early_remap ioremap |
9 | #define dmi_iounmap(x,l) iounmap(x) | 9 | #define dmi_early_unmap(x, l) iounmap(x) |
10 | #define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) | 10 | #define dmi_remap ioremap |
11 | #define dmi_unmap iounmap | ||
12 | #define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) | ||
11 | 13 | ||
12 | #endif | 14 | #endif |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d3b9186e4c23..5aadc49a7621 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -731,6 +731,7 @@ config APB_TIMER | |||
731 | # The code disables itself when not needed. | 731 | # The code disables itself when not needed. |
732 | config DMI | 732 | config DMI |
733 | default y | 733 | default y |
734 | select DMI_SCAN_MACHINE_NON_EFI_FALLBACK | ||
734 | bool "Enable DMI scanning" if EXPERT | 735 | bool "Enable DMI scanning" if EXPERT |
735 | ---help--- | 736 | ---help--- |
736 | Enabled scanning of DMI to identify machine quirks. Say Y | 737 | Enabled scanning of DMI to identify machine quirks. Say Y |
diff --git a/arch/x86/include/asm/dmi.h b/arch/x86/include/asm/dmi.h index fd8f9e2ca35f..535192f6bfad 100644 --- a/arch/x86/include/asm/dmi.h +++ b/arch/x86/include/asm/dmi.h | |||
@@ -13,7 +13,9 @@ static __always_inline __init void *dmi_alloc(unsigned len) | |||
13 | } | 13 | } |
14 | 14 | ||
15 | /* Use early IO mappings for DMI because it's initialized early */ | 15 | /* Use early IO mappings for DMI because it's initialized early */ |
16 | #define dmi_ioremap early_ioremap | 16 | #define dmi_early_remap early_ioremap |
17 | #define dmi_iounmap early_iounmap | 17 | #define dmi_early_unmap early_iounmap |
18 | #define dmi_remap ioremap | ||
19 | #define dmi_unmap iounmap | ||
18 | 20 | ||
19 | #endif /* _ASM_X86_DMI_H */ | 21 | #endif /* _ASM_X86_DMI_H */ |
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 074787281c94..5a29fac951ec 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig | |||
@@ -108,6 +108,9 @@ config DMI_SYSFS | |||
108 | under /sys/firmware/dmi when this option is enabled and | 108 | under /sys/firmware/dmi when this option is enabled and |
109 | loaded. | 109 | loaded. |
110 | 110 | ||
111 | config DMI_SCAN_MACHINE_NON_EFI_FALLBACK | ||
112 | bool | ||
113 | |||
111 | config ISCSI_IBFT_FIND | 114 | config ISCSI_IBFT_FIND |
112 | bool "iSCSI Boot Firmware Table Attributes" | 115 | bool "iSCSI Boot Firmware Table Attributes" |
113 | depends on X86 | 116 | depends on X86 |
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index c7e81ff8f3ef..17afc51f3054 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -116,7 +116,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, | |||
116 | { | 116 | { |
117 | u8 *buf; | 117 | u8 *buf; |
118 | 118 | ||
119 | buf = dmi_ioremap(dmi_base, dmi_len); | 119 | buf = dmi_early_remap(dmi_base, dmi_len); |
120 | if (buf == NULL) | 120 | if (buf == NULL) |
121 | return -1; | 121 | return -1; |
122 | 122 | ||
@@ -124,7 +124,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, | |||
124 | 124 | ||
125 | add_device_randomness(buf, dmi_len); | 125 | add_device_randomness(buf, dmi_len); |
126 | 126 | ||
127 | dmi_iounmap(buf, dmi_len); | 127 | dmi_early_unmap(buf, dmi_len); |
128 | return 0; | 128 | return 0; |
129 | } | 129 | } |
130 | 130 | ||
@@ -527,18 +527,18 @@ void __init dmi_scan_machine(void) | |||
527 | * needed during early boot. This also means we can | 527 | * needed during early boot. This also means we can |
528 | * iounmap the space when we're done with it. | 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 | if (p == NULL) | 531 | if (p == NULL) |
532 | goto error; | 532 | goto error; |
533 | memcpy_fromio(buf, p, 32); | 533 | memcpy_fromio(buf, p, 32); |
534 | dmi_iounmap(p, 32); | 534 | dmi_early_unmap(p, 32); |
535 | 535 | ||
536 | if (!dmi_present(buf)) { | 536 | if (!dmi_present(buf)) { |
537 | dmi_available = 1; | 537 | dmi_available = 1; |
538 | goto out; | 538 | goto out; |
539 | } | 539 | } |
540 | } else { | 540 | } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { |
541 | p = dmi_ioremap(0xF0000, 0x10000); | 541 | p = dmi_early_remap(0xF0000, 0x10000); |
542 | if (p == NULL) | 542 | if (p == NULL) |
543 | goto error; | 543 | goto error; |
544 | 544 | ||
@@ -554,12 +554,12 @@ void __init dmi_scan_machine(void) | |||
554 | memcpy_fromio(buf + 16, q, 16); | 554 | memcpy_fromio(buf + 16, q, 16); |
555 | if (!dmi_present(buf)) { | 555 | if (!dmi_present(buf)) { |
556 | dmi_available = 1; | 556 | dmi_available = 1; |
557 | dmi_iounmap(p, 0x10000); | 557 | dmi_early_unmap(p, 0x10000); |
558 | goto out; | 558 | goto out; |
559 | } | 559 | } |
560 | memcpy(buf, buf + 16, 16); | 560 | memcpy(buf, buf + 16, 16); |
561 | } | 561 | } |
562 | dmi_iounmap(p, 0x10000); | 562 | dmi_early_unmap(p, 0x10000); |
563 | } | 563 | } |
564 | error: | 564 | error: |
565 | pr_info("DMI not present or invalid.\n"); | 565 | pr_info("DMI not present or invalid.\n"); |
@@ -831,13 +831,13 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *), | |||
831 | if (!dmi_available) | 831 | if (!dmi_available) |
832 | return -1; | 832 | return -1; |
833 | 833 | ||
834 | buf = ioremap(dmi_base, dmi_len); | 834 | buf = dmi_remap(dmi_base, dmi_len); |
835 | if (buf == NULL) | 835 | if (buf == NULL) |
836 | return -1; | 836 | return -1; |
837 | 837 | ||
838 | dmi_table(buf, dmi_len, dmi_num, decode, private_data); | 838 | dmi_table(buf, dmi_len, dmi_num, decode, private_data); |
839 | 839 | ||
840 | iounmap(buf); | 840 | dmi_unmap(buf); |
841 | return 0; | 841 | return 0; |
842 | } | 842 | } |
843 | EXPORT_SYMBOL_GPL(dmi_walk); | 843 | EXPORT_SYMBOL_GPL(dmi_walk); |