Skip to contentSkip to conversation

ACPICA: 20140325 Release

PATCH In review Lv Zheng 2 participants 30 messages Apr 4, 2014 – Apr 8, 2014

Subsystems (3)
lore
Share & tools
lore

Lv Zheng

author
#0 lore raw

cover ACPICA: 20140325 Release

The 20140325 ACPICA kernel resident system updates are linuxized based on the pm/linux-next branch.

The patch set has passed the following build/boot tests. Build tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. i386 + allyes + CONFIG_ACPI=y
3. i386 + default + COFNIG_ACPI=n
4. i386 + allyes + CONFIG_ACPI=n
5. x86_64 + default + COFNIG_ACPI=y
6. x86_64 + allyes + CONFIG_ACPI=y
7. x86_64 + default + COFNIG_ACPI=n
8. x86_64 + allyes + CONFIG_ACPI=n
Boot tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. x86_64 + default + COFNIG_ACPI=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "HP Compaq 8200 Elite SFF PC"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64 All drivers/acpi configurations
All platform drivers
All ACPI drivers
4 DRM drivers that implement ACPI opregion
All buses with ACPI bindings
All cpufreq configurations
All xen configurations
All ACPI tabln drivers
4. allyes: kernel configuration generated by allyesconfig.

After applying this series, the divergence result is:
1089 Lines, 38.9 Kbytes.

Bob Moore (10):
ACPICA: Add EXPORT_SYMBOL macros for install/remove SCI handler
interfaces.
ACPICA: Update comments for ACPICA name - no functional change.
ACPICA: gcc-specific: Fix possible issue with the strchr function.
ACPICA: Unload operator: Emit a warning if and when it is ever used.
ACPICA: Disassembler: Add support to decode _HID and _CID values.
ACPICA: Disassembler: Add decoding of Notify() values.
ACPICA: Add a missing field for debug dump of mutex objects.
ACPICA: Table Manager: Misc cleanup and renames, no functional
change.
ACPICA: Table Manager: Split tbinstal.c into two files.
ACPICA: Update version to 20140325.

Colin Ian King (1):
ACPICA: Linux-specific header: Add support for PPC64 compilation.

David Binderman (1):
ACPICA: utstring: Check array index bound before use.

Lv Zheng (16):
ACPICA: Update use of acpi_os_wait_events_complete interface.
ACPI: Merge divergence of the commmit: ACPICA: Linux-specific header:
Update support for Linux/acpi applications.
ACPICA: Remove indent divergences to reduce the difficulties of
maintaining the revised ACPICA commits.
ACPICA: Tables: Fix the issues in handling virtual addressed tables.
ACPICA: Tables: Fix the issue that multiple ACPI_FREE()s are invoked
for same pointer around acpi_tb_add_table().
ACPICA: Tables: Cleanup split INSTALLED/VALIDATED table state logics.
ACPICA: Tables: Fix the issue that table validations are not
balanced.
ACPICA: Tables: Fix the issue that table checksums are not always
verified before installation.
ACPICA: Tables: Cleanup ACPI_TABLE_ORIGIN_xxx flags.
ACPICA: Tables: Avoid SSDT installation when
acpi_gbl_disable_ssdt_table_load is specified.
ACPICA: Tables: Add acpi_install_table() API to be invoked by OSPM
early table installation.
ACPICA: acpidump: Add support to generate acpidump release.
ACPICA: acpidump: Update new structures and add missing file.
ACPICA: acpidump: Update Makefile to use new acpidump.
ACPICA: acpidump: Remove old acpidump source.
ACPICA: acpidump: Update manual file.

 Documentation/kernel-parameters.txt                |   10 +-
 drivers/acpi/acpica/Makefile                       |    1 +
 drivers/acpi/acpica/acapps.h                       |  170 +++
 drivers/acpi/acpica/acglobal.h                     |    9 +-
 drivers/acpi/acpica/aclocal.h                      |    8 +-
 drivers/acpi/acpica/actables.h                     |   60 +-
 drivers/acpi/acpica/acutils.h                      |   10 +-
 drivers/acpi/acpica/evmisc.c                       |    3 +-
 drivers/acpi/acpica/evsci.c                        |    2 +-
 drivers/acpi/acpica/evxface.c                      |   61 +-
 drivers/acpi/acpica/exconfig.c                     |   82 +-
 drivers/acpi/acpica/exdump.c                       |    4 +-
 drivers/acpi/acpica/tbdata.c                       |  723 +++++++++++
 drivers/acpi/acpica/tbfadt.c                       |   10 +-
 drivers/acpi/acpica/tbfind.c                       |    4 +-
 drivers/acpi/acpica/tbinstal.c                     |  837 +++++--------
 drivers/acpi/acpica/tbutils.c                      |  171 +--
 drivers/acpi/acpica/tbxface.c                      |   18 +-
 drivers/acpi/acpica/tbxfload.c                     |   87 +-
 drivers/acpi/acpica/utdecode.c                     |   74 +-
 drivers/acpi/acpica/utstring.c                     |    2 +-
 drivers/acpi/osl.c                                 |   11 +-
 include/acpi/acpixf.h                              |    7 +-
 include/acpi/actbl.h                               |   11 +-
 include/acpi/platform/acgcc.h                      |   11 +
 include/acpi/platform/aclinux.h                    |    5 +-
 tools/power/acpi/Makefile                          |   26 +-
 tools/power/acpi/common/cmfsize.c                  |  101 ++
 tools/power/acpi/common/getopt.c                   |  239 ++++
 tools/power/acpi/man/acpidump.8                    |   85 +-
 .../acpi/os_specific/service_layers/oslinuxtbl.c   | 1275 ++++++++++++++++++++
 .../acpi/os_specific/service_layers/osunixdir.c    |  204 ++++
 .../acpi/os_specific/service_layers/osunixmap.c    |  151 +++
 tools/power/acpi/tools/acpidump/acpidump.c         |  559 ---------
 tools/power/acpi/tools/acpidump/acpidump.h         |  131 ++
 tools/power/acpi/tools/acpidump/apdump.c           |  451 +++++++
 tools/power/acpi/tools/acpidump/apfiles.c          |  228 ++++
 tools/power/acpi/tools/acpidump/apmain.c           |  340 ++++++
 38 files changed, 4780 insertions(+), 1401 deletions(-)
 create mode 100644 drivers/acpi/acpica/acapps.h
 create mode 100644 drivers/acpi/acpica/tbdata.c
 create mode 100644 tools/power/acpi/common/cmfsize.c
 create mode 100644 tools/power/acpi/common/getopt.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixdir.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixmap.c
 delete mode 100644 tools/power/acpi/tools/acpidump/acpidump.c
 create mode 100644 tools/power/acpi/tools/acpidump/acpidump.h
 create mode 100644 tools/power/acpi/tools/acpidump/apdump.c
 create mode 100644 tools/power/acpi/tools/acpidump/apfiles.c
 create mode 100644 tools/power/acpi/tools/acpidump/apmain.c
Signature · 1 line
1.7.10
author
#1 lore raw

PATCH 1/28 ACPICA: Add EXPORT_SYMBOL macros for install/remove SCI handler interfaces.

From: Bob Moore <[email protected]>

These recently added interfaces did not have these macros, used by some hosts.

---
 drivers/acpi/acpica/evxface.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/acpica/evxface.c +4 -2
index a734b27..a41a0e7 100644
@@ -457,6 +457,8 @@ exit:
 	return_ACPI_STATUS(status);
 }
 
+ACPI_EXPORT_SYMBOL(acpi_install_sci_handler)
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_remove_sci_handler
@@ -468,7 +470,6 @@ exit:
  * DESCRIPTION: Remove a handler for a System Control Interrupt.
  *
  ******************************************************************************/
-
 acpi_status acpi_remove_sci_handler(acpi_sci_handler address)
 {
 	struct acpi_sci_handler_info *prev_sci_handler;
@@ -522,6 +523,8 @@ unlock_and_exit:
 	return_ACPI_STATUS(status);
 }
 
+ACPI_EXPORT_SYMBOL(acpi_remove_sci_handler)
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_install_global_event_handler
@@ -537,7 +540,6 @@ unlock_and_exit:
  *              Can be used to update event counters, etc.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_install_global_event_handler(acpi_gbl_event_handler handler, void *context)
 {
Signature · 1 line
1.7.10
author
#2 lore raw

PATCH 2/28 ACPICA: utstring: Check array index bound before use.

In reply to Lv Zheng

From: David Binderman <[email protected]>

ACPICA BZ 1077. David Binderman.

---
 drivers/acpi/acpica/utstring.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/utstring.c +1 -1
index 7721933..6dc54b3 100644
@@ -353,7 +353,7 @@ void acpi_ut_print_string(char *string, u16 max_length)
 	}
 
 	acpi_os_printf("\"");
-	for (i = 0; string[i] && (i < max_length); i++) {
+	for (i = 0; (i < max_length) && string[i]; i++) {
 
 		/* Escape sequences */
 
Signature · 1 line
1.7.10
author
#3 lore raw

PATCH 3/28 ACPICA: Update comments for ACPICA name - no functional change.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Change all comments that contain the string "ACPI CA" to "ACPICA" so that the name is standard across the entire source base.

---
 drivers/acpi/acpica/acglobal.h |    4 ++--
 drivers/acpi/acpica/evsci.c    |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/acpica/acglobal.h +2 -2
index 49bbc71..11ce629 100644
@@ -103,8 +103,8 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_auto_serialize_methods, TRUE);
 
 /*
  * Create the predefined _OSI method in the namespace? Default is TRUE
- * because ACPI CA is fully compatible with other ACPI implementations.
- * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
+ * because ACPICA is fully compatible with other ACPI implementations.
+ * Changing this will revert ACPICA (and machine ASL) to pre-OSI behavior.
  */
 ACPI_INIT_GLOBAL(u8, acpi_gbl_create_osi_method, TRUE);
 
drivers/acpi/acpica/evsci.c +1 -1
index 4d8a709..29630e3 100644
@@ -117,7 +117,7 @@ static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
 	ACPI_FUNCTION_TRACE(ev_sci_xrupt_handler);
 
 	/*
-	 * We are guaranteed by the ACPI CA initialization/shutdown code that
+	 * We are guaranteed by the ACPICA initialization/shutdown code that
 	 * if this interrupt handler is installed, ACPI is enabled.
 	 */
 
Signature · 1 line
1.7.10
author
#4 lore raw

PATCH 4/28 ACPICA: gcc-specific: Fix possible issue with the strchr function.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Some versions of gcc implement strchr via a macro, which either contains bugs or can provoke a bug in the compiler. This change fixes a possible compile-time error when using this function. The problem is usually seen when compiling the getopt.c module.

---
 include/acpi/platform/acgcc.h |   11 +++++++++++
 1 file changed, 11 insertions(+)
include/acpi/platform/acgcc.h +11 -0
index a476b91..384875d 100644
@@ -64,4 +64,15 @@
  */
 #define ACPI_UNUSED_VAR __attribute__ ((unused))
 
+/*
+ * Some versions of gcc implement strchr() with a buggy macro. So,
+ * undef it here. Prevents error messages of this form (usually from the
+ * file getopt.c):
+ *
+ * error: logical '&&' with non-zero constant will always evaluate as true
+ */
+#ifdef strchr
+#undef strchr
+#endif
+
 #endif				/* __ACGCC_H__ */
Signature · 1 line
1.7.10
author
#5 lore raw

PATCH 5/28 ACPICA: Unload operator: Emit a warning if and when it is ever used.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

We would like to see the ASL for any machine that uses this operator, so emit at least a warning to hopefully draw some attention.

---
 drivers/acpi/acpica/exconfig.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/acpi/acpica/exconfig.c +7 -0
index 8ba1464..1b734eb 100644
@@ -576,6 +576,13 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
 	ACPI_FUNCTION_TRACE(ex_unload_table);
 
 	/*
+	 * Temporarily emit a warning so that the ASL for the machine can be
+	 * hopefully obtained. This is to say that the Unload() operator is
+	 * extremely rare if not completely unused.
+	 */
+	ACPI_WARNING((AE_INFO, "Received request to unload an ACPI table"));
+
+	/*
 	 * Validate the handle
 	 * Although the handle is partially validated in acpi_ex_reconfiguration()
 	 * when it calls acpi_ex_resolve_operands(), the handle is more completely
Signature · 1 line
1.7.10
author
#6 lore raw

PATCH 6/28 ACPICA: Disassembler: Add support to decode _HID and _CID values.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

For _HID and _CID, the disassembler will emit a string that describes the device if the _HID/_CID value is recognized. acpihelp updated also. acpihelp will now search for a specific ID as well as displaying the list of "known" (to ACPICA) IDs.

This patch does not affect Linux kernel behavior as the disassembler and the acpihelp are not shipped in Linux kernel.

---
 drivers/acpi/acpica/acglobal.h |    1 +
 drivers/acpi/acpica/aclocal.h  |    8 +++++++-
 drivers/acpi/acpica/acutils.h  |    7 +++++++
 3 files changed, 15 insertions(+), 1 deletion(-)
drivers/acpi/acpica/acglobal.h +1 -0
index 11ce629..71bb5b5 100644
@@ -509,5 +509,6 @@ ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
  ****************************************************************************/
 
 extern const struct ah_predefined_name asl_predefined_info[];
+extern const AH_DEVICE_ID asl_device_ids[];
 
 #endif				/* __ACGLOBAL_H__ */
drivers/acpi/acpica/aclocal.h +7 -1
index 52a21da..f68cb60 100644
@@ -733,7 +733,8 @@ union acpi_parse_value {
 #define ACPI_DASM_MATCHOP               0x06	/* Parent opcode is a Match() operator */
 #define ACPI_DASM_LNOT_PREFIX           0x07	/* Start of a Lnot_equal (etc.) pair of opcodes */
 #define ACPI_DASM_LNOT_SUFFIX           0x08	/* End  of a Lnot_equal (etc.) pair of opcodes */
-#define ACPI_DASM_IGNORE                0x09	/* Not used at this time */
+#define ACPI_DASM_HID_STRING            0x09	/* String is a _HID or _CID */
+#define ACPI_DASM_IGNORE                0x0A	/* Not used at this time */
 
 /*
  * Generic operation (for example:  If, While, Store)
@@ -1147,4 +1148,9 @@ struct ah_predefined_name {
 #endif
 };
 
+struct ah_device_id {
+	char *name;
+	char *description;
+};
+
 #endif				/* __ACLOCAL_H__ */
drivers/acpi/acpica/acutils.h +7 -0
index ceeec0b..5328610 100644
@@ -737,4 +737,11 @@ acpi_ut_method_error(const char *module_name,
 		     struct acpi_namespace_node *node,
 		     const char *path, acpi_status lookup_status);
 
+/*
+ * Utility functions for ACPI names and IDs
+ */
+const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg);
+
+const AH_DEVICE_ID *acpi_ah_match_hardware_id(char *hid);
+
 #endif				/* _ACUTILS_H */
Signature · 1 line
1.7.10
author
#7 lore raw

PATCH 7/28 ACPICA: Disassembler: Add decoding of Notify() values.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

For Notify operators, displays a comment that describe the meaning of the notify value.

This patch updates the debugging information that is enabled for CONFIG_ACPI_DEBUG builds.

---
 drivers/acpi/acpica/acutils.h  |    3 +-
 drivers/acpi/acpica/evmisc.c   |    3 +-
 drivers/acpi/acpica/utdecode.c |   74 ++++++++++++++++++++++++++++++++++------
 3 files changed, 66 insertions(+), 14 deletions(-)
drivers/acpi/acpica/acutils.h +1 -2
index 5328610..2cf8d2c 100644
@@ -176,8 +176,7 @@ acpi_status acpi_ut_init_globals(void);
 
 char *acpi_ut_get_mutex_name(u32 mutex_id);
 
-const char *acpi_ut_get_notify_name(u32 notify_value);
-
+const char *acpi_ut_get_notify_name(u32 notify_value, acpi_object_type type);
 #endif
 
 char *acpi_ut_get_type_name(acpi_object_type type);
drivers/acpi/acpica/evmisc.c +2 -1
index 5d594eb..24ea342 100644
@@ -167,7 +167,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
 			  "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n",
 			  acpi_ut_get_node_name(node),
 			  acpi_ut_get_type_name(node->type), notify_value,
-			  acpi_ut_get_notify_name(notify_value), node));
+			  acpi_ut_get_notify_name(notify_value, ACPI_TYPE_ANY),
+			  node));
 
 	status = acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch,
 				 info);
drivers/acpi/acpica/utdecode.c +63 -11

93 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#8 lore raw

PATCH 8/28 ACPICA: Update use of acpi_os_wait_events_complete interface.

In reply to Lv Zheng

This patch cleans up all of the acpi_os_wait_events_complete() invocations to make it to be invoked inside of ACPICA in the way to accommodate Linux's work queue implementation.

According to the report, current Linux kernel code is facing a boot time race issue in the acpi_remove_notify_handler(). This is because:
Linux is using work queues to implement a deferred handler call environment while ACPICA expects OSPM to implement acpi_os_wait_events_complete() using wait queues. The position to invoke a "waiter" is not suitable for a "flusher" as new invocations can be scheduled after this position and before the deletion of the handler from its management container.

Since the following commit has deleted acpi_os_wait_events_complete() parameters, it thus might not be possible for OSPM to achieve a safe removal using wait queues. This requires ACPICA to be changed accordingly to "flush" handlers rather than "wait" them to be drain up:

Commit: 5ff986a2a9db11858247b71fe242fe17617229aa
Date: Wed, 16 May 2012 13:36:07 -0700
Subject: Introduce acpi_os_wait_events_complete interface.

This interface will block until asynchronous events like notifies and GPEs are complete. Within ACPICA, it is called before a notify or GPE handler is removed. ACPICA BZ 868.

This patch fixes this issue by invoking acpi_os_wait_events_complete() in the way to "flush" things - it thus should be put to the position after handler is removed from its management container but before it is destructed.

The technical concerns are:
1. MTX_NAMESPACE is used to protect things that acpi_os_wait_events_complete() might be waiting for, thus MTX_NAMESPACE must be unlocked before invoking acpi_os_wait_events_complete().
2. MTX_NAMESPACE is also used to implement the serialization of acpi_install_notify_handler() and acpi_remove_notify_handler(). This patch changes this logic, thus if there are many acpi_install/remove_notify_handler() invoked in parallel, the acpi_os_wait_events_complete() might face the races which could cause it never running to an end. Normally this will require additional code to implement a separate locking facility which is not implemented due to 3.
3. Given ACPICA users will always invoke acpi_install_notify_handler() once during Linux module/device initialization and invoke acpi_remove_notify_handler() once during module/device finalization, problem stated in 2 will not happen in Linux environment due to the mutual exclusive module/device existence, this fix thus is sufficient.
Same concerns can apply to acpi_install/remove_gpe_handler(). Reported and
tested: Ronald Vink. Fixed: Lv Zheng.

---
 drivers/acpi/acpica/evxface.c |   55 +++++++++++++++++++++++++++--------------
 1 file changed, 36 insertions(+), 19 deletions(-)
drivers/acpi/acpica/evxface.c +36 -19
index a41a0e7..11e5803 100644
@@ -239,7 +239,7 @@ acpi_remove_notify_handler(acpi_handle device,
 	union acpi_operand_object *obj_desc;
 	union acpi_operand_object *handler_obj;
 	union acpi_operand_object *previous_handler_obj;
-	acpi_status status;
+	acpi_status status = AE_OK;
 	u32 i;
 
 	ACPI_FUNCTION_TRACE(acpi_remove_notify_handler);
@@ -251,20 +251,17 @@ acpi_remove_notify_handler(acpi_handle device,
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	/* Make sure all deferred notify tasks are completed */
-
-	acpi_os_wait_events_complete();
-
-	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
-	if (ACPI_FAILURE(status)) {
-		return_ACPI_STATUS(status);
-	}
-
 	/* Root Object. Global handlers are removed here */
 
 	if (device == ACPI_ROOT_OBJECT) {
 		for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
 			if (handler_type & (i + 1)) {
+				status =
+				    acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+				if (ACPI_FAILURE(status)) {
+					return_ACPI_STATUS(status);
+				}
+
 				if (!acpi_gbl_global_notify[i].handler ||
 				    (acpi_gbl_global_notify[i].handler !=
 				     handler)) {
@@ -277,31 +274,40 @@ acpi_remove_notify_handler(acpi_handle device,
 
 				acpi_gbl_global_notify[i].handler = NULL;
 				acpi_gbl_global_notify[i].context = NULL;
+
+				(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+
+				/* Make sure all deferred notify tasks are completed */
+
+				acpi_os_wait_events_complete();
 			}
 		}
 
-		goto unlock_and_exit;
+		return_ACPI_STATUS(AE_OK);
 	}
 
 	/* All other objects: Are Notifies allowed on this object? */
 
 	if (!acpi_ev_is_notify_object(node)) {
-		status = AE_TYPE;
-		goto unlock_and_exit;
+		return_ACPI_STATUS(AE_TYPE);
 	}
 
 	/* Must have an existing internal object */
 
 	obj_desc = acpi_ns_get_attached_object(node);
 	if (!obj_desc) {
-		status = AE_NOT_EXIST;
-		goto unlock_and_exit;
+		return_ACPI_STATUS(AE_NOT_EXIST);
 	}
 
 	/* Internal object exists. Find the handler and remove it */
 
 	for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++) {
 		if (handler_type & (i + 1)) {
+			status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
+			if (ACPI_FAILURE(status)) {
+				return_ACPI_STATUS(status);
+			}
+
 			handler_obj = obj_desc->common_notify.notify_list[i];
 			previous_handler_obj = NULL;
 
@@ -329,10 +335,17 @@ acpi_remove_notify_handler(acpi_handle device,
 				    handler_obj->notify.next[i];
 			}
 
+			(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
+
+			/* Make sure all deferred notify tasks are completed */
+
+			acpi_os_wait_events_complete();
 			acpi_ut_remove_reference(handler_obj);
 		}
 	}
 
+	return_ACPI_STATUS(status);
+
 unlock_and_exit:
 	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
 	return_ACPI_STATUS(status);
@@ -842,10 +855,6 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	/* Make sure all deferred GPE tasks are completed */
-
-	acpi_os_wait_events_complete();
-
 	status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
 	if (ACPI_FAILURE(status)) {
 		return_ACPI_STATUS(status);
@@ -897,9 +906,17 @@ acpi_remove_gpe_handler(acpi_handle gpe_device,
 		(void)acpi_ev_add_gpe_reference(gpe_event_info);
 	}
 
+	acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
+	(void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
+
+	/* Make sure all deferred GPE tasks are completed */
+
+	acpi_os_wait_events_complete();
+
 	/* Now we can free the handler object */
 
 	ACPI_FREE(handler);
+	return_ACPI_STATUS(status);
 
 unlock_and_exit:
 	acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
Signature · 1 line
1.7.10
author
#9 lore raw

PATCH 9/28 ACPI: Merge divergence of the commmit: ACPICA: Linux-specific header: Update support for Linux/acpi applications.

In reply to Lv Zheng

When the following commmit is back ported to ACPICA, comments have been updated:
Subject: ACPICA: Linux-specific header: Update support for Linux/acpi
applications.

This patch back ports the differences between the ACPICA upstream and Linux.

---
 include/acpi/platform/aclinux.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/platform/aclinux.h +1 -1
index 93c55ed..0d94be8 100644
@@ -91,7 +91,7 @@
 #include <ctype.h>
 #include <unistd.h>
 
-/* Disable kernel specific declarators */
+/* Define/disable kernel-specific declarators */
 
 #ifndef __init
 #define __init
Signature · 1 line
1.7.10
author
#10 lore raw

PATCH 10/28 ACPICA: Linux-specific header: Add support for PPC64 compilation.

In reply to Lv Zheng

From: Colin Ian King <[email protected]>

Adds PPC64 as a 64-bit architecture. Colin Ian King.

---
 include/acpi/platform/aclinux.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/acpi/platform/aclinux.h +2 -1
index 0d94be8..f242909 100644
@@ -106,7 +106,8 @@
 #define ACPI_FLUSH_CPU_CACHE()
 #define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
 
-#if defined(__ia64__) || defined(__x86_64__) || defined(__aarch64__)
+#if defined(__ia64__)    || defined(__x86_64__) ||\
+	defined(__aarch64__) || defined(__PPC64__)
 #define ACPI_MACHINE_WIDTH          64
 #define COMPILER_DEPENDENT_INT64    long
 #define COMPILER_DEPENDENT_UINT64   unsigned long
Signature · 1 line
1.7.10
author
#11 lore raw

PATCH 11/28 ACPICA: Add a missing field for debug dump of mutex objects.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Adds "OriginalSyncLevel" field to the output.

---
 drivers/acpi/acpica/exdump.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/acpica/exdump.c +3 -1
index 973fdae..925202a 100644
@@ -134,9 +134,11 @@ static struct acpi_exdump_info acpi_ex_dump_method[9] = {
 	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
 };
 
-static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
+static struct acpi_exdump_info acpi_ex_dump_mutex[6] = {
 	{ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL},
 	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"},
+	{ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.original_sync_level),
+	 "Original Sync Level"},
 	{ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
 	{ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
 	 "Acquire Depth"},
Signature · 1 line
1.7.10
author
#12 lore raw

PATCH 12/28 ACPICA: Remove indent divergences to reduce the difficulties of maintaining the revised ACPICA commits.

In reply to Lv Zheng

The divergences in the ACPICA files makes it difficult to maintain linuxize ACPICA table commits. This patch reduces such divergences before applying table manager commits so that human interventions of patch rebasing can be reduced.

---
 drivers/acpi/acpica/tbinstal.c |    6 +++++-
 drivers/acpi/acpica/tbutils.c  |    4 ++--
 drivers/acpi/acpica/tbxface.c  |   10 +++++-----
 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/acpi/acpica/tbinstal.c +5 -1
index e304094..73fffb0 100644
@@ -75,6 +75,7 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
 			    acpi_os_map_memory(table_desc->address,
 					       table_desc->length);
 		}
+
 		if (!table_desc->pointer) {
 			return_ACPI_STATUS(AE_NO_MEMORY);
 		}
@@ -459,10 +460,13 @@ acpi_tb_store_table(acpi_physical_address address,
 
 void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
 {
+
 	/* Table must be mapped or allocated */
+
 	if (!table_desc->pointer) {
 		return;
 	}
+
 	switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
 	case ACPI_TABLE_ORIGIN_MAPPED:
 
@@ -657,7 +661,7 @@ acpi_status acpi_tb_release_owner_id(u32 table_index)
  *
  ******************************************************************************/
 
-acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
+acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id)
 {
 	acpi_status status = AE_BAD_PARAMETER;
 
drivers/acpi/acpica/tbutils.c +2 -2
index a4702ee..3f1afca 100644
@@ -582,8 +582,8 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 			if (ACPI_FAILURE(status)) {
 				ACPI_WARNING((AE_INFO,
 					      "Truncating %u table entries!",
-					      (unsigned) (table_count -
-					       (acpi_gbl_root_table_list.
+					      (unsigned)(table_count -
+							 (acpi_gbl_root_table_list.
 							  current_table_count -
 							  2))));
 				break;
drivers/acpi/acpica/tbxface.c +5 -5
index a159315..4debc12 100644
@@ -206,8 +206,8 @@ acpi_status
 acpi_get_table_header(char *signature,
 		      u32 instance, struct acpi_table_header *out_table_header)
 {
-       u32 i;
-       u32 j;
+	u32 i;
+	u32 j;
 	struct acpi_table_header *header;
 
 	/* Parameter validation */
@@ -321,8 +321,8 @@ acpi_get_table_with_size(char *signature,
 	       u32 instance, struct acpi_table_header **out_table,
 	       acpi_size *tbl_size)
 {
-       u32 i;
-       u32 j;
+	u32 i;
+	u32 j;
 	acpi_status status;
 
 	/* Parameter validation */
@@ -390,7 +390,7 @@ ACPI_EXPORT_SYMBOL(acpi_get_table)
  *
  ******************************************************************************/
 acpi_status
-acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
+acpi_get_table_by_index(u32 table_index, struct acpi_table_header ** table)
 {
 	acpi_status status;
 
Signature · 1 line
1.7.10
author
#13 lore raw

PATCH 13/28 ACPICA: Tables: Fix the issues in handling virtual addressed tables.

In reply to Lv Zheng

When table is overridden or reloaded, acpi_tb_delete_table() is called where struct acpi_table_desc.Pointer will be NULL. It thus is impossible for virtual addressed tables to obtain the .Pointer again in acpi_tb_verify_table().

This patch stores virtual table addresses (ACPI_TABLE_ORIGIN_ALLOCATED, ACPI_TABLE_ORIGIN_UNKNOWN, ACPI_TABLE_ORIGIN_OVERRIDE) in the
struct acpi_table_desc.Address field and refills the struct acpi_table_desc.Pointer using these addresses in acpi_tb_verify_table(). Note that if a table with ACPI_TABLE_ORIGIN_ALLOCATED set is actually freed, the .Address field should be invalidated and thus must be replaced with NULL to avoid wrong future validations occuring in acpi_tb_verify_table().

---
 drivers/acpi/acpica/exconfig.c |    4 ++--
 drivers/acpi/acpica/tbinstal.c |   20 ++++++++++++++++++--
 drivers/acpi/acpica/tbutils.c  |    1 +
 3 files changed, 21 insertions(+), 4 deletions(-)
drivers/acpi/acpica/exconfig.c +2 -2
index 1b734eb..649a8ef 100644
@@ -435,7 +435,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 			return_ACPI_STATUS(status);
 		}
 
-		table_desc.address = obj_desc->region.address;
+		table_desc.address = ACPI_PTR_TO_PHYSADDR(table_desc.pointer);
 		break;
 
 	case ACPI_TYPE_BUFFER:	/* Buffer or resolved region_field */
@@ -476,7 +476,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 		}
 
 		ACPI_MEMCPY(table_desc.pointer, table, length);
-		table_desc.address = ACPI_TO_INTEGER(table_desc.pointer);
+		table_desc.address = ACPI_PTR_TO_PHYSADDR(table_desc.pointer);
 		break;
 
 	default:
drivers/acpi/acpica/tbinstal.c +18 -2
index 73fffb0..144076a 100644
@@ -69,11 +69,26 @@ acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc)
 	/* Map the table if necessary */
 
 	if (!table_desc->pointer) {
-		if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
-		    ACPI_TABLE_ORIGIN_MAPPED) {
+		switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
+		case ACPI_TABLE_ORIGIN_MAPPED:
+
 			table_desc->pointer =
 			    acpi_os_map_memory(table_desc->address,
 					       table_desc->length);
+			break;
+
+		case ACPI_TABLE_ORIGIN_ALLOCATED:
+		case ACPI_TABLE_ORIGIN_UNKNOWN:
+		case ACPI_TABLE_ORIGIN_OVERRIDE:
+
+			table_desc->pointer =
+			    ACPI_CAST_PTR(struct acpi_table_header,
+					  table_desc->address);
+			break;
+
+		default:
+
+			break;
 		}
 
 		if (!table_desc->pointer) {
@@ -476,6 +491,7 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
 	case ACPI_TABLE_ORIGIN_ALLOCATED:
 
 		ACPI_FREE(table_desc->pointer);
+		table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
 		break;
 
 		/* Not mapped or allocated, there is nothing we can do */
drivers/acpi/acpica/tbutils.c +1 -0
index 3f1afca..9b6992d 100644
@@ -179,6 +179,7 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
 
 	ACPI_MEMCPY(new_table, table_desc->pointer, table_desc->length);
 	acpi_tb_delete_table(table_desc);
+	table_desc->address = ACPI_PTR_TO_PHYSADDR(new_table);
 	table_desc->pointer = new_table;
 	table_desc->flags = ACPI_TABLE_ORIGIN_ALLOCATED;
 
Signature · 1 line
1.7.10
author
#14 lore raw

PATCH 14/28 ACPICA: Tables: Fix the issue that multiple ACPI_FREE()s are invoked for same pointer around acpi_tb_add_table().

In reply to Lv Zheng

Currently there are following issues in acpi_tb_add_table():
Following logic is currently correct:
1. When a table is allocated in acpi_ex_load_op(), if a reloading happens, the allocated memory is freed by acpi_tb_add_table() and AE_OK is returned to the caller to avoid the caller to free it again.
Following logic is currently incorrect:
1. When a table is allocated in acpi_ex_load_op() or by the acpi_load_table() caller, if the table is already loaded, there will be twice ACPI_FREE() called for the same pointer when acpi_tb_add_table() returns AE_ALREADY_EXISTS.

This patch only fixes the above incorrect logic in acpi_tb_add_table():
1. Only invoke acpi_tb_delete_table() if AE_OK is going to be returned.
2. After doing so, we do not invoke ACPI_FREE() when returning AE_OK;

---
 drivers/acpi/acpica/exconfig.c |    2 +-
 drivers/acpi/acpica/tbinstal.c |    7 +------
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/acpi/acpica/exconfig.c +1 -1
index 649a8ef..11a014c 100644
@@ -504,7 +504,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 
 		/* Delete allocated table buffer */
 
-		acpi_tb_delete_table(&table_desc);
+		ACPI_FREE(table_desc.pointer);
 		return_ACPI_STATUS(status);
 	}
 
drivers/acpi/acpica/tbinstal.c +1 -6
index 144076a..0040e19 100644
@@ -203,12 +203,6 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
 		 * need to be unregistered when they are unloaded, and slots in the
 		 * root table list should be reused when empty.
 		 */
-
-		/*
-		 * Table is already registered.
-		 * We can delete the table that was passed as a parameter.
-		 */
-		acpi_tb_delete_table(table_desc);
 		*table_index = i;
 
 		if (acpi_gbl_root_table_list.tables[i].
@@ -221,6 +215,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
 		} else {
 			/* Table was unloaded, allow it to be reloaded */
 
+			acpi_tb_delete_table(table_desc);
 			table_desc->pointer =
 			    acpi_gbl_root_table_list.tables[i].pointer;
 			table_desc->address =
Signature · 1 line
1.7.10
author
#15 lore raw

PATCH 15/28 ACPICA: Tables: Cleanup split INSTALLED/VALIDATED table state logics.

In reply to Lv Zheng

This patch is mainly a naming cleanup to clarify hidden logics, no functional changes.

acpi_initialize_tables() is used by Linux to install table addresses for early boot steps. During this stage, table addresses are mapped by early_ioremap() mechanism which is different from the runtime IO mappings. Thus it is not safe for ACPICA to keep mapped pointers in struct acpi_table_desc structure during this stage.

In order to support this in ACPICA, table states are divided into
1. "INSTALLED" (where struct acpi_table_desc.Pointer is always NULL) and
2. "VALIDATED" (where struct acpi_table_desc.Pointer is always not NULL). During acpi_initialize_tables(), table state are ensured to be "INSTALLED" but not "VALIDATED". This logic is ensured by the original code in very ambigious way. For example, currently acpi_tb_delete_table() is invoked in some place to perform an uninstallation while it is invoked in other place to perform an invalidation. They happen to work just because no one enters the penalty where the 2 behaviours are not equivalent.

The naming cleanups are made in this patch:
A. For installation and validation:
There is code setting struct acpi_table_desc.Pointer first and delete it immediately to keep the descriptor's state as "INSTALLED" during the installation. This patch implements this in more direct way. After applying it, struct acpi_table_desc.Pointer will never be set in acpi_tb_install_table() and acpi_tb_override_table() as they are the only functions invoked during acpi_initialize_tables(). This is achieved by:
1. Rename acpi_tb_verify_table() to acpi_tb_validate_table() to clarify this change.
2. Rename acpi_tb_table_override() to acpi_tb_override_table() to keep nameing consistencies as other APIs (verb. Table).
3. Stops setting struct acpi_table_desc.Pointer in acpi_tb_install_table() and acpi_tb_table_override().
4. Introduce acpi_tb_acquire_table() to acquire the table pointer that is not maintained in the struct acpi_table_desc of the global root table list and rewrite acpi_tb_validate_table() using this new function to reduce redundancies.
5. Replace the table pointer using the overridden table pointer in acpi_tb_add_table(). As acpi_tb_add_table() is not invoked during early boot stage, tables returned from this functions should be "VALIDATED". As acpi_tb_override_table() is modified by this patch to return a "INSTALLED" but not "VALIDATED" descriptor, to keep acpi_tb_add_table() unchanged, struct acpi_table_desc.Pointer is filled in acpi_tb_add_table().
B. For invalidation and uninstallation:
The original code invalidate table by invoking acpi_tb_delete_table() here and there, but actually this function should only be used to uninstall tables. This can work just because its invocations are equivalent to invalidation in some cases.
This patch splits acpi_tb_delete_table() into acpi_tb_invalidate_table() and acpi_tb_uninstall_table() and cleans up the hidden logic using the new APIs. This is achieved by:
1. Rename acpi_tb_delete_table() to acpi_tb_uninstall_table() as it is mainly called before resetting struct acpi_table_desc.Address. Thus the table descriptor is in "not INSTALLED" state. This patch enforces this by setting struct acpi_table_desc.Address to NULL in this function.
2. Introduce acpi_tb_invalidate_table() to be the reversal of acpi_tb_validate_table() and invoke it in acpi_tb_uninstall_table().
3. Introduce acpi_tb_release_table() to release the table pointer that is not maintained in acpi_gbl_root_table_list and rewrite acpi_tb_invalidate_table() using this new function to reduce redundancies.

After cleaning up, the maintainability of the internal APIs are also improved:
1. acpi_tb_acquire_table: Acquire struct acpi_table_header according to ACPI_TABLE_ORIGIN_xxx flags.
2. acpi_tb_release_table: Release struct acpi_table_header according to ACPI_TABLE_ORIGIN_xxx flags.
3. acpi_tb_install_table: Make struct acpi_table_desc.Address not NULL according to ACPI_TABLE_ORIGIN_xxx flags.
4. acpi_tb_uninstall_table: Make struct acpi_table_desc.Address NULL according to ACPI_TABLE_ORIGIN_xxx flags.
5. acpi_tb_validate_table: Make struct acpi_table_desc.Pointer not NULL according to ACPI_TABLE_ORIGIN_xxx flags.
6. acpi_tb_invalidate_table: Make struct acpi_table_desc.Pointer NULL according to ACPI_TABLE_ORIGIN_xxx flags.
7. acpi_tb_override_table: Replace struct acpi_table_desc.Address and struct acpi_table_desc.Flags. It only happens in "INSTALLED" state.

The patch has been unit tested in acpi_exec by:
1. Initializing;
2. Executing exc_tbl ASLTS tests;
3. Executing "Load" command.
So that all original acpi_tb_install_table() and acpi_tb_override_table() invocations are covered.

Known Issues:
1. Cleanup acpi_tb_add_table() to Kill Code Redundancies
Current implementation in acpi_tb_add_table() is not very clean, further patch can rewrite acpi_tb_add_table() with ordered acpi_tb_install_table(), acpi_tb_override_table() and acpi_tb_validate_table(). It is not done in this patch so that it is easy for the reviewers to understand the changes in this patch.

---
 drivers/acpi/acpica/actables.h |   17 ++-
 drivers/acpi/acpica/tbfind.c   |    4 +-
 drivers/acpi/acpica/tbinstal.c |  299 +++++++++++++++++++++++++++-------------
 drivers/acpi/acpica/tbutils.c  |   11 +-
 drivers/acpi/acpica/tbxface.c  |    6 +-
 drivers/acpi/acpica/tbxfload.c |    6 +-
 6 files changed, 235 insertions(+), 108 deletions(-)
drivers/acpi/acpica/actables.h +14 -3
index 5fa4b20..c569eab 100644
@@ -72,14 +72,25 @@ acpi_tb_find_table(char *signature,
  */
 acpi_status acpi_tb_resize_root_table_list(void);
 
-acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
+acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc);
 
-struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
+void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc);
+
+struct acpi_table_header *acpi_tb_override_table(struct acpi_table_header
 						 *table_header,
 						 struct acpi_table_desc
 						 *table_desc);
 
 acpi_status
+acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
+		      struct acpi_table_header **table_ptr,
+		      u32 *table_length, u8 *table_flags);
+
+void
+acpi_tb_release_table(struct acpi_table_header *table,
+		      u32 table_length, u8 table_flags);
+
+acpi_status
 acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
 
 acpi_status
@@ -87,7 +98,7 @@ acpi_tb_store_table(acpi_physical_address address,
 		    struct acpi_table_header *table,
 		    u32 length, u8 flags, u32 *table_index);
 
-void acpi_tb_delete_table(struct acpi_table_desc *table_desc);
+void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc);
 
 void acpi_tb_terminate(void);
 
drivers/acpi/acpica/tbfind.c +2 -2
index c120039..cb94770 100644
@@ -99,8 +99,8 @@ acpi_tb_find_table(char *signature,
 			/* Table is not currently mapped, map it */
 
 			status =
-			    acpi_tb_verify_table(&acpi_gbl_root_table_list.
-						 tables[i]);
+			    acpi_tb_validate_table(&acpi_gbl_root_table_list.
+						   tables[i]);
 			if (ACPI_FAILURE(status)) {
 				return_ACPI_STATUS(status);
 			}
drivers/acpi/acpica/tbinstal.c +205 -94

429 lines not on this page · raw message

drivers/acpi/acpica/tbutils.c +8 -3
index 9b6992d..c61432f 100644
@@ -178,7 +178,7 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
 	}
 
 	ACPI_MEMCPY(new_table, table_desc->pointer, table_desc->length);
-	acpi_tb_delete_table(table_desc);
+	acpi_tb_uninstall_table(table_desc);
 	table_desc->address = ACPI_PTR_TO_PHYSADDR(new_table);
 	table_desc->pointer = new_table;
 	table_desc->flags = ACPI_TABLE_ORIGIN_ALLOCATED;
@@ -268,7 +268,7 @@ acpi_tb_install_table(acpi_physical_address address,
 	 * fully mapped later (in verify table). In any case, we must
 	 * unmap the header that was mapped above.
 	 */
-	final_table = acpi_tb_table_override(table, table_desc);
+	final_table = acpi_tb_override_table(table, table_desc);
 	if (!final_table) {
 		final_table = table;	/* There was no override */
 	}
@@ -290,7 +290,12 @@ acpi_tb_install_table(acpi_physical_address address,
 	 * flag set and will not be deleted below.
 	 */
 	if (final_table != table) {
-		acpi_tb_delete_table(table_desc);
+		/*
+		 * Table is in "INSTALLED" state, the final_table pointer is not
+		 * maintained in the root table list.
+		 */
+		acpi_tb_release_table(final_table, table_desc->length,
+				      table_desc->flags);
 	}
 
 unmap_and_exit:
drivers/acpi/acpica/tbxface.c +3 -3
index 4debc12..ae3fe4d 100644
@@ -346,7 +346,7 @@ acpi_get_table_with_size(char *signature,
 		}
 
 		status =
-		    acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
+		    acpi_tb_validate_table(&acpi_gbl_root_table_list.tables[i]);
 		if (ACPI_SUCCESS(status)) {
 			*out_table = acpi_gbl_root_table_list.tables[i].pointer;
 			*tbl_size = acpi_gbl_root_table_list.tables[i].length;
@@ -416,8 +416,8 @@ acpi_get_table_by_index(u32 table_index, struct acpi_table_header ** table)
 		/* Table is not mapped, map it */
 
 		status =
-		    acpi_tb_verify_table(&acpi_gbl_root_table_list.
-					 tables[table_index]);
+		    acpi_tb_validate_table(&acpi_gbl_root_table_list.
+					   tables[table_index]);
 		if (ACPI_FAILURE(status)) {
 			(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 			return_ACPI_STATUS(status);
drivers/acpi/acpica/tbxfload.c +3 -3
index 0909420..a2899b0 100644
@@ -117,7 +117,7 @@ static acpi_status acpi_tb_load_namespace(void)
 				tables[ACPI_TABLE_INDEX_DSDT].signature),
 			       ACPI_SIG_DSDT)
 	    ||
-	    ACPI_FAILURE(acpi_tb_verify_table
+	    ACPI_FAILURE(acpi_tb_validate_table
 			 (&acpi_gbl_root_table_list.
 			  tables[ACPI_TABLE_INDEX_DSDT]))) {
 		status = AE_NO_ACPI_TABLES;
@@ -128,7 +128,7 @@ static acpi_status acpi_tb_load_namespace(void)
 	 * Save the DSDT pointer for simple access. This is the mapped memory
 	 * address. We must take care here because the address of the .Tables
 	 * array can change dynamically as tables are loaded at run-time. Note:
-	 * .Pointer field is not validated until after call to acpi_tb_verify_table.
+	 * .Pointer field is not validated until after call to acpi_tb_validate_table.
 	 */
 	acpi_gbl_DSDT =
 	    acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer;
@@ -174,7 +174,7 @@ static acpi_status acpi_tb_load_namespace(void)
 					(acpi_gbl_root_table_list.tables[i].
 					 signature), ACPI_SIG_PSDT))
 		    ||
-		    ACPI_FAILURE(acpi_tb_verify_table
+		    ACPI_FAILURE(acpi_tb_validate_table
 				 (&acpi_gbl_root_table_list.tables[i]))) {
 			continue;
 		}
Signature · 1 line
1.7.10
author
#16 lore raw

PATCH 16/28 ACPICA: Tables: Fix the issue that table validations are not balanced.

In reply to Lv Zheng

As acpi_tb_validate_table() returns failure on checksum verification without doing invalidatation, all its invocations that are not done to a descriptor stored in acpi_gbl_root_table_list are checked and balanced.

But this is not a real issue as the descritors that have been passed to acpi_tb_add_table() are all virtual address tables and the validations are in fact no-op. The cleanup can ensure that any future extensions made on acpi_tb_add_table() to allow it to be invoked with physical address tables will not trigger memory leakage regressions.

---
 drivers/acpi/acpica/tbinstal.c |    1 +
 1 file changed, 1 insertion(+)
drivers/acpi/acpica/tbinstal.c +1 -0
index 93a99ef..d3e1db2 100644
@@ -236,6 +236,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
 	if (!table_desc->pointer) {
 		status = acpi_tb_validate_table(table_desc);
 		if (ACPI_FAILURE(status) || !table_desc->pointer) {
+			acpi_tb_invalidate_table(table_desc);
 			return_ACPI_STATUS(status);
 		}
 	}
Signature · 1 line
1.7.10
author
#17 lore raw

PATCH 17/28 ACPICA: Tables: Fix the issue that table checksums are not always verified before installation.

In reply to Lv Zheng

The original table handling code does not always verify checksums before installing a table, this is because code to achieve this must be implemented here and there in the redundant code blocks.

There are two stages during table initialization:
1. "INSTALLED" after acpi_tb_install_table() and acpi_tb_override_table(), struct acpi_table_desc.Pointer is ensured to be NULL. This can be safely used during OSPM's early boot stage.
2. "VALIDATED" after acpi_tb_validate_table(), struct acpi_table_desc.Pointer is ensured to be not NULL. This must not be used during OSPM's early boot stage.

This patch changes acpi_tb_add_table() into an early boot safe API to reduce code redundancies by changing the table state that is returned by this function from "VALIDATED" to "INSTALLED". Then the table verification code can be done in a single place. Originally, the acpi_tb_add_table() can only be used by dynamic table loadings that are executed after early boot stage, it cannot be used by static table loadings that are executed in early boot stage as:
1. The address of the table is a virtual address either maintained by OSPMs who call acpi_load_table() or by ACPICA whenever "Load" or "LoadTable" opcodes are executed, while during early boot stage, physical address of the table should be used for table loading.
2. The API will ensure the state of the loaded table to be "VALIDATED" while during early boot stage, tables maintained by root table list should be kept as "INSTALLED".

To achieve this:
1. Rename acpi_tb_install_table() to acpi_tb_install_fixed_table() as it only applies to DSDT/FACS installation. Rename acpi_tb_add_table() to acpi_tb_install_non_fixed_table() as it will be applied to the installation of the rest kinds of tables.
2. Introduce acpi_tb_install_table(), acpi_tb_install_and_override_table to collect redudant code where their invocations actually have slight differences.
1. acpi_tb_install_table() is used to fill an struct acpi_table_desc where the table length is known to the caller.
2. acpi_tb_install_and_override_table() is used to perform necessary overriding before installation.
3. Change a parameter of acpi_tb_install_non_fixed_table() from struct acpi_table_desc to acpi_physical_address to allow it to be invoked by static table loadings. Also cleanup acpi_ex_load_op() and acpi_load_table() to accomodate to the parameter change.
4. Invoke acpi_tb_install_non_fixed_table() for all table loadings other than DSDT/FACS in acpi_tb_parse_root_table() to improve code maintainability (logics are collected in the single function). Also delete useless code from acpi_tb_parse_root_table().
5. Remove all acpi_tb_validate_table() from acpi_tb_install_non_fixed_table() and acpi_tb_install_fixed_table() so that the table descriptor is kept in the state of "INSTALLED" but not "VALIDATED" after returning from these functions.
6. Introduce temporary struct acpi_table_desc (new_table_desc/old_table_desc) into the functions to indicate a table descriptor that is not maintained by acpi_gbl_root_table_list. Introduce acpi_tb_acquire_temporal_table() and acpi_tb_release_temporal_table() to handle the use cases of such temporal tables. They are only used for verified installation.
7. Introduce acpi_tb_verify_table() to validate table and verify table checksum, also remove table checksum verification from acpi_tb_validate_table(). Invoke acpi_tb_validate_table() in the functions that will convert a table into "LOADED" state or invoke it from acpi_get_table_XXX() APIs. Invoke acpi_tb_verify_table() on temporary struct acpi_table_desc(s) that are going to be "INSTALLED".
8. Change acpi_tb_override_table() logic so that a temporary struct acpi_table_desc will be overridden before installtion, this makes code simpler.

After applying the patch, tables are always installed after being overridden and the table checksums are always verified before installation.

---
 drivers/acpi/acpica/actables.h |   24 +-
 drivers/acpi/acpica/exconfig.c |   75 ++---
 drivers/acpi/acpica/tbfadt.c   |   10 +-
 drivers/acpi/acpica/tbinstal.c |  708 +++++++++++++++++++++++++++++-----------
 drivers/acpi/acpica/tbutils.c  |  173 +---------
 drivers/acpi/acpica/tbxfload.c |   26 +-
 6 files changed, 607 insertions(+), 409 deletions(-)
drivers/acpi/acpica/actables.h +17 -7
index c569eab..32aec48 100644
@@ -76,10 +76,10 @@ acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc);
 
 void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc);
 
-struct acpi_table_header *acpi_tb_override_table(struct acpi_table_header
-						 *table_header,
-						 struct acpi_table_desc
-						 *table_desc);
+acpi_status
+acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature);
+
+void acpi_tb_override_table(struct acpi_table_desc *old_table_desc);
 
 acpi_status
 acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
@@ -91,7 +91,8 @@ acpi_tb_release_table(struct acpi_table_header *table,
 		      u32 table_length, u8 table_flags);
 
 acpi_status
-acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
+acpi_tb_install_non_fixed_table(acpi_physical_address address,
+				u8 flags, u8 reload, u32 *table_index);
 
 acpi_status
 acpi_tb_store_table(acpi_physical_address address,
@@ -135,8 +136,17 @@ void acpi_tb_check_dsdt_header(void);
 struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
 
 void
-acpi_tb_install_table(acpi_physical_address address,
-		      char *signature, u32 table_index);
+acpi_tb_install_table(struct acpi_table_desc *table_desc,
+		      acpi_physical_address address,
+		      u8 flags, struct acpi_table_header *table);
+
+void
+acpi_tb_install_and_override_table(u32 table_index,
+				   struct acpi_table_desc *new_table_desc);
+
+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);
 
drivers/acpi/acpica/exconfig.c +34 -41

156 lines not on this page · raw message

drivers/acpi/acpica/tbfadt.c +5 -5
index ec14588..a37af16 100644
@@ -332,15 +332,15 @@ void acpi_tb_parse_fadt(u32 table_index)
 
 	/* Obtain the DSDT and FACS tables via their addresses within the FADT */
 
-	acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
-			      ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
+	acpi_tb_install_fixed_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
+				    ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
 
 	/* If Hardware Reduced flag is set, there is no FACS */
 
 	if (!acpi_gbl_reduced_hardware) {
-		acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.
-				      Xfacs, ACPI_SIG_FACS,
-				      ACPI_TABLE_INDEX_FACS);
+		acpi_tb_install_fixed_table((acpi_physical_address)
+					    acpi_gbl_FADT.Xfacs, ACPI_SIG_FACS,
+					    ACPI_TABLE_INDEX_FACS);
 	}
 }
 
drivers/acpi/acpica/tbinstal.c +517 -191

855 lines not on this page · raw message

drivers/acpi/acpica/tbutils.c +18 -155

207 lines not on this page · raw message

drivers/acpi/acpica/tbxfload.c +16 -10
index a2899b0..77e8d26 100644
@@ -226,7 +226,6 @@ unlock_and_exit:
 acpi_status acpi_load_table(struct acpi_table_header *table)
 {
 	acpi_status status;
-	struct acpi_table_desc table_desc;
 	u32 table_index;
 
 	ACPI_FUNCTION_TRACE(acpi_load_table);
@@ -237,14 +236,6 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
 	}
 
-	/* Init local table descriptor */
-
-	ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
-	table_desc.address = ACPI_PTR_TO_PHYSADDR(table);
-	table_desc.pointer = table;
-	table_desc.length = table->length;
-	table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
-
 	/* Must acquire the interpreter lock during this operation */
 
 	status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
@@ -255,7 +246,22 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
 	/* Install the table and load it into the namespace */
 
 	ACPI_INFO((AE_INFO, "Host-directed Dynamic ACPI Table Load:"));
-	status = acpi_tb_add_table(&table_desc, &table_index);
+	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
+	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
+						 ACPI_TABLE_ORIGIN_UNKNOWN,
+						 TRUE, &table_index);
+	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
+	if (ACPI_FAILURE(status)) {
+		goto unlock_and_exit;
+	}
+
+	/*
+	 * Note: Now table is "INSTALLED", it must be validated before
+	 * using.
+	 */
+	status =
+	    acpi_tb_validate_table(&acpi_gbl_root_table_list.
+				   tables[table_index]);
 	if (ACPI_FAILURE(status)) {
 		goto unlock_and_exit;
 	}
Signature · 1 line
1.7.10
author
#18 lore raw

PATCH 18/28 ACPICA: Tables: Cleanup ACPI_TABLE_ORIGIN_xxx flags.

In reply to Lv Zheng

This patch refines ACPI_TABLE_ORIGIN_xxx flags. No functional changes.

The previous commits have introduced the following internal APIs:
1. acpi_tb_acquire_table: Acquire struct acpi_table_header according to ACPI_TABLE_ORIGIN_xxx flags.
2. acpi_tb_release_table: Release struct acpi_table_header according to ACPI_TABLE_ORIGIN_xxx flags.
3. acpi_tb_install_table: Make struct acpi_table_desc.Address not NULL according to ACPI_TABLE_ORIGIN_xxx flags.
4. acpi_tb_uninstall_table: Make struct acpi_table_desc.Address NULL according to ACPI_TABLE_ORIGIN_xxx flags.
5. acpi_tb_validate_table: Make struct acpi_table_desc.Pointer not NULL according to ACPI_TABLE_ORIGIN_xxx flags.
6. acpi_tb_invalidate_table: Make struct acpi_table_desc.Pointer NULL according to ACPI_TABLE_ORIGIN_xxx flags.
It thus detects that the ACPI_TABLE_ORIGIN_UNKNOWN is redundant to ACPI_TABLE_ORIGIN_OVERRIDE.

The ACPI_TABLE_ORIGIN_xxTERN_VIRTUAL flags are named as VIRTUAL in order not to confuse with x86 logical address, this patch also renames all "logical override" into "virtual override".

---
 drivers/acpi/acpica/exconfig.c |    2 +-
 drivers/acpi/acpica/tbinstal.c |   31 ++++++++++++++-----------------
 drivers/acpi/acpica/tbutils.c  |    4 ++--
 drivers/acpi/acpica/tbxface.c  |    2 +-
 drivers/acpi/acpica/tbxfload.c |    2 +-
 include/acpi/actbl.h           |   11 +++++------
 6 files changed, 24 insertions(+), 28 deletions(-)
drivers/acpi/acpica/exconfig.c +1 -1
index 52ea900..4dfe6c0 100644
@@ -483,7 +483,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 	ACPI_INFO((AE_INFO, "Dynamic OEM Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
-						 ACPI_TABLE_ORIGIN_ALLOCATED,
+						 ACPI_TABLE_ORIGIN_INTERN_VIRTUAL,
 						 TRUE, &table_index);
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	if (ACPI_FAILURE(status)) {
drivers/acpi/acpica/tbinstal.c +14 -17
index 099e678..cf1ccc5 100644
@@ -86,15 +86,14 @@ acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
 	struct acpi_table_header *table = NULL;
 
 	switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
-	case ACPI_TABLE_ORIGIN_MAPPED:
+	case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL:
 
 		table =
 		    acpi_os_map_memory(table_desc->address, table_desc->length);
 		break;
 
-	case ACPI_TABLE_ORIGIN_ALLOCATED:
-	case ACPI_TABLE_ORIGIN_UNKNOWN:
-	case ACPI_TABLE_ORIGIN_OVERRIDE:
+	case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL:
+	case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL:
 
 		table =
 		    ACPI_CAST_PTR(struct acpi_table_header,
@@ -140,14 +139,13 @@ acpi_tb_release_table(struct acpi_table_header *table,
 		      u32 table_length, u8 table_flags)
 {
 	switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
-	case ACPI_TABLE_ORIGIN_MAPPED:
+	case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL:
 
 		acpi_os_unmap_memory(table, table_length);
 		break;
 
-	case ACPI_TABLE_ORIGIN_ALLOCATED:
-	case ACPI_TABLE_ORIGIN_UNKNOWN:
-	case ACPI_TABLE_ORIGIN_OVERRIDE:
+	case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL:
+	case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL:
 	default:
 
 		break;
@@ -333,7 +331,7 @@ acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc,
 	struct acpi_table_header *table_header;
 
 	switch (flags & ACPI_TABLE_ORIGIN_MASK) {
-	case ACPI_TABLE_ORIGIN_MAPPED:
+	case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL:
 
 		/* Try to obtain the length of the table */
 
@@ -348,9 +346,8 @@ acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc,
 				     sizeof(struct acpi_table_header));
 		return (AE_OK);
 
-	case ACPI_TABLE_ORIGIN_ALLOCATED:
-	case ACPI_TABLE_ORIGIN_UNKNOWN:
-	case ACPI_TABLE_ORIGIN_OVERRIDE:
+	case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL:
+	case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL:
 
 		table_header = ACPI_CAST_PTR(struct acpi_table_header, address);
 		if (!table_header) {
@@ -473,7 +470,7 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
 	/* Fill a table descriptor for validation */
 
 	status = acpi_tb_acquire_temporal_table(&new_table_desc, address,
-						ACPI_TABLE_ORIGIN_MAPPED);
+						ACPI_TABLE_ORIGIN_INTERN_PHYSICAL);
 	if (ACPI_FAILURE(status)) {
 		ACPI_ERROR((AE_INFO, "Could not acquire table length at %p",
 			    ACPI_CAST_PTR(void, address)));
@@ -546,7 +543,7 @@ acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index)
  *
  * FUNCTION:    acpi_tb_install_non_fixed_table
  *
- * PARAMETERS:  address             - Address of the table (might be a logical
+ * PARAMETERS:  address             - Address of the table (might be a virtual
  *                                    address depending on the table_flags)
  *              flags               - Flags for the table
  *              reload              - Whether reload should be performed
@@ -720,7 +717,7 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
 	if (ACPI_SUCCESS(status) && table) {
 		acpi_tb_acquire_temporal_table(&new_table_desc,
 					       ACPI_PTR_TO_PHYSADDR(table),
-					       ACPI_TABLE_ORIGIN_OVERRIDE);
+					       ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL);
 		override_type = "Logical";
 		goto finish_override;
 	}
@@ -731,7 +728,7 @@ void acpi_tb_override_table(struct acpi_table_desc *old_table_desc)
 						 &address, &length);
 	if (ACPI_SUCCESS(status) && address && length) {
 		acpi_tb_acquire_temporal_table(&new_table_desc, address,
-					       ACPI_TABLE_ORIGIN_MAPPED);
+					       ACPI_TABLE_ORIGIN_INTERN_PHYSICAL);
 		override_type = "Physical";
 		goto finish_override;
 	}
@@ -928,7 +925,7 @@ void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
 	acpi_tb_invalidate_table(table_desc);
 
 	if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
-	    ACPI_TABLE_ORIGIN_ALLOCATED) {
+	    ACPI_TABLE_ORIGIN_INTERN_VIRTUAL) {
 		ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address));
 	}
 
drivers/acpi/acpica/tbutils.c +2 -2
index e58dfbf..1bf9de7 100644
@@ -182,7 +182,7 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
 	acpi_tb_install_table(&acpi_gbl_root_table_list.
 			      tables[ACPI_TABLE_INDEX_DSDT],
 			      ACPI_PTR_TO_PHYSADDR(new_table),
-			      ACPI_TABLE_ORIGIN_ALLOCATED, new_table);
+			      ACPI_TABLE_ORIGIN_INTERN_VIRTUAL, new_table);
 
 	ACPI_INFO((AE_INFO,
 		   "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
@@ -473,7 +473,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 		    acpi_tb_install_non_fixed_table(acpi_tb_get_root_table_entry
 						    (table_entry,
 						     table_entry_size),
-						    ACPI_TABLE_ORIGIN_MAPPED,
+						    ACPI_TABLE_ORIGIN_INTERN_PHYSICAL,
 						    FALSE, &table_index);
 
 		if (ACPI_SUCCESS(status) &&
drivers/acpi/acpica/tbxface.c +1 -1
index ae3fe4d..19c0b13 100644
@@ -233,7 +233,7 @@ acpi_get_table_header(char *signature,
 		if (!acpi_gbl_root_table_list.tables[i].pointer) {
 			if ((acpi_gbl_root_table_list.tables[i].flags &
 			     ACPI_TABLE_ORIGIN_MASK) ==
-			    ACPI_TABLE_ORIGIN_MAPPED) {
+			    ACPI_TABLE_ORIGIN_INTERN_PHYSICAL) {
 				header =
 				    acpi_os_map_memory(acpi_gbl_root_table_list.
 						       tables[i].address,
drivers/acpi/acpica/tbxfload.c +1 -1
index 77e8d26..62bbd38 100644
@@ -248,7 +248,7 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
 	ACPI_INFO((AE_INFO, "Host-directed Dynamic ACPI Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
-						 ACPI_TABLE_ORIGIN_UNKNOWN,
+						 ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL,
 						 TRUE, &table_index);
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	if (ACPI_FAILURE(status)) {
include/acpi/actbl.h +5 -6
index 3b30e36..0cdf4cc 100644
@@ -367,12 +367,11 @@ struct acpi_table_desc {
 
 /* Masks for Flags field above */
 
-#define ACPI_TABLE_ORIGIN_UNKNOWN       (0)
-#define ACPI_TABLE_ORIGIN_MAPPED        (1)
-#define ACPI_TABLE_ORIGIN_ALLOCATED     (2)
-#define ACPI_TABLE_ORIGIN_OVERRIDE      (4)
-#define ACPI_TABLE_ORIGIN_MASK          (7)
-#define ACPI_TABLE_IS_LOADED            (8)
+#define ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL    (0)	/* Virtual address, external maintained */
+#define ACPI_TABLE_ORIGIN_INTERN_PHYSICAL   (1)	/* Physical address, internal mapped */
+#define ACPI_TABLE_ORIGIN_INTERN_VIRTUAL    (2)	/* Virtual address, internal allocated */
+#define ACPI_TABLE_ORIGIN_MASK              (3)
+#define ACPI_TABLE_IS_LOADED                (8)
 
 /*
  * Get the remaining ACPI tables
Signature · 1 line
1.7.10
author
#19 lore raw

PATCH 19/28 ACPICA: Tables: Avoid SSDT installation when acpi_gbl_disable_ssdt_table_load is specified.

In reply to Lv Zheng

It is reported that when acpi_gbl_disable_ssdt_table_load is specified, user still can see it installed into /sys/firmware/acpi/tables on Linux boxes. This is because the option only stops table "loading", but doesn't stop table "installing", thus it is still in the acpi_gbl_root_table_list. With previous cleanups, it is possible to prevent SSDT installations to make it not such confusing. The global variable is also renamed. Lv Zheng.

---
 Documentation/kernel-parameters.txt |   10 +++++++++-
 drivers/acpi/acpica/acglobal.h      |    4 ++--
 drivers/acpi/acpica/tbinstal.c      |   12 ++++++++++++
 drivers/acpi/acpica/tbxfload.c      |   13 -------------
 drivers/acpi/osl.c                  |   11 +++++------
 include/acpi/acpixf.h               |    2 +-
 6 files changed, 29 insertions(+), 23 deletions(-)
Documentation/kernel-parameters.txt +9 -1
index 91f0be8..0081db1 100644
@@ -237,7 +237,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			This feature is enabled by default.
 			This option allows to turn off the feature.
 
-	acpi_no_auto_ssdt	[HW,ACPI] Disable automatic loading of SSDT
+	acpi_no_static_ssdt	[HW,ACPI]
+			Disable installation of static SSDTs at early boot time
+			By default, SSDTs contained in the RSDT/XSDT will be
+			installed automatically and they will appear under
+			/sys/firmware/acpi/tables.
+			This option turns off this feature.
+			Note that specifying this option does not affect
+			dynamic table installation which will install SSDT
+			tables to /sys/firmware/acpi/tables/dynamic.
 
 	acpica_no_return_repair [HW, ACPI]
 			Disable AML predefined validation mechanism
drivers/acpi/acpica/acglobal.h +2 -2
index 71bb5b5..0cac564 100644
@@ -160,10 +160,10 @@ ACPI_INIT_GLOBAL(u8, acpi_gbl_truncate_io_addresses, FALSE);
 ACPI_INIT_GLOBAL(u8, acpi_gbl_disable_auto_repair, FALSE);
 
 /*
- * Optionally do not load any SSDTs from the RSDT/XSDT during initialization.
+ * Optionally do not install any SSDTs from the RSDT/XSDT during initialization.
  * This can be useful for debugging ACPI problems on some machines.
  */
-ACPI_INIT_GLOBAL(u8, acpi_gbl_disable_ssdt_table_load, FALSE);
+ACPI_INIT_GLOBAL(u8, acpi_gbl_disable_ssdt_table_install, FALSE);
 
 /*
  * We keep track of the latest version of Windows that has been requested by
drivers/acpi/acpica/tbinstal.c +12 -0
index cf1ccc5..de10d32 100644
@@ -580,6 +580,18 @@ acpi_tb_install_non_fixed_table(acpi_physical_address address,
 		return_ACPI_STATUS(status);
 	}
 
+	/*
+	 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
+	 * be useful for debugging ACPI problems on some machines.
+	 */
+	if (!reload && acpi_gbl_disable_ssdt_table_install &&
+	    ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) {
+		ACPI_INFO((AE_INFO, "Ignoring installation of %4.4s at %p",
+			   new_table_desc.signature.ascii, ACPI_CAST_PTR(void,
+									 address)));
+		goto release_and_exit;
+	}
+
 	/* Validate and verify a table before installation */
 
 	status = acpi_tb_verify_table(&new_table_desc, NULL);
drivers/acpi/acpica/tbxfload.c +0 -13
index 62bbd38..3f9eaf5 100644
@@ -179,19 +179,6 @@ static acpi_status acpi_tb_load_namespace(void)
 			continue;
 		}
 
-		/*
-		 * Optionally do not load any SSDTs from the RSDT/XSDT. This can
-		 * be useful for debugging ACPI problems on some machines.
-		 */
-		if (acpi_gbl_disable_ssdt_table_load) {
-			ACPI_INFO((AE_INFO, "Ignoring %4.4s at %p",
-				   acpi_gbl_root_table_list.tables[i].signature.
-				   ascii, ACPI_CAST_PTR(void,
-							acpi_gbl_root_table_list.
-							tables[i].address)));
-			continue;
-		}
-
 		/* Ignore errors while loading tables, get as many as possible */
 
 		(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
drivers/acpi/osl.c +5 -6
index f7fd72a..ff23fcc 100644
@@ -1771,16 +1771,15 @@ acpi_status acpi_os_release_object(acpi_cache_t * cache, void *object)
 }
 #endif
 
-static int __init acpi_no_auto_ssdt_setup(char *s)
+static int __init acpi_no_static_ssdt_setup(char *s)
 {
-        printk(KERN_NOTICE PREFIX "SSDT auto-load disabled\n");
+	acpi_gbl_disable_ssdt_table_install = TRUE;
+	pr_info("ACPI: static SSDT installation disabled\n");
 
-        acpi_gbl_disable_ssdt_table_load = TRUE;
-
-        return 1;
+	return 0;
 }
 
-__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
+early_param("acpi_no_static_ssdt", acpi_no_static_ssdt_setup);
 
 static int __init acpi_disable_return_repair(char *s)
 {
include/acpi/acpixf.h +1 -1
index 44f5e97..2280c19 100644
@@ -75,7 +75,7 @@ extern u8 acpi_gbl_auto_serialize_methods;
 extern u8 acpi_gbl_copy_dsdt_locally;
 extern u8 acpi_gbl_create_osi_method;
 extern u8 acpi_gbl_disable_auto_repair;
-extern u8 acpi_gbl_disable_ssdt_table_load;
+extern u8 acpi_gbl_disable_ssdt_table_install;
 extern u8 acpi_gbl_do_not_use_xsdt;
 extern u8 acpi_gbl_enable_aml_debug_object;
 extern u8 acpi_gbl_enable_interpreter_slack;
Signature · 1 line
1.7.10
author
#20 lore raw

PATCH 20/28 ACPICA: Tables: Add acpi_install_table() API to be invoked by OSPM early table installation.

In reply to Lv Zheng

This patch adds a new API - acpi_install_table(). OSPMs can use this API to install tables during early boot stage. Lv Zheng.

Reference: https://lkml.org/lkml/2014/2/28/372

---
 drivers/acpi/acpica/actables.h |    6 ++++--
 drivers/acpi/acpica/exconfig.c |    2 +-
 drivers/acpi/acpica/tbinstal.c |   16 ++++++++++-----
 drivers/acpi/acpica/tbutils.c  |    2 +-
 drivers/acpi/acpica/tbxfload.c |   42 ++++++++++++++++++++++++++++++++++++++--
 include/acpi/acpixf.h          |    3 +++
 6 files changed, 60 insertions(+), 11 deletions(-)
drivers/acpi/acpica/actables.h +4 -2
index 32aec48..3d20a96 100644
@@ -92,7 +92,8 @@ acpi_tb_release_table(struct acpi_table_header *table,
 
 acpi_status
 acpi_tb_install_non_fixed_table(acpi_physical_address address,
-				u8 flags, u8 reload, u32 *table_index);
+				u8 flags,
+				u8 reload, u8 override, u32 *table_index);
 
 acpi_status
 acpi_tb_store_table(acpi_physical_address address,
@@ -142,7 +143,8 @@ acpi_tb_install_table(struct acpi_table_desc *table_desc,
 
 void
 acpi_tb_install_and_override_table(u32 table_index,
-				   struct acpi_table_desc *new_table_desc);
+				   struct acpi_table_desc *new_table_desc,
+				   u8 override);
 
 acpi_status
 acpi_tb_install_fixed_table(acpi_physical_address address,
drivers/acpi/acpica/exconfig.c +1 -1
index 4dfe6c0..815003d 100644
@@ -484,7 +484,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
 	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
 						 ACPI_TABLE_ORIGIN_INTERN_VIRTUAL,
-						 TRUE, &table_index);
+						 TRUE, TRUE, &table_index);
 	(void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
 	if (ACPI_FAILURE(status)) {
 
drivers/acpi/acpica/tbinstal.c +11 -5
index de10d32..9835213 100644
@@ -394,6 +394,7 @@ static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc)
  *
  * PARAMETERS:  table_index             - Index into root table array
  *              new_table_desc          - New table descriptor to install
+ *              override                - Whether override should be performed
  *
  * RETURN:      None
  *
@@ -406,7 +407,8 @@ static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc)
 
 void
 acpi_tb_install_and_override_table(u32 table_index,
-				   struct acpi_table_desc *new_table_desc)
+				   struct acpi_table_desc *new_table_desc,
+				   u8 override)
 {
 	if (table_index >= acpi_gbl_root_table_list.current_table_count) {
 		return;
@@ -419,7 +421,9 @@ acpi_tb_install_and_override_table(u32 table_index,
 	 * one if desired. Any table within the RSDT/XSDT can be replaced,
 	 * including the DSDT which is pointed to by the FADT.
 	 */
-	acpi_tb_override_table(new_table_desc);
+	if (override) {
+		acpi_tb_override_table(new_table_desc);
+	}
 
 	acpi_tb_install_table(&acpi_gbl_root_table_list.tables[table_index],
 			      new_table_desc->address, new_table_desc->flags,
@@ -484,7 +488,7 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
 		goto release_and_exit;
 	}
 
-	acpi_tb_install_and_override_table(table_index, &new_table_desc);
+	acpi_tb_install_and_override_table(table_index, &new_table_desc, TRUE);
 
 release_and_exit:
 
@@ -547,6 +551,7 @@ acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index)
  *                                    address depending on the table_flags)
  *              flags               - Flags for the table
  *              reload              - Whether reload should be performed
+ *              override            - Whether override should be performed
  *              table_index         - Where the table index is returned
  *
  * RETURN:      Status
@@ -562,7 +567,8 @@ acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index)
 
 acpi_status
 acpi_tb_install_non_fixed_table(acpi_physical_address address,
-				u8 flags, u8 reload, u32 *table_index)
+				u8 flags,
+				u8 reload, u8 override, u32 *table_index)
 {
 	u32 i;
 	acpi_status status = AE_OK;
@@ -687,7 +693,7 @@ acpi_tb_install_non_fixed_table(acpi_physical_address address,
 		goto release_and_exit;
 	}
 	*table_index = i;
-	acpi_tb_install_and_override_table(i, &new_table_desc);
+	acpi_tb_install_and_override_table(i, &new_table_desc, override);
 
 release_and_exit:
 
drivers/acpi/acpica/tbutils.c +1 -1
index 1bf9de7..aa11949 100644
@@ -474,7 +474,7 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 						    (table_entry,
 						     table_entry_size),
 						    ACPI_TABLE_ORIGIN_INTERN_PHYSICAL,
-						    FALSE, &table_index);
+						    FALSE, TRUE, &table_index);
 
 		if (ACPI_SUCCESS(status) &&
 		    ACPI_COMPARE_NAME(&acpi_gbl_root_table_list.
drivers/acpi/acpica/tbxfload.c +40 -2

60 lines not on this page · raw message

include/acpi/acpixf.h +3 -0
index 2280c19..8dc9340 100644
@@ -164,6 +164,9 @@ acpi_decode_pld_buffer(u8 *in_buffer,
 /*
  * ACPI table load/unload interfaces
  */
+acpi_status __init
+acpi_install_table(acpi_physical_address address, u8 physical);
+
 acpi_status acpi_load_table(struct acpi_table_header *table);
 
 acpi_status acpi_unload_parent_table(acpi_handle object);
Signature · 1 line
1.7.10
author
#21 lore raw

PATCH 21/28 ACPICA: Table Manager: Misc cleanup and renames, no functional change.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Some various cleanups and renames.

---
 drivers/acpi/acpica/actables.h |   18 ++--
 drivers/acpi/acpica/exconfig.c |    8 +-
 drivers/acpi/acpica/tbinstal.c |  179 +++++++++++++++++++++-------------------
 drivers/acpi/acpica/tbutils.c  |   20 +++--
 drivers/acpi/acpica/tbxface.c  |    2 +-
 drivers/acpi/acpica/tbxfload.c |   16 ++--
 include/acpi/actbl.h           |    6 +-
 7 files changed, 133 insertions(+), 116 deletions(-)
drivers/acpi/acpica/actables.h +9 -9
index 3d20a96..ade430c 100644
@@ -91,9 +91,9 @@ acpi_tb_release_table(struct acpi_table_header *table,
 		      u32 table_length, u8 table_flags);
 
 acpi_status
-acpi_tb_install_non_fixed_table(acpi_physical_address address,
-				u8 flags,
-				u8 reload, u8 override, u32 *table_index);
+acpi_tb_install_standard_table(acpi_physical_address address,
+			       u8 flags,
+			       u8 reload, u8 override, u32 *table_index);
 
 acpi_status
 acpi_tb_store_table(acpi_physical_address address,
@@ -137,14 +137,14 @@ void acpi_tb_check_dsdt_header(void);
 struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
 
 void
-acpi_tb_install_table(struct acpi_table_desc *table_desc,
-		      acpi_physical_address address,
-		      u8 flags, struct acpi_table_header *table);
+acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
+			      acpi_physical_address address,
+			      u8 flags, struct acpi_table_header *table);
 
 void
-acpi_tb_install_and_override_table(u32 table_index,
-				   struct acpi_table_desc *new_table_desc,
-				   u8 override);
+acpi_tb_install_table_with_override(u32 table_index,
+				    struct acpi_table_desc *new_table_desc,
+				    u8 override);
 
 acpi_status
 acpi_tb_install_fixed_table(acpi_physical_address address,
drivers/acpi/acpica/exconfig.c +5 -3
index 815003d..7d29494 100644
@@ -482,9 +482,11 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
 
 	ACPI_INFO((AE_INFO, "Dynamic OEM Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
-	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
-						 ACPI_TABLE_ORIGIN_INTERN_VIRTUAL,
-						 TRUE, TRUE, &table_index);
+
+	status = acpi_tb_install_standard_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/tbinstal.c +95 -84

477 lines not on this page · raw message

drivers/acpi/acpica/tbutils.c +11 -9
index aa11949..6c31d77 100644
@@ -179,10 +179,12 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
 
 	ACPI_MEMCPY(new_table, table_desc->pointer, table_desc->length);
 	acpi_tb_uninstall_table(table_desc);
-	acpi_tb_install_table(&acpi_gbl_root_table_list.
-			      tables[ACPI_TABLE_INDEX_DSDT],
-			      ACPI_PTR_TO_PHYSADDR(new_table),
-			      ACPI_TABLE_ORIGIN_INTERN_VIRTUAL, new_table);
+
+	acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.
+				      tables[ACPI_TABLE_INDEX_DSDT],
+				      ACPI_PTR_TO_PHYSADDR(new_table),
+				      ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL,
+				      new_table);
 
 	ACPI_INFO((AE_INFO,
 		   "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
@@ -470,11 +472,11 @@ acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
 		/* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
 
 		status =
-		    acpi_tb_install_non_fixed_table(acpi_tb_get_root_table_entry
-						    (table_entry,
-						     table_entry_size),
-						    ACPI_TABLE_ORIGIN_INTERN_PHYSICAL,
-						    FALSE, TRUE, &table_index);
+		    acpi_tb_install_standard_table(acpi_tb_get_root_table_entry
+						   (table_entry,
+						    table_entry_size),
+						   ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL,
+						   FALSE, TRUE, &table_index);
 
 		if (ACPI_SUCCESS(status) &&
 		    ACPI_COMPARE_NAME(&acpi_gbl_root_table_list.
drivers/acpi/acpica/tbxface.c +1 -1
index 19c0b13..6482b0d 100644
@@ -233,7 +233,7 @@ acpi_get_table_header(char *signature,
 		if (!acpi_gbl_root_table_list.tables[i].pointer) {
 			if ((acpi_gbl_root_table_list.tables[i].flags &
 			     ACPI_TABLE_ORIGIN_MASK) ==
-			    ACPI_TABLE_ORIGIN_INTERN_PHYSICAL) {
+			    ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL) {
 				header =
 				    acpi_os_map_memory(acpi_gbl_root_table_list.
 						       tables[i].address,
drivers/acpi/acpica/tbxfload.c +9 -7
index 529f633..ab5308b 100644
@@ -219,13 +219,13 @@ acpi_install_table(acpi_physical_address address, u8 physical)
 	ACPI_FUNCTION_TRACE(acpi_install_table);
 
 	if (physical) {
-		flags = ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL;
+		flags = ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL;
 	} else {
-		flags = ACPI_TABLE_ORIGIN_INTERN_PHYSICAL;
+		flags = ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL;
 	}
 
-	status = acpi_tb_install_non_fixed_table(address, flags,
-						 FALSE, FALSE, &table_index);
+	status = acpi_tb_install_standard_table(address, flags,
+						FALSE, FALSE, &table_index);
 
 	return_ACPI_STATUS(status);
 }
@@ -272,9 +272,11 @@ acpi_status acpi_load_table(struct acpi_table_header *table)
 
 	ACPI_INFO((AE_INFO, "Host-directed Dynamic ACPI Table Load:"));
 	(void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
-	status = acpi_tb_install_non_fixed_table(ACPI_PTR_TO_PHYSADDR(table),
-						 ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL,
-						 TRUE, FALSE, &table_index);
+
+	status = acpi_tb_install_standard_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)) {
 		goto unlock_and_exit;
include/acpi/actbl.h +3 -3
index 0cdf4cc..1cc7ef1 100644
@@ -367,9 +367,9 @@ struct acpi_table_desc {
 
 /* Masks for Flags field above */
 
-#define ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL    (0)	/* Virtual address, external maintained */
-#define ACPI_TABLE_ORIGIN_INTERN_PHYSICAL   (1)	/* Physical address, internal mapped */
-#define ACPI_TABLE_ORIGIN_INTERN_VIRTUAL    (2)	/* Virtual address, internal allocated */
+#define ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL  (0)	/* Virtual address, external maintained */
+#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_LOADED                (8)
 
Signature · 1 line
1.7.10
author
#22 lore raw

PATCH 22/28 ACPICA: Table Manager: Split tbinstal.c into two files.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

New file is tbdata.c -- management functions for ACPICA table manager data structures.

---
 drivers/acpi/acpica/Makefile   |    1 +
 drivers/acpi/acpica/actables.h |   29 +-
 drivers/acpi/acpica/tbdata.c   |  723 +++++++++++++++++++++++++++++++++++++++
 drivers/acpi/acpica/tbinstal.c |  738 ++--------------------------------------
 4 files changed, 771 insertions(+), 720 deletions(-)
 create mode 100644 drivers/acpi/acpica/tbdata.c
drivers/acpi/acpica/Makefile +1 -0
index b7ed86a..8bb43f0 100644
@@ -135,6 +135,7 @@ acpi-y +=		\
 	rsxface.o
 
 acpi-y +=		\
+	tbdata.o	\
 	tbfadt.o	\
 	tbfind.o	\
 	tbinstal.o	\
drivers/acpi/acpica/actables.h +20 -9
index ade430c..bda9a7e 100644
@@ -54,6 +54,26 @@ acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
 u8 *acpi_tb_scan_memory_for_rsdp(u8 *start_address, u32 length);
 
 /*
+ * tbdata - table data structure management
+ */
+acpi_status acpi_tb_get_next_root_index(u32 *table_index);
+
+void
+acpi_tb_init_table_descriptor(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,
+			   acpi_physical_address address, u8 flags);
+
+void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc);
+
+u8 acpi_tb_is_table_loaded(u32 table_index);
+
+void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
+
+/*
  * tbfadt - FADT parse/convert/validate
  */
 void acpi_tb_parse_fadt(u32 table_index);
@@ -112,10 +132,6 @@ acpi_status acpi_tb_release_owner_id(u32 table_index);
 
 acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id);
 
-u8 acpi_tb_is_table_loaded(u32 table_index);
-
-void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
-
 /*
  * tbutils - table manager utilities
  */
@@ -137,11 +153,6 @@ void acpi_tb_check_dsdt_header(void);
 struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index);
 
 void
-acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
-			      acpi_physical_address address,
-			      u8 flags, struct acpi_table_header *table);
-
-void
 acpi_tb_install_table_with_override(u32 table_index,
 				    struct acpi_table_desc *new_table_desc,
 				    u8 override);
drivers/acpi/acpica/tbdata.c new file +723 -0

723 lines not on this page · raw message

drivers/acpi/acpica/tbinstal.c +27 -711

804 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#23 lore raw

PATCH 23/28 ACPICA: acpidump: Add support to generate acpidump release.

In reply to Lv Zheng

The acpidump is initiated by Bob Moore and Chao Guan, fixed and completed by Lv Zheng.

This patch is a generation of the commit that adds acpidump release automation into ACPICA release process. Lv Zheng.

Note that this patch doesn't replace the kernel shipped acpidump with the new acpidump. The replacement is done by further patches.

---
 drivers/acpi/acpica/acapps.h                       |  170 +++
 tools/power/acpi/common/getopt.c                   |  239 ++++
 .../acpi/os_specific/service_layers/oslinuxtbl.c   | 1275 ++++++++++++++++++++
 .../acpi/os_specific/service_layers/osunixdir.c    |  204 ++++
 .../acpi/os_specific/service_layers/osunixmap.c    |  151 +++
 tools/power/acpi/tools/acpidump/acpidump.h         |  131 ++
 tools/power/acpi/tools/acpidump/apdump.c           |  451 +++++++
 tools/power/acpi/tools/acpidump/apfiles.c          |  228 ++++
 tools/power/acpi/tools/acpidump/apmain.c           |  340 ++++++
 9 files changed, 3189 insertions(+)
 create mode 100644 drivers/acpi/acpica/acapps.h
 create mode 100644 tools/power/acpi/common/getopt.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixdir.c
 create mode 100644 tools/power/acpi/os_specific/service_layers/osunixmap.c
 create mode 100644 tools/power/acpi/tools/acpidump/acpidump.h
 create mode 100644 tools/power/acpi/tools/acpidump/apdump.c
 create mode 100644 tools/power/acpi/tools/acpidump/apfiles.c
 create mode 100644 tools/power/acpi/tools/acpidump/apmain.c
drivers/acpi/acpica/acapps.h new file +170 -0
new file mode 100644
index 0000000..8698ffb
@@ -0,0 +1,170 @@
+/******************************************************************************
+ *
+ * Module Name: acapps - common include for ACPI applications/tools
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2014, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef _ACAPPS
+#define _ACAPPS
+
+/* Common info for tool signons */
+
+#define ACPICA_NAME                 "Intel ACPI Component Architecture"
+#define ACPICA_COPYRIGHT            "Copyright (c) 2000 - 2014 Intel Corporation"
+
+#if ACPI_MACHINE_WIDTH == 64
+#define ACPI_WIDTH          "-64"
+
+#elif ACPI_MACHINE_WIDTH == 32
+#define ACPI_WIDTH          "-32"
+
+#else
+#error unknown ACPI_MACHINE_WIDTH
+#define ACPI_WIDTH          "-??"
+
+#endif
+
+/* Macros for signons and file headers */
+
+#define ACPI_COMMON_SIGNON(utility_name) \
+	"\n%s\n%s version %8.8X%s [%s]\n%s\n\n", \
+	ACPICA_NAME, \
+	utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, __DATE__, \
+	ACPICA_COPYRIGHT
+
+#define ACPI_COMMON_HEADER(utility_name, prefix) \
+	"%s%s\n%s%s version %8.8X%s [%s]\n%s%s\n%s\n", \
+	prefix, ACPICA_NAME, \
+	prefix, utility_name, ((u32) ACPI_CA_VERSION), ACPI_WIDTH, __DATE__, \
+	prefix, ACPICA_COPYRIGHT, \
+	prefix
+
+/* Macros for usage messages */
+
+#define ACPI_USAGE_HEADER(usage) \
+	printf ("Usage: %s\nOptions:\n", usage);
+
+#define ACPI_OPTION(name, description) \
+	printf ("  %-18s%s\n", name, description);
+
+#define FILE_SUFFIX_DISASSEMBLY     "dsl"
+#define ACPI_TABLE_FILE_SUFFIX      ".dat"
+
+/*
+ * getopt
+ */
+int acpi_getopt(int argc, char **argv, char *opts);
+
+int acpi_getopt_argument(int argc, char **argv);
+
+extern int acpi_gbl_optind;
+extern int acpi_gbl_opterr;
+extern int acpi_gbl_sub_opt_char;
+extern char *acpi_gbl_optarg;
+
+/*
+ * cmfsize - Common get file size function
+ */
+u32 cm_get_file_size(FILE * file);
+
+#ifndef ACPI_DUMP_APP
+/*
+ * adisasm
+ */
+acpi_status
+ad_aml_disassemble(u8 out_to_file,
+		   char *filename, char *prefix, char **out_filename);
+
+void ad_print_statistics(void);
+
+acpi_status ad_find_dsdt(u8 **dsdt_ptr, u32 *dsdt_length);
+
+void ad_dump_tables(void);
+
+acpi_status ad_get_local_tables(void);
+
+acpi_status
+ad_parse_table(struct acpi_table_header *table,
+	       acpi_owner_id * owner_id, u8 load_table, u8 external);
+
+acpi_status ad_display_tables(char *filename, struct acpi_table_header *table);
+
+acpi_status ad_display_statistics(void);
+
+/*
+ * adwalk
+ */
+void
+acpi_dm_cross_reference_namespace(union acpi_parse_object *parse_tree_root,
+				  struct acpi_namespace_node *namespace_root,
+				  acpi_owner_id owner_id);
+
+void acpi_dm_dump_tree(union acpi_parse_object *origin);
+
+void acpi_dm_find_orphan_methods(union acpi_parse_object *origin);
+
+void
+acpi_dm_finish_namespace_load(union acpi_parse_object *parse_tree_root,
+			      struct acpi_namespace_node *namespace_root,
+			      acpi_owner_id owner_id);
+
+void
+acpi_dm_convert_resource_indexes(union acpi_parse_object *parse_tree_root,
+				 struct acpi_namespace_node *namespace_root);
+
+/*
+ * adfile
+ */
+acpi_status ad_initialize(void);
+
+char *fl_generate_filename(char *input_filename, char *suffix);
+
+acpi_status
+fl_split_input_pathname(char *input_path,
+			char **out_directory_path, char **out_filename);
+
+char *ad_generate_filename(char *prefix, char *table_id);
+
+void
+ad_write_table(struct acpi_table_header *table,
+	       u32 length, char *table_name, char *oem_table_id);
+#endif
+
+#endif				/* _ACAPPS */
tools/power/acpi/common/getopt.c new file +239 -0

239 lines not on this page · raw message

tools/power/acpi/os_specific/service_layers/oslinuxtbl.c new file +1275 -0

1,275 lines not on this page · raw message

tools/power/acpi/os_specific/service_layers/osunixdir.c new file +204 -0

204 lines not on this page · raw message

tools/power/acpi/os_specific/service_layers/osunixmap.c new file +151 -0

151 lines not on this page · raw message

tools/power/acpi/tools/acpidump/acpidump.h new file +131 -0

131 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apdump.c new file +451 -0

451 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apfiles.c new file +228 -0

228 lines not on this page · raw message

tools/power/acpi/tools/acpidump/apmain.c new file +340 -0

151 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.10

Part of the diff is not shown here. View the raw message.

author
#24 lore raw

PATCH 24/28 ACPICA: acpidump: Update new structures and add missing file.

In reply to Lv Zheng

This patch is the generation of a commit that updates release automation with newly added structures and files that are referenced by the acpidump.

---
 drivers/acpi/acpica/acglobal.h    |    2 +-
 drivers/acpi/acpica/acutils.h     |    2 +-
 tools/power/acpi/common/cmfsize.c |  101 +++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 tools/power/acpi/common/cmfsize.c
drivers/acpi/acpica/acglobal.h +1 -1
index 0cac564..1f60290 100644
@@ -509,6 +509,6 @@ ACPI_INIT_GLOBAL(ACPI_FILE, acpi_gbl_debug_file, NULL);
  ****************************************************************************/
 
 extern const struct ah_predefined_name asl_predefined_info[];
-extern const AH_DEVICE_ID asl_device_ids[];
+extern const struct ah_device_id asl_device_ids[];
 
 #endif				/* __ACGLOBAL_H__ */
drivers/acpi/acpica/acutils.h +1 -1
index 2cf8d2c..1e256c5 100644
@@ -741,6 +741,6 @@ acpi_ut_method_error(const char *module_name,
  */
 const struct ah_predefined_name *acpi_ah_match_predefined_name(char *nameseg);
 
-const AH_DEVICE_ID *acpi_ah_match_hardware_id(char *hid);
+const struct ah_device_id *acpi_ah_match_hardware_id(char *hid);
 
 #endif				/* _ACUTILS_H */
tools/power/acpi/common/cmfsize.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
1.7.10
author
#25 lore raw

PATCH 25/28 ACPICA: acpidump: Update Makefile to use new acpidump.

In reply to Lv Zheng

This patch updates tools Makefile to use new acpidump.

ACPICA's acpidump relies on various ACPICA components/common/os_specific source code. They are located in various kernel folders, being searched and compiled using vpath technique in Makefile. These files include:
1. drivers/acpi/acpica/acapps.h
2. tools/power/acpi/common/getopt.c
3. tools/power/acpi/common/cmfsize.c
4. tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
5. tools/power/acpi/os_specific/service_layers/osunixdir.c
6. tools/power/acpi/os_specific/service_layers/osunixmap.c

This patch has been tested on DELL Inspiron Mini, acpidump output can be successfully generated by typing the following commands:

# cd tools/power/acpi
# make DEBUG=false
# sudo make install DESTDIR=/opt
# sudo make uninstall DESTDIR=/opt
# make clean
Or
# cd tools
# make acpi
# sudo make acpi_install
# sudo make acpi_uninstall
# make acpi_clean
A kernel build test is also performed on DELL Inspiron Mini to verify that
the changes done to actypes.h and aclinux.h won't affect the kernel
build process.
Cc Chao Guan <[email protected]>
Cc Bob Moore <[email protected]>
---
 tools/power/acpi/Makefile |   26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
tools/power/acpi/Makefile +23 -3
index d9186a2..98625fa 100644
@@ -68,7 +68,8 @@ WARNINGS += $(call cc-supports,-Wstrict-prototypes)
 WARNINGS += $(call cc-supports,-Wdeclaration-after-statement)
 
 KERNEL_INCLUDE := ../../../include
-CFLAGS += -D_LINUX -DDEFINE_ALTERNATE_TYPES -I$(KERNEL_INCLUDE)
+ACPICA_INCLUDE := ../../../drivers/acpi/acpica
+CFLAGS += -D_LINUX -I$(KERNEL_INCLUDE) -I$(ACPICA_INCLUDE)
 CFLAGS += $(WARNINGS)
 
 ifeq ($(strip $(V)),false)
@@ -101,10 +102,29 @@ endif
 # --- ACPIDUMP BEGIN ---
 
 vpath %.c \
-	tools/acpidump
+	../../../drivers/acpi/acpica\
+	tools/acpidump\
+	common\
+	os_specific/service_layers
+
+CFLAGS += -DACPI_DUMP_APP -Itools/acpidump
 
 DUMP_OBJS = \
-	acpidump.o
+	apdump.o\
+	apfiles.o\
+	apmain.o\
+	osunixdir.o\
+	osunixmap.o\
+	tbprint.o\
+	tbxfroot.o\
+	utbuffer.o\
+	utexcep.o\
+	utmath.o\
+	utstring.o\
+	utxferror.o\
+	oslinuxtbl.o\
+	cmfsize.o\
+	getopt.o
 
 DUMP_OBJS := $(addprefix $(OUTPUT)tools/acpidump/,$(DUMP_OBJS))
 
Signature · 1 line
1.7.10
author
#26 lore raw

PATCH 26/28 ACPICA: acpidump: Remove old acpidump source.

In reply to Lv Zheng

This patch removes old acpidump source.

---
 tools/power/acpi/tools/acpidump/acpidump.c |  559 ----------------------------
 1 file changed, 559 deletions(-)
 delete mode 100644 tools/power/acpi/tools/acpidump/acpidump.c
tools/power/acpi/tools/acpidump/acpidump.c deleted +0 -559
deleted file mode 100644
index a84553a..0000000
@@ -1,559 +0,0 @@
-/*
- * (c) Alexey Starikovskiy, Intel, 2005-2006.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- *    substantially similar to the "NO WARRANTY" disclaimer below
- *    ("Disclaimer") and any redistribution must be conditioned upon
- *    including a substantially similar Disclaimer requirement for further
- *    binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- *    of any contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#ifdef DEFINE_ALTERNATE_TYPES
-/* hack to enable building old application with new headers -lenb */
-#define acpi_fadt_descriptor acpi_table_fadt
-#define acpi_rsdp_descriptor acpi_table_rsdp
-#define DSDT_SIG ACPI_SIG_DSDT
-#define FACS_SIG ACPI_SIG_FACS
-#define FADT_SIG ACPI_SIG_FADT
-#define xfirmware_ctrl Xfacs
-#define firmware_ctrl facs
-
-typedef int				s32;
-typedef unsigned char			u8;
-typedef unsigned short			u16;
-typedef unsigned int			u32;
-typedef unsigned long long		u64;
-typedef long long			s64;
-#endif
-
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-
-#include <dirent.h>
-
-#include <acpi/acconfig.h>
-#include <acpi/platform/acenv.h>
-#include <acpi/actypes.h>
-#include <acpi/actbl.h>
-
-static inline u8 checksum(u8 * buffer, u32 length)
-{
-	u8 sum = 0, *i = buffer;
-	buffer += length;
-	for (; i < buffer; sum += *(i++));
-	return sum;
-}
-
-static unsigned long psz, addr, length;
-static int print, connect, skip;
-static u8 select_sig[4];
-
-static unsigned long read_efi_systab( void )
-{
-	char buffer[80];
-	unsigned long addr;
-	FILE *f = fopen("/sys/firmware/efi/systab", "r");
-	if (f) {
-		while (fgets(buffer, 80, f)) {
-			if (sscanf(buffer, "ACPI20=0x%lx", &addr) == 1)
-				return addr;
-		}
-		fclose(f);
-	}
-	return 0;
-}
-
-static u8 *acpi_map_memory(unsigned long where, unsigned length)
-{
-	unsigned long offset;
-	u8 *there;
-	int fd = open("/dev/mem", O_RDONLY);
-	if (fd < 0) {
-		fprintf(stderr, "acpi_os_map_memory: cannot open /dev/mem\n");
-		exit(1);
-	}
-	offset = where % psz;
-	there = mmap(NULL, length + offset, PROT_READ, MAP_PRIVATE,
-			 fd, where - offset);
-	close(fd);
-	if (there == MAP_FAILED) return 0;
-	return (there + offset);
-}
-
-static void acpi_unmap_memory(u8 * there, unsigned length)
-{
-	unsigned long offset = (unsigned long)there % psz;
-	munmap(there - offset, length + offset);
-}
-
-static struct acpi_table_header *acpi_map_table(unsigned long where, char *sig)
-{
-	unsigned size;
-	struct acpi_table_header *tbl = (struct acpi_table_header *)
-	    acpi_map_memory(where, sizeof(struct acpi_table_header));
-	if (!tbl || (sig && memcmp(sig, tbl->signature, 4))) return 0;
-	size = tbl->length;
-	acpi_unmap_memory((u8 *) tbl, sizeof(struct acpi_table_header));
-	return (struct acpi_table_header *)acpi_map_memory(where, size);
-}
-
-static void acpi_unmap_table(struct acpi_table_header *tbl)
-{
-	acpi_unmap_memory((u8 *)tbl, tbl->length);
-}
-
-static struct acpi_rsdp_descriptor *acpi_scan_for_rsdp(u8 *begin, u32 length)
-{
-	struct acpi_rsdp_descriptor *rsdp;
-	u8 *i, *end = begin + length;
-	/* Search from given start address for the requested length */
-	for (i = begin; i < end; i += ACPI_RSDP_SCAN_STEP) {
-		/* The signature and checksum must both be correct */
-		if (memcmp((char *)i, "RSD PTR ", 8)) continue;
-		rsdp = (struct acpi_rsdp_descriptor *)i;
-		/* Signature matches, check the appropriate checksum */
-		if (!checksum((u8 *) rsdp, (rsdp->revision < 2) ?
-			      ACPI_RSDP_CHECKSUM_LENGTH :
-			      ACPI_RSDP_XCHECKSUM_LENGTH))
-			/* Checksum valid, we have found a valid RSDP */
-			return rsdp;
-	}
-	/* Searched entire block, no RSDP was found */
-	return 0;
-}
-
-/*
- * Output data
- */
-static void acpi_show_data(int fd, u8 * data, int size)
-{
-	char buffer[256];
-	int len;
-	int i, remain = size;
-	while (remain > 0) {
-		len = snprintf(buffer, 256, "  %04x:", size - remain);
-		for (i = 0; i < 16 && i < remain; i++) {
-			len +=
-			    snprintf(&buffer[len], 256 - len, " %02x", data[i]);
-		}
-		for (; i < 16; i++) {
-			len += snprintf(&buffer[len], 256 - len, "   ");
-		}
-		len += snprintf(&buffer[len], 256 - len, "  ");
-		for (i = 0; i < 16 && i < remain; i++) {
-			buffer[len++] = (isprint(data[i])) ? data[i] : '.';
-		}
-		buffer[len++] = '\n';
-		write(fd, buffer, len);
-		data += 16;
-		remain -= 16;
-	}
-}
-
-/*
- * Output ACPI table
- */
-static void acpi_show_table(int fd, struct acpi_table_header *table, unsigned long addr)
-{
-	char buff[80];
-	int len = snprintf(buff, 80, "%.4s @ %p\n", table->signature, (void *)addr);
-	write(fd, buff, len);
-	acpi_show_data(fd, (u8 *) table, table->length);
-	buff[0] = '\n';
-	write(fd, buff, 1);
-}
-
-static void write_table(int fd, struct acpi_table_header *tbl, unsigned long addr)
-{
-	static int select_done = 0;
-	if (!select_sig[0]) {
-		if (print) {
-			acpi_show_table(fd, tbl, addr);
-		} else {
-			write(fd, tbl, tbl->length);
-		}
-	} else if (!select_done && !memcmp(select_sig, tbl->signature, 4)) {
-		if (skip > 0) {
-			--skip;
-			return;
-		}
-		if (print) {
-			acpi_show_table(fd, tbl, addr);
-		} else {
-			write(fd, tbl, tbl->length);
-		}
-		select_done = 1;
-	}
-}
-
-static void acpi_dump_FADT(int fd, struct acpi_table_header *tbl, unsigned long xaddr) {
-	struct acpi_fadt_descriptor x;
-	unsigned long addr;
-	size_t len = sizeof(struct acpi_fadt_descriptor);
-	if (len > tbl->length) len = tbl->length;
-	memcpy(&x, tbl, len);
-	x.header.length = len;
-	if (checksum((u8 *)tbl, len)) {
-		fprintf(stderr, "Wrong checksum for FADT!\n");
-	}
-	if (x.header.length >= 148 && x.Xdsdt) {
-		addr = (unsigned long)x.Xdsdt;
-		if (connect) {
-			x.Xdsdt = lseek(fd, 0, SEEK_CUR);
-		}
-	} else if (x.header.length >= 44 && x.dsdt) {
-		addr = (unsigned long)x.dsdt;
-		if (connect) {
-			x.dsdt = lseek(fd, 0, SEEK_CUR);
-		}
-	} else {
-		fprintf(stderr, "No DSDT in FADT!\n");
-		goto no_dsdt;
-	}
-	tbl = acpi_map_table(addr, DSDT_SIG);
-	if (!tbl) goto no_dsdt;
-	if (checksum((u8 *)tbl, tbl->length))
-		fprintf(stderr, "Wrong checksum for DSDT!\n");
-	write_table(fd, tbl, addr);
-	acpi_unmap_table(tbl);
-no_dsdt:
-	if (x.header.length >= 140 && x.xfirmware_ctrl) {
-		addr = (unsigned long)x.xfirmware_ctrl;
-		if (connect) {
-			x.xfirmware_ctrl = lseek(fd, 0, SEEK_CUR);
-		}
-	} else if (x.header.length >= 40 && x.firmware_ctrl) {
-		addr = (unsigned long)x.firmware_ctrl;
-		if (connect) {
-			x.firmware_ctrl = lseek(fd, 0, SEEK_CUR);
-		}
-	} else {
-		fprintf(stderr, "No FACS in FADT!\n");
-		goto no_facs;
-	}
-	tbl = acpi_map_table(addr, FACS_SIG);
-	if (!tbl) goto no_facs;
-	/* do not checksum FACS */
-	write_table(fd, tbl, addr);
-	acpi_unmap_table(tbl);
-no_facs:
-	write_table(fd, (struct acpi_table_header *)&x, xaddr);
-}
-
-static int acpi_dump_SDT(int fd, struct acpi_rsdp_descriptor *rsdp)
-{
-	struct acpi_table_header *sdt, *tbl = 0;
-	int xsdt = 1, i, num;
-	char *offset;
-	unsigned long addr;
-	if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
-		tbl = acpi_map_table(rsdp->xsdt_physical_address, "XSDT");
-	}
-	if (!tbl && rsdp->rsdt_physical_address) {
-		xsdt = 0;
-		tbl = acpi_map_table(rsdp->rsdt_physical_address, "RSDT");
-	}
-	if (!tbl) return 0;
-	sdt = malloc(tbl->length);
-	memcpy(sdt, tbl, tbl->length);
-	acpi_unmap_table(tbl);
-	if (checksum((u8 *)sdt, sdt->length))
-		fprintf(stderr, "Wrong checksum for %s!\n", (xsdt)?"XSDT":"RSDT");
-	num = (sdt->length - sizeof(struct acpi_table_header))/((xsdt)?sizeof(u64):sizeof(u32));
-	offset = (char *)sdt + sizeof(struct acpi_table_header);
-	for (i = 0; i < num; ++i, offset += ((xsdt) ? sizeof(u64) : sizeof(u32))) {
-		addr = (xsdt) ? (unsigned long)(*(u64 *)offset):
-				(unsigned long)(*(u32 *)offset);
-		if (!addr) continue;
-		tbl = acpi_map_table(addr, 0);
-		if (!tbl) continue;
-		if (!memcmp(tbl->signature, FADT_SIG, 4)) {
-			acpi_dump_FADT(fd, tbl, addr);
-		} else {
-			if (checksum((u8 *)tbl, tbl->length))
-				fprintf(stderr, "Wrong checksum for generic table!\n");
-			write_table(fd, tbl, addr);
-		}
-		acpi_unmap_table(tbl);
-		if (connect) {
-			if (xsdt)
-				(*(u64*)offset) = lseek(fd, 0, SEEK_CUR);
-			else
-				(*(u32*)offset) = lseek(fd, 0, SEEK_CUR);
-		}
-	}
-	if (xsdt) {
-		addr = (unsigned long)rsdp->xsdt_physical_address;
-		if (connect) {
-			rsdp->xsdt_physical_address = lseek(fd, 0, SEEK_CUR);
-		}
-	} else {
-		addr = (unsigned long)rsdp->rsdt_physical_address;
-		if (connect) {
-			rsdp->rsdt_physical_address = lseek(fd, 0, SEEK_CUR);
-		}
-	}
-	write_table(fd, sdt, addr);
-	free (sdt);
-	return 1;
-}
-
-#define DYNAMIC_SSDT	"/sys/firmware/acpi/tables/dynamic"
-
-static void acpi_dump_dynamic_SSDT(int fd)
-{
-	struct stat file_stat;
-	char filename[256], *ptr;
-	DIR *tabledir;
-	struct dirent *entry;
-	FILE *fp;
-	int count, readcount, length;
-	struct acpi_table_header table_header, *ptable;
-
-	if (stat(DYNAMIC_SSDT, &file_stat) == -1) {
-		/* The directory doesn't exist */
-		return;
-	}
-	tabledir = opendir(DYNAMIC_SSDT);
-	if(!tabledir){
-		/*can't open the directory */
-		return;
-         }
-
-	while ((entry = readdir(tabledir)) != 0){
-		/* skip the file of . /.. */
-		if (entry->d_name[0] == '.')
-			continue;
-
-		sprintf(filename, "%s/%s", DYNAMIC_SSDT, entry->d_name);
-		fp = fopen(filename, "r");
-		if (fp == NULL) {
-			fprintf(stderr, "Can't open the file of %s\n",
-						filename);
-			continue;
-		}
-		/* Read the Table header to parse the table length */
-		count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
-		if (count < sizeof(table_header)) {
-			/* the length is lessn than ACPI table header. skip it */
-			fclose(fp);
-			continue;
-		}
-		length = table_header.length;
-		ptr = malloc(table_header.length);
-		fseek(fp, 0, SEEK_SET);
-		readcount = 0;
-		while(!feof(fp) && readcount < length) {
-			count = fread(ptr + readcount, 1, 256, fp);
-			readcount += count;
-		}
-		fclose(fp);
-		ptable = (struct acpi_table_header *) ptr;
-		if (checksum((u8 *) ptable, ptable->length))
-			fprintf(stderr, "Wrong checksum "
-					"for dynamic SSDT table!\n");
-		write_table(fd, ptable, 0);
-		free(ptr);
-	}
-	closedir(tabledir);
-	return;
-}
-
-static void usage(const char *progname)
-{
-	puts("Usage:");
-	printf("%s [--addr 0x1234][--table DSDT][--output filename]"
-		"[--binary][--length 0x456][--help]\n", progname);
-	puts("\t--addr 0x1234 or -a 0x1234 -- look for tables at this physical address");
-	puts("\t--table DSDT or -t DSDT -- only dump table with DSDT signature");
-	puts("\t--output filename or -o filename -- redirect output from stdin to filename");
-	puts("\t--binary or -b -- dump data in binary form rather than in hex-dump format");
-	puts("\t--length 0x456 or -l 0x456 -- works only with --addr, dump physical memory"
-		"\n\t\tregion without trying to understand it's contents");
-	puts("\t--skip 2 or -s 2 -- skip 2 tables of the given name and output only 3rd one");
-	puts("\t--help or -h -- this help message");
-	exit(0);
-}
-
-static struct option long_options[] = {
-	{"addr", 1, 0, 0},
-	{"table", 1, 0, 0},
-	{"output", 1, 0, 0},
-	{"binary", 0, 0, 0},
-	{"length", 1, 0, 0},
-	{"skip", 1, 0, 0},
-	{"help", 0, 0, 0},
-	{0, 0, 0, 0}
-};
-int main(int argc, char **argv)
-{
-	int option_index, c, fd;
-	u8 *raw;
-	struct acpi_rsdp_descriptor rsdpx, *x = 0;
-	char *filename = 0;
-	char buff[80];
-	memset(select_sig, 0, 4);
-	print = 1;
-	connect = 0;
-	addr = length = 0;
-	skip = 0;
-	while (1) {
-		option_index = 0;
-		c = getopt_long(argc, argv, "a:t:o:bl:s:h",
-				    long_options, &option_index);
-		if (c == -1)
-			break;
-
-		switch (c) {
-		case 0:
-			switch (option_index) {
-			case 0:
-				addr = strtoul(optarg, (char **)NULL, 16);
-				break;
-			case 1:
-				memcpy(select_sig, optarg, 4);
-				break;
-			case 2:
-				filename = optarg;
-				break;
-			case 3:
-				print = 0;
-				break;
-			case 4:
-				length = strtoul(optarg, (char **)NULL, 16);
-				break;
-			case 5:
-				skip = strtoul(optarg, (char **)NULL, 10);
-				break;
-			case 6:
-				usage(argv[0]);
-				exit(0);
-			}
-			break;
-		case 'a':
-			addr = strtoul(optarg, (char **)NULL, 16);
-			break;
-		case 't':
-			memcpy(select_sig, optarg, 4);
-			break;
-		case 'o':
-			filename = optarg;
-			break;
-		case 'b':
-			print = 0;
-			break;
-		case 'l':
-			length = strtoul(optarg, (char **)NULL, 16);
-			break;
-		case 's':
-			skip = strtoul(optarg, (char **)NULL, 10);
-			break;
-		case 'h':
-			usage(argv[0]);
-			exit(0);
-		default:
-			printf("Unknown option!\n");
-			usage(argv[0]);
-			exit(0);
-		}
-	}
-
-	fd = STDOUT_FILENO;
-	if (filename) {
-		fd = creat(filename, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
-		if (fd < 0)
-			return fd;
-	}
-
-	if (!select_sig[0] && !print) {
-		connect = 1;
-	}
-
-	psz = sysconf(_SC_PAGESIZE);
-	if (length && addr) {
-		/* We know length and address, it means we just want a memory dump */
-		if (!(raw = acpi_map_memory(addr, length)))
-			goto not_found;
-		write(fd, raw, length);
-		acpi_unmap_memory(raw, length);
-		close(fd);
-		return 0;
-	}
-
-	length = sizeof(struct acpi_rsdp_descriptor);
-	if (!addr) {
-		addr = read_efi_systab();
-		if (!addr) {
-			addr = ACPI_HI_RSDP_WINDOW_BASE;
-			length = ACPI_HI_RSDP_WINDOW_SIZE;
-		}
-	}
-
-	if (!(raw = acpi_map_memory(addr, length)) ||
-	    !(x = acpi_scan_for_rsdp(raw, length)))
-		goto not_found;
-
-	/* Find RSDP and print all found tables */
-	memcpy(&rsdpx, x, sizeof(struct acpi_rsdp_descriptor));
-	acpi_unmap_memory(raw, length);
-	if (connect) {
-		lseek(fd, sizeof(struct acpi_rsdp_descriptor), SEEK_SET);
-	}
-	if (!acpi_dump_SDT(fd, &rsdpx))
-		goto not_found;
-	if (connect) {
-		lseek(fd, 0, SEEK_SET);
-		write(fd, x, (rsdpx.revision < 2) ?
-			ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
-	} else if (!select_sig[0] || !memcmp("RSD PTR ", select_sig, 4)) {
-		addr += (long)x - (long)raw;
-		length = snprintf(buff, 80, "RSD PTR @ %p\n", (void *)addr);
-		write(fd, buff, length);
-		acpi_show_data(fd, (u8 *) & rsdpx, (rsdpx.revision < 2) ?
-				ACPI_RSDP_CHECKSUM_LENGTH : ACPI_RSDP_XCHECKSUM_LENGTH);
-		buff[0] = '\n';
-		write(fd, buff, 1);
-	}
-	acpi_dump_dynamic_SSDT(fd);
-	close(fd);
-	return 0;
-not_found:
-	close(fd);
-	fprintf(stderr, "ACPI tables were not found. If you know location "
-		"of RSD PTR table (from dmesg, etc), "
-		"supply it with either --addr or -a option\n");
-	return 1;
-}
Signature · 1 line
1.7.10
author
#27 lore raw

PATCH 27/28 ACPICA: acpidump: Update manual file.

In reply to Lv Zheng

This patch updates man file of acpidump.

Cc Chao Guan <[email protected]>
Cc Bob Moore <[email protected]>
---
 tools/power/acpi/man/acpidump.8 |   85 +++++++++++++++++++++++++++++++++------
 1 file changed, 73 insertions(+), 12 deletions(-)
tools/power/acpi/man/acpidump.8 +73 -12
index adfa991..38f095d 100644
@@ -1,18 +1,64 @@
 .TH ACPIDUMP 8
 .SH NAME
-acpidump \- Dump system's ACPI tables to an ASCII file.
+acpidump \- dump a system's ACPI tables to an ASCII file
+
 .SH SYNOPSIS
-.ft B
-.B acpidump > acpidump.out
+.B acpidump
+.RI [ options ]
+.br
+
 .SH DESCRIPTION
-\fBacpidump \fP dumps the systems ACPI tables to an ASCII file
-appropriate for attaching to a bug report.
+.B acpidump
+dumps the systems ACPI tables to an ASCII file appropriate for
+attaching to a bug report.
 
 Subsequently, they can be processed by utilities in the ACPICA package.
-.SS Options
-no options worth worrying about.
-.PP
-.SH EXAMPLE
+
+.SH OPTIONS
+acpidump options are as follow:
+.TP
+.B Options
+.TP
+.B \-b
+Dump tables to binary files
+.TP
+.B \-c
+Dump customized tables
+.TP
+.B \-h \-?
+This help message
+.TP
+.B \-o <File>
+Redirect output to file
+.TP
+.B \-r <Address>
+Dump tables from specified RSDP
+.TP
+.B \-s
+Print table summaries only
+.TP
+.B \-v
+Display version information
+.TP
+.B \-z
+Verbose mode
+.TP
+.B Table Options
+.TP
+.B \-a <Address>
+Get table via a physical address
+.TP
+.B \-f <BinaryFile>
+Get table via a binary file
+.TP
+.B \-n <Signature>
+Get table via a name/signature
+.TP
+Invocation without parameters dumps all available tables
+.TP
+Multiple mixed instances of -a, -f, and -n are supported
+
+.SH EXAMPLES
 
 .nf
 # acpidump > acpidump.out
@@ -50,10 +96,25 @@ ACPICA: https://acpica.org/
 .ta
 .nf
 /dev/mem
+/sys/firmware/acpi/tables/*
 /sys/firmware/acpi/tables/dynamic/*
+/sys/firmware/efi/systab
 .fi
 
-.PP
 .SH AUTHOR
-.nf
-Written by Len Brown <[email protected]>
+.TP
+Original by:
+ Len Brown <[email protected]>
+.TP
+Written by:
+ Chao Guan <[email protected]>
+.TP
+Updated by:
+ Bob Moore <[email protected]>
+ Lv Zheng <[email protected]>
+
+.SH SEE ALSO
+\&\fIacpixtract\fR\|(8), \fIiasl\fR\|(8).
+
+.SH COPYRIGHT
+COPYRIGHT (c) 2013, Intel Corporation.
Signature · 1 line
1.7.10
author
#28 lore raw

PATCH 28/28 ACPICA: Update version to 20140325.

In reply to Lv Zheng

From: Bob Moore <[email protected]>

Version 20140325.

---
 include/acpi/acpixf.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/acpi/acpixf.h +1 -1
index 8dc9340..913d076 100644
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20140214
+#define ACPI_CA_VERSION                 0x20140325
 
 #include <acpi/acconfig.h>
 #include <acpi/actypes.h>
Signature · 1 line
1.7.10
#29 lore raw
In reply to Lv Zheng
Quoted 70 lines · Lv Zheng

The 20140325 ACPICA kernel resident system updates are linuxized based on the pm/linux-next branch.

The patch set has passed the following build/boot tests. Build tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. i386 + allyes + CONFIG_ACPI=y
3. i386 + default + COFNIG_ACPI=n
4. i386 + allyes + CONFIG_ACPI=n
5. x86_64 + default + COFNIG_ACPI=y
6. x86_64 + allyes + CONFIG_ACPI=y
7. x86_64 + default + COFNIG_ACPI=n
8. x86_64 + allyes + CONFIG_ACPI=n
Boot tests are performed as follows:
1. i386 + default + COFNIG_ACPI=y
2. x86_64 + default + COFNIG_ACPI=y
Where:
1. i386: machine named as "Dell Inspiron Mini 1010"
2. x86_64: machine named as "HP Compaq 8200 Elite SFF PC"
3. default: kernel configuration with following items enabled:
All hardware drivers related to the machines of i386/x86_64 All drivers/acpi configurations
All platform drivers
All ACPI drivers
4 DRM drivers that implement ACPI opregion
All buses with ACPI bindings
All cpufreq configurations
All xen configurations
All ACPI tabln drivers
4. allyes: kernel configuration generated by allyesconfig.

After applying this series, the divergence result is:
1089 Lines, 38.9 Kbytes.

Bob Moore (10):
ACPICA: Add EXPORT_SYMBOL macros for install/remove SCI handler
interfaces.
ACPICA: Update comments for ACPICA name - no functional change.
ACPICA: gcc-specific: Fix possible issue with the strchr function.
ACPICA: Unload operator: Emit a warning if and when it is ever used.
ACPICA: Disassembler: Add support to decode _HID and _CID values.
ACPICA: Disassembler: Add decoding of Notify() values.
ACPICA: Add a missing field for debug dump of mutex objects.
ACPICA: Table Manager: Misc cleanup and renames, no functional
change.
ACPICA: Table Manager: Split tbinstal.c into two files.
ACPICA: Update version to 20140325.

Colin Ian King (1):
ACPICA: Linux-specific header: Add support for PPC64 compilation.

David Binderman (1):
ACPICA: utstring: Check array index bound before use.

Lv Zheng (16):
ACPICA: Update use of acpi_os_wait_events_complete interface.
ACPI: Merge divergence of the commmit: ACPICA: Linux-specific header:
Update support for Linux/acpi applications.
ACPICA: Remove indent divergences to reduce the difficulties of
maintaining the revised ACPICA commits.
ACPICA: Tables: Fix the issues in handling virtual addressed tables.
ACPICA: Tables: Fix the issue that multiple ACPI_FREE()s are invoked
for same pointer around acpi_tb_add_table().
ACPICA: Tables: Cleanup split INSTALLED/VALIDATED table state logics.
ACPICA: Tables: Fix the issue that table validations are not
balanced.
ACPICA: Tables: Fix the issue that table checksums are not always
verified before installation.
ACPICA: Tables: Cleanup ACPI_TABLE_ORIGIN_xxx flags.
ACPICA: Tables: Avoid SSDT installation when

Quoted 8 lines

acpi_gbl_disable_ssdt_table_load is specified.
ACPICA: Tables: Add acpi_install_table() API to be invoked by OSPM
early table installation.
ACPICA: acpidump: Add support to generate acpidump release.
ACPICA: acpidump: Update new structures and add missing file.
ACPICA: acpidump: Update Makefile to use new acpidump.
ACPICA: acpidump: Remove old acpidump source.
ACPICA: acpidump: Update manual file.

Looks good to me, but since I don't see anything super-urgent here, I've queued it up for 3.16 in the bleeding-edge branch (I'll move it to linux-next after 3.15-rc1).

Thanks!

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.