[PATCH 4/4] ACPICA: Fix for a Store->ArgX when ArgX contains a reference to a field.

2013-10-30 Thread Lv Zheng
From: Bob Moore 

commit 4be4be8fee2ee99a52f94f90d03d2f287ee1db86 upstream.

This change fixes a problem where a Store operation to an ArgX object
that contained a reference to a field object did not complete the
automatic dereference and then write to the actual field object.
Instead, the object type of the field object was inadvertently changed
to match the type of the source operand. The new behavior will actually
write to the field object (buffer field or field unit), thus matching
the correct ACPI-defined behavior.

 Cc:  # 3.8.x: 3f654ba: ACPICA: Interpreter: Fix
 Cc:  # 3.8.x: 63660e0: ACPICA: DeRefOf operator:
 Cc:  # 3.8.x: a50abf4: ACPICA: Return error if
 Cc:  # 3.8.x
Signed-off-by: Bob Moore 
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Lv Zheng 
---
 drivers/acpi/acpica/exstore.c |  166 +
 1 file changed, 102 insertions(+), 64 deletions(-)

diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 4ff37e8..cd7079d 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object 
*val_desc,
  union acpi_operand_object *dest_desc,
  struct acpi_walk_state *walk_state);
 
+static acpi_status
+acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
+struct acpi_namespace_node *node,
+struct acpi_walk_state *walk_state);
+
 
/***
  *
  * FUNCTION:acpi_ex_store
@@ -376,7 +381,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object 
*source_desc,
  *  When storing into an object the data is converted to the
  *  target object type then stored in the object. This means
  *  that the target object type (for an initialized target) will
- *  not be changed by a store operation.
+ *  not be changed by a store operation. A copy_object can change
+ *  the target type, however.
+ *
+ *  The implicit_conversion flag is set to NO/FALSE only when
+ *  storing to an arg_x -- as per the rules of the ACPI spec.
  *
  *  Assumes parameters are already validated.
  *
@@ -400,7 +409,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object 
*source_desc,
target_type = acpi_ns_get_type(node);
target_desc = acpi_ns_get_attached_object(node);
 
-   ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
+   ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n",
  source_desc,
  acpi_ut_get_object_type_name(source_desc), node,
  acpi_ut_get_type_name(target_type)));
@@ -414,46 +423,31 @@ acpi_ex_store_object_to_node(union acpi_operand_object 
*source_desc,
return_ACPI_STATUS(status);
}
 
-   /* If no implicit conversion, drop into the default case below */
-
-   if ((!implicit_conversion) ||
-   ((walk_state->opcode == AML_COPY_OP) &&
-(target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
-(target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
-(target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
-   /*
-* Force execution of default (no implicit conversion). Note:
-* copy_object does not perform an implicit conversion, as per 
the ACPI
-* spec -- except in case of region/bank/index fields -- 
because these
-* objects must retain their original type permanently.
-*/
-   target_type = ACPI_TYPE_ANY;
-   }
-
/* Do the actual store operation */
 
switch (target_type) {
-   case ACPI_TYPE_BUFFER_FIELD:
-   case ACPI_TYPE_LOCAL_REGION_FIELD:
-   case ACPI_TYPE_LOCAL_BANK_FIELD:
-   case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
-   /* For fields, copy the source data to the target field. */
-
-   status = acpi_ex_write_data_to_field(source_desc, target_desc,
-_state->result_obj);
-   break;
-
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
 
/*
-* These target types are all of type Integer/String/Buffer, and
-* therefore support implicit conversion before the store.
-*
-* Copy and/or convert the source object to a new target object
+* The simple data types all support implicit source operand
+* conversion before the store.
 */
+
+   if ((walk_state->opcode == AML_COPY_OP) || 
!implicit_conversion) {
+   /*
+* However, copy_object and Stores 

[PATCH 4/4] ACPICA: Fix for a Store-ArgX when ArgX contains a reference to a field.

2013-10-30 Thread Lv Zheng
From: Bob Moore robert.mo...@intel.com

commit 4be4be8fee2ee99a52f94f90d03d2f287ee1db86 upstream.

This change fixes a problem where a Store operation to an ArgX object
that contained a reference to a field object did not complete the
automatic dereference and then write to the actual field object.
Instead, the object type of the field object was inadvertently changed
to match the type of the source operand. The new behavior will actually
write to the field object (buffer field or field unit), thus matching
the correct ACPI-defined behavior.

 Cc: sta...@vger.kernel.org # 3.8.x: 3f654ba: ACPICA: Interpreter: Fix
 Cc: sta...@vger.kernel.org # 3.8.x: 63660e0: ACPICA: DeRefOf operator:
 Cc: sta...@vger.kernel.org # 3.8.x: a50abf4: ACPICA: Return error if
 Cc: sta...@vger.kernel.org # 3.8.x
Signed-off-by: Bob Moore robert.mo...@intel.com
Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
Signed-off-by: Lv Zheng lv.zh...@intel.com
---
 drivers/acpi/acpica/exstore.c |  166 +
 1 file changed, 102 insertions(+), 64 deletions(-)

diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 4ff37e8..cd7079d 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object 
*val_desc,
  union acpi_operand_object *dest_desc,
  struct acpi_walk_state *walk_state);
 
+static acpi_status
+acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
+struct acpi_namespace_node *node,
+struct acpi_walk_state *walk_state);
+
 
/***
  *
  * FUNCTION:acpi_ex_store
@@ -376,7 +381,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object 
*source_desc,
  *  When storing into an object the data is converted to the
  *  target object type then stored in the object. This means
  *  that the target object type (for an initialized target) will
- *  not be changed by a store operation.
+ *  not be changed by a store operation. A copy_object can change
+ *  the target type, however.
+ *
+ *  The implicit_conversion flag is set to NO/FALSE only when
+ *  storing to an arg_x -- as per the rules of the ACPI spec.
  *
  *  Assumes parameters are already validated.
  *
@@ -400,7 +409,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object 
*source_desc,
target_type = acpi_ns_get_type(node);
target_desc = acpi_ns_get_attached_object(node);
 
-   ACPI_DEBUG_PRINT((ACPI_DB_EXEC, Storing %p(%s) into node %p(%s)\n,
+   ACPI_DEBUG_PRINT((ACPI_DB_EXEC, Storing %p (%s) to node %p (%s)\n,
  source_desc,
  acpi_ut_get_object_type_name(source_desc), node,
  acpi_ut_get_type_name(target_type)));
@@ -414,46 +423,31 @@ acpi_ex_store_object_to_node(union acpi_operand_object 
*source_desc,
return_ACPI_STATUS(status);
}
 
-   /* If no implicit conversion, drop into the default case below */
-
-   if ((!implicit_conversion) ||
-   ((walk_state-opcode == AML_COPY_OP) 
-(target_type != ACPI_TYPE_LOCAL_REGION_FIELD) 
-(target_type != ACPI_TYPE_LOCAL_BANK_FIELD) 
-(target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
-   /*
-* Force execution of default (no implicit conversion). Note:
-* copy_object does not perform an implicit conversion, as per 
the ACPI
-* spec -- except in case of region/bank/index fields -- 
because these
-* objects must retain their original type permanently.
-*/
-   target_type = ACPI_TYPE_ANY;
-   }
-
/* Do the actual store operation */
 
switch (target_type) {
-   case ACPI_TYPE_BUFFER_FIELD:
-   case ACPI_TYPE_LOCAL_REGION_FIELD:
-   case ACPI_TYPE_LOCAL_BANK_FIELD:
-   case ACPI_TYPE_LOCAL_INDEX_FIELD:
-
-   /* For fields, copy the source data to the target field. */
-
-   status = acpi_ex_write_data_to_field(source_desc, target_desc,
-walk_state-result_obj);
-   break;
-
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
 
/*
-* These target types are all of type Integer/String/Buffer, and
-* therefore support implicit conversion before the store.
-*
-* Copy and/or convert the source object to a new target object
+* The simple data types all support implicit source operand
+* conversion before the store.
 */
+
+