ACPICA: Ignore sync_level for methods that have been auto-serialized.
authorBob Moore <robert.moore@intel.com>
Mon, 24 Mar 2014 06:49:13 +0000 (14:49 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 26 Mar 2014 15:25:59 +0000 (16:25 +0100)
Cannot use a sync_level for methods that have been serialized at load-time
or runtime because this may interfere with any existing use of sync_levels
within the ASL code. So, we simply ignore the sync_level for these methods,
thus preserving any existing sync_level priorities. Note, the use of
sync_levels is actually rather rare within BIOS ASL code.

References: http://www.spinics.net/lists/linux-acpi/msg49496.html
Reported-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Reported-by: Sabrina Dubroka <sd@queasysnail.net>
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>
drivers/acpi/acpica/acobject.h
drivers/acpi/acpica/dsmethod.c

index 1a4d61805ebc64a83bc9242414536f7fecfb25cf..22fb6449d3d61f792ac4777f1f24139b905b08ae 100644 (file)
@@ -193,7 +193,8 @@ struct acpi_object_method {
 #define ACPI_METHOD_INTERNAL_ONLY       0x02   /* Method is implemented internally (_OSI) */
 #define ACPI_METHOD_SERIALIZED          0x04   /* Method is serialized */
 #define ACPI_METHOD_SERIALIZED_PENDING  0x08   /* Method is to be marked serialized */
-#define ACPI_METHOD_MODIFIED_NAMESPACE  0x10   /* Method modified the namespace */
+#define ACPI_METHOD_IGNORE_SYNC_LEVEL   0x10   /* Method was auto-serialized at table load time */
+#define ACPI_METHOD_MODIFIED_NAMESPACE  0x20   /* Method modified the namespace */
 
 /******************************************************************************
  *
index 73764c7d1c5da0e7d83724dbee4e65a96837dbbc..3c7f7378b94d1692af3266e96902e587f2b8379b 100644 (file)
@@ -175,8 +175,15 @@ acpi_ds_detect_named_opcodes(struct acpi_walk_state *walk_state,
         * At this point, we know we have a Named object opcode.
         * Mark the method as serialized. Later code will create a mutex for
         * this method to enforce serialization.
+        *
+        * Note, ACPI_METHOD_IGNORE_SYNC_LEVEL flag means that we will ignore the
+        * Sync Level mechanism for this method, even though it is now serialized.
+        * Otherwise, there can be conflicts with existing ASL code that actually
+        * uses sync levels.
         */
-       walk_state->method_desc->method.info_flags |= ACPI_METHOD_SERIALIZED;
+       walk_state->method_desc->method.sync_level = 0;
+       walk_state->method_desc->method.info_flags |=
+           (ACPI_METHOD_SERIALIZED | ACPI_METHOD_IGNORE_SYNC_LEVEL);
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                          "Method serialized [%4.4s] %p - [%s] (%4.4X)\n",
@@ -349,13 +356,19 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
                /*
                 * The current_sync_level (per-thread) must be less than or equal to
                 * the sync level of the method. This mechanism provides some
-                * deadlock prevention
+                * deadlock prevention.
+                *
+                * If the method was auto-serialized, we just ignore the sync level
+                * mechanism, because auto-serialization of methods can interfere
+                * with ASL code that actually uses sync levels.
                 *
                 * Top-level method invocation has no walk state at this point
                 */
                if (walk_state &&
-                   (walk_state->thread->current_sync_level >
-                    obj_desc->method.mutex->mutex.sync_level)) {
+                   (!(obj_desc->method.
+                      info_flags & ACPI_METHOD_IGNORE_SYNC_LEVEL))
+                   && (walk_state->thread->current_sync_level >
+                       obj_desc->method.mutex->mutex.sync_level)) {
                        ACPI_ERROR((AE_INFO,
                                    "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)",
                                    acpi_ut_get_node_name(method_node),
@@ -800,7 +813,8 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
                        method_desc->method.info_flags &=
                            ~ACPI_METHOD_SERIALIZED_PENDING;
                        method_desc->method.info_flags |=
-                           ACPI_METHOD_SERIALIZED;
+                           (ACPI_METHOD_SERIALIZED |
+                            ACPI_METHOD_IGNORE_SYNC_LEVEL);
                        method_desc->method.sync_level = 0;
                }