ia64/linux-2.6.18-xen.hg

changeset 549:d59a4aaf8615

acpi: Fix a bug related to parse named objects

This patch is pulled from native linux, and is needed in our patchset
to make it run, otherwise will parse wrong _PSD info.

Fixed a problem with the Package operator where all named
references were created as object references and left otherwise
unresolved. According to the ACPI specification, a Package can
only contain Data Objects or references to control methods. The
implication is that named references to Data Objects (Integer,
Buffer, String, Package, BufferField, Field) should be resolved
immediately upon package creation. This is the approach taken
with this change. References to all other named objects (Methods,
Devices, Scopes, etc.) are all now properly created as reference
objects.

Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 14 13:53:06 2008 +0100 (2008-05-14)
parents 12bcbf80b8e4
children 2d858799d109 a741afb71700
files drivers/acpi/dispatcher/dsobject.c
line diff
     1.1 --- a/drivers/acpi/dispatcher/dsobject.c	Wed May 14 13:51:50 2008 +0100
     1.2 +++ b/drivers/acpi/dispatcher/dsobject.c	Wed May 14 13:53:06 2008 +0100
     1.3 @@ -137,6 +137,71 @@ acpi_ds_build_internal_object(struct acp
     1.4  				return_ACPI_STATUS(status);
     1.5  			}
     1.6  		}
     1.7 +
     1.8 +		/* Special object resolution for elements of a package */
     1.9 +
    1.10 +		if ((op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
    1.11 +		    (op->common.parent->common.aml_opcode ==
    1.12 +		     AML_VAR_PACKAGE_OP)) {
    1.13 +			/*
    1.14 +			 * Attempt to resolve the node to a value before we insert it into
    1.15 +			 * the package. If this is a reference to a common data type,
    1.16 +			 * resolve it immediately. According to the ACPI spec, package
    1.17 +			 * elements can only be "data objects" or method references.
    1.18 +			 * Attempt to resolve to an Integer, Buffer, String or Package.
    1.19 +			 * If cannot, return the named reference (for things like Devices,
    1.20 +			 * Methods, etc.) Buffer Fields and Fields will resolve to simple
    1.21 +			 * objects (int/buf/str/pkg).
    1.22 +			 *
    1.23 +			 * NOTE: References to things like Devices, Methods, Mutexes, etc.
    1.24 +			 * will remain as named references. This behavior is not described
    1.25 +			 * in the ACPI spec, but it appears to be an oversight.
    1.26 +			 */
    1.27 +			obj_desc = (union acpi_operand_object *)op->common.node;
    1.28 +
    1.29 +			status =
    1.30 +			    acpi_ex_resolve_node_to_value(ACPI_CAST_INDIRECT_PTR
    1.31 +							  (struct
    1.32 +							   acpi_namespace_node,
    1.33 +							   &obj_desc),
    1.34 +							  walk_state);
    1.35 +			if (ACPI_FAILURE(status)) {
    1.36 +				return_ACPI_STATUS(status);
    1.37 +			}
    1.38 +
    1.39 +			switch (op->common.node->type) {
    1.40 +				/*
    1.41 +				 * For these types, we need the actual node, not the subobject.
    1.42 +				 * However, the subobject got an extra reference count above.
    1.43 +				 */
    1.44 +			case ACPI_TYPE_MUTEX:
    1.45 +			case ACPI_TYPE_METHOD:
    1.46 +			case ACPI_TYPE_POWER:
    1.47 +			case ACPI_TYPE_PROCESSOR:
    1.48 +			case ACPI_TYPE_EVENT:
    1.49 +			case ACPI_TYPE_REGION:
    1.50 +			case ACPI_TYPE_DEVICE:
    1.51 +			case ACPI_TYPE_THERMAL:
    1.52 +
    1.53 +				obj_desc =
    1.54 +				    (union acpi_operand_object *)op->common.
    1.55 +				    node;
    1.56 +				break;
    1.57 +
    1.58 +			default:
    1.59 +				break;
    1.60 +			}
    1.61 +
    1.62 +			/*
    1.63 +			 * If above resolved to an operand object, we are done. Otherwise,
    1.64 +			 * we have a NS node, we must create the package entry as a named
    1.65 +			 * reference.
    1.66 +			 */
    1.67 +			if (ACPI_GET_DESCRIPTOR_TYPE(obj_desc) !=
    1.68 +			    ACPI_DESC_TYPE_NAMED) {
    1.69 +				goto exit;
    1.70 +			}
    1.71 +		}
    1.72  	}
    1.73  
    1.74  	/* Create and init a new internal ACPI object */
    1.75 @@ -156,6 +221,7 @@ acpi_ds_build_internal_object(struct acp
    1.76  		return_ACPI_STATUS(status);
    1.77  	}
    1.78  
    1.79 +      exit:
    1.80  	*obj_desc_ptr = obj_desc;
    1.81  	return_ACPI_STATUS(AE_OK);
    1.82  }
    1.83 @@ -358,12 +424,25 @@ acpi_ds_build_internal_package_obj(struc
    1.84  	arg = arg->common.next;
    1.85  	for (i = 0; arg; i++) {
    1.86  		if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
    1.87 -
    1.88 -			/* Object (package or buffer) is already built */
    1.89 +			if (arg->common.node->type == ACPI_TYPE_METHOD) {
    1.90 +				/*
    1.91 +				 * A method reference "looks" to the parser to be a method
    1.92 +				 * invocation, so we special case it here
    1.93 +				 */
    1.94 +				arg->common.aml_opcode = AML_INT_NAMEPATH_OP;
    1.95 +				status =
    1.96 +				    acpi_ds_build_internal_object(walk_state,
    1.97 +								  arg,
    1.98 +								  &obj_desc->
    1.99 +								  package.
   1.100 +								  elements[i]);
   1.101 +			} else {
   1.102 +				/* This package element is already built, just get it */
   1.103  
   1.104 -			obj_desc->package.elements[i] =
   1.105 -			    ACPI_CAST_PTR(union acpi_operand_object,
   1.106 -					  arg->common.node);
   1.107 +				obj_desc->package.elements[i] =
   1.108 +				    ACPI_CAST_PTR(union acpi_operand_object,
   1.109 +						  arg->common.node);
   1.110 +			}
   1.111  		} else {
   1.112  			status = acpi_ds_build_internal_object(walk_state, arg,
   1.113  							       &obj_desc->