From patchwork Thu Oct 22 03:02:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1385888 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XlUo7d0Z; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CGskn5PRvz9sSn for ; Thu, 22 Oct 2020 14:08:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2A13824E9; Thu, 22 Oct 2020 05:04:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XlUo7d0Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5DC38248D; Thu, 22 Oct 2020 05:03:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A7EBE82461 for ; Thu, 22 Oct 2020 05:03:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id n6so9369ioc.12 for ; Wed, 21 Oct 2020 20:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=do0uJg820VZJu61f7PNfkWZOpdlWyQ8LZ7DrmSOf92I=; b=XlUo7d0ZIREZE060lOA9O0Kh3UfWlYBUONyLEULiLOd7ibq7XYUVDnHBI/v42KCbsF 1twPPcUEpD3V0JffhLycyQZKM8q1FwA5+vQl68md6ktFRipvJ/Kx5WF1ix3EKWvEzVqL q3aE234aC8rRusnqnT/y+uKfFRV6/Bo5JB9kg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=do0uJg820VZJu61f7PNfkWZOpdlWyQ8LZ7DrmSOf92I=; b=NwebuFDZ6nokiwmoHSLJc2+Jgx0Fx74a5vJuC7osRsrAYrYxPTzJnvUsr0cpcgSX2L F6iRjYJnlyfIEQUbsp4Yo3hzgGg1VGp/kGo9HvsG6ghX+sx4aML/GLh3t4hL+xvd8LQm tN+hCe6lEEHmOe+3DBtQEPcyyMxvdUsmAbE2WsMPvkJfesYFgaz2q5UvKoqDUtGnbg5U MSEhTElCADYC4ZQ/RY9yv6X/i36GiuaEmqnCGbc7JGCIDG9H0oKXk7i42wGBKnC3TDmK /dj4FeYRhvAwVwcl3l2RJGl+7Ps+jfOHNlWwZJvkQWnqYlzo1xxE50FWqCXzjj1f/5Iq 5DCw== X-Gm-Message-State: AOAM533WtKrBbmaHLvL57GdZ4Rxdrn+HbvGkpYTwwP+e6IbO0A1tpwCL KCcPGysY3ZlYcHS7/zQ15Vrv1VSOqT+rbHFE X-Google-Smtp-Source: ABdhPJxk5DP7tWjW3lDJGoY/vMA/LQ6chrbdyqsxMctuSyagkf6RGb81eHLQDi4L4vwU2A9INE9kkA== X-Received: by 2002:a02:6d4b:: with SMTP id e11mr179379jaf.41.1603335824387; Wed, 21 Oct 2020 20:03:44 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id p4sm206171ilg.79.2020.10.21.20.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 20:03:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Bernhard Messerklinger , Wolfgang Wallner , Walter Lozano , Simon Glass , Bin Meng Subject: [PATCH v2 20/30] acpi: Don't reset the tables with every new generation Date: Wed, 21 Oct 2020 21:02:53 -0600 Message-Id: <20201022030303.584490-19-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201022030303.584490-1-sjg@chromium.org> References: <20201022030303.584490-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Bin Meng --- (no changes since v1) arch/x86/lib/acpi_table.c | 1 + drivers/core/acpi.c | 10 ++++++---- include/dm/acpi.h | 9 +++++++++ test/dm/acpi.c | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 423df5cbf9b..66cff822dc2 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 7fe93992b5f..63a791f335e 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 e8b0336f6d8..e6951b6a25d 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 1f252a8d454..f5eddac10d0 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();