提交 9a22b6e7 编写于 作者: I Ingo Molnar

dmi scan: warn about too early calls to dmi_check_system()

It happened to me recently that i added a dmi_check_system() quirk
in a too early codepath, and it was silently ignored because all the
DMI tables and strings were still empty.

As this situation is clearly a programming error / kernel bug,
warn when it happens, instead of silently ignoring quirks.
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 8308c54d
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
*/ */
static char dmi_empty_string[] = " "; static char dmi_empty_string[] = " ";
/*
* Catch too early calls to dmi_check_system():
*/
static int dmi_initialized;
static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
{ {
const u8 *bp = ((u8 *) dm) + dm->length; const u8 *bp = ((u8 *) dm) + dm->length;
...@@ -366,7 +371,7 @@ void __init dmi_scan_machine(void) ...@@ -366,7 +371,7 @@ void __init dmi_scan_machine(void)
if (efi_enabled) { if (efi_enabled) {
if (efi.smbios == EFI_INVALID_TABLE_ADDR) if (efi.smbios == EFI_INVALID_TABLE_ADDR)
goto out; goto error;
/* This is called as a core_initcall() because it isn't /* This is called as a core_initcall() because it isn't
* needed during early boot. This also means we can * needed during early boot. This also means we can
...@@ -374,13 +379,13 @@ void __init dmi_scan_machine(void) ...@@ -374,13 +379,13 @@ void __init dmi_scan_machine(void)
*/ */
p = dmi_ioremap(efi.smbios, 32); p = dmi_ioremap(efi.smbios, 32);
if (p == NULL) if (p == NULL)
goto out; goto error;
rc = dmi_present(p + 0x10); /* offset of _DMI_ string */ rc = dmi_present(p + 0x10); /* offset of _DMI_ string */
dmi_iounmap(p, 32); dmi_iounmap(p, 32);
if (!rc) { if (!rc) {
dmi_available = 1; dmi_available = 1;
return; goto out;
} }
} }
else { else {
...@@ -391,19 +396,22 @@ void __init dmi_scan_machine(void) ...@@ -391,19 +396,22 @@ void __init dmi_scan_machine(void)
*/ */
p = dmi_ioremap(0xF0000, 0x10000); p = dmi_ioremap(0xF0000, 0x10000);
if (p == NULL) if (p == NULL)
goto out; goto error;
for (q = p; q < p + 0x10000; q += 16) { for (q = p; q < p + 0x10000; q += 16) {
rc = dmi_present(q); rc = dmi_present(q);
if (!rc) { if (!rc) {
dmi_available = 1; dmi_available = 1;
dmi_iounmap(p, 0x10000); dmi_iounmap(p, 0x10000);
return; goto out;
} }
} }
dmi_iounmap(p, 0x10000); dmi_iounmap(p, 0x10000);
} }
out: printk(KERN_INFO "DMI not present or invalid.\n"); error:
printk(KERN_INFO "DMI not present or invalid.\n");
out:
dmi_initialized = 1;
} }
/** /**
...@@ -424,6 +432,8 @@ int dmi_check_system(const struct dmi_system_id *list) ...@@ -424,6 +432,8 @@ int dmi_check_system(const struct dmi_system_id *list)
int i, count = 0; int i, count = 0;
const struct dmi_system_id *d = list; const struct dmi_system_id *d = list;
WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
while (d->ident) { while (d->ident) {
for (i = 0; i < ARRAY_SIZE(d->matches); i++) { for (i = 0; i < ARRAY_SIZE(d->matches); i++) {
int s = d->matches[i].slot; int s = d->matches[i].slot;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册