* [RFC PATCH 1/8] ACPICA: Tables: Add an error message complaining driver bugs
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
@ 2016-03-24 8:30 ` Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 2/8] ACPICA: Tables: Invoke acpi_tb_validate_tableby_index() instead of acpi_get_table_by_index() Lv Zheng
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:30 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
This patch adds an error message to complain a driver bug that the
early mappings are not unmapped by the drivers. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
drivers/acpi/acpica/tbxface.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 326df65..5700e72 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -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();
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 2/8] ACPICA: Tables: Invoke acpi_tb_validate_tableby_index() instead of acpi_get_table_by_index()
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 1/8] ACPICA: Tables: Add an error message complaining driver bugs Lv Zheng
@ 2016-03-24 8:30 ` Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 3/8] ACPICA: Tables: Fix an issue the dynamic table loading contains code with MTX_TABLES released Lv Zheng
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:30 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
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.
Link: https://bugs.acpica.org/show_bug.cgi?id=1253
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
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(-)
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 848ad3a..9310cb4 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -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
*/
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 5aa1c5f..71d700a 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -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);
}
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 4cc9d98..22eea92 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -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;
}
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index a1d177d..98102af 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -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,
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index f631a47..de76a1d 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -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);
}
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 9240c76..b64fbe3 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -78,16 +78,16 @@ acpi_status acpi_tb_initialize_facs(void)
} else if (acpi_gbl_FADT.Xfacs &&
(!acpi_gbl_FADT.facs
|| !acpi_gbl_use32_bit_facs_addresses)) {
- (void)acpi_get_table_by_index(acpi_gbl_xfacs_index,
- ACPI_CAST_INDIRECT_PTR(struct
- acpi_table_header,
- &facs));
+ (void)acpi_tb_validate_table_by_index(acpi_gbl_xfacs_index,
+ ACPI_CAST_INDIRECT_PTR
+ (struct acpi_table_header,
+ &facs));
acpi_gbl_FACS = facs;
} else if (acpi_gbl_FADT.facs) {
- (void)acpi_get_table_by_index(acpi_gbl_facs_index,
- ACPI_CAST_INDIRECT_PTR(struct
- acpi_table_header,
- &facs));
+ (void)acpi_tb_validate_table_by_index(acpi_gbl_facs_index,
+ ACPI_CAST_INDIRECT_PTR
+ (struct acpi_table_header,
+ &facs));
acpi_gbl_FACS = facs;
}
@@ -407,3 +407,60 @@ u8 acpi_is_valid_signature(char *signature)
return (TRUE);
}
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_tb_validate_table_by_index
+ *
+ * PARAMETERS: table_index - Table index
+ * out_table - Where the pointer to the table is returned
+ *
+ * RETURN: Status and pointer to the requested table
+ *
+ * DESCRIPTION: Obtain a table by an index into the global table list. Used
+ * internally only as the table will be put into the state of
+ * "VALIDATED" by internal references.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_validate_table_by_index(u32 table_index,
+ struct acpi_table_header ** out_table)
+{
+ acpi_status status = AE_OK;
+ struct acpi_table_desc *table_desc;
+
+ ACPI_FUNCTION_TRACE(acpi_tb_validate_table_by_index);
+
+ /* Parameter validation */
+
+ if (!out_table) {
+ return_ACPI_STATUS(AE_BAD_PARAMETER);
+ }
+
+ (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
+
+ /* Validate index */
+
+ if (table_index >= acpi_gbl_root_table_list.current_table_count) {
+ status = AE_BAD_PARAMETER;
+ goto unlock_and_exit;
+ }
+ table_desc = &acpi_gbl_root_table_list.tables[table_index];
+
+ if (!(table_desc->flags & ACPI_TABLE_IS_VALIDATED)) {
+
+ /* Table is not validated, validate it */
+
+ status = acpi_tb_validate_table(table_desc);
+ if (ACPI_FAILURE(status)) {
+ goto unlock_and_exit;
+ }
+ table_desc->flags |= ACPI_TABLE_IS_VALIDATED;
+ }
+ *out_table = table_desc->pointer;
+
+unlock_and_exit:
+ (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
+ return_ACPI_STATUS(status);
+}
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 5700e72..ef2c5f9 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -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
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index c19700e..9513849 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -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)
/*
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 3/8] ACPICA: Tables: Fix an issue the dynamic table loading contains code with MTX_TABLES released
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 1/8] ACPICA: Tables: Add an error message complaining driver bugs Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 2/8] ACPICA: Tables: Invoke acpi_tb_validate_tableby_index() instead of acpi_get_table_by_index() Lv Zheng
@ 2016-03-24 8:30 ` Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 4/8] ACPICA: Tables: Cleanup acpi_tb_copy_dsdt() Lv Zheng
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:30 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
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.
Link: https://bugs.acpica.org/show_bug.cgi?id=1254
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
drivers/acpi/acpica/exconfig.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 98102af..3418c90 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -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);
}
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 4/8] ACPICA: Tables: Cleanup acpi_tb_copy_dsdt()
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
` (2 preceding siblings ...)
2016-03-24 8:30 ` [RFC PATCH 3/8] ACPICA: Tables: Fix an issue the dynamic table loading contains code with MTX_TABLES released Lv Zheng
@ 2016-03-24 8:30 ` Lv Zheng
2016-03-24 8:30 ` [RFC PATCH 5/8] ACPICA: Tables: Remove acpi_tb_install_fixed_table() Lv Zheng
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:30 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
This patch cleans up acpi_tb_copy_dsdt(), removing a useless parameter.
No functional change. Lv Zheng.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
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(-)
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 9310cb4..6f08c9c 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -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,
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index b64fbe3..ec6ce69 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -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);
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index ac71abc..9d3cf30 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -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;
}
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 5/8] ACPICA: Tables: Remove acpi_tb_install_fixed_table()
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
` (3 preceding siblings ...)
2016-03-24 8:30 ` [RFC PATCH 4/8] ACPICA: Tables: Cleanup acpi_tb_copy_dsdt() Lv Zheng
@ 2016-03-24 8:30 ` Lv Zheng
2016-03-24 8:31 ` [RFC PATCH 6/8] ACPICA: Tables: Correct function namings Lv Zheng
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:30 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
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.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
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(-)
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 6f08c9c..06d4d3d 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -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);
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 635d951..2d24c4b 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -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);
}
}
}
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 4dc6108..f9f9b41 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -157,68 +157,6 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
/*******************************************************************************
*
- * FUNCTION: acpi_tb_install_fixed_table
- *
- * PARAMETERS: address - Physical address of DSDT or FACS
- * signature - Table signature, NULL if no need to
- * match
- * table_index - Where the table index is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data
- * structure.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_tb_install_fixed_table(acpi_physical_address address,
- char *signature, u32 *table_index)
-{
- struct acpi_table_desc new_table_desc;
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(tb_install_fixed_table);
-
- if (!address) {
- ACPI_ERROR((AE_INFO,
- "Null physical address for ACPI table [%s]",
- signature));
- return (AE_NO_MEMORY);
- }
-
- /* Fill a table descriptor for validation */
-
- status = acpi_tb_acquire_temp_table(&new_table_desc, address,
- ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
- if (ACPI_FAILURE(status)) {
- ACPI_ERROR((AE_INFO,
- "Could not acquire table length at %8.8X%8.8X",
- ACPI_FORMAT_UINT64(address)));
- return_ACPI_STATUS(status);
- }
-
- /* Validate and verify a table before installation */
-
- status = acpi_tb_verify_temp_table(&new_table_desc, signature);
- if (ACPI_FAILURE(status)) {
- goto release_and_exit;
- }
-
- /* Add the table to the global root table list */
-
- acpi_tb_install_table_with_override(&new_table_desc, TRUE, table_index);
-
-release_and_exit:
-
- /* Release the temporary table descriptor */
-
- acpi_tb_release_temp_table(&new_table_desc);
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
* FUNCTION: acpi_tb_install_standard_table
*
* PARAMETERS: address - Address of the table (might be a virtual
@@ -230,8 +168,7 @@ release_and_exit:
*
* RETURN: Status
*
- * DESCRIPTION: This function is called to install an ACPI table that is
- * neither DSDT nor FACS (a "standard" table.)
+ * DESCRIPTION: This function is called to verify and install an ACPI table.
* When this function is called by "Load" or "LoadTable" opcodes,
* or by acpi_load_table() API, the "Reload" parameter is set.
* After sucessfully returning from this function, table is
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 6/8] ACPICA: Tables: Correct function namings
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
` (4 preceding siblings ...)
2016-03-24 8:30 ` [RFC PATCH 5/8] ACPICA: Tables: Remove acpi_tb_install_fixed_table() Lv Zheng
@ 2016-03-24 8:31 ` Lv Zheng
2016-03-24 8:31 ` [RFC PATCH 7/8] ACPICA: Tables: Add acpi_uninstall_table() to remove ACPI tables Lv Zheng
2016-03-24 8:31 ` [RFC PATCH 8/8] ACPICA: Tables: Add acpi_unload_table() to unload definition block tables Lv Zheng
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:31 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
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.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
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(-)
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 06d4d3d..5e4d780 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -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);
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 3418c90..55039c4 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -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)) {
diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
index 7da79ce..87ae305 100644
--- a/drivers/acpi/acpica/tbdata.c
+++ b/drivers/acpi/acpica/tbdata.c
@@ -51,7 +51,7 @@ ACPI_MODULE_NAME("tbdata")
/*******************************************************************************
*
- * FUNCTION: acpi_tb_init_table_descriptor
+ * FUNCTION: acpi_tb_install_table
*
* PARAMETERS: table_desc - Table descriptor
* address - Physical address of the table
@@ -60,13 +60,14 @@ ACPI_MODULE_NAME("tbdata")
*
* RETURN: None
*
- * DESCRIPTION: Initialize a new table descriptor
+ * DESCRIPTION: This function is called to install the table, the returned
+ * table descriptor is in "INSTALLED" state.
*
******************************************************************************/
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)
{
/*
@@ -82,6 +83,41 @@ acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
/*******************************************************************************
*
+ * FUNCTION: acpi_tb_uninstall_table
+ *
+ * PARAMETERS: table_desc - Table descriptor
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Uninstall one internal ACPI table, this is the inverse of
+ * acpi_tb_install_table().
+ *
+ ******************************************************************************/
+
+void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
+{
+
+ ACPI_FUNCTION_TRACE(tb_uninstall_table);
+
+ /* Table must be installed */
+
+ if (!table_desc->address) {
+ return_VOID;
+ }
+
+ acpi_tb_invalidate_table(table_desc);
+
+ if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
+ ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
+ ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address));
+ }
+
+ table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
+ return_VOID;
+}
+
+/*******************************************************************************
+ *
* FUNCTION: acpi_tb_acquire_table
*
* PARAMETERS: table_desc - Table descriptor
@@ -205,8 +241,7 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
return (AE_NO_MEMORY);
}
- acpi_tb_init_table_descriptor(table_desc, address, flags,
- table_header);
+ acpi_tb_install_table(table_desc, address, flags, table_header);
acpi_os_unmap_memory(table_header,
sizeof(struct acpi_table_header));
return (AE_OK);
@@ -220,8 +255,7 @@ acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
return (AE_NO_MEMORY);
}
- acpi_tb_init_table_descriptor(table_desc, address, flags,
- table_header);
+ acpi_tb_install_table(table_desc, address, flags, table_header);
return (AE_OK);
default:
@@ -343,7 +377,7 @@ acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
* Note that Length contains the size of the mapping after invoking
* this work around, this value is required by
* acpi_tb_release_temp_table().
- * We can do this because in acpi_init_table_descriptor(), the Length
+ * We can do this because in acpi_tb_install_table(), the Length
* field of the installed descriptor is filled with the actual
* table length obtaining from the table header.
*/
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 2d24c4b..cc2b774 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -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);
}
}
}
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index f9f9b41..2f6a5fb 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -136,10 +136,9 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
acpi_tb_override_table(new_table_desc);
}
- acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i],
- new_table_desc->address,
- new_table_desc->flags,
- new_table_desc->pointer);
+ acpi_tb_install_table(&acpi_gbl_root_table_list.tables[i],
+ new_table_desc->address, new_table_desc->flags,
+ new_table_desc->pointer);
acpi_tb_print_table_header(new_table_desc->address,
new_table_desc->pointer);
@@ -157,7 +156,7 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
/*******************************************************************************
*
- * FUNCTION: acpi_tb_install_standard_table
+ * FUNCTION: acpi_tb_verify_and_install_table
*
* PARAMETERS: address - Address of the table (might be a virtual
* address depending on the table_flags)
@@ -177,9 +176,9 @@ acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc,
******************************************************************************/
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)
{
u32 i;
acpi_status status = AE_OK;
@@ -382,46 +381,11 @@ finish_override:
* Replace the original table descriptor and keep its state as
* "VALIDATED".
*/
- acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address,
- new_table_desc.flags,
- new_table_desc.pointer);
+ acpi_tb_install_table(old_table_desc, new_table_desc.address,
+ new_table_desc.flags, new_table_desc.pointer);
acpi_tb_validate_temp_table(old_table_desc);
/* Release the temporary table descriptor */
acpi_tb_release_temp_table(&new_table_desc);
}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_tb_uninstall_table
- *
- * PARAMETERS: table_desc - Table descriptor
- *
- * RETURN: None
- *
- * DESCRIPTION: Delete one internal ACPI table
- *
- ******************************************************************************/
-
-void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
-{
-
- ACPI_FUNCTION_TRACE(tb_uninstall_table);
-
- /* Table must be installed */
-
- if (!table_desc->address) {
- return_VOID;
- }
-
- acpi_tb_invalidate_table(table_desc);
-
- if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
- ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
- ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address));
- }
-
- table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
- return_VOID;
-}
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index ec6ce69..5956c4a 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -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.
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 9d3cf30..47b8b82 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -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)) {
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 7/8] ACPICA: Tables: Add acpi_uninstall_table() to remove ACPI tables
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
` (5 preceding siblings ...)
2016-03-24 8:31 ` [RFC PATCH 6/8] ACPICA: Tables: Correct function namings Lv Zheng
@ 2016-03-24 8:31 ` Lv Zheng
2016-03-24 8:31 ` [RFC PATCH 8/8] ACPICA: Tables: Add acpi_unload_table() to unload definition block tables Lv Zheng
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:31 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
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.
Original-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
drivers/acpi/acpica/tbxfload.c | 42 ++++++++++++++++++++++++++++++++++++----
drivers/acpi/osl.c | 3 ++-
include/acpi/acpixf.h | 4 +++-
3 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index 47b8b82..a4475f3 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -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
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index bef06c9..e8c0737 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -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;
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index cef1223..e41a99c 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -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))
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread* [RFC PATCH 8/8] ACPICA: Tables: Add acpi_unload_table() to unload definition block tables
2016-03-24 8:30 [RFC PATCH 0/8] ACPICA: Tables: Table cleanup and new APIs Lv Zheng
` (6 preceding siblings ...)
2016-03-24 8:31 ` [RFC PATCH 7/8] ACPICA: Tables: Add acpi_uninstall_table() to remove ACPI tables Lv Zheng
@ 2016-03-24 8:31 ` Lv Zheng
7 siblings, 0 replies; 9+ messages in thread
From: Lv Zheng @ 2016-03-24 8:31 UTC (permalink / raw)
To: Rafael J. Wysocki, Rafael J. Wysocki, Len Brown
Cc: Lv Zheng, Lv Zheng, linux-acpi
This patch adds acpi_unload_table() API and adds parameter in
acpi_load_table() to be used for the new acpi_unload_table() API.
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
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(-)
diff --git a/drivers/acpi/acpica/dbfileio.c b/drivers/acpi/acpica/dbfileio.c
index 4832879..283565c 100644
--- a/drivers/acpi/acpica/dbfileio.c
+++ b/drivers/acpi/acpica/dbfileio.c
@@ -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
diff --git a/drivers/acpi/acpica/tbxfload.c b/drivers/acpi/acpica/tbxfload.c
index a4475f3..042afb7 100644
--- a/drivers/acpi/acpica/tbxfload.c
+++ b/drivers/acpi/acpica/tbxfload.c
@@ -335,6 +335,7 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_uninstall_table)
*
* PARAMETERS: table - Pointer to a buffer containing the ACPI
* table to be loaded.
+ * out_table_index - Where the table index is returned
*
* RETURN: Status
*
@@ -345,7 +346,8 @@ ACPI_EXPORT_SYMBOL_INIT(acpi_uninstall_table)
* to ensure that the table is not deleted or unmapped.
*
******************************************************************************/
-acpi_status acpi_load_table(struct acpi_table_header *table)
+acpi_status
+acpi_load_table(struct acpi_table_header *table, u32 *out_table_index)
{
acpi_status status;
u32 table_index;
@@ -354,6 +356,9 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
/* Parameter validation */
+ if (out_table_index) {
+ *out_table_index = ACPI_INVALID_TABLE_INDEX;
+ }
if (!table) {
return_ACPI_STATUS(AE_BAD_PARAMETER);
}
@@ -400,6 +405,9 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
}
unlock_and_exit:
+ if (out_table_index && ACPI_SUCCESS(status)) {
+ *out_table_index = table_index;
+ }
(void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
return_ACPI_STATUS(status);
}
@@ -476,40 +484,75 @@ acpi_status acpi_unload_parent_table(acpi_handle object)
break;
}
- /* Ensure the table is actually loaded */
+ (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
+ status = acpi_unload_table(i);
+ (void)acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
+ break;
+ }
- if (!acpi_tb_is_table_loaded(i)) {
- status = AE_NOT_EXIST;
- break;
- }
+ (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
+ return_ACPI_STATUS(status);
+}
- /* Invoke table handler if present */
+ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
- if (acpi_gbl_table_handler) {
- (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
- acpi_gbl_root_table_list.
- tables[i].pointer,
- acpi_gbl_table_handler_context);
- }
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_unload_table
+ *
+ * PARAMETERS: table_index - The table index
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Unload a definition block table.
+ *
+ ******************************************************************************/
+acpi_status acpi_unload_table(u32 table_index)
+{
+ acpi_status status;
- /*
- * Delete all namespace objects owned by this table. Note that
- * these objects can appear anywhere in the namespace by virtue
- * of the AML "Scope" operator. Thus, we need to track ownership
- * by an ID, not simply a position within the hierarchy.
- */
- status = acpi_tb_delete_namespace_by_owner(i);
- if (ACPI_FAILURE(status)) {
- break;
- }
+ ACPI_FUNCTION_TRACE(acpi_unload_table);
- status = acpi_tb_release_owner_id(i);
- acpi_tb_set_table_loaded_flag(i, FALSE);
- break;
+ /* Must acquire the interpreter lock during this operation */
+
+ status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
+ if (ACPI_FAILURE(status)) {
+ return_ACPI_STATUS(status);
+ }
+
+ /* Ensure the table is actually loaded */
+
+ if (!acpi_tb_is_table_loaded(table_index)) {
+ status = AE_NOT_EXIST;
+ goto error_exit;
}
+ /* Invoke table handler if present */
+
+ if (acpi_gbl_table_handler) {
+ (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
+ acpi_gbl_root_table_list.
+ tables[table_index].pointer,
+ acpi_gbl_table_handler_context);
+ }
+
+ /*
+ * Delete all namespace objects owned by this table. Note that
+ * these objects can appear anywhere in the namespace by virtue
+ * of the AML "Scope" operator. Thus, we need to track ownership
+ * by an ID, not simply a position within the hierarchy.
+ */
+ status = acpi_tb_delete_namespace_by_owner(table_index);
+ if (ACPI_FAILURE(status)) {
+ goto error_exit;
+ }
+
+ status = acpi_tb_release_owner_id(table_index);
+ acpi_tb_set_table_loaded_flag(table_index, FALSE);
+
+error_exit:
(void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
return_ACPI_STATUS(status);
}
-ACPI_EXPORT_SYMBOL(acpi_unload_parent_table)
+ACPI_EXPORT_SYMBOL(acpi_unload_table)
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 339bce0..57d627d 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -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);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index e41a99c..bb2d69b 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -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))
--
1.7.10
^ permalink raw reply related [flat|nested] 9+ messages in thread