In order to prevent bootmem allocator (memblock) from allocating hotpluggable
memory for the kernel, we need to obtain SRAT earlier.
In part1 patch-set, we have split acpi_gbl_root_table_list initialization into
two steps: install and override.
This patch-set will do install step earlier. This will help us to find SRAT provided
by firmware earlier in later patches.
The current kernel looks like this:
setup_arch()
|->acpi_initrd_override() /* Find all tables specified by users in initrd,
| and store them in acpi_tables_addr array. */
|......
|->acpi_boot_table_init() /* Find all tables in firmware and install them
into acpi_gbl_root_table_list. Check acpi_tables_addr,
if any table needs to be overrided, override it. */
After this patch-set, the kernel will look like this:
setup_arch()
|->early_acpi_boot_table_init() /* Find all tables in firmware and install them
| into acpi_gbl_root_table_list. No override. */
|
|->acpi_initrd_override() /* Find all tables specified by users in initrd,
| and store them in acpi_tables_addr array. */
|......
|->acpi_boot_table_init() /* Check acpi_tables_addr, if any table needs to
be overrided, override it. */
Tang Chen (5):
x86, acpi: Call two new functions instead of acpi_initialize_tables()
in acpi_table_init().
x86, acpi: Split acpi_table_init() into two parts.
x86, acpi: Rename check_multiple_madt() and make it global.
x86, acpi: Split acpi_boot_table_init() into two parts.
x86, acpi: Initialize acpi golbal root table list earlier.
arch/x86/kernel/acpi/boot.c | 32 ++++++++++++++++++++------------
arch/x86/kernel/setup.c | 8 +++++++-
drivers/acpi/tables.c | 29 +++++++++++++++++++++++------
include/acpi/acpixf.h | 4 ++++
include/linux/acpi.h | 4 ++++
5 files changed, 58 insertions(+), 19 deletions(-)
As the previous patches split the acpi_gbl_root_table_list initialization
procedure into two steps: install and override, this patch does the "install"
steps earlier, right after memblock is ready.
In this way, we are able to find SRAT in firmware earlier. And then, we can
prevent memblock from allocating hotpluggable memory for the kernel.
Signed-off-by: Tang Chen <[email protected]>
Reviewed-by: Zhang Yanfei <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 30 +++++++++++++++++-------------
arch/x86/kernel/setup.c | 8 +++++++-
include/linux/acpi.h | 1 +
3 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index ddb0bc1..30daefd 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1497,6 +1497,23 @@ static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
{}
};
+void __init early_acpi_boot_table_init(void)
+{
+ dmi_check_system(acpi_dmi_table);
+
+ /*
+ * If acpi_disabled, bail out
+ */
+ if (acpi_disabled)
+ return;
+
+ /*
+ * Initialize the ACPI boot-time table parser.
+ */
+ if (acpi_table_init_firmware())
+ disable_acpi();
+}
+
/*
* acpi_boot_table_init() and acpi_boot_init()
* called from setup_arch(), always.
@@ -1504,9 +1521,6 @@ static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
* 2. enumerates lapics
* 3. enumerates io-apics
*
- * acpi_table_init() is separate to allow reading SRAT without
- * other side effects.
- *
* side effects of acpi_boot_init:
* acpi_lapic = 1 if LAPIC found
* acpi_ioapic = 1 if IOAPIC found
@@ -1518,22 +1532,12 @@ static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
void __init acpi_boot_table_init(void)
{
- dmi_check_system(acpi_dmi_table);
-
/*
* If acpi_disabled, bail out
*/
if (acpi_disabled)
return;
- /*
- * Initialize the ACPI boot-time table parser.
- */
- if (acpi_table_init_firmware()) {
- disable_acpi();
- return;
- }
-
acpi_table_init_override();
acpi_check_multiple_madt();
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index f8ec578..fdb5a26 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1074,6 +1074,12 @@ void __init setup_arch(char **cmdline_p)
memblock_x86_fill();
/*
+ * Parse the ACPI tables from firmware for possible boot-time SMP
+ * configuration.
+ */
+ early_acpi_boot_table_init();
+
+ /*
* The EFI specification says that boot service code won't be called
* after ExitBootServices(). This is, in fact, a lie.
*/
@@ -1130,7 +1136,7 @@ void __init setup_arch(char **cmdline_p)
io_delay_init();
/*
- * Parse the ACPI tables for possible boot-time SMP configuration.
+ * Finish parsing the ACPI tables.
*/
acpi_boot_table_init();
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 44a3e5f..c5e7b2a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -91,6 +91,7 @@ char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
void __acpi_unmap_table(char *map, unsigned long size);
int early_acpi_boot_init(void);
int acpi_boot_init (void);
+void early_acpi_boot_table_init (void);
void acpi_boot_table_init (void);
int acpi_mps_check (void);
int acpi_numa_init (void);
--
1.7.1
The previous patches introduces two new functions:
acpi_initialize_tables_firmware() and acpi_initialize_tables_override(),
which work just the same as acpi_initialize_tables() if they are called
in sequence.
In order to split acpi_table_init() on acpi side, call these two functions
in acpi_table_init().
Since acpi_table_init() is also used in ia64, we keep it works as before.
Signed-off-by: Tang Chen <[email protected]>
Reviewed-by: Zhang Yanfei <[email protected]>
---
drivers/acpi/tables.c | 5 ++++-
include/acpi/acpixf.h | 4 ++++
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index d67a1fe..c8f2d01 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -349,10 +349,13 @@ int __init acpi_table_init(void)
{
acpi_status status;
- status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0);
+ status = acpi_initialize_tables_firmware(initial_tables,
+ ACPI_MAX_TABLES, 0);
if (ACPI_FAILURE(status))
return 1;
+ acpi_initialize_tables_override();
+
check_multiple_madt();
return 0;
}
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 22d497e..99c9d7b 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -115,6 +115,10 @@ extern u32 acpi_rsdt_forced;
* Initialization
*/
acpi_status
+acpi_initialize_tables_firmware(struct acpi_table_desc *initial_storage,
+ u32 initial_table_count, u8 allow_resize);
+void acpi_initialize_tables_override(void);
+acpi_status
acpi_initialize_tables(struct acpi_table_desc *initial_storage,
u32 initial_table_count, u8 allow_resize);
--
1.7.1
Since we split acpi_table_init() into two steps, and want to do
the two steps separately, we need to do check_multiple_madt() after
acpi_table_init_override().
But we also have to keep acpi_table_init() as before because it
is also used in ia64, we have to do check_multiple_madt() directly
in acpi_boot_table_init() in x86.
This patch make check_multiple_madt() global, and rename it to
acpi_check_multiple_madt() because all interfaces provided by
drivers/acpi/tables.c begins with "acpi_".
Signed-off-by: Tang Chen <[email protected]>
Reviewed-by: Zhang Yanfei <[email protected]>
---
drivers/acpi/tables.c | 4 ++--
include/linux/acpi.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 4913a85..45727b2 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -314,7 +314,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler)
* but some report two. Provide a knob to use either.
* (don't you wish instance 0 and 1 were not the same?)
*/
-static void __init check_multiple_madt(void)
+void __init acpi_check_multiple_madt(void)
{
struct acpi_table_header *table = NULL;
acpi_size tbl_size;
@@ -369,7 +369,7 @@ int __init acpi_table_init(void)
acpi_table_init_override();
- check_multiple_madt();
+ acpi_check_multiple_madt();
return 0;
}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9704179..44a3e5f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -95,6 +95,7 @@ void acpi_boot_table_init (void);
int acpi_mps_check (void);
int acpi_numa_init (void);
+void acpi_check_multiple_madt(void);
int acpi_table_init_firmware(void);
void acpi_table_init_override(void);
int acpi_table_init (void);
--
1.7.1
This patch splits acpi_table_init() into two steps.
Since acpi_table_init() is used not just in x86, also used in ia64,
we introduce two new functions:
acpi_table_init_firmware() and acpi_table_init_override(),
which work just the same as acpi_table_init() if they are called
in sequence. This will keep acpi_table_init() works as before on
other platforms, and we only call these new functions in Linux.
Signed-off-by: Tang Chen <[email protected]>
Reviewed-by: Zhang Yanfei <[email protected]>
---
drivers/acpi/tables.c | 26 ++++++++++++++++++++------
include/linux/acpi.h | 2 ++
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index c8f2d01..4913a85 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -336,6 +336,23 @@ static void __init check_multiple_madt(void)
return;
}
+int __init acpi_table_init_firmware(void)
+{
+ acpi_status status;
+
+ status = acpi_initialize_tables_firmware(initial_tables,
+ ACPI_MAX_TABLES, 0);
+ if (ACPI_FAILURE(status))
+ return 1;
+
+ return 0;
+}
+
+void __init acpi_table_init_override(void)
+{
+ acpi_initialize_tables_override();
+}
+
/*
* acpi_table_init()
*
@@ -347,16 +364,13 @@ static void __init check_multiple_madt(void)
int __init acpi_table_init(void)
{
- acpi_status status;
-
- status = acpi_initialize_tables_firmware(initial_tables,
- ACPI_MAX_TABLES, 0);
- if (ACPI_FAILURE(status))
+ if (acpi_table_init_firmware())
return 1;
- acpi_initialize_tables_override();
+ acpi_table_init_override();
check_multiple_madt();
+
return 0;
}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 353ba25..9704179 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -95,6 +95,8 @@ void acpi_boot_table_init (void);
int acpi_mps_check (void);
int acpi_numa_init (void);
+int acpi_table_init_firmware(void);
+void acpi_table_init_override(void);
int acpi_table_init (void);
int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
int __init acpi_table_parse_entries(char *id, unsigned long table_size,
--
1.7.1
This patch splits acpi_boot_table_init() into two steps,
so that we can do each step separately in later patches.
Signed-off-by: Tang Chen <[email protected]>
Reviewed-by: Zhang Yanfei <[email protected]>
---
arch/x86/kernel/acpi/boot.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 2627a81..ddb0bc1 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1529,11 +1529,15 @@ void __init acpi_boot_table_init(void)
/*
* Initialize the ACPI boot-time table parser.
*/
- if (acpi_table_init()) {
+ if (acpi_table_init_firmware()) {
disable_acpi();
return;
}
+ acpi_table_init_override();
+
+ acpi_check_multiple_madt();
+
acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
/*
--
1.7.1