Skip to contentSkip to conversation

ACPICA: Tables: Table cleanup and new APIs

RFC PATCH New Lv Zheng 1 participant 9 messages Mar 24, 2016

Subsystems (3)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

cover ACPICA: Tables: Table cleanup and new APIs

This patch is a linuxized result of ACPICA upstream pull request 121.
https://github.com/acpica/acpica/pull/121/
This is for review only. Please do not merge it.

Lv Zheng (8):
ACPICA: Tables: Add an error message complaining driver bugs
ACPICA: Tables: Invoke acpi_tb_validate_tableby_index() instead of
acpi_get_table_by_index()
ACPICA: Tables: Fix an issue the dynamic table loading contains code
with MTX_TABLES released
ACPICA: Tables: Cleanup acpi_tb_copy_dsdt()
ACPICA: Tables: Remove acpi_tb_install_fixed_table()
ACPICA: Tables: Correct function namings
ACPICA: Tables: Add acpi_uninstall_table() to remove ACPI tables
ACPICA: Tables: Add acpi_unload_table() to unload definition block
tables

 drivers/acpi/acpica/actables.h    |   22 +++---
 drivers/acpi/acpica/dbfileio.c    |    2 +-
 drivers/acpi/acpica/dsinit.c      |    2 +-
 drivers/acpi/acpica/dsopcode.c    |    2 +-
 drivers/acpi/acpica/exconfig.c    |   18 +++--
 drivers/acpi/acpica/nsparse.c     |    2 +-
 drivers/acpi/acpica/tbdata.c      |   54 +++++++++++---
 drivers/acpi/acpica/tbfadt.c      |   24 +++---
 drivers/acpi/acpica/tbinstal.c    |  119 +++--------------------------
 drivers/acpi/acpica/tbutils.c     |   94 ++++++++++++++++++-----
 drivers/acpi/acpica/tbxface.c     |   18 ++++-
 drivers/acpi/acpica/tbxfload.c    |  149 ++++++++++++++++++++++++++++---------
 drivers/acpi/osl.c                |    3 +-
 drivers/pci/hotplug/sgi_hotplug.c |    2 +-
 include/acpi/acpixf.h             |    8 +-
 include/acpi/actbl.h              |    1 +
 16 files changed, 307 insertions(+), 213 deletions(-)
Signature · 1 line
1.7.10
author
#1 lore raw

RFC PATCH 1/8 ACPICA: Tables: Add an error message complaining driver bugs

This patch adds an error message to complain a driver bug that the early mappings are not unmapped by the drivers. Lv Zheng.

---
 drivers/acpi/acpica/tbxface.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/acpi/acpica/tbxface.c +16 -0
index 326df65..5700e72 100644
@@ -167,6 +167,7 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_tables)
 acpi_status __init acpi_reallocate_root_table(void)
 {
 	acpi_status status;
+	u32 i;
 
 	ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
 
@@ -178,6 +179,21 @@ acpi_status __init acpi_reallocate_root_table(void)
 		return_ACPI_STATUS(AE_SUPPORT);
 	}
 
+	/*
+	 * Ensure OS early boot logic, which is required by some hosts. If the
+	 * table state is reported to be wrong, developers should fix the
+	 * issue by invoking acpi_put_table() for the reported table during the
+	 * early stage.
+	 */
+	for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
+		if (acpi_gbl_root_table_list.tables[i].pointer) {
+			ACPI_ERROR((AE_INFO,
+				    "BUG: Table [%4.4s] isn't invalidated after booting",
+				    acpi_gbl_root_table_list.tables[i].
+				    signature.ascii));
+		}
+	}
+
 	acpi_gbl_root_table_list.flags |= ACPI_ROOT_ALLOW_RESIZE;
 
 	status = acpi_tb_resize_root_table_list();
Signature · 1 line
1.7.10
author
#2 lore raw

RFC PATCH 2/8 ACPICA: Tables: Invoke acpi_tb_validate_tableby_index() instead of acpi_get_table_by_index()

In reply to Lv Zheng

Serving for the external users, acpi_get_table_by_index() should be restricted not to map the tables into struct acpi_table_desc.Pointer or it is likely to be changed into reference couting based style so that the mappings can be freed when there is no reference to make OS early/late APIs combined.

While all internal acpi_get_table_by_index() usages should be changed to be an internal validatation based API so that the tables are always mapped to .Pointer as long as they are referenced inside of ACPICA. From the reference counting's point of view, the internal reference should be increased/decreased only once.

Except the flag to ensure the new API is not invoked inside of ACPICA twice, there is no functional change in this patch. This patch just copies acpi_get_tableby_index() to form a new API for internal usage so that further patches can safely modify acpi_get_table_by_index() to make it an external only API.

---
 drivers/acpi/acpica/actables.h |    4 +++
 drivers/acpi/acpica/dsinit.c   |    2 +-
 drivers/acpi/acpica/dsopcode.c |    2 +-
 drivers/acpi/acpica/exconfig.c |    4 +--
 drivers/acpi/acpica/nsparse.c  |    2 +-
 drivers/acpi/acpica/tbutils.c  |   73 +++++++++++++++++++++++++++++++++++-----
 drivers/acpi/acpica/tbxface.c  |    2 +-
 include/acpi/actbl.h           |    1 +
 8 files changed, 76 insertions(+), 14 deletions(-)
drivers/acpi/acpica/actables.h +4 -0
index 848ad3a..9310cb4 100644
@@ -163,6 +163,10 @@ acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
 
 u8 acpi_is_valid_signature(char *signature);
 
+acpi_status
+acpi_tb_validate_table_by_index(u32 table_index,
+				struct acpi_table_header **out_table);
+
 /*
  * tbxfload
  */
drivers/acpi/acpica/dsinit.c +1 -1
index 5aa1c5f..71d700a 100644
@@ -232,7 +232,7 @@ acpi_ds_initialize_objects(u32 table_index,
 	}
 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
 
-	status = acpi_get_table_by_index(table_index, &table);
+	status = acpi_tb_validate_table_by_index(table_index, &table);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
drivers/acpi/acpica/dsopcode.c +1 -1
index 4cc9d98..22eea92 100644
@@ -535,7 +535,7 @@ acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
 		goto cleanup;
 	}
 
-	status = acpi_get_table_by_index(table_index, &table);
+	status = acpi_tb_validate_table_by_index(table_index, &table);
 	if (ACPI_FAILURE(status)) {
 		goto cleanup;
 	}
drivers/acpi/acpica/exconfig.c +2 -2
index a1d177d..98102af 100644
@@ -252,7 +252,7 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
 		}
 	}
 
-	status = acpi_get_table_by_index(table_index, &table);
+	status = acpi_tb_validate_table_by_index(table_index, &table);
 	if (ACPI_SUCCESS(status)) {
 		ACPI_INFO(("Dynamic OEM Table Load:"));
 		acpi_tb_print_table_header(0, table);
@@ -601,7 +601,7 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
 	/* Invoke table handler if present */
 
 	if (acpi_gbl_table_handler) {
-		status = acpi_get_table_by_index(table_index, &table);
+		status = acpi_tb_validate_table_by_index(table_index, &table);
 		if (ACPI_SUCCESS(status)) {
 			(void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
 						     table,
drivers/acpi/acpica/nsparse.c +1 -1
index f631a47..de76a1d 100644
@@ -78,7 +78,7 @@ acpi_ns_one_complete_parse(u32 pass_number,
 
 	ACPI_FUNCTION_TRACE(ns_one_complete_parse);
 
-	status = acpi_get_table_by_index(table_index, &table);
+	status = acpi_tb_validate_table_by_index(table_index, &table);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
drivers/acpi/acpica/tbutils.c +65 -8

84 lines not on this page · raw message

drivers/acpi/acpica/tbxface.c +1 -1
index 5700e72..ef2c5f9 100644
@@ -364,7 +364,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table)
  * RETURN:      Status and pointer to the requested table
  *
  * DESCRIPTION: Obtain a table by an index into the global table list. Used
- *              internally also.
+ *              externally only.
  *
  ******************************************************************************/
 acpi_status
include/acpi/actbl.h +1 -0
index c19700e..9513849 100644
@@ -379,6 +379,7 @@ struct acpi_table_desc {
 #define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1)	/* Physical address, internally mapped */
 #define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL  (2)	/* Virtual address, internallly allocated */
 #define ACPI_TABLE_ORIGIN_MASK              (3)
+#define ACPI_TABLE_IS_VALIDATED             (4)	/* Internal validated */
 #define ACPI_TABLE_IS_LOADED                (8)
 
 /*
Signature · 1 line
1.7.10
author
#3 lore raw

RFC PATCH 3/8 ACPICA: Tables: Fix an issue the dynamic table loading contains code with MTX_TABLES released

In reply to Lv Zheng

Panic can be seen when OS runs _PDC from different CPUs to dynamically "Load" the tables. And this is because acpi_tb_validate_table() is an early stage only API and cannot be deployed to the racing environment. While here we want the table to be transitioned into the "VALIDATED" state before being transitioned into "LOADED" state, so acpi_tb_validate_table_by_index() is actually the proper API that should be invoked here and it properly locks the table descriptor with MTX_TABLES mutex. Lv Zheng.

---
 drivers/acpi/acpica/exconfig.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/acpi/acpica/exconfig.c +5 -3
index 98102af..3418c90 100644
@@ -493,10 +493,12 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 	/*
 	 * Note: Now table is "INSTALLED", it must be validated before
 	 * loading.
+	 * As Table pointer has been installed, no code from here will still be
+	 * using the original pointer. Furthermore, the table handler actually
+	 * wants a validation result of the table. So this pointer is refilled
+	 * by the returning value of acpi_tb_validate_table_by_index().
 	 */
-	status =
-	    acpi_tb_validate_table(&acpi_gbl_root_table_list.
-				   tables[table_index]);
+	status = acpi_tb_validate_table_by_index(table_index, &table);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
 	}
Signature · 1 line
1.7.10
author
#4 lore raw

RFC PATCH 4/8 ACPICA: Tables: Cleanup acpi_tb_copy_dsdt()

In reply to Lv Zheng

This patch cleans up acpi_tb_copy_dsdt(), removing a useless parameter. No functional change. Lv Zheng.

---
 drivers/acpi/acpica/actables.h |    2 +-
 drivers/acpi/acpica/tbutils.c  |    9 ++++-----
 drivers/acpi/acpica/tbxfload.c |    2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)
drivers/acpi/acpica/actables.h +1 -1
index 9310cb4..6f08c9c 100644
@@ -149,7 +149,7 @@ acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
 
 void acpi_tb_check_dsdt_header(void);
 
-struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
+struct acpi_table_header *acpi_tb_copy_dsdt(void);
 
 void
 acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
drivers/acpi/acpica/tbutils.c +4 -5
index b64fbe3..ec6ce69 100644
@@ -141,7 +141,7 @@ void acpi_tb_check_dsdt_header(void)
  *
  * FUNCTION:    acpi_tb_copy_dsdt
  *
- * PARAMETERS:  table_desc          - Installed table to copy
+ * PARAMETERS:  None
  *
  * RETURN:      None
  *
@@ -151,12 +151,12 @@ void acpi_tb_check_dsdt_header(void)
  *
  ******************************************************************************/
 
-struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
+struct acpi_table_header *acpi_tb_copy_dsdt(void)
 {
 	struct acpi_table_header *new_table;
 	struct acpi_table_desc *table_desc;
 
-	table_desc = &acpi_gbl_root_table_list.tables[table_index];
+	table_desc = &acpi_gbl_root_table_list.tables[acpi_gbl_dsdt_index];
 
 	new_table = ACPI_ALLOCATE(table_desc->length);
 	if (!new_table) {
@@ -168,8 +168,7 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
 	memcpy(new_table, table_desc->pointer, table_desc->length);
 	acpi_tb_uninstall_table(table_desc);
 
-	acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.
-				      tables[acpi_gbl_dsdt_index],
+	acpi_tb_init_table_descriptor(table_desc,
 				      ACPI_PTR_TO_PHYSADDR(new_table),
 				      ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
 				      new_table);
drivers/acpi/acpica/tbxfload.c +1 -1
index ac71abc..9d3cf30 100644
@@ -175,7 +175,7 @@ acpi_status acpi_tb_load_namespace(void)
 	 * the DSDT.
 	 */
 	if (acpi_gbl_copy_dsdt_locally) {
-		new_dsdt = acpi_tb_copy_dsdt(acpi_gbl_dsdt_index);
+		new_dsdt = acpi_tb_copy_dsdt();
 		if (new_dsdt) {
 			acpi_gbl_DSDT = new_dsdt;
 		}
Signature · 1 line
1.7.10
author
#5 lore raw

RFC PATCH 5/8 ACPICA: Tables: Remove acpi_tb_install_fixed_table()

In reply to Lv Zheng

acpi_tb_install_fixed_table() is now redundant as we've removed the fixed table indexing mechanism. This patch cleans up the code accordingly. No functional change. Lv Zheng.

---
 drivers/acpi/acpica/actables.h |    4 ---
 drivers/acpi/acpica/tbfadt.c   |   24 ++++++++-------
 drivers/acpi/acpica/tbinstal.c |   65 +---------------------------------------
 3 files changed, 15 insertions(+), 78 deletions(-)
drivers/acpi/acpica/actables.h +0 -4
index 6f08c9c..06d4d3d 100644
@@ -155,10 +155,6 @@ void
 acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
 				    u8 override, u32 *table_index);
 
-acpi_status
-acpi_tb_install_fixed_table(acpi_physical_address address,
-			    char *signature, u32 *table_index);
-
 acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
 
 u8 acpi_is_valid_signature(char *signature);
drivers/acpi/acpica/tbfadt.c +14 -10
index 635d951..2d24c4b 100644
@@ -344,23 +344,27 @@ void acpi_tb_parse_fadt(void)
 
 	/* Obtain the DSDT and FACS tables via their addresses within the FADT */
 
-	acpi_tb_install_fixed_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
-				    ACPI_SIG_DSDT, &acpi_gbl_dsdt_index);
+	acpi_tb_install_standard_table((acpi_physical_address) acpi_gbl_FADT.
+				       Xdsdt,
+				       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+				       FALSE, TRUE, &acpi_gbl_dsdt_index);
 
 	/* If Hardware Reduced flag is set, there is no FACS */
 
 	if (!acpi_gbl_reduced_hardware) {
 		if (acpi_gbl_FADT.facs) {
-			acpi_tb_install_fixed_table((acpi_physical_address)
-						    acpi_gbl_FADT.facs,
-						    ACPI_SIG_FACS,
-						    &acpi_gbl_facs_index);
+			acpi_tb_install_standard_table((acpi_physical_address)
+						       acpi_gbl_FADT.facs,
+						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+						       FALSE, TRUE,
+						       &acpi_gbl_facs_index);
 		}
 		if (acpi_gbl_FADT.Xfacs) {
-			acpi_tb_install_fixed_table((acpi_physical_address)
-						    acpi_gbl_FADT.Xfacs,
-						    ACPI_SIG_FACS,
-						    &acpi_gbl_xfacs_index);
+			acpi_tb_install_standard_table((acpi_physical_address)
+						       acpi_gbl_FADT.Xfacs,
+						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+						       FALSE, TRUE,
+						       &acpi_gbl_xfacs_index);
 		}
 	}
 }
drivers/acpi/acpica/tbinstal.c +1 -64

77 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#6 lore raw

RFC PATCH 6/8 ACPICA: Tables: Correct function namings

In reply to Lv Zheng

This patch converts acpi_tb_install_standard_table() to acpi_tb_verify_and_install_table() to reflect the recent changes. This patch also converts acpi_tb_init_table_descriptor() to acpi_tb_install_table() to be fully compliant to the table manager design. Lv Zheng.

---
 drivers/acpi/acpica/actables.h |   12 ++++-----
 drivers/acpi/acpica/exconfig.c |    6 ++---
 drivers/acpi/acpica/tbdata.c   |   54 ++++++++++++++++++++++++++++++++--------
 drivers/acpi/acpica/tbfadt.c   |   28 ++++++++++-----------
 drivers/acpi/acpica/tbinstal.c |   54 +++++++---------------------------------
 drivers/acpi/acpica/tbutils.c  |   14 +++++------
 drivers/acpi/acpica/tbxfload.c |   10 ++++----
 7 files changed, 87 insertions(+), 91 deletions(-)
drivers/acpi/acpica/actables.h +6 -6
index 06d4d3d..5e4d780 100644
@@ -63,9 +63,9 @@ acpi_tb_get_next_table_descriptor(u32 *table_index,
 				  struct acpi_table_desc **table_desc);
 
 void
-acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
-			      acpi_physical_address address,
-			      u8 flags, struct acpi_table_header *table);
+acpi_tb_install_table(struct acpi_table_desc *table_desc,
+		      acpi_physical_address address,
+		      u8 flags, struct acpi_table_header *table);
 
 acpi_status
 acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
@@ -117,9 +117,9 @@ acpi_tb_release_table(struct acpi_table_header *table,
 		      u32 table_length, u8 table_flags);
 
 acpi_status
-acpi_tb_install_standard_table(acpi_physical_address address,
-			       u8 flags,
-			       u8 reload, u8 override, u32 *table_index);
+acpi_tb_verify_and_install_table(acpi_physical_address address,
+				 u8 flags,
+				 u8 reload, u8 override, u32 *table_index);
 
 void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc);
 
drivers/acpi/acpica/exconfig.c +3 -3
index 3418c90..55039c4 100644
@@ -477,9 +477,9 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 	ACPI_INFO(("Dynamic OEM Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
-	status = acpi_tb_install_standard_table(ACPI_PTR_TO_PHYSADDR(table),
-						ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
-						TRUE, TRUE, &table_index);
+	status = acpi_tb_verify_and_install_table(ACPI_PTR_TO_PHYSADDR(table),
+						  ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
+						  TRUE, TRUE, &table_index);
 
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/tbdata.c +44 -10

93 lines not on this page · raw message

drivers/acpi/acpica/tbfadt.c +14 -14
index 2d24c4b..cc2b774 100644
@@ -344,27 +344,27 @@ void acpi_tb_parse_fadt(void)
 
 	/* Obtain the DSDT and FACS tables via their addresses within the FADT */
 
-	acpi_tb_install_standard_table((acpi_physical_address) acpi_gbl_FADT.
-				       Xdsdt,
-				       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
-				       FALSE, TRUE, &acpi_gbl_dsdt_index);
+	acpi_tb_verify_and_install_table((acpi_physical_address) acpi_gbl_FADT.
+					 Xdsdt,
+					 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+					 FALSE, TRUE, &acpi_gbl_dsdt_index);
 
 	/* If Hardware Reduced flag is set, there is no FACS */
 
 	if (!acpi_gbl_reduced_hardware) {
 		if (acpi_gbl_FADT.facs) {
-			acpi_tb_install_standard_table((acpi_physical_address)
-						       acpi_gbl_FADT.facs,
-						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
-						       FALSE, TRUE,
-						       &acpi_gbl_facs_index);
+			acpi_tb_verify_and_install_table((acpi_physical_address)
+							 acpi_gbl_FADT.facs,
+							 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+							 FALSE, TRUE,
+							 &acpi_gbl_facs_index);
 		}
 		if (acpi_gbl_FADT.Xfacs) {
-			acpi_tb_install_standard_table((acpi_physical_address)
-						       acpi_gbl_FADT.Xfacs,
-						       ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
-						       FALSE, TRUE,
-						       &acpi_gbl_xfacs_index);
+			acpi_tb_verify_and_install_table((acpi_physical_address)
+							 acpi_gbl_FADT.Xfacs,
+							 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+							 FALSE, TRUE,
+							 &acpi_gbl_xfacs_index);
 		}
 	}
 }
drivers/acpi/acpica/tbinstal.c +9 -45

81 lines not on this page · raw message

drivers/acpi/acpica/tbutils.c +6 -8
index ec6ce69..5956c4a 100644
@@ -168,10 +168,8 @@ struct acpi_table_header *acpi_tb_copy_dsdt(void)
 	memcpy(new_table, table_desc->pointer, table_desc->length);
 	acpi_tb_uninstall_table(table_desc);
 
-	acpi_tb_init_table_descriptor(table_desc,
-				      ACPI_PTR_TO_PHYSADDR(new_table),
-				      ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
-				      new_table);
+	acpi_tb_install_table(table_desc, ACPI_PTR_TO_PHYSADDR(new_table),
+			      ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, new_table);
 
 	ACPI_INFO(("Forced DSDT copy: length 0x%05X copied locally, original unmapped", new_table->length));
 
@@ -358,10 +356,10 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 			goto next_table;
 		}
 
-		status = acpi_tb_install_standard_table(address,
-							ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
-							FALSE, TRUE,
-							&table_index);
+		status = acpi_tb_verify_and_install_table(address,
+							  ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+							  FALSE, TRUE,
+							  &table_index);
 
 		if (ACPI_SUCCESS(status) &&
 		    ACPI_COMPARE_NAME(&acpi_gbl_root_table_list.
drivers/acpi/acpica/tbxfload.c +5 -5
index 9d3cf30..47b8b82 100644
@@ -287,8 +287,8 @@ acpi_install_table(acpi_physical_address address, u8 physical)
 		flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL;
 	}
 
-	status = acpi_tb_install_standard_table(address, flags,
-						FALSE, FALSE, &table_index);
+	status = acpi_tb_verify_and_install_table(address, flags,
+						  FALSE, FALSE, &table_index);
 
 	return_ACPI_STATUS(status);
 }
@@ -336,9 +336,9 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
 	ACPI_INFO(("Host-directed Dynamic ACPI Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 
-	status = acpi_tb_install_standard_table(ACPI_PTR_TO_PHYSADDR(table),
-						ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
-						TRUE, FALSE, &table_index);
+	status = acpi_tb_verify_and_install_table(ACPI_PTR_TO_PHYSADDR(table),
+						  ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL,
+						  TRUE, FALSE, &table_index);
 
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	if (ACPI_FAILURE(status)) {
Signature · 1 line
1.7.10
author
#7 lore raw

RFC PATCH 7/8 ACPICA: Tables: Add acpi_uninstall_table() to remove ACPI tables

In reply to Lv Zheng

There are existing internal functions that allow the removal of ACPI tables, but they are not exposed to OS in any useful way.

Introduce acpi_uninstall_table() which allows table states to be "UNINSTALLED" in the global table list, resulting in failures of subsequent calls to acpi_get_table() for those tables.

The rationale for this change is the ability to remove the BGRT table during kexec boot. The BGRT table refers to memory regions that are no longer reserved by the firmware once the kexec kernel boots, having been released for general allocation by the previous kernel.

Note that acpi_tb_uninstall_table() is designed with limitation that it must only be called after an acpi_tb_install_table() call as it doesn't handle table reference count synchronizations. So it is only safe in a single-threaded early booting environment.

---
 drivers/acpi/acpica/tbxfload.c |   42 ++++++++++++++++++++++++++++++++++++----
 drivers/acpi/osl.c             |    3 ++-
 include/acpi/acpixf.h          |    4 +++-
 3 files changed, 43 insertions(+), 6 deletions(-)
drivers/acpi/acpica/tbxfload.c +38 -4
index 47b8b82..a4475f3 100644
@@ -263,6 +263,7 @@ unlock_and_exit:
  * PARAMETERS:  address             - Address of the ACPI table to be installed.
  *              physical            - Whether the address is a physical table
  *                                    address or not
+ *              out_table_index     - Where the table index is returned
  *
  * RETURN:      Status
  *
@@ -272,12 +273,12 @@ unlock_and_exit:
  *
  ******************************************************************************/
 
-acpi_status __init
-acpi_install_table(acpi_physical_address address, u8 physical)
+acpi_status
+acpi_install_table(acpi_physical_address address,
+		   u8 physical, u32 *out_table_index)
 {
 	acpi_status status;
 	u8 flags;
-	u32 table_index;
 
 	ACPI_FUNCTION_TRACE(acpi_install_table);
 
@@ -288,7 +289,8 @@ acpi_install_table(acpi_physical_address address, u8 physical)
 	}
 
 	status = acpi_tb_verify_and_install_table(address, flags,
-						  FALSE, FALSE, &table_index);
+						  FALSE, FALSE,
+						  out_table_index);
 
 	return_ACPI_STATUS(status);
 }
@@ -297,6 +299,38 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_install_table)
 
 /*******************************************************************************
  *
+ * FUNCTION:    acpi_uninstall_table
+ *
+ * PARAMETERS:  table_index         - Table index
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dynamically uninstall an ACPI table.
+ *              Note: This function should only be invoked after
+ *                    acpi_initialize_tables() and before acpi_load_tables().
+ *
+ ******************************************************************************/
+void acpi_uninstall_table(u32 table_index)
+{
+
+	ACPI_FUNCTION_TRACE(acpi_uninstall_table);
+
+	/*
+	 * This function can only be used during early stage, so the table mutex
+	 * isn't required to be held.
+	 */
+	if (table_index < acpi_gbl_root_table_list.current_table_count) {
+		acpi_tb_uninstall_table(&acpi_gbl_root_table_list.
+					tables[table_index]);
+	}
+
+	return_VOID;
+}
+
+ACPI_EXPORT_SYMBOL_INIT(acpi_uninstall_table)
+
+/*******************************************************************************
+ *
  * FUNCTION:    acpi_load_table
  *
  * PARAMETERS:  table               - Pointer to a buffer containing the ACPI
drivers/acpi/osl.c +2 -1
index bef06c9..e8c0737 100644
@@ -809,6 +809,7 @@ void __init acpi_initrd_initialize_tables(void)
 	int table_offset = 0;
 	int table_index = 0;
 	u32 table_length;
+	u32 ddb;
 	struct acpi_table_header *table;
 
 	if (!acpi_tables_addr)
@@ -835,7 +836,7 @@ void __init acpi_initrd_initialize_tables(void)
 
 		acpi_table_taint(table);
 		acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
-		acpi_install_table(acpi_tables_addr + table_offset, TRUE);
+		acpi_install_table(acpi_tables_addr + table_offset, TRUE, &ddb);
 		set_bit(table_index, acpi_initrd_installed);
 next_table:
 		table_offset += table_length;
include/acpi/acpixf.h +3 -1
index cef1223..e41a99c 100644
@@ -469,7 +469,9 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status
  */
 ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init
 			    acpi_install_table(acpi_physical_address address,
-					       u8 physical))
+					       u8 physical,
+					       u32 *out_table_index))
+ACPI_EXTERNAL_RETURN_VOID(void acpi_uninstall_table(u32 table_index))
 
 ACPI_EXTERNAL_RETURN_STATUS(acpi_status
 			    acpi_load_table(struct acpi_table_header *table))
Signature · 1 line
1.7.10
author
#8 lore raw

RFC PATCH 8/8 ACPICA: Tables: Add acpi_unload_table() to unload definition block tables

In reply to Lv Zheng

This patch adds acpi_unload_table() API and adds parameter in acpi_load_table() to be used for the new acpi_unload_table() API.

---
 drivers/acpi/acpica/dbfileio.c    |    2 +-
 drivers/acpi/acpica/tbxfload.c    |   97 ++++++++++++++++++++++++++-----------
 drivers/pci/hotplug/sgi_hotplug.c |    2 +-
 include/acpi/acpixf.h             |    4 +-
 4 files changed, 75 insertions(+), 30 deletions(-)
drivers/acpi/acpica/dbfileio.c +1 -1
index 4832879..283565c 100644
@@ -138,7 +138,7 @@ acpi_status acpi_db_load_tables(struct acpi_new_table_desc *list_head)
 	while (table_list_head) {
 		table = table_list_head->table;
 
-		status = acpi_load_table(table);
+		status = acpi_load_table(table, NULL);
 		if (ACPI_FAILURE(status)) {
 			if (status == AE_ALREADY_EXISTS) {
 				acpi_os_printf
drivers/acpi/acpica/tbxfload.c +70 -27

135 lines not on this page · raw message

drivers/pci/hotplug/sgi_hotplug.c +1 -1
index 339bce0..57d627d 100644
@@ -355,7 +355,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
 	if (SN_ACPI_BASE_SUPPORT() && ssdt) {
 		acpi_status ret;
 
-		ret = acpi_load_table((struct acpi_table_header *)ssdt);
+		ret = acpi_load_table((struct acpi_table_header *)ssdt, NULL);
 		if (ACPI_FAILURE(ret)) {
 			printk(KERN_ERR "%s: acpi_load_table failed (0x%x)\n",
 			       __func__, ret);
include/acpi/acpixf.h +3 -1
index e41a99c..bb2d69b 100644
@@ -474,7 +474,9 @@ ACPI_EXTERNAL_RETURN_STATUS(acpi_status __init
 ACPI_EXTERNAL_RETURN_VOID(void acpi_uninstall_table(u32 table_index))
 
 ACPI_EXTERNAL_RETURN_STATUS(acpi_status
-			    acpi_load_table(struct acpi_table_header *table))
+			    acpi_load_table(struct acpi_table_header *table,
+					    u32 *out_table_index))
+ACPI_EXTERNAL_RETURN_STATUS(acpi_status acpi_unload_table(u32 table_inde))
 
 ACPI_EXTERNAL_RETURN_STATUS(acpi_status
 			    acpi_unload_parent_table(acpi_handle object))
Signature · 1 line
1.7.10