summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2017-08-03 02:27:22 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-08-03 17:34:17 -0400
commita62a7117d91ca83d319566cbe16039f4e9f413c2 (patch)
tree23be92692a4e0191972530325761627ca526bb73
parent7ab58197d84c29cf20162eaaed1eb2cc94fc73a7 (diff)
ACPICA: Implement deferred resolution of reference package elements
ACPICA commit 0c08790c56fdf0dc081ae869495a09d8c4230854 This change defers the resolution of package elements that are named references until after the entire namespace has been loaded from the definition block. This allows such references to be in fact forward references for both module level code and control methods. Link: https://github.com/acpica/acpica/commit/0c08790c Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/acdispat.h13
-rw-r--r--drivers/acpi/acpica/aclocal.h2
-rw-r--r--drivers/acpi/acpica/acobject.h3
-rw-r--r--drivers/acpi/acpica/acutils.h2
-rw-r--r--drivers/acpi/acpica/dsobject.c398
-rw-r--r--drivers/acpi/acpica/dsopcode.c9
-rw-r--r--drivers/acpi/acpica/dspkginit.c496
-rw-r--r--drivers/acpi/acpica/nsarguments.c21
-rw-r--r--drivers/acpi/acpica/nsinit.c14
-rw-r--r--drivers/acpi/acpica/nsnames.c9
-rw-r--r--drivers/acpi/acpica/psloop.c14
-rw-r--r--drivers/acpi/acpica/utmisc.c8
-rw-r--r--drivers/acpi/acpica/utobject.c5
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/uttrack.c9
16 files changed, 661 insertions, 345 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index b125bdd3d58b..1709551bc4aa 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -18,6 +18,7 @@ acpi-y := \
18 dsmthdat.o \ 18 dsmthdat.o \
19 dsobject.o \ 19 dsobject.o \
20 dsopcode.o \ 20 dsopcode.o \
21 dspkginit.o \
21 dsutils.o \ 22 dsutils.o \
22 dswexec.o \ 23 dswexec.o \
23 dswload.o \ 24 dswload.o \
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 0d95c85cce06..f8f3a6e74128 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -237,6 +237,11 @@ acpi_ds_initialize_objects(u32 table_index,
237 * dsobject - Parser/Interpreter interface - object initialization and conversion 237 * dsobject - Parser/Interpreter interface - object initialization and conversion
238 */ 238 */
239acpi_status 239acpi_status
240acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
241 union acpi_parse_object *op,
242 union acpi_operand_object **obj_desc_ptr);
243
244acpi_status
240acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state, 245acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
241 union acpi_parse_object *op, 246 union acpi_parse_object *op,
242 u32 buffer_length, 247 u32 buffer_length,
@@ -259,6 +264,14 @@ acpi_ds_create_node(struct acpi_walk_state *walk_state,
259 union acpi_parse_object *op); 264 union acpi_parse_object *op);
260 265
261/* 266/*
267 * dspkginit - Package object initialization
268 */
269acpi_status
270acpi_ds_init_package_element(u8 object_type,
271 union acpi_operand_object *source_object,
272 union acpi_generic_state *state, void *context);
273
274/*
262 * dsutils - Parser/Interpreter interface utility routines 275 * dsutils - Parser/Interpreter interface utility routines
263 */ 276 */
264void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state); 277void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state);
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index bae943b5f377..0d45b8bb1678 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -605,7 +605,7 @@ struct acpi_update_state {
605 * Pkg state - used to traverse nested package structures 605 * Pkg state - used to traverse nested package structures
606 */ 606 */
607struct acpi_pkg_state { 607struct acpi_pkg_state {
608 ACPI_STATE_COMMON u16 index; 608 ACPI_STATE_COMMON u32 index;
609 union acpi_operand_object *source_object; 609 union acpi_operand_object *source_object;
610 union acpi_operand_object *dest_object; 610 union acpi_operand_object *dest_object;
611 struct acpi_walk_state *walk_state; 611 struct acpi_walk_state *walk_state;
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 549f227348cd..5226146190bf 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -339,11 +339,12 @@ struct acpi_object_addr_handler {
339struct acpi_object_reference { 339struct acpi_object_reference {
340 ACPI_OBJECT_COMMON_HEADER u8 class; /* Reference Class */ 340 ACPI_OBJECT_COMMON_HEADER u8 class; /* Reference Class */
341 u8 target_type; /* Used for Index Op */ 341 u8 target_type; /* Used for Index Op */
342 u8 reserved; 342 u8 resolved; /* Reference has been resolved to a value */
343 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */ 343 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */
344 struct acpi_namespace_node *node; /* ref_of or Namepath */ 344 struct acpi_namespace_node *node; /* ref_of or Namepath */
345 union acpi_operand_object **where; /* Target of Index */ 345 union acpi_operand_object **where; /* Target of Index */
346 u8 *index_pointer; /* Used for Buffers and Strings */ 346 u8 *index_pointer; /* Used for Buffers and Strings */
347 u8 *aml; /* Used for deferred resolution of the ref */
347 u32 value; /* Used for Local/Arg/Index/ddb_handle */ 348 u32 value; /* Used for Local/Arg/Index/ddb_handle */
348}; 349};
349 350
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 0a5601405584..745134ade35f 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -516,7 +516,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
516 516
517union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, 517union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
518 void *external_object, 518 void *external_object,
519 u16 index); 519 u32 index);
520 520
521acpi_status 521acpi_status
522acpi_ut_create_update_state_and_push(union acpi_operand_object *object, 522acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 7df3152ed856..82448551781b 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -52,12 +52,6 @@
52#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsobject") 53ACPI_MODULE_NAME("dsobject")
54 54
55/* Local prototypes */
56static acpi_status
57acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
58 union acpi_parse_object *op,
59 union acpi_operand_object **obj_desc_ptr);
60
61#ifndef ACPI_NO_METHOD_EXECUTION 55#ifndef ACPI_NO_METHOD_EXECUTION
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
@@ -73,15 +67,13 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
73 * Simple objects are any objects other than a package object! 67 * Simple objects are any objects other than a package object!
74 * 68 *
75 ******************************************************************************/ 69 ******************************************************************************/
76 70acpi_status
77static acpi_status
78acpi_ds_build_internal_object(struct acpi_walk_state *walk_state, 71acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
79 union acpi_parse_object *op, 72 union acpi_parse_object *op,
80 union acpi_operand_object **obj_desc_ptr) 73 union acpi_operand_object **obj_desc_ptr)
81{ 74{
82 union acpi_operand_object *obj_desc; 75 union acpi_operand_object *obj_desc;
83 acpi_status status; 76 acpi_status status;
84 acpi_object_type type;
85 77
86 ACPI_FUNCTION_TRACE(ds_build_internal_object); 78 ACPI_FUNCTION_TRACE(ds_build_internal_object);
87 79
@@ -89,140 +81,47 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
89 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 81 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
90 /* 82 /*
91 * This is a named object reference. If this name was 83 * This is a named object reference. If this name was
92 * previously looked up in the namespace, it was stored in this op. 84 * previously looked up in the namespace, it was stored in
93 * Otherwise, go ahead and look it up now 85 * this op. Otherwise, go ahead and look it up now
94 */ 86 */
95 if (!op->common.node) { 87 if (!op->common.node) {
96 status = acpi_ns_lookup(walk_state->scope_info,
97 op->common.value.string,
98 ACPI_TYPE_ANY,
99 ACPI_IMODE_EXECUTE,
100 ACPI_NS_SEARCH_PARENT |
101 ACPI_NS_DONT_OPEN_SCOPE, NULL,
102 ACPI_CAST_INDIRECT_PTR(struct
103 acpi_namespace_node,
104 &(op->
105 common.
106 node)));
107 if (ACPI_FAILURE(status)) {
108
109 /* Check if we are resolving a named reference within a package */
110
111 if ((status == AE_NOT_FOUND)
112 && (acpi_gbl_enable_interpreter_slack)
113 &&
114 ((op->common.parent->common.aml_opcode ==
115 AML_PACKAGE_OP)
116 || (op->common.parent->common.aml_opcode ==
117 AML_VARIABLE_PACKAGE_OP))) {
118 /*
119 * We didn't find the target and we are populating elements
120 * of a package - ignore if slack enabled. Some ASL code
121 * contains dangling invalid references in packages and
122 * expects that no exception will be issued. Leave the
123 * element as a null element. It cannot be used, but it
124 * can be overwritten by subsequent ASL code - this is
125 * typically the case.
126 */
127 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
128 "Ignoring unresolved reference in package [%4.4s]\n",
129 walk_state->
130 scope_info->scope.
131 node->name.ascii));
132
133 return_ACPI_STATUS(AE_OK);
134 } else {
135 ACPI_ERROR_NAMESPACE(op->common.value.
136 string, status);
137 }
138
139 return_ACPI_STATUS(status);
140 }
141 }
142
143 /* Special object resolution for elements of a package */
144
145 if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
146 (op->common.parent->common.aml_opcode ==
147 AML_VARIABLE_PACKAGE_OP)) {
148 /*
149 * Attempt to resolve the node to a value before we insert it into
150 * the package. If this is a reference to a common data type,
151 * resolve it immediately. According to the ACPI spec, package
152 * elements can only be "data objects" or method references.
153 * Attempt to resolve to an Integer, Buffer, String or Package.
154 * If cannot, return the named reference (for things like Devices,
155 * Methods, etc.) Buffer Fields and Fields will resolve to simple
156 * objects (int/buf/str/pkg).
157 *
158 * NOTE: References to things like Devices, Methods, Mutexes, etc.
159 * will remain as named references. This behavior is not described
160 * in the ACPI spec, but it appears to be an oversight.
161 */
162 obj_desc =
163 ACPI_CAST_PTR(union acpi_operand_object,
164 op->common.node);
165
166 status =
167 acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
168 (struct
169 acpi_namespace_node,
170 &obj_desc),
171 walk_state);
172 if (ACPI_FAILURE(status)) {
173 return_ACPI_STATUS(status);
174 }
175
176 /*
177 * Special handling for Alias objects. We need to setup the type
178 * and the Op->Common.Node to point to the Alias target. Note,
179 * Alias has at most one level of indirection internally.
180 */
181 type = op->common.node->type;
182 if (type == ACPI_TYPE_LOCAL_ALIAS) {
183 type = obj_desc->common.type;
184 op->common.node =
185 ACPI_CAST_PTR(struct acpi_namespace_node,
186 op->common.node->object);
187 }
188
189 switch (type) {
190 /*
191 * For these types, we need the actual node, not the subobject.
192 * However, the subobject did not get an extra reference count above.
193 *
194 * TBD: should ex_resolve_node_to_value be changed to fix this?
195 */
196 case ACPI_TYPE_DEVICE:
197 case ACPI_TYPE_THERMAL:
198
199 acpi_ut_add_reference(op->common.node->object);
200 88
201 /*lint -fallthrough */ 89 /* Check if we are resolving a named reference within a package */
202 /*
203 * For these types, we need the actual node, not the subobject.
204 * The subobject got an extra reference count in ex_resolve_node_to_value.
205 */
206 case ACPI_TYPE_MUTEX:
207 case ACPI_TYPE_METHOD:
208 case ACPI_TYPE_POWER:
209 case ACPI_TYPE_PROCESSOR:
210 case ACPI_TYPE_EVENT:
211 case ACPI_TYPE_REGION:
212
213 /* We will create a reference object for these types below */
214 break;
215 90
216 default: 91 if ((op->common.parent->common.aml_opcode ==
92 AML_PACKAGE_OP)
93 || (op->common.parent->common.aml_opcode ==
94 AML_VARIABLE_PACKAGE_OP)) {
217 /* 95 /*
218 * All other types - the node was resolved to an actual 96 * We won't resolve package elements here, we will do this
219 * object, we are done. 97 * after all ACPI tables are loaded into the namespace. This
98 * behavior supports both forward references to named objects
99 * and external references to objects in other tables.
220 */ 100 */
221 goto exit; 101 goto create_new_object;
102 } else {
103 status = acpi_ns_lookup(walk_state->scope_info,
104 op->common.value.string,
105 ACPI_TYPE_ANY,
106 ACPI_IMODE_EXECUTE,
107 ACPI_NS_SEARCH_PARENT |
108 ACPI_NS_DONT_OPEN_SCOPE,
109 NULL,
110 ACPI_CAST_INDIRECT_PTR
111 (struct
112 acpi_namespace_node,
113 &(op->common.node)));
114 if (ACPI_FAILURE(status)) {
115 ACPI_ERROR_NAMESPACE(op->common.value.
116 string, status);
117 return_ACPI_STATUS(status);
118 }
222 } 119 }
223 } 120 }
224 } 121 }
225 122
123create_new_object:
124
226 /* Create and init a new internal ACPI object */ 125 /* Create and init a new internal ACPI object */
227 126
228 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info 127 obj_desc = acpi_ut_create_internal_object((acpi_ps_get_opcode_info
@@ -240,7 +139,27 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
240 return_ACPI_STATUS(status); 139 return_ACPI_STATUS(status);
241 } 140 }
242 141
243exit: 142 /*
143 * Handling for unresolved package reference elements.
144 * These are elements that are namepaths.
145 */
146 if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
147 (op->common.parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
148 obj_desc->reference.resolved = TRUE;
149
150 if ((op->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
151 !obj_desc->reference.node) {
152 /*
153 * Name was unresolved above.
154 * Get the prefix node for later lookup
155 */
156 obj_desc->reference.node =
157 walk_state->scope_info->scope.node;
158 obj_desc->reference.aml = op->common.aml;
159 obj_desc->reference.resolved = FALSE;
160 }
161 }
162
244 *obj_desc_ptr = obj_desc; 163 *obj_desc_ptr = obj_desc;
245 return_ACPI_STATUS(status); 164 return_ACPI_STATUS(status);
246} 165}
@@ -351,200 +270,6 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
351 270
352/******************************************************************************* 271/*******************************************************************************
353 * 272 *
354 * FUNCTION: acpi_ds_build_internal_package_obj
355 *
356 * PARAMETERS: walk_state - Current walk state
357 * op - Parser object to be translated
358 * element_count - Number of elements in the package - this is
359 * the num_elements argument to Package()
360 * obj_desc_ptr - Where the ACPI internal object is returned
361 *
362 * RETURN: Status
363 *
364 * DESCRIPTION: Translate a parser Op package object to the equivalent
365 * namespace object
366 *
367 * NOTE: The number of elements in the package will be always be the num_elements
368 * count, regardless of the number of elements in the package list. If
369 * num_elements is smaller, only that many package list elements are used.
370 * if num_elements is larger, the Package object is padded out with
371 * objects of type Uninitialized (as per ACPI spec.)
372 *
373 * Even though the ASL compilers do not allow num_elements to be smaller
374 * than the Package list length (for the fixed length package opcode), some
375 * BIOS code modifies the AML on the fly to adjust the num_elements, and
376 * this code compensates for that. This also provides compatibility with
377 * other AML interpreters.
378 *
379 ******************************************************************************/
380
381acpi_status
382acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
383 union acpi_parse_object *op,
384 u32 element_count,
385 union acpi_operand_object **obj_desc_ptr)
386{
387 union acpi_parse_object *arg;
388 union acpi_parse_object *parent;
389 union acpi_operand_object *obj_desc = NULL;
390 acpi_status status = AE_OK;
391 u32 i;
392 u16 index;
393 u16 reference_count;
394
395 ACPI_FUNCTION_TRACE(ds_build_internal_package_obj);
396
397 /* Find the parent of a possibly nested package */
398
399 parent = op->common.parent;
400 while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
401 (parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
402 parent = parent->common.parent;
403 }
404
405 /*
406 * If we are evaluating a Named package object "Name (xxxx, Package)",
407 * the package object already exists, otherwise it must be created.
408 */
409 obj_desc = *obj_desc_ptr;
410 if (!obj_desc) {
411 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
412 *obj_desc_ptr = obj_desc;
413 if (!obj_desc) {
414 return_ACPI_STATUS(AE_NO_MEMORY);
415 }
416
417 obj_desc->package.node = parent->common.node;
418 }
419
420 /*
421 * Allocate the element array (array of pointers to the individual
422 * objects) based on the num_elements parameter. Add an extra pointer slot
423 * so that the list is always null terminated.
424 */
425 obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
426 element_count +
427 1) * sizeof(void *));
428
429 if (!obj_desc->package.elements) {
430 acpi_ut_delete_object_desc(obj_desc);
431 return_ACPI_STATUS(AE_NO_MEMORY);
432 }
433
434 obj_desc->package.count = element_count;
435
436 /*
437 * Initialize the elements of the package, up to the num_elements count.
438 * Package is automatically padded with uninitialized (NULL) elements
439 * if num_elements is greater than the package list length. Likewise,
440 * Package is truncated if num_elements is less than the list length.
441 */
442 arg = op->common.value.arg;
443 arg = arg->common.next;
444 for (i = 0; arg && (i < element_count); i++) {
445 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
446 if (arg->common.node->type == ACPI_TYPE_METHOD) {
447 /*
448 * A method reference "looks" to the parser to be a method
449 * invocation, so we special case it here
450 */
451 arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
452 status =
453 acpi_ds_build_internal_object(walk_state,
454 arg,
455 &obj_desc->
456 package.
457 elements[i]);
458 } else {
459 /* This package element is already built, just get it */
460
461 obj_desc->package.elements[i] =
462 ACPI_CAST_PTR(union acpi_operand_object,
463 arg->common.node);
464 }
465 } else {
466 status =
467 acpi_ds_build_internal_object(walk_state, arg,
468 &obj_desc->package.
469 elements[i]);
470 }
471
472 if (*obj_desc_ptr) {
473
474 /* Existing package, get existing reference count */
475
476 reference_count =
477 (*obj_desc_ptr)->common.reference_count;
478 if (reference_count > 1) {
479
480 /* Make new element ref count match original ref count */
481
482 for (index = 0; index < (reference_count - 1);
483 index++) {
484 acpi_ut_add_reference((obj_desc->
485 package.
486 elements[i]));
487 }
488 }
489 }
490
491 arg = arg->common.next;
492 }
493
494 /* Check for match between num_elements and actual length of package_list */
495
496 if (arg) {
497 /*
498 * num_elements was exhausted, but there are remaining elements in the
499 * package_list. Truncate the package to num_elements.
500 *
501 * Note: technically, this is an error, from ACPI spec: "It is an error
502 * for NumElements to be less than the number of elements in the
503 * PackageList". However, we just print a message and
504 * no exception is returned. This provides Windows compatibility. Some
505 * BIOSs will alter the num_elements on the fly, creating this type
506 * of ill-formed package object.
507 */
508 while (arg) {
509 /*
510 * We must delete any package elements that were created earlier
511 * and are not going to be used because of the package truncation.
512 */
513 if (arg->common.node) {
514 acpi_ut_remove_reference(ACPI_CAST_PTR
515 (union
516 acpi_operand_object,
517 arg->common.node));
518 arg->common.node = NULL;
519 }
520
521 /* Find out how many elements there really are */
522
523 i++;
524 arg = arg->common.next;
525 }
526
527 ACPI_INFO(("Actual Package length (%u) is larger than "
528 "NumElements field (%u), truncated",
529 i, element_count));
530 } else if (i < element_count) {
531 /*
532 * Arg list (elements) was exhausted, but we did not reach num_elements count.
533 * Note: this is not an error, the package is padded out with NULLs.
534 */
535 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
536 "Package List length (%u) smaller than NumElements "
537 "count (%u), padded with null elements\n",
538 i, element_count));
539 }
540
541 obj_desc->package.flags |= AOPOBJ_DATA_VALID;
542 op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
543 return_ACPI_STATUS(status);
544}
545
546/*******************************************************************************
547 *
548 * FUNCTION: acpi_ds_create_node 273 * FUNCTION: acpi_ds_create_node
549 * 274 *
550 * PARAMETERS: walk_state - Current walk state 275 * PARAMETERS: walk_state - Current walk state
@@ -662,11 +387,20 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
662 387
663 case ACPI_TYPE_PACKAGE: 388 case ACPI_TYPE_PACKAGE:
664 /* 389 /*
665 * Defer evaluation of Package term_arg operand 390 * Defer evaluation of Package term_arg operand and all
391 * package elements. (01/2017): We defer the element
392 * resolution to allow forward references from the package
393 * in order to provide compatibility with other ACPI
394 * implementations.
666 */ 395 */
667 obj_desc->package.node = 396 obj_desc->package.node =
668 ACPI_CAST_PTR(struct acpi_namespace_node, 397 ACPI_CAST_PTR(struct acpi_namespace_node,
669 walk_state->operands[0]); 398 walk_state->operands[0]);
399
400 if (!op->named.data) {
401 return_ACPI_STATUS(AE_OK);
402 }
403
670 obj_desc->package.aml_start = op->named.data; 404 obj_desc->package.aml_start = op->named.data;
671 obj_desc->package.aml_length = op->named.length; 405 obj_desc->package.aml_length = op->named.length;
672 break; 406 break;
@@ -818,9 +552,11 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
818 /* Node was saved in Op */ 552 /* Node was saved in Op */
819 553
820 obj_desc->reference.node = op->common.node; 554 obj_desc->reference.node = op->common.node;
821 obj_desc->reference.object =
822 op->common.node->object;
823 obj_desc->reference.class = ACPI_REFCLASS_NAME; 555 obj_desc->reference.class = ACPI_REFCLASS_NAME;
556 if (op->common.node) {
557 obj_desc->reference.object =
558 op->common.node->object;
559 }
824 break; 560 break;
825 561
826 case AML_DEBUG_OP: 562 case AML_DEBUG_OP:
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index dfc3c25a083d..0336df7ac47d 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -599,6 +599,15 @@ acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
599 */ 599 */
600 walk_state->operand_index = walk_state->num_operands; 600 walk_state->operand_index = walk_state->num_operands;
601 601
602 /* Ignore if child is not valid */
603
604 if (!op->common.value.arg) {
605 ACPI_ERROR((AE_INFO,
606 "Dispatch: Missing child while executing TermArg for %X",
607 op->common.aml_opcode));
608 return_ACPI_STATUS(AE_OK);
609 }
610
602 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1); 611 status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
603 if (ACPI_FAILURE(status)) { 612 if (ACPI_FAILURE(status)) {
604 return_ACPI_STATUS(status); 613 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/acpica/dspkginit.c b/drivers/acpi/acpica/dspkginit.c
new file mode 100644
index 000000000000..6d487edfe2de
--- /dev/null
+++ b/drivers/acpi/acpica/dspkginit.c
@@ -0,0 +1,496 @@
1/******************************************************************************
2 *
3 * Module Name: dspkginit - Completion of deferred package initialization
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2017, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47#include "amlcode.h"
48#include "acdispat.h"
49#include "acinterp.h"
50
51#define _COMPONENT ACPI_NAMESPACE
52ACPI_MODULE_NAME("dspkginit")
53
54/* Local prototypes */
55static void
56acpi_ds_resolve_package_element(union acpi_operand_object **element);
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_ds_build_internal_package_obj
61 *
62 * PARAMETERS: walk_state - Current walk state
63 * op - Parser object to be translated
64 * element_count - Number of elements in the package - this is
65 * the num_elements argument to Package()
66 * obj_desc_ptr - Where the ACPI internal object is returned
67 *
68 * RETURN: Status
69 *
70 * DESCRIPTION: Translate a parser Op package object to the equivalent
71 * namespace object
72 *
73 * NOTE: The number of elements in the package will be always be the num_elements
74 * count, regardless of the number of elements in the package list. If
75 * num_elements is smaller, only that many package list elements are used.
76 * if num_elements is larger, the Package object is padded out with
77 * objects of type Uninitialized (as per ACPI spec.)
78 *
79 * Even though the ASL compilers do not allow num_elements to be smaller
80 * than the Package list length (for the fixed length package opcode), some
81 * BIOS code modifies the AML on the fly to adjust the num_elements, and
82 * this code compensates for that. This also provides compatibility with
83 * other AML interpreters.
84 *
85 ******************************************************************************/
86
87acpi_status
88acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
89 union acpi_parse_object *op,
90 u32 element_count,
91 union acpi_operand_object **obj_desc_ptr)
92{
93 union acpi_parse_object *arg;
94 union acpi_parse_object *parent;
95 union acpi_operand_object *obj_desc = NULL;
96 acpi_status status = AE_OK;
97 u16 reference_count;
98 u32 index;
99 u32 i;
100
101 ACPI_FUNCTION_TRACE(ds_build_internal_package_obj);
102
103 /* Find the parent of a possibly nested package */
104
105 parent = op->common.parent;
106 while ((parent->common.aml_opcode == AML_PACKAGE_OP) ||
107 (parent->common.aml_opcode == AML_VARIABLE_PACKAGE_OP)) {
108 parent = parent->common.parent;
109 }
110
111 /*
112 * If we are evaluating a Named package object of the form:
113 * Name (xxxx, Package)
114 * the package object already exists, otherwise it must be created.
115 */
116 obj_desc = *obj_desc_ptr;
117 if (!obj_desc) {
118 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
119 *obj_desc_ptr = obj_desc;
120 if (!obj_desc) {
121 return_ACPI_STATUS(AE_NO_MEMORY);
122 }
123
124 obj_desc->package.node = parent->common.node;
125 }
126
127 if (obj_desc->package.flags & AOPOBJ_DATA_VALID) { /* Just in case */
128 return_ACPI_STATUS(AE_OK);
129 }
130
131 /*
132 * Allocate the element array (array of pointers to the individual
133 * objects) based on the num_elements parameter. Add an extra pointer slot
134 * so that the list is always null terminated.
135 */
136 obj_desc->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
137 element_count +
138 1) * sizeof(void *));
139
140 if (!obj_desc->package.elements) {
141 acpi_ut_delete_object_desc(obj_desc);
142 return_ACPI_STATUS(AE_NO_MEMORY);
143 }
144
145 obj_desc->package.count = element_count;
146 arg = op->common.value.arg;
147 arg = arg->common.next;
148
149 if (arg) {
150 obj_desc->package.flags |= AOPOBJ_DATA_VALID;
151 }
152
153 /*
154 * Initialize the elements of the package, up to the num_elements count.
155 * Package is automatically padded with uninitialized (NULL) elements
156 * if num_elements is greater than the package list length. Likewise,
157 * Package is truncated if num_elements is less than the list length.
158 */
159 for (i = 0; arg && (i < element_count); i++) {
160 if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
161 if (arg->common.node->type == ACPI_TYPE_METHOD) {
162 /*
163 * A method reference "looks" to the parser to be a method
164 * invocation, so we special case it here
165 */
166 arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
167 status =
168 acpi_ds_build_internal_object(walk_state,
169 arg,
170 &obj_desc->
171 package.
172 elements[i]);
173 } else {
174 /* This package element is already built, just get it */
175
176 obj_desc->package.elements[i] =
177 ACPI_CAST_PTR(union acpi_operand_object,
178 arg->common.node);
179 }
180 } else {
181 status =
182 acpi_ds_build_internal_object(walk_state, arg,
183 &obj_desc->package.
184 elements[i]);
185 if (status == AE_NOT_FOUND) {
186 ACPI_ERROR((AE_INFO, "%-48s",
187 "****DS namepath not found"));
188 }
189
190 /*
191 * Initialize this package element. This function handles the
192 * resolution of named references within the package.
193 */
194 acpi_ds_init_package_element(0,
195 obj_desc->package.
196 elements[i], NULL,
197 &obj_desc->package.
198 elements[i]);
199 }
200
201 if (*obj_desc_ptr) {
202
203 /* Existing package, get existing reference count */
204
205 reference_count =
206 (*obj_desc_ptr)->common.reference_count;
207 if (reference_count > 1) {
208
209 /* Make new element ref count match original ref count */
210 /* TBD: Probably need an acpi_ut_add_references function */
211
212 for (index = 0;
213 index < ((u32)reference_count - 1);
214 index++) {
215 acpi_ut_add_reference((obj_desc->
216 package.
217 elements[i]));
218 }
219 }
220 }
221
222 arg = arg->common.next;
223 }
224
225 /* Check for match between num_elements and actual length of package_list */
226
227 if (arg) {
228 /*
229 * num_elements was exhausted, but there are remaining elements in
230 * the package_list. Truncate the package to num_elements.
231 *
232 * Note: technically, this is an error, from ACPI spec: "It is an
233 * error for NumElements to be less than the number of elements in
234 * the PackageList". However, we just print a message and no
235 * exception is returned. This provides compatibility with other
236 * ACPI implementations. Some firmware implementations will alter
237 * the num_elements on the fly, possibly creating this type of
238 * ill-formed package object.
239 */
240 while (arg) {
241 /*
242 * We must delete any package elements that were created earlier
243 * and are not going to be used because of the package truncation.
244 */
245 if (arg->common.node) {
246 acpi_ut_remove_reference(ACPI_CAST_PTR
247 (union
248 acpi_operand_object,
249 arg->common.node));
250 arg->common.node = NULL;
251 }
252
253 /* Find out how many elements there really are */
254
255 i++;
256 arg = arg->common.next;
257 }
258
259 ACPI_INFO(("Actual Package length (%u) is larger than "
260 "NumElements field (%u), truncated",
261 i, element_count));
262 } else if (i < element_count) {
263 /*
264 * Arg list (elements) was exhausted, but we did not reach
265 * num_elements count.
266 *
267 * Note: this is not an error, the package is padded out
268 * with NULLs.
269 */
270 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
271 "Package List length (%u) smaller than NumElements "
272 "count (%u), padded with null elements\n",
273 i, element_count));
274 }
275
276 obj_desc->package.flags |= AOPOBJ_DATA_VALID;
277 op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_desc);
278 return_ACPI_STATUS(status);
279}
280
281/*******************************************************************************
282 *
283 * FUNCTION: acpi_ds_init_package_element
284 *
285 * PARAMETERS: acpi_pkg_callback
286 *
287 * RETURN: Status
288 *
289 * DESCRIPTION: Resolve a named reference element within a package object
290 *
291 ******************************************************************************/
292
293acpi_status
294acpi_ds_init_package_element(u8 object_type,
295 union acpi_operand_object *source_object,
296 union acpi_generic_state *state, void *context)
297{
298 union acpi_operand_object **element_ptr;
299
300 if (!source_object) {
301 return (AE_OK);
302 }
303
304 /*
305 * The following code is a bit of a hack to workaround a (current)
306 * limitation of the acpi_pkg_callback interface. We need a pointer
307 * to the location within the element array because a new object
308 * may be created and stored there.
309 */
310 if (context) {
311
312 /* A direct call was made to this function */
313
314 element_ptr = (union acpi_operand_object **)context;
315 } else {
316 /* Call came from acpi_ut_walk_package_tree */
317
318 element_ptr = state->pkg.this_target_obj;
319 }
320
321 /* We are only interested in reference objects/elements */
322
323 if (source_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
324
325 /* Attempt to resolve the (named) reference to a namespace node */
326
327 acpi_ds_resolve_package_element(element_ptr);
328 } else if (source_object->common.type == ACPI_TYPE_PACKAGE) {
329 source_object->package.flags |= AOPOBJ_DATA_VALID;
330 }
331
332 return (AE_OK);
333}
334
335/*******************************************************************************
336 *
337 * FUNCTION: acpi_ds_resolve_package_element
338 *
339 * PARAMETERS: element_ptr - Pointer to a reference object
340 *
341 * RETURN: Possible new element is stored to the indirect element_ptr
342 *
343 * DESCRIPTION: Resolve a package element that is a reference to a named
344 * object.
345 *
346 ******************************************************************************/
347
348static void
349acpi_ds_resolve_package_element(union acpi_operand_object **element_ptr)
350{
351 acpi_status status;
352 union acpi_generic_state scope_info;
353 union acpi_operand_object *element = *element_ptr;
354 struct acpi_namespace_node *resolved_node;
355 char *external_path = NULL;
356 acpi_object_type type;
357
358 ACPI_FUNCTION_TRACE(ds_resolve_package_element);
359
360 /* Check if reference element is already resolved */
361
362 if (element->reference.resolved) {
363 return_VOID;
364 }
365
366 /* Element must be a reference object of correct type */
367
368 scope_info.scope.node = element->reference.node; /* Prefix node */
369
370 status = acpi_ns_lookup(&scope_info, (char *)element->reference.aml, /* Pointer to AML path */
371 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
372 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
373 NULL, &resolved_node);
374 if (ACPI_FAILURE(status)) {
375 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
376 (char *)element->reference.
377 aml, NULL, &external_path);
378
379 ACPI_EXCEPTION((AE_INFO, status,
380 "Could not find/resolve named package element: %s",
381 external_path));
382
383 ACPI_FREE(external_path);
384 *element_ptr = NULL;
385 return_VOID;
386 } else if (resolved_node->type == ACPI_TYPE_ANY) {
387
388 /* Named reference not resolved, return a NULL package element */
389
390 ACPI_ERROR((AE_INFO,
391 "Could not resolve named package element [%4.4s] in [%4.4s]",
392 resolved_node->name.ascii,
393 scope_info.scope.node->name.ascii));
394 *element_ptr = NULL;
395 return_VOID;
396 }
397#if 0
398 else if (resolved_node->flags & ANOBJ_TEMPORARY) {
399 /*
400 * A temporary node found here indicates that the reference is
401 * to a node that was created within this method. We are not
402 * going to allow it (especially if the package is returned
403 * from the method) -- the temporary node will be deleted out
404 * from under the method. (05/2017).
405 */
406 ACPI_ERROR((AE_INFO,
407 "Package element refers to a temporary name [%4.4s], "
408 "inserting a NULL element",
409 resolved_node->name.ascii));
410 *element_ptr = NULL;
411 return_VOID;
412 }
413#endif
414
415 /*
416 * Special handling for Alias objects. We need resolved_node to point
417 * to the Alias target. This effectively "resolves" the alias.
418 */
419 if (resolved_node->type == ACPI_TYPE_LOCAL_ALIAS) {
420 resolved_node = ACPI_CAST_PTR(struct acpi_namespace_node,
421 resolved_node->object);
422 }
423
424 /* Update the reference object */
425
426 element->reference.resolved = TRUE;
427 element->reference.node = resolved_node;
428 type = element->reference.node->type;
429
430 /*
431 * Attempt to resolve the node to a value before we insert it into
432 * the package. If this is a reference to a common data type,
433 * resolve it immediately. According to the ACPI spec, package
434 * elements can only be "data objects" or method references.
435 * Attempt to resolve to an Integer, Buffer, String or Package.
436 * If cannot, return the named reference (for things like Devices,
437 * Methods, etc.) Buffer Fields and Fields will resolve to simple
438 * objects (int/buf/str/pkg).
439 *
440 * NOTE: References to things like Devices, Methods, Mutexes, etc.
441 * will remain as named references. This behavior is not described
442 * in the ACPI spec, but it appears to be an oversight.
443 */
444 status = acpi_ex_resolve_node_to_value(&resolved_node, NULL);
445 if (ACPI_FAILURE(status)) {
446 return_VOID;
447 }
448#if 0
449/* TBD - alias support */
450 /*
451 * Special handling for Alias objects. We need to setup the type
452 * and the Op->Common.Node to point to the Alias target. Note,
453 * Alias has at most one level of indirection internally.
454 */
455 type = op->common.node->type;
456 if (type == ACPI_TYPE_LOCAL_ALIAS) {
457 type = obj_desc->common.type;
458 op->common.node = ACPI_CAST_PTR(struct acpi_namespace_node,
459 op->common.node->object);
460 }
461#endif
462
463 switch (type) {
464 /*
465 * These object types are a result of named references, so we will
466 * leave them as reference objects. In other words, these types
467 * have no intrinsic "value".
468 */
469 case ACPI_TYPE_DEVICE:
470 case ACPI_TYPE_THERMAL:
471
472 /* TBD: This may not be necesssary */
473
474 acpi_ut_add_reference(resolved_node->object);
475 break;
476
477 case ACPI_TYPE_MUTEX:
478 case ACPI_TYPE_METHOD:
479 case ACPI_TYPE_POWER:
480 case ACPI_TYPE_PROCESSOR:
481 case ACPI_TYPE_EVENT:
482 case ACPI_TYPE_REGION:
483
484 break;
485
486 default:
487 /*
488 * For all other types - the node was resolved to an actual
489 * operand object with a value, return the object
490 */
491 *element_ptr = (union acpi_operand_object *)resolved_node;
492 break;
493 }
494
495 return_VOID;
496}
diff --git a/drivers/acpi/acpica/nsarguments.c b/drivers/acpi/acpica/nsarguments.c
index 9095d51f6b37..67b7370dcae5 100644
--- a/drivers/acpi/acpica/nsarguments.c
+++ b/drivers/acpi/acpica/nsarguments.c
@@ -69,9 +69,14 @@ void acpi_ns_check_argument_types(struct acpi_evaluate_info *info)
69 u8 user_arg_type; 69 u8 user_arg_type;
70 u32 i; 70 u32 i;
71 71
72 /* If not a predefined name, cannot typecheck args */ 72 /*
73 73 * If not a predefined name, cannot typecheck args, because
74 if (!info->predefined) { 74 * we have no idea what argument types are expected.
75 * Also, ignore typecheck if warnings/errors if this method
76 * has already been evaluated at least once -- in order
77 * to suppress repetitive messages.
78 */
79 if (!info->predefined || (info->node->flags & ANOBJ_EVALUATED)) {
75 return; 80 return;
76 } 81 }
77 82
@@ -93,6 +98,10 @@ void acpi_ns_check_argument_types(struct acpi_evaluate_info *info)
93 acpi_ut_get_type_name 98 acpi_ut_get_type_name
94 (user_arg_type), 99 (user_arg_type),
95 acpi_ut_get_type_name(arg_type))); 100 acpi_ut_get_type_name(arg_type)));
101
102 /* Prevent any additional typechecking for this method */
103
104 info->node->flags |= ANOBJ_EVALUATED;
96 } 105 }
97 } 106 }
98} 107}
@@ -121,7 +130,7 @@ acpi_ns_check_acpi_compliance(char *pathname,
121 u32 aml_param_count; 130 u32 aml_param_count;
122 u32 required_param_count; 131 u32 required_param_count;
123 132
124 if (!predefined) { 133 if (!predefined || (node->flags & ANOBJ_EVALUATED)) {
125 return; 134 return;
126 } 135 }
127 136
@@ -215,6 +224,10 @@ acpi_ns_check_argument_count(char *pathname,
215 u32 aml_param_count; 224 u32 aml_param_count;
216 u32 required_param_count; 225 u32 required_param_count;
217 226
227 if (node->flags & ANOBJ_EVALUATED) {
228 return;
229 }
230
218 if (!predefined) { 231 if (!predefined) {
219 /* 232 /*
220 * Not a predefined name. Check the incoming user argument count 233 * Not a predefined name. Check the incoming user argument count
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index ce33e7297ea7..9c6297949712 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -396,6 +396,20 @@ acpi_ns_init_one_object(acpi_handle obj_handle,
396 396
397 info->package_init++; 397 info->package_init++;
398 status = acpi_ds_get_package_arguments(obj_desc); 398 status = acpi_ds_get_package_arguments(obj_desc);
399 if (ACPI_FAILURE(status)) {
400 break;
401 }
402
403 /*
404 * Resolve all named references in package objects (and all
405 * sub-packages). This action has been deferred until the entire
406 * namespace has been loaded, in order to support external and
407 * forward references from individual package elements (05/2017).
408 */
409 status = acpi_ut_walk_package_tree(obj_desc, NULL,
410 acpi_ds_init_package_element,
411 NULL);
412 obj_desc->package.flags |= AOPOBJ_DATA_VALID;
399 break; 413 break;
400 414
401 default: 415 default:
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index aa16aeaa8937..a410760a0308 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -89,7 +89,14 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
89{ 89{
90 acpi_size size; 90 acpi_size size;
91 91
92 ACPI_FUNCTION_ENTRY(); 92 /* Validate the Node */
93
94 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
95 ACPI_ERROR((AE_INFO,
96 "Invalid/cached reference target node: %p, descriptor type %d",
97 node, ACPI_GET_DESCRIPTOR_TYPE(node)));
98 return (0);
99 }
93 100
94 size = acpi_ns_build_normalized_path(node, NULL, 0, FALSE); 101 size = acpi_ns_build_normalized_path(node, NULL, 0, FALSE);
95 return (size); 102 return (size);
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index b4224005783c..bb04dec168ad 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -164,6 +164,11 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
164 INCREMENT_ARG_LIST(walk_state->arg_types); 164 INCREMENT_ARG_LIST(walk_state->arg_types);
165 } 165 }
166 166
167 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
168 "Final argument count: %u pass %u\n",
169 walk_state->arg_count,
170 walk_state->pass_number));
171
167 /* 172 /*
168 * Handle executable code at "module-level". This refers to 173 * Handle executable code at "module-level". This refers to
169 * executable opcodes that appear outside of any control method. 174 * executable opcodes that appear outside of any control method.
@@ -277,6 +282,11 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
277 AML_NAME_OP) 282 AML_NAME_OP)
278 && (walk_state->pass_number <= 283 && (walk_state->pass_number <=
279 ACPI_IMODE_LOAD_PASS2)) { 284 ACPI_IMODE_LOAD_PASS2)) {
285 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
286 "Setup Package/Buffer: Pass %u, AML Ptr: %p\n",
287 walk_state->pass_number,
288 aml_op_start));
289
280 /* 290 /*
281 * Skip parsing of Buffers and Packages because we don't have 291 * Skip parsing of Buffers and Packages because we don't have
282 * enough info in the first pass to parse them correctly. 292 * enough info in the first pass to parse them correctly.
@@ -570,6 +580,10 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
570 580
571 /* Check for arguments that need to be processed */ 581 /* Check for arguments that need to be processed */
572 582
583 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
584 "Parseloop: argument count: %u\n",
585 walk_state->arg_count));
586
573 if (walk_state->arg_count) { 587 if (walk_state->arg_count) {
574 /* 588 /*
575 * There are arguments (complex ones), push Op and 589 * There are arguments (complex ones), push Op and
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 443ffad01209..4d9f3a2a4f8e 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -224,7 +224,7 @@ acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
224 * 224 *
225 * RETURN: Status 225 * RETURN: Status
226 * 226 *
227 * DESCRIPTION: Walk through a package 227 * DESCRIPTION: Walk through a package, including subpackages
228 * 228 *
229 ******************************************************************************/ 229 ******************************************************************************/
230 230
@@ -236,8 +236,8 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
236 acpi_status status = AE_OK; 236 acpi_status status = AE_OK;
237 union acpi_generic_state *state_list = NULL; 237 union acpi_generic_state *state_list = NULL;
238 union acpi_generic_state *state; 238 union acpi_generic_state *state;
239 u32 this_index;
240 union acpi_operand_object *this_source_obj; 239 union acpi_operand_object *this_source_obj;
240 u32 this_index;
241 241
242 ACPI_FUNCTION_TRACE(ut_walk_package_tree); 242 ACPI_FUNCTION_TRACE(ut_walk_package_tree);
243 243
@@ -251,8 +251,10 @@ acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
251 /* Get one element of the package */ 251 /* Get one element of the package */
252 252
253 this_index = state->pkg.index; 253 this_index = state->pkg.index;
254 this_source_obj = (union acpi_operand_object *) 254 this_source_obj =
255 state->pkg.source_object->package.elements[this_index]; 255 state->pkg.source_object->package.elements[this_index];
256 state->pkg.this_target_obj =
257 &state->pkg.source_object->package.elements[this_index];
256 258
257 /* 259 /*
258 * Check for: 260 * Check for:
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index 64e6641bfe82..cb3db9fed50d 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -483,6 +483,11 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
483 483
484 /* A namespace node should never get here */ 484 /* A namespace node should never get here */
485 485
486 ACPI_ERROR((AE_INFO,
487 "Received a namespace node [%4.4s] "
488 "where an operand object is required",
489 ACPI_CAST_PTR(struct acpi_namespace_node,
490 internal_object)->name.ascii));
486 return_ACPI_STATUS(AE_AML_INTERNAL); 491 return_ACPI_STATUS(AE_AML_INTERNAL);
487 } 492 }
488 493
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index 64308c304ade..eafabcd2fada 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -226,7 +226,7 @@ union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
226 226
227union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object, 227union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
228 void *external_object, 228 void *external_object,
229 u16 index) 229 u32 index)
230{ 230{
231 union acpi_generic_state *state; 231 union acpi_generic_state *state;
232 232
diff --git a/drivers/acpi/acpica/uttrack.c b/drivers/acpi/acpica/uttrack.c
index 9a07a42cae34..3c8de88ecbd5 100644
--- a/drivers/acpi/acpica/uttrack.c
+++ b/drivers/acpi/acpica/uttrack.c
@@ -591,6 +591,10 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
591 return_VOID; 591 return_VOID;
592 } 592 }
593 593
594 if (!acpi_gbl_global_list) {
595 goto exit;
596 }
597
594 element = acpi_gbl_global_list->list_head; 598 element = acpi_gbl_global_list->list_head;
595 while (element) { 599 while (element) {
596 if ((element->component & component) && 600 if ((element->component & component) &&
@@ -602,7 +606,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
602 606
603 if (element->size < 607 if (element->size <
604 sizeof(struct acpi_common_descriptor)) { 608 sizeof(struct acpi_common_descriptor)) {
605 acpi_os_printf("%p Length 0x%04X %9.9s-%u " 609 acpi_os_printf("%p Length 0x%04X %9.9s-%4.4u "
606 "[Not a Descriptor - too small]\n", 610 "[Not a Descriptor - too small]\n",
607 descriptor, element->size, 611 descriptor, element->size,
608 element->module, element->line); 612 element->module, element->line);
@@ -612,7 +616,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
612 if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) != 616 if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) !=
613 ACPI_DESC_TYPE_CACHED) { 617 ACPI_DESC_TYPE_CACHED) {
614 acpi_os_printf 618 acpi_os_printf
615 ("%p Length 0x%04X %9.9s-%u [%s] ", 619 ("%p Length 0x%04X %9.9s-%4.4u [%s] ",
616 descriptor, element->size, 620 descriptor, element->size,
617 element->module, element->line, 621 element->module, element->line,
618 acpi_ut_get_descriptor_name 622 acpi_ut_get_descriptor_name
@@ -705,6 +709,7 @@ void acpi_ut_dump_allocations(u32 component, const char *module)
705 element = element->next; 709 element = element->next;
706 } 710 }
707 711
712exit:
708 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY); 713 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
709 714
710 /* Print summary */ 715 /* Print summary */