aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-11-04 09:57:33 -0700
committerBin Meng <bmeng.cn@gmail.com>2020-11-06 09:51:31 +0800
commit18434aec1b69d8490cb23ef35b2f39cf1784d1d0 (patch)
tree097c9ba2c28a6b825ecccff390eafd00ffc40795
parent01e3c9d2ecbb532ab98da46ceebe8507b6bceec8 (diff)
downloadu-boot-18434aec1b69d8490cb23ef35b2f39cf1784d1d0.zip
u-boot-18434aec1b69d8490cb23ef35b2f39cf1784d1d0.tar.gz
u-boot-18434aec1b69d8490cb23ef35b2f39cf1784d1d0.tar.bz2
acpi: Don't reset the tables with every new generation
At present if SSDT and DSDT code is created, only the latter is retained for examination by the 'acpi items' command. Fix this by only resetting the list when explicitly requested. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--arch/x86/lib/acpi_table.c1
-rw-r--r--drivers/core/acpi.c10
-rw-r--r--include/dm/acpi.h9
-rw-r--r--test/dm/acpi.c4
4 files changed, 20 insertions, 4 deletions
diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 423df5c..66cff82 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -531,6 +531,7 @@ ulong write_acpi_tables(ulong start_addr)
debug("ACPI: Writing ACPI tables at %lx\n", start_addr);
+ acpi_reset_items();
acpi_setup_base_tables(ctx, start);
debug("ACPI: * FACS\n");
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index 7fe9399..63a791f 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -268,8 +268,7 @@ int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent,
if (func) {
void *start = ctx->current;
- log_debug("\n");
- log_debug("- %s %p\n", parent->name, func);
+ log_debug("- method %d, %s %p\n", method, parent->name, func);
ret = device_ofdata_to_platdata(parent);
if (ret)
return log_msg_ret("ofdata", ret);
@@ -299,7 +298,6 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx)
int ret;
log_debug("Writing SSDT tables\n");
- item_count = 0;
ret = acpi_recurse_method(ctx, dm_root(), METHOD_FILL_SSDT, TYPE_SSDT);
log_debug("Writing SSDT finished, err=%d\n", ret);
ret = sort_acpi_item_type(ctx, start, TYPE_SSDT);
@@ -315,7 +313,6 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx)
int ret;
log_debug("Writing DSDT tables\n");
- item_count = 0;
ret = acpi_recurse_method(ctx, dm_root(), METHOD_INJECT_DSDT,
TYPE_DSDT);
log_debug("Writing DSDT finished, err=%d\n", ret);
@@ -326,6 +323,11 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx)
return ret;
}
+void acpi_reset_items(void)
+{
+ item_count = 0;
+}
+
int acpi_write_dev_tables(struct acpi_ctx *ctx)
{
int ret;
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index e8b0336..e6951b6 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -226,6 +226,15 @@ void acpi_dump_items(enum acpi_dump_option option);
*/
int acpi_get_path(const struct udevice *dev, char *out_path, int maxlen);
+/**
+ * acpi_reset_items() - Reset the list of ACPI items to empty
+ *
+ * This list keeps track of DSDT and SSDT items that are generated
+ * programmatically. The 'acpi items' command shows the list. Use this function
+ * to empty the list, before writing new items.
+ */
+void acpi_reset_items(void);
+
#endif /* __ACPI__ */
#endif
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 1f252a8..f5eddac 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -477,6 +477,7 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)
buf = malloc(BUF_SIZE);
ut_assertnonnull(buf);
+ acpi_reset_items();
ctx.current = buf;
buf[4] = 'z'; /* sentinel */
ut_assertok(acpi_fill_ssdt(&ctx));
@@ -507,6 +508,7 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)
buf = malloc(BUF_SIZE);
ut_assertnonnull(buf);
+ acpi_reset_items();
ctx.current = buf;
buf[4] = 'z'; /* sentinel */
ut_assertok(acpi_inject_dsdt(&ctx));
@@ -537,6 +539,7 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
buf = malloc(BUF_SIZE);
ut_assertnonnull(buf);
+ acpi_reset_items();
ctx.current = buf;
ut_assertok(acpi_fill_ssdt(&ctx));
console_record_reset();
@@ -545,6 +548,7 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
ut_assert_nextline("dev 'acpi-test2', type 1, size 2");
ut_assert_console_end();
+ acpi_reset_items();
ctx.current = buf;
ut_assertok(acpi_inject_dsdt(&ctx));
console_record_reset();