From: Lv Zheng <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Len Brown <len.brown@intel.com>
Cc: Lv Zheng <lv.zheng@intel.com>, Lv Zheng <zetalog@gmail.com>,
<linux-kernel@vger.kernel.org>,
linux-acpi@vger.kernel.org, Bob Moore <robert.moore@intel.com>
Subject: [PATCH 02/22] ACPICA: Parser: Cleanup aml_offset in struct acpi_walk_state.
Date: Thu, 23 Jul 2015 12:52:11 +0800 [thread overview]
Message-ID: <daaa7193bfcf2eca2bd2f74a51ef363944ad747c.1437627016.git.lv.zheng@intel.com> (raw)
In-Reply-To: <cover.1437627016.git.lv.zheng@intel.com>
ACPICA commit d254405814495058276c0c2f9d96794d15a6c91c
This patch converts aml_offset in struct acpi_walk_state to AML address.
AML offset is actually only used by the debugger, using AML address is more
direct and efficient during the parsing stage so that we don't need to
calculate it during the parsing stage.
On the other hand, we can see several issues in the current parser logic
around the aml_offset:
1. union acpi_operand_object.Common.aml_offset is redundantly assigned in
acpi_ps_parse_loop().
2. aml_offset is not an indication of the offset from the table header but
the offset from the entry of a list of objects. Sometimes, it indicates
an entry for a Method/Package/Buffer, which makes it difficult to be
reversely calculated to a table header offset.
3. When being used with method tracers (for example, Linux function trace),
it's better to have AML address logged instead of the AML offset because
the address is the only attribute that can uniquely identify the opcode.
This patch is required to solve the above issues. Lv Zheng.
Link: https://github.com/acpica/acpica/commit/d2544058
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
---
drivers/acpi/acpica/acstruct.h | 2 +-
drivers/acpi/acpica/dsmethod.c | 9 +++++++--
drivers/acpi/acpica/psloop.c | 15 +++++++++------
drivers/acpi/acpica/psobject.c | 15 +++++++++------
4 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 44997ca..f9992dc 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -85,7 +85,7 @@ struct acpi_walk_state {
u8 namespace_override; /* Override existing objects */
u8 result_size; /* Total elements for the result stack */
u8 result_count; /* Current number of occupied elements of result stack */
- u32 aml_offset;
+ u8 *aml;
u32 arg_types;
u32 method_breakpoint; /* For single stepping */
u32 user_breakpoint; /* User AML breakpoint */
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 85bb951..bf8c16e 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -214,6 +214,8 @@ acpi_ds_detect_named_opcodes(struct acpi_walk_state *walk_state,
acpi_status
acpi_ds_method_error(acpi_status status, struct acpi_walk_state * walk_state)
{
+ u32 aml_offset;
+
ACPI_FUNCTION_ENTRY();
/* Ignore AE_OK and control exception codes */
@@ -234,13 +236,16 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state * walk_state)
* Handler can map the exception code to anything it wants, including
* AE_OK, in which case the executing method will not be aborted.
*/
+ aml_offset = (u32)ACPI_PTR_DIFF(walk_state->aml,
+ walk_state->parser_state.
+ aml_start);
+
status = acpi_gbl_exception_handler(status,
walk_state->method_node ?
walk_state->method_node->
name.integer : 0,
walk_state->opcode,
- walk_state->aml_offset,
- NULL);
+ aml_offset, NULL);
acpi_ex_enter_interpreter();
}
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 6136458..ce66e73 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -125,10 +125,7 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
*/
while (GET_CURRENT_ARG_TYPE(walk_state->arg_types)
&& !walk_state->arg_count) {
- walk_state->aml_offset =
- (u32)ACPI_PTR_DIFF(walk_state->parser_state.aml,
- walk_state->parser_state.
- aml_start);
+ walk_state->aml = walk_state->parser_state.aml;
status =
acpi_ps_get_next_arg(walk_state,
@@ -140,7 +137,10 @@ acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
}
if (arg) {
- arg->common.aml_offset = walk_state->aml_offset;
+ arg->common.aml_offset =
+ (u32)ACPI_PTR_DIFF(walk_state->aml,
+ walk_state->parser_state.
+ aml_start);
acpi_ps_append_arg(op, arg);
}
@@ -494,7 +494,10 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
continue;
}
- op->common.aml_offset = walk_state->aml_offset;
+ op->common.aml_offset =
+ (u32)ACPI_PTR_DIFF(walk_state->aml,
+ walk_state->parser_state.
+ aml_start);
if (walk_state->op_info) {
ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
diff --git a/drivers/acpi/acpica/psobject.c b/drivers/acpi/acpica/psobject.c
index 2f5ddd8..6ba3bb7 100644
--- a/drivers/acpi/acpica/psobject.c
+++ b/drivers/acpi/acpica/psobject.c
@@ -66,12 +66,11 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
{
+ u32 aml_offset;
ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
- walk_state->aml_offset =
- (u32)ACPI_PTR_DIFF(walk_state->parser_state.aml,
- walk_state->parser_state.aml_start);
+ walk_state->aml = walk_state->parser_state.aml;
walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
/*
@@ -98,10 +97,14 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
/* The opcode is unrecognized. Complain and skip unknown opcodes */
if (walk_state->pass_number == 2) {
+ aml_offset = (u32)ACPI_PTR_DIFF(walk_state->aml,
+ walk_state->
+ parser_state.aml_start);
+
ACPI_ERROR((AE_INFO,
"Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
walk_state->opcode,
- (u32)(walk_state->aml_offset +
+ (u32)(aml_offset +
sizeof(struct acpi_table_header))));
ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16),
@@ -115,14 +118,14 @@ static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
acpi_os_printf
("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
walk_state->opcode,
- (u32)(walk_state->aml_offset +
+ (u32)(aml_offset +
sizeof(struct acpi_table_header)));
/* Dump the context surrounding the invalid opcode */
acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
aml - 16), 48, DB_BYTE_DISPLAY,
- (walk_state->aml_offset +
+ (aml_offset +
sizeof(struct acpi_table_header) -
16));
acpi_os_printf(" */\n");
--
1.7.10
next prev parent reply other threads:[~2015-07-23 4:52 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 4:51 [PATCH 00/22] ACPICA: 20150717 Release Lv Zheng
2015-07-23 4:52 ` [PATCH 01/22] ACPICA: Parser: Reduce parser/namespace divergences for tracer support Lv Zheng
2015-07-23 4:52 ` Lv Zheng [this message]
2015-07-23 4:52 ` [PATCH 03/22] ACPICA: Parser: Cleanup aml_offset in union acpi_operand_object Lv Zheng
2015-07-23 4:52 ` [PATCH 04/22] ACPICA: Dispatcher: Cleanup union acpi_operand_object's AML address assignments Lv Zheng
2015-07-23 4:52 ` [PATCH 05/22] ACPICA: Executer: Add back pointing reference of method operand Lv Zheng
2015-07-23 4:52 ` [PATCH 06/22] ACPICA: Namespace: Add function to directly return normalized full path Lv Zheng
2015-07-23 4:52 ` [PATCH 07/22] ACPICA: Dispatcher: Move stack traversal code to dispatcher Lv Zheng
2015-07-23 4:52 ` [PATCH 08/22] ACPICA: Dispatcher: Add trace support for interpreter Lv Zheng
2015-07-23 4:52 ` [PATCH 09/22] ACPICA: Executer: Add interpreter tracing mode for method tracing facility Lv Zheng
2015-07-23 4:53 ` [PATCH 10/22] ACPICA: Executer: Add OSL trace hook support Lv Zheng
2015-07-23 4:53 ` [PATCH 11/22] ACPICA: Executer: Add option to bypass opcode tracing Lv Zheng
2015-07-23 4:53 ` [PATCH 12/22] ACPICA: Parser: Remove redundant opcode execution debugging output Lv Zheng
2015-07-23 4:53 ` [PATCH 13/22] ACPICA: Remove extraneous check for null walk_state Lv Zheng
2015-07-23 4:53 ` [PATCH 14/22] ACPICA: iASL: Add new warnings for method local_x and arg_x variables Lv Zheng
2015-07-23 4:53 ` [PATCH 15/22] ACPICA: MSVC: Fix inclusion order issue of <crtdbg.h> Lv Zheng
2015-07-23 4:53 ` [PATCH 16/22] ACPICA: Cleanup use of all non-ANSI local C library functions Lv Zheng
2015-07-23 4:53 ` [PATCH 17/22] ACPICA: Cleanup use of NEGATIVE and POSITIVE defines Lv Zheng
2015-07-23 4:54 ` [PATCH 18/22] ACPICA: iASL: Add support for TCPA Server Table Lv Zheng
2015-07-23 4:54 ` [PATCH 19/22] ACPICA: Debugger: Reduce structure size for debugger Lv Zheng
2015-07-23 4:54 ` [PATCH 20/22] ACPICA: Debugger: Move debugger specific APIs to debugger component Lv Zheng
2015-07-23 4:54 ` [PATCH 21/22] ACPICA: iASL/Disassembler: Add prototype verbose mode Lv Zheng
2015-07-23 4:54 ` [PATCH 22/22] ACPICA: Update version to 20150717 Lv Zheng
2015-07-23 5:06 ` [PATCH 0/4] ACPI: Update method tracing facility Lv Zheng
2015-07-23 5:06 ` [PATCH 1/4] ACPI / sysfs: Add ACPI_LV_REPAIR debug level Lv Zheng
2015-07-23 5:06 ` [PATCH 2/4] ACPI / sysfs: Update method tracing facility Lv Zheng
2015-07-23 5:06 ` [PATCH 3/4] ACPI / Documentation: Update method tracing documentation Lv Zheng
2015-07-23 5:07 ` [PATCH 4/4] ACPI / sysfs: Add support to allow leading "\" missing in trace_method_name Lv Zheng
2015-07-23 20:51 ` [PATCH 0/4] ACPI: Update method tracing facility Rafael J. Wysocki
2015-07-24 2:02 ` Zheng, Lv
2015-07-24 19:55 ` Rafael J. Wysocki
2015-07-27 0:42 ` Zheng, Lv
2015-07-29 0:58 ` [PATCH 00/22] ACPICA: 20150717 Release Rafael J. Wysocki
2015-07-29 1:41 ` Zheng, Lv
2015-08-05 8:23 ` [PATCH v2 0/4] ACPI: Update method tracing facility Lv Zheng
2015-08-05 8:23 ` [PATCH v2 1/4] ACPI / sysfs: Add ACPI_LV_REPAIR debug level Lv Zheng
2015-08-05 8:23 ` [PATCH v2 2/4] ACPI / sysfs: Update method tracing facility Lv Zheng
2015-08-05 8:23 ` [PATCH v2 3/4] ACPI / sysfs: Add support to allow leading "\" missing in trace_method_name Lv Zheng
2015-08-05 8:24 ` [PATCH v2 4/4] ACPI / Documentation: Update method tracing documentation Lv Zheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=daaa7193bfcf2eca2bd2f74a51ef363944ad747c.1437627016.git.lv.zheng@intel.com \
--to=lv.zheng@intel.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=robert.moore@intel.com \
--cc=zetalog@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®