From patchwork Thu Oct 22 03:02:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1385884 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=l3MOl320; 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 4CGsjb2L5vz9sSn for ; Thu, 22 Oct 2020 14:07:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6D2D8824D5; Thu, 22 Oct 2020 05:04:28 +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="l3MOl320"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 23A368243C; Thu, 22 Oct 2020 05:03:48 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 B415D8243D for ; Thu, 22 Oct 2020 05:03:43 +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-xd43.google.com with SMTP id h21so15244iob.10 for ; Wed, 21 Oct 2020 20:03:43 -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=+7vXio9C2LXeJCLVgW/WhYEgrcXBkaX74kXysSsLBOU=; b=l3MOl320SwxX2JDAkYukHo8Lj1gF90na424AfQCarxDxOAHWr4beE/LWVdXrdVM8HV UEBXcfSdTpcTSDD5NBZyqV0Oyb2sY5+4lUei1a5n0oHI444pdQiU0PcvgOJcXFJhj8M8 kK2Qn8+ryKn3GVcf+tZwVvg7MVkamqRaRU8Eo= 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=+7vXio9C2LXeJCLVgW/WhYEgrcXBkaX74kXysSsLBOU=; b=qibLJSJGOmRgx4bWlqXluin0njoA6qXUBEuHDqNwYpP9IX/6LysjudJTcc1rjvhmZs 2i73IyxkZ1niHuUNjv89E8HaZxgZKApUliQcOKz8SE9h7aweF4qDlRq8U9e4bAZOEQfD naBJUD81o6TSP/igbjo43kLzLPt84q4XBaPdA2aoG7XTQdzbmRN9BI4k0Nm/+pQ62imj 9bGZUZUdAkTNSlFdaQubnOoHuZ6cQNMUiwLXVzH8Y9hSEpjTDTU8LPncZyQprlCSPuoX LpCy5ByOoKkMfuxpUQYNA0izAL5YsSOUt/YF9IfphaVfuvKJz3MkXfrgWmPvoCXGkCGu ER5A== X-Gm-Message-State: AOAM5311H87RBmAgD7lZTMWWz2B7SYRCLJkD+D5ygrk+acefIVc2vbiL nI4vJ9GIQoh/X8hvDYSszWkl8PdDuxt1OmOj X-Google-Smtp-Source: ABdhPJzmAJgp9B/En4dIrLo1GSBVV4oqBOfYRj029t0ZrMMk1D98qZ4y1Au0rjIbVbxAYncZkcx0Qw== X-Received: by 2002:a02:c80a:: with SMTP id p10mr199619jao.114.1603335822463; Wed, 21 Oct 2020 20:03:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 20:03:42 -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 18/30] x86: acpi: Allow the SSDT to be empty Date: Wed, 21 Oct 2020 21:02:51 -0600 Message-Id: <20201022030303.584490-17-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 If there is nothing in the SSDT we should not include it in the tables. Update the implementation to check this. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- (no changes since v1) arch/x86/lib/acpi_table.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index f0f342d8935..c5c5c6e6794 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -470,8 +470,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) header->checksum = table_compute_checksum((void *)spcr, header->length); } -void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, - const char *oem_table_id) +static int acpi_create_ssdt(struct acpi_ctx *ctx, + struct acpi_table_header *ssdt, + const char *oem_table_id) { memset((void *)ssdt, '\0', sizeof(struct acpi_table_header)); @@ -484,9 +485,19 @@ void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, acpi_fill_ssdt(ctx); - /* (Re)calculate length and checksum. */ + /* (Re)calculate length and checksum */ ssdt->length = ctx->current - (void *)ssdt; ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length); + log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length); + + /* Drop the table if it is empty */ + if (ssdt->length == sizeof(struct acpi_table_header)) { + ctx->current = ssdt; + return -ENOENT; + } + acpi_align(ctx); + + return 0; } /* @@ -596,11 +607,8 @@ ulong write_acpi_tables(ulong start_addr) debug("ACPI: * SSDT\n"); ssdt = (struct acpi_table_header *)ctx->current; - acpi_create_ssdt(ctx, ssdt, OEM_TABLE_ID); - if (ssdt->length > sizeof(struct acpi_table_header)) { - acpi_inc_align(ctx, ssdt->length); + if (!acpi_create_ssdt(ctx, ssdt, OEM_TABLE_ID)) acpi_add_table(ctx, ssdt); - } debug("ACPI: * MCFG\n"); mcfg = ctx->current;