]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
ACPICA: Enhance error messages from namespace create/lookup operations
authorBob Moore <robert.moore@intel.com>
Fri, 17 Nov 2017 23:42:22 +0000 (15:42 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 27 Nov 2017 00:20:32 +0000 (01:20 +0100)
ACPICA commit b09c8d7bdc8c5a3db0a8d38bfd6182c023885e12

1) Emit the full pathname (scope+name) instead of just the name
2) For AE_ALREADY_EXISTS and AE_NOT_FOUND, use the "firmware error"
string to point to the true problem.

Link: https://github.com/acpica/acpica/commit/b09c8d7b
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>
12 files changed:
drivers/acpi/acpica/acmacros.h
drivers/acpi/acpica/acnamesp.h
drivers/acpi/acpica/acutils.h
drivers/acpi/acpica/dsfield.c
drivers/acpi/acpica/dsobject.c
drivers/acpi/acpica/dsutils.c
drivers/acpi/acpica/dswload.c
drivers/acpi/acpica/dswload2.c
drivers/acpi/acpica/nsconvert.c
drivers/acpi/acpica/nsnames.c
drivers/acpi/acpica/psargs.c
drivers/acpi/acpica/uterror.c

index c7f0c96cc00fcb113fa02f482762ad9dc49fcfd3..128a3d71b5986523bcaa1ec9c33fa351030b96d6 100644 (file)
  * the plist contains a set of parens to allow variable-length lists.
  * These macros are used for both the debug and non-debug versions of the code.
  */
-#define ACPI_ERROR_NAMESPACE(s, e)          acpi_ut_namespace_error (AE_INFO, s, e);
+#define ACPI_ERROR_NAMESPACE(s, p, e)       acpi_ut_prefixed_namespace_error (AE_INFO, s, p, e);
 #define ACPI_ERROR_METHOD(s, n, p, e)       acpi_ut_method_error (AE_INFO, s, n, p, e);
 #define ACPI_WARN_PREDEFINED(plist)         acpi_ut_predefined_warning plist
 #define ACPI_INFO_PREDEFINED(plist)         acpi_ut_predefined_info plist
index 54a0c51b3e37ef7d3ca2856318d3c7740d0fd738..2fb1bb78d85c60c61b274f4eae83cbd8d00a5ea5 100644 (file)
@@ -289,6 +289,9 @@ acpi_ns_build_normalized_path(struct acpi_namespace_node *node,
 char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
                                      u8 no_trailing);
 
+char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
+                                     const char *internal_path);
+
 char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
 
 acpi_status
index bb97a18158eca617defa8e7c8436a623d322920a..d38187ee11c86cdf6c1180fcb17367b5b81a8a89 100644 (file)
@@ -126,10 +126,10 @@ extern const char *acpi_gbl_ptyp_decode[];
 #endif
 
 #ifndef ACPI_MSG_BIOS_ERROR
-#define ACPI_MSG_BIOS_ERROR     "ACPI BIOS Error (bug): "
+#define ACPI_MSG_BIOS_ERROR     "Firmware Error (ACPI): "
 #endif
 #ifndef ACPI_MSG_BIOS_WARNING
-#define ACPI_MSG_BIOS_WARNING   "ACPI BIOS Warning (bug): "
+#define ACPI_MSG_BIOS_WARNING   "Firmware Warning (ACPI): "
 #endif
 
 /*
@@ -734,9 +734,11 @@ acpi_ut_predefined_bios_error(const char *module_name,
                              u8 node_flags, const char *format, ...);
 
 void
-acpi_ut_namespace_error(const char *module_name,
-                       u32 line_number,
-                       const char *internal_name, acpi_status lookup_status);
+acpi_ut_prefixed_namespace_error(const char *module_name,
+                                u32 line_number,
+                                union acpi_generic_state *prefix_scope,
+                                const char *internal_name,
+                                acpi_status lookup_status);
 
 void
 acpi_ut_method_error(const char *module_name,
index 7bcf5f5ea0297ffcec2cbd39b9171e4ba93afd50..0cab34a593d504a77c70221bde482232c83bd0ad 100644 (file)
@@ -209,7 +209,8 @@ acpi_ds_create_buffer_field(union acpi_parse_object *op,
                                        ACPI_IMODE_LOAD_PASS1, flags,
                                        walk_state, &node);
                if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
+                       ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                            arg->common.value.string, status);
                        return_ACPI_STATUS(status);
                }
        }
@@ -383,7 +384,9 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
                                                        walk_state,
                                                        &info->connection_node);
                                if (ACPI_FAILURE(status)) {
-                                       ACPI_ERROR_NAMESPACE(child->common.
+                                       ACPI_ERROR_NAMESPACE(walk_state->
+                                                            scope_info,
+                                                            child->common.
                                                             value.name,
                                                             status);
                                        return_ACPI_STATUS(status);
@@ -402,7 +405,8 @@ acpi_ds_get_field_names(struct acpi_create_field_info *info,
                                                ACPI_NS_DONT_OPEN_SCOPE,
                                                walk_state, &info->field_node);
                        if (ACPI_FAILURE(status)) {
-                               ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
+                               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                                    (char *)&arg->named.name,
                                                     status);
                                return_ACPI_STATUS(status);
                        } else {
@@ -498,7 +502,8 @@ acpi_ds_create_field(union acpi_parse_object *op,
                                                        &region_node);
 #endif
                if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
+                       ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                            arg->common.value.name, status);
                        return_ACPI_STATUS(status);
                }
        }
@@ -618,7 +623,8 @@ acpi_ds_init_field_objects(union acpi_parse_object *op,
                                                ACPI_IMODE_LOAD_PASS1, flags,
                                                walk_state, &node);
                        if (ACPI_FAILURE(status)) {
-                               ACPI_ERROR_NAMESPACE((char *)&arg->named.name,
+                               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                                    (char *)&arg->named.name,
                                                     status);
                                if (status != AE_ALREADY_EXISTS) {
                                        return_ACPI_STATUS(status);
@@ -681,7 +687,8 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
                                                        &region_node);
 #endif
                if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR_NAMESPACE(arg->common.value.name, status);
+                       ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                            arg->common.value.name, status);
                        return_ACPI_STATUS(status);
                }
        }
@@ -695,7 +702,8 @@ acpi_ds_create_bank_field(union acpi_parse_object *op,
                           ACPI_NS_SEARCH_PARENT, walk_state,
                           &info.register_node);
        if (ACPI_FAILURE(status)) {
-               ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
+               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                    arg->common.value.string, status);
                return_ACPI_STATUS(status);
        }
 
@@ -765,7 +773,8 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
                           ACPI_NS_SEARCH_PARENT, walk_state,
                           &info.register_node);
        if (ACPI_FAILURE(status)) {
-               ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
+               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                    arg->common.value.string, status);
                return_ACPI_STATUS(status);
        }
 
@@ -778,7 +787,8 @@ acpi_ds_create_index_field(union acpi_parse_object *op,
                           ACPI_NS_SEARCH_PARENT, walk_state,
                           &info.data_register_node);
        if (ACPI_FAILURE(status)) {
-               ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
+               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                    arg->common.value.string, status);
                return_ACPI_STATUS(status);
        }
 
index 82448551781b43bf3d276df6ee9378416cb2a08b..b21fe084ffc8cd2937a4059b4237bd99d17f01aa 100644 (file)
@@ -112,7 +112,9 @@ acpi_ds_build_internal_object(struct acpi_walk_state *walk_state,
                                                         acpi_namespace_node,
                                                         &(op->common.node)));
                                if (ACPI_FAILURE(status)) {
-                                       ACPI_ERROR_NAMESPACE(op->common.value.
+                                       ACPI_ERROR_NAMESPACE(walk_state->
+                                                            scope_info,
+                                                            op->common.value.
                                                             string, status);
                                        return_ACPI_STATUS(status);
                                }
index 0dabd9b95684c9fd527f163606de9a9a24f09e46..4c5faf629a83187a760298a7f7f7803435df150c 100644 (file)
@@ -583,7 +583,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
                        }
 
                        if (ACPI_FAILURE(status)) {
-                               ACPI_ERROR_NAMESPACE(name_string, status);
+                               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                                    name_string, status);
                        }
                }
 
index eaa859a89702a2290d62e87ecf5ef9131afe708a..5771e4e4a99af2c9b98650e3b87af093034b2901 100644 (file)
@@ -207,7 +207,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
                }
 #endif
                if (ACPI_FAILURE(status)) {
-                       ACPI_ERROR_NAMESPACE(path, status);
+                       ACPI_ERROR_NAMESPACE(walk_state->scope_info, path,
+                                            status);
                        return_ACPI_STATUS(status);
                }
 
@@ -375,7 +376,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
                        }
 
                        if (ACPI_FAILURE(status)) {
-                               ACPI_ERROR_NAMESPACE(path, status);
+                               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                                    path, status);
                                return_ACPI_STATUS(status);
                        }
                }
index aad83ef5a4ecb6529906e4fa132c31a38be018c6..b3d0aaec8203a063f3bc051375e67b849c350fa2 100644 (file)
@@ -184,11 +184,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                                if (status == AE_NOT_FOUND) {
                                        status = AE_OK;
                                } else {
-                                       ACPI_ERROR_NAMESPACE(buffer_ptr,
+                                       ACPI_ERROR_NAMESPACE(walk_state->
+                                                            scope_info,
+                                                            buffer_ptr,
                                                             status);
                                }
 #else
-                               ACPI_ERROR_NAMESPACE(buffer_ptr, status);
+                               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                                    buffer_ptr, status);
 #endif
                                return_ACPI_STATUS(status);
                        }
@@ -343,7 +346,8 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
        }
 
        if (ACPI_FAILURE(status)) {
-               ACPI_ERROR_NAMESPACE(buffer_ptr, status);
+               ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                    buffer_ptr, status);
                return_ACPI_STATUS(status);
        }
 
@@ -719,7 +723,8 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                         */
                        op->common.node = new_node;
                } else {
-                       ACPI_ERROR_NAMESPACE(arg->common.value.string, status);
+                       ACPI_ERROR_NAMESPACE(walk_state->scope_info,
+                                            arg->common.value.string, status);
                }
                break;
 
index 539d775bbc92344ae719e0e1da38dbed9580419a..d55dcc82f4348f92d5e29c9ba899aa3d18c92f45 100644 (file)
@@ -495,7 +495,8 @@ acpi_ns_convert_to_reference(struct acpi_namespace_node *scope,
 
                /* Check if we are resolving a named reference within a package */
 
-               ACPI_ERROR_NAMESPACE(original_object->string.pointer, status);
+               ACPI_ERROR_NAMESPACE(&scope_info,
+                                    original_object->string.pointer, status);
                goto error_exit;
        }
 
index a410760a03089f63c8a9a4b9b26c6e44bffe7583..4203d4589b6d64ff97cf00fe0caad6c366fa9ab6 100644 (file)
@@ -49,6 +49,9 @@
 #define _COMPONENT          ACPI_NAMESPACE
 ACPI_MODULE_NAME("nsnames")
 
+/* Local Prototypes */
+static void acpi_ns_normalize_pathname(char *original_path);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_get_external_pathname
@@ -63,6 +66,7 @@ ACPI_MODULE_NAME("nsnames")
  *              for error and debug statements.
  *
  ******************************************************************************/
+
 char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
 {
        char *name_buffer;
@@ -352,3 +356,145 @@ char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
 
        return_PTR(name_buffer);
 }
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_build_prefixed_pathname
+ *
+ * PARAMETERS:  prefix_scope        - Scope/Path that prefixes the internal path
+ *              internal_path       - Name or path of the namespace node
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Construct a fully qualified pathname from a concatenation of:
+ *              1) Path associated with the prefix_scope namespace node
+ *              2) External path representation of the Internal path
+ *
+ ******************************************************************************/
+
+char *acpi_ns_build_prefixed_pathname(union acpi_generic_state *prefix_scope,
+                                     const char *internal_path)
+{
+       acpi_status status;
+       char *full_path = NULL;
+       char *external_path;
+       char *prefix_path = NULL;
+       u32 prefix_path_length = 0;
+
+       /* If there is a prefix, get the pathname to it */
+
+       if (prefix_scope && prefix_scope->scope.node) {
+               prefix_path =
+                   acpi_ns_get_normalized_pathname(prefix_scope->scope.node,
+                                                   TRUE);
+               if (prefix_path) {
+                       prefix_path_length = strlen(prefix_path);
+               }
+       }
+
+       status = acpi_ns_externalize_name(ACPI_UINT32_MAX, internal_path,
+                                         NULL, &external_path);
+       if (ACPI_FAILURE(status)) {
+               goto cleanup;
+       }
+
+       /* Merge the prefix path and the path. 2 is for one dot and trailing null */
+
+       full_path =
+           ACPI_ALLOCATE_ZEROED(prefix_path_length + strlen(external_path) +
+                                2);
+       if (!full_path) {
+               goto cleanup;
+       }
+
+       /* Don't merge if the External path is already fully qualified */
+
+       if (prefix_path && (*external_path != '\\') && (*external_path != '^')) {
+               strcat(full_path, prefix_path);
+               if (prefix_path[1]) {
+                       strcat(full_path, ".");
+               }
+       }
+
+       acpi_ns_normalize_pathname(external_path);
+       strcat(full_path, external_path);
+
+cleanup:
+       if (prefix_path) {
+               ACPI_FREE(prefix_path);
+       }
+
+       return (full_path);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_normalize_pathname
+ *
+ * PARAMETERS:  original_path       - Path to be normalized, in External format
+ *
+ * RETURN:      The original path is processed in-place
+ *
+ * DESCRIPTION: Remove trailing underscores from each element of a path.
+ *
+ *              For example:  \A___.B___.C___ becomes \A.B.C
+ *
+ ******************************************************************************/
+
+static void acpi_ns_normalize_pathname(char *original_path)
+{
+       char *input_path = original_path;
+       char *new_path_buffer;
+       char *new_path;
+       u32 i;
+
+       /* Allocate a temp buffer in which to construct the new path */
+
+       new_path_buffer = ACPI_ALLOCATE_ZEROED(strlen(input_path) + 1);
+       new_path = new_path_buffer;
+       if (!new_path_buffer) {
+               return;
+       }
+
+       /* Special characters may appear at the beginning of the path */
+
+       if (*input_path == '\\') {
+               *new_path = *input_path;
+               new_path++;
+               input_path++;
+       }
+
+       while (*input_path == '^') {
+               *new_path = *input_path;
+               new_path++;
+               input_path++;
+       }
+
+       /* Remainder of the path */
+
+       while (*input_path) {
+
+               /* Do one nameseg at a time */
+
+               for (i = 0; (i < ACPI_NAME_SIZE) && *input_path; i++) {
+                       if ((i == 0) || (*input_path != '_')) { /* First char is allowed to be underscore */
+                               *new_path = *input_path;
+                               new_path++;
+                       }
+
+                       input_path++;
+               }
+
+               /* Dot means that there are more namesegs to come */
+
+               if (*input_path == '.') {
+                       *new_path = *input_path;
+                       new_path++;
+                       input_path++;
+               }
+       }
+
+       *new_path = 0;
+       strcpy(original_path, new_path_buffer);
+       ACPI_FREE(new_path_buffer);
+}
index eb9dfaca555fe31d0a0c318c682268fa3ffece11..171e2faa7c50640aa82f490fde8bc284ebed2d43 100644 (file)
@@ -361,7 +361,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
        /* Final exception check (may have been changed from code above) */
 
        if (ACPI_FAILURE(status)) {
-               ACPI_ERROR_NAMESPACE(path, status);
+               ACPI_ERROR_NAMESPACE(walk_state->scope_info, path, status);
 
                if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
                    ACPI_PARSE_EXECUTE) {
index e3368186e1c1bd72e903a0625a3d6639cb55ebaf..42388dcb5ccc9f42fb434eaf9d6938d3d1e59fb4 100644 (file)
@@ -180,6 +180,78 @@ acpi_ut_predefined_bios_error(const char *module_name,
        va_end(arg_list);
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ut_prefixed_namespace_error
+ *
+ * PARAMETERS:  module_name         - Caller's module name (for error output)
+ *              line_number         - Caller's line number (for error output)
+ *              prefix_scope        - Scope/Path that prefixes the internal path
+ *              internal_path       - Name or path of the namespace node
+ *              lookup_status       - Exception code from NS lookup
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Print error message with the full pathname constructed this way:
+ *
+ *                  prefix_scope_node_full_path.externalized_internal_path
+ *
+ * NOTE:        10/2017: Treat the major ns_lookup errors as firmware errors
+ *
+ ******************************************************************************/
+
+void
+acpi_ut_prefixed_namespace_error(const char *module_name,
+                                u32 line_number,
+                                union acpi_generic_state *prefix_scope,
+                                const char *internal_path,
+                                acpi_status lookup_status)
+{
+       char *full_path;
+       const char *message;
+
+       /*
+        * Main cases:
+        * 1) Object creation, object must not already exist
+        * 2) Object lookup, object must exist
+        */
+       switch (lookup_status) {
+       case AE_ALREADY_EXISTS:
+
+               acpi_os_printf(ACPI_MSG_BIOS_ERROR);
+               message = "Failure creating";
+               break;
+
+       case AE_NOT_FOUND:
+
+               acpi_os_printf(ACPI_MSG_BIOS_ERROR);
+               message = "Failure looking up";
+               break;
+
+       default:
+
+               acpi_os_printf(ACPI_MSG_ERROR);
+               message = "Failure looking up";
+               break;
+       }
+
+       /* Concatenate the prefix path and the internal path */
+
+       full_path =
+           acpi_ns_build_prefixed_pathname(prefix_scope, internal_path);
+
+       acpi_os_printf("%s [%s], %s", message,
+                      full_path ? full_path : "Could not get pathname",
+                      acpi_format_exception(lookup_status));
+
+       if (full_path) {
+               ACPI_FREE(full_path);
+       }
+
+       ACPI_MSG_SUFFIX;
+}
+
+#ifdef __OBSOLETE_FUNCTION
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ut_namespace_error
@@ -240,6 +312,7 @@ acpi_ut_namespace_error(const char *module_name,
        ACPI_MSG_SUFFIX;
        ACPI_MSG_REDIRECT_END;
 }
+#endif
 
 /*******************************************************************************
  *