aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2018-02-03 05:25:20 -0500
committerJean Delvare <jdelvare@suse.de>2018-02-03 05:25:20 -0500
commit7117794feb1602ea5efca1c7bfd5b78c3278d29d (patch)
treedc9e69e830c6ab064490d164ae4828ea9abacdd1
parent8cf4e6a04f734e831c2ac7f405071d1cde690ba8 (diff)
firmware: dmi_scan: Drop dmi_initialized
I don't think it makes sense to check for a possible bad initialization order at run time on every system when it is all decided at build time. A more efficient way to make sure developers do not introduce new calls to dmi_check_system() too early in the initialization sequence is to simply document the expected call order. That way, developers have a chance to get it right immediately, without having to test-boot their kernel, wonder why it does not work, and parse the kernel logs for a warning message. And we get rid of the run-time performance penalty as a nice side effect. Signed-off-by: Jean Delvare <jdelvare@suse.de> Cc: Ingo Molnar <mingo@kernel.org>
-rw-r--r--drivers/firmware/dmi_scan.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 84356d86f359..8cd5db6691b2 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -26,11 +26,6 @@ static u16 dmi_num;
26static u8 smbios_entry_point[32]; 26static u8 smbios_entry_point[32];
27static int smbios_entry_point_size; 27static int smbios_entry_point_size;
28 28
29/*
30 * Catch too early calls to dmi_check_system():
31 */
32static int dmi_initialized;
33
34/* DMI system identification string used during boot */ 29/* DMI system identification string used during boot */
35static char dmi_ids_string[128] __initdata; 30static char dmi_ids_string[128] __initdata;
36 31
@@ -633,7 +628,7 @@ void __init dmi_scan_machine(void)
633 628
634 if (!dmi_smbios3_present(buf)) { 629 if (!dmi_smbios3_present(buf)) {
635 dmi_available = 1; 630 dmi_available = 1;
636 goto out; 631 return;
637 } 632 }
638 } 633 }
639 if (efi.smbios == EFI_INVALID_TABLE_ADDR) 634 if (efi.smbios == EFI_INVALID_TABLE_ADDR)
@@ -651,7 +646,7 @@ void __init dmi_scan_machine(void)
651 646
652 if (!dmi_present(buf)) { 647 if (!dmi_present(buf)) {
653 dmi_available = 1; 648 dmi_available = 1;
654 goto out; 649 return;
655 } 650 }
656 } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) { 651 } else if (IS_ENABLED(CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK)) {
657 p = dmi_early_remap(0xF0000, 0x10000); 652 p = dmi_early_remap(0xF0000, 0x10000);
@@ -668,7 +663,7 @@ void __init dmi_scan_machine(void)
668 if (!dmi_smbios3_present(buf)) { 663 if (!dmi_smbios3_present(buf)) {
669 dmi_available = 1; 664 dmi_available = 1;
670 dmi_early_unmap(p, 0x10000); 665 dmi_early_unmap(p, 0x10000);
671 goto out; 666 return;
672 } 667 }
673 memcpy(buf, buf + 16, 16); 668 memcpy(buf, buf + 16, 16);
674 } 669 }
@@ -686,7 +681,7 @@ void __init dmi_scan_machine(void)
686 if (!dmi_present(buf)) { 681 if (!dmi_present(buf)) {
687 dmi_available = 1; 682 dmi_available = 1;
688 dmi_early_unmap(p, 0x10000); 683 dmi_early_unmap(p, 0x10000);
689 goto out; 684 return;
690 } 685 }
691 memcpy(buf, buf + 16, 16); 686 memcpy(buf, buf + 16, 16);
692 } 687 }
@@ -694,8 +689,6 @@ void __init dmi_scan_machine(void)
694 } 689 }
695 error: 690 error:
696 pr_info("DMI not present or invalid.\n"); 691 pr_info("DMI not present or invalid.\n");
697 out:
698 dmi_initialized = 1;
699} 692}
700 693
701static ssize_t raw_table_read(struct file *file, struct kobject *kobj, 694static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
@@ -827,14 +820,14 @@ static bool dmi_is_end_of_table(const struct dmi_system_id *dmi)
827 * Walk the blacklist table running matching functions until someone 820 * Walk the blacklist table running matching functions until someone
828 * returns non zero or we hit the end. Callback function is called for 821 * returns non zero or we hit the end. Callback function is called for
829 * each successful match. Returns the number of matches. 822 * each successful match. Returns the number of matches.
823 *
824 * dmi_scan_machine must be called before this function is called.
830 */ 825 */
831int dmi_check_system(const struct dmi_system_id *list) 826int dmi_check_system(const struct dmi_system_id *list)
832{ 827{
833 int count = 0; 828 int count = 0;
834 const struct dmi_system_id *d; 829 const struct dmi_system_id *d;
835 830
836 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
837
838 for (d = list; !dmi_is_end_of_table(d); d++) 831 for (d = list; !dmi_is_end_of_table(d); d++)
839 if (dmi_matches(d)) { 832 if (dmi_matches(d)) {
840 count++; 833 count++;
@@ -857,6 +850,8 @@ EXPORT_SYMBOL(dmi_check_system);
857 * 850 *
858 * Walk the blacklist table until the first match is found. Return the 851 * Walk the blacklist table until the first match is found. Return the
859 * pointer to the matching entry or NULL if there's no match. 852 * pointer to the matching entry or NULL if there's no match.
853 *
854 * dmi_scan_machine must be called before this function is called.
860 */ 855 */
861const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list) 856const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
862{ 857{