Skip to content

Commit a406dea

Browse files
acpibobrafaeljw
authored andcommitted
ACPICA: Cleanup/simplify module-level code support
This prepares the code for eventual removal of the original style of deferred execution of the MLC. Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Erik Schmauss <erik.schmauss@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent b4c0de3 commit a406dea

9 files changed

Lines changed: 116 additions & 70 deletions

File tree

‎drivers/acpi/acpica/evrgnini.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ acpi_status acpi_ev_initialize_region(union acpi_operand_object *region_obj)
526526
* Node's object was replaced by this Method object and we
527527
* saved the handler in the method object.
528528
*
529+
* Note: Only used for the legacy MLC support. Will
530+
* be removed in the future.
531+
*
529532
* See acpi_ns_exec_module_code
530533
*/
531534
if (!acpi_gbl_execute_tables_as_methods &&

‎drivers/acpi/acpica/nseval.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info)
310310
* DESCRIPTION: Execute all elements of the global module-level code list.
311311
* Each element is executed as a single control method.
312312
*
313+
* NOTE: With this option enabled, each block of detected executable AML
314+
* code that is outside of any control method is wrapped with a temporary
315+
* control method object and placed on a global list. The methods on this
316+
* list are executed below.
317+
*
318+
* This function executes the module-level code for all tables only after
319+
* all of the tables have been loaded. It is a legacy option and is
320+
* not compatible with other ACPI implementations. See acpi_ns_load_table.
321+
*
322+
* This function will be removed when the legacy option is removed.
323+
*
313324
******************************************************************************/
314325

315326
void acpi_ns_exec_module_code_list(void)
@@ -325,6 +336,9 @@ void acpi_ns_exec_module_code_list(void)
325336

326337
next = acpi_gbl_module_code_list;
327338
if (!next) {
339+
ACPI_DEBUG_PRINT((ACPI_DB_INIT_NAMES,
340+
"Legacy MLC block list is empty\n"));
341+
328342
return_VOID;
329343
}
330344

‎drivers/acpi/acpica/nsload.c‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,17 @@ acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node)
111111
"**** Completed Table Object Initialization\n"));
112112

113113
/*
114-
* Execute any module-level code that was detected during the table load
115-
* phase. Although illegal since ACPI 2.0, there are many machines that
116-
* contain this type of code. Each block of detected executable AML code
117-
* outside of any control method is wrapped with a temporary control
118-
* method object and placed on a global list. The methods on this list
119-
* are executed below.
114+
* This case handles the legacy option that groups all module-level
115+
* code blocks together and defers execution until all of the tables
116+
* are loaded. Execute all of these blocks at this time.
117+
* Execute any module-level code that was detected during the table
118+
* load phase.
120119
*
121-
* This case executes the module-level code for each table immediately
122-
* after the table has been loaded. This provides compatibility with
123-
* other ACPI implementations. Optionally, the execution can be deferred
124-
* until later, see acpi_initialize_objects.
120+
* Note: this option is deprecated and will be eliminated in the
121+
* future. Use of this option can cause problems with AML code that
122+
* depends upon in-order immediate execution of module-level code.
125123
*/
126-
if (!acpi_gbl_execute_tables_as_methods
127-
&& !acpi_gbl_group_module_level_code) {
128-
acpi_ns_exec_module_code_list();
129-
}
130-
124+
acpi_ns_exec_module_code_list();
131125
return_ACPI_STATUS(status);
132126
}
133127

‎drivers/acpi/acpica/nsparse.c‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,17 @@ ACPI_MODULE_NAME("nsparse")
2727
*
2828
* RETURN: Status
2929
*
30-
* DESCRIPTION: Load ACPI/AML table by executing the entire table as a
31-
* term_list.
30+
* DESCRIPTION: Load ACPI/AML table by executing the entire table as a single
31+
* large control method.
32+
*
33+
* NOTE: The point of this is to execute any module-level code in-place
34+
* as the table is parsed. Some AML code depends on this behavior.
35+
*
36+
* It is a run-time option at this time, but will eventually become
37+
* the default.
38+
*
39+
* Note: This causes the table to only have a single-pass parse.
40+
* However, this is compatible with other ACPI implementations.
3241
*
3342
******************************************************************************/
3443
acpi_status
@@ -233,6 +242,17 @@ acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node)
233242
ACPI_FUNCTION_TRACE(ns_parse_table);
234243

235244
if (acpi_gbl_execute_tables_as_methods) {
245+
/*
246+
* This case executes the AML table as one large control method.
247+
* The point of this is to execute any module-level code in-place
248+
* as the table is parsed. Some AML code depends on this behavior.
249+
*
250+
* It is a run-time option at this time, but will eventually become
251+
* the default.
252+
*
253+
* Note: This causes the table to only have a single-pass parse.
254+
* However, this is compatible with other ACPI implementations.
255+
*/
236256
ACPI_DEBUG_PRINT_RAW((ACPI_DB_PARSE,
237257
"%s: **** Start table execution pass\n",
238258
ACPI_GET_FUNCTION_NAME));

‎drivers/acpi/acpica/psloop.c‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,18 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
136136
walk_state->pass_number));
137137

138138
/*
139-
* Handle executable code at "module-level". This refers to
140-
* executable opcodes that appear outside of any control method.
139+
* This case handles the legacy option that groups all module-level
140+
* code blocks together and defers execution until all of the tables
141+
* are loaded. Execute all of these blocks at this time.
142+
* Execute any module-level code that was detected during the table
143+
* load phase.
144+
*
145+
* Note: this option is deprecated and will be eliminated in the
146+
* future. Use of this option can cause problems with AML code that
147+
* depends upon in-order immediate execution of module-level code.
141148
*/
142-
if ((walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) &&
149+
if (acpi_gbl_group_module_level_code &&
150+
(walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) &&
143151
((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
144152
/*
145153
* We want to skip If/Else/While constructs during Pass1 because we
@@ -306,6 +314,16 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
306314
* object to the global list. Note, the mutex field of the method
307315
* object is used to link multiple module-level code objects.
308316
*
317+
* NOTE: In this legacy option, each block of detected executable AML
318+
* code that is outside of any control method is wrapped with a temporary
319+
* control method object and placed on a global list below.
320+
*
321+
* This function executes the module-level code for all tables only after
322+
* all of the tables have been loaded. It is a legacy option and is
323+
* not compatible with other ACPI implementations. See acpi_ns_load_table.
324+
*
325+
* This function will be removed when the legacy option is removed.
326+
*
309327
******************************************************************************/
310328

311329
static void

‎drivers/acpi/acpica/tbdata.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -932,12 +932,18 @@ acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node)
932932

933933
status = acpi_ns_load_table(table_index, parent_node);
934934

935-
/* Execute any module-level code that was found in the table */
936-
937-
if (!acpi_gbl_execute_tables_as_methods
938-
&& acpi_gbl_group_module_level_code) {
939-
acpi_ns_exec_module_code_list();
940-
}
935+
/*
936+
* This case handles the legacy option that groups all module-level
937+
* code blocks together and defers execution until all of the tables
938+
* are loaded. Execute all of these blocks at this time.
939+
* Execute any module-level code that was detected during the table
940+
* load phase.
941+
*
942+
* Note: this option is deprecated and will be eliminated in the
943+
* future. Use of this option can cause problems with AML code that
944+
* depends upon in-order immediate execution of module-level code.
945+
*/
946+
acpi_ns_exec_module_code_list();
941947

942948
/*
943949
* Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is

‎drivers/acpi/acpica/tbxfload.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ acpi_status ACPI_INIT_FUNCTION acpi_load_tables(void)
7272
if (acpi_gbl_execute_tables_as_methods
7373
|| !acpi_gbl_group_module_level_code) {
7474
/*
75-
* Initialize the objects that remain uninitialized. This
76-
* runs the executable AML that may be part of the
77-
* declaration of these objects:
78-
* operation_regions, buffer_fields, Buffers, and Packages.
75+
* If the module-level code support is enabled, initialize the objects
76+
* in the namespace that remain uninitialized. This runs the executable
77+
* AML that may be part of the declaration of these name objects:
78+
* operation_regions, buffer_fields, Buffers, and Packages.
79+
*
80+
* Note: The module-level code is optional at this time, but will
81+
* become the default in the future.
7982
*/
8083
status = acpi_ns_initialize_objects();
8184
if (ACPI_FAILURE(status)) {

‎drivers/acpi/acpica/utxfinit.c‎

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -211,41 +211,29 @@ acpi_status ACPI_INIT_FUNCTION acpi_initialize_objects(u32 flags)
211211

212212
ACPI_FUNCTION_TRACE(acpi_initialize_objects);
213213

214-
#ifdef ACPI_EXEC_APP
215214
/*
216-
* This call implements the "initialization file" option for acpi_exec.
217-
* This is the precise point that we want to perform the overrides.
215+
* This case handles the legacy option that groups all module-level
216+
* code blocks together and defers execution until all of the tables
217+
* are loaded. Execute all of these blocks at this time.
218+
* Execute any module-level code that was detected during the table
219+
* load phase.
220+
*
221+
* Note: this option is deprecated and will be eliminated in the
222+
* future. Use of this option can cause problems with AML code that
223+
* depends upon in-order immediate execution of module-level code.
218224
*/
219-
ae_do_object_overrides();
220-
#endif
225+
acpi_ns_exec_module_code_list();
221226

222227
/*
223-
* Execute any module-level code that was detected during the table load
224-
* phase. Although illegal since ACPI 2.0, there are many machines that
225-
* contain this type of code. Each block of detected executable AML code
226-
* outside of any control method is wrapped with a temporary control
227-
* method object and placed on a global list. The methods on this list
228-
* are executed below.
229-
*
230-
* This case executes the module-level code for all tables only after
231-
* all of the tables have been loaded. It is a legacy option and is
232-
* not compatible with other ACPI implementations. See acpi_ns_load_table.
228+
* Initialize the objects that remain uninitialized. This
229+
* runs the executable AML that may be part of the
230+
* declaration of these objects:
231+
* operation_regions, buffer_fields, Buffers, and Packages.
233232
*/
234-
if (!acpi_gbl_execute_tables_as_methods
235-
&& acpi_gbl_group_module_level_code) {
236-
acpi_ns_exec_module_code_list();
237-
238-
/*
239-
* Initialize the objects that remain uninitialized. This
240-
* runs the executable AML that may be part of the
241-
* declaration of these objects:
242-
* operation_regions, buffer_fields, Buffers, and Packages.
243-
*/
244-
if (!(flags & ACPI_NO_OBJECT_INIT)) {
245-
status = acpi_ns_initialize_objects();
246-
if (ACPI_FAILURE(status)) {
247-
return_ACPI_STATUS(status);
248-
}
233+
if (!(flags & ACPI_NO_OBJECT_INIT)) {
234+
status = acpi_ns_initialize_objects();
235+
if (ACPI_FAILURE(status)) {
236+
return_ACPI_STATUS(status);
249237
}
250238
}
251239

‎include/acpi/actypes.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -537,17 +537,17 @@ typedef u64 acpi_integer;
537537
******************************************************************************/
538538

539539
/*
540-
* Initialization sequence
540+
* Initialization sequence options
541541
*/
542-
#define ACPI_FULL_INITIALIZATION 0x00
543-
#define ACPI_NO_ADDRESS_SPACE_INIT 0x01
544-
#define ACPI_NO_HARDWARE_INIT 0x02
545-
#define ACPI_NO_EVENT_INIT 0x04
546-
#define ACPI_NO_HANDLER_INIT 0x08
547-
#define ACPI_NO_ACPI_ENABLE 0x10
548-
#define ACPI_NO_DEVICE_INIT 0x20
549-
#define ACPI_NO_OBJECT_INIT 0x40
550-
#define ACPI_NO_FACS_INIT 0x80
542+
#define ACPI_FULL_INITIALIZATION 0x0000
543+
#define ACPI_NO_FACS_INIT 0x0001
544+
#define ACPI_NO_ACPI_ENABLE 0x0002
545+
#define ACPI_NO_HARDWARE_INIT 0x0004
546+
#define ACPI_NO_EVENT_INIT 0x0008
547+
#define ACPI_NO_HANDLER_INIT 0x0010
548+
#define ACPI_NO_OBJECT_INIT 0x0020
549+
#define ACPI_NO_DEVICE_INIT 0x0040
550+
#define ACPI_NO_ADDRESS_SPACE_INIT 0x0080
551551

552552
/*
553553
* Initialization state

0 commit comments

Comments
 (0)