From patchwork Mon Sep 28 04:25:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1372329 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=UXs9m3YA; 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 4C08dc1zZJz9sSn for ; Mon, 28 Sep 2020 14:28:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48BFA823BE; Mon, 28 Sep 2020 06:26:49 +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="UXs9m3YA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBEC88231E; Mon, 28 Sep 2020 06:26:30 +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.6 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-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) (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 527E382383 for ; Mon, 28 Sep 2020 06:26:26 +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-ot1-x344.google.com with SMTP id n61so8363887ota.10 for ; Sun, 27 Sep 2020 21:26:26 -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=y0Bbge1DQfMbWYwUWkRx9vMtzTnssCq4FzM7q1bYzwI=; b=UXs9m3YAYO6GMCI+WTp269dPmu+ne0x8a5i+hCEQ6pg5Zq5mLGBYHmjaPQgNL31Tef WYuSBzpdlpkE7qYkariolLt3oiVPTy07/cAY/q4nYi2KEmdWS2AEiuuE5vhVgFmPdqx5 554K2j/YI73PdqWfbO6h2YPbj+EzwkyIlh4oc= 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=y0Bbge1DQfMbWYwUWkRx9vMtzTnssCq4FzM7q1bYzwI=; b=bruIMUpuTA2ndFnOv1jJ1/yOsRXbs0QRrl5ypegNtrM53ppHDDKSwP4xC00B63tzlM 7BJQ2n6R3OtrbwejgcGY6EDiHHCsHBI0YL32VDdAkGFURUwPkpAY9Odx/pALQYbBTWNR GW/TJE5TyWHlLPWiSCbIQxRCWwBk0cStD02oEUSbuN0o+lAOOFvTsR4RAcpb8NPmS5LV UkOwBz/H+pQxYH6ZX/OVNoe99xqpzgYdYlk2T0Mx8qLZooaxgmxaXCRGkyGXicpx400x +sIdbUMcQbz4W73aOS3WTCQcmFdXJ3bA4H+S40EtA7bCcC7C7FlYDVOGr17zNOIlpzAi CEjg== X-Gm-Message-State: AOAM531yN+cOynKSYSvg+owyeXlNwQ6BGJKE5y0HJKIIiJhMCpATrDbd rVbi5cNRr7kUbVFC93C2skKbgPAc55fdplWU X-Google-Smtp-Source: ABdhPJxA6jU55iYMofoz3zMEc562ncpXMfQGXI1Yj6euqrenshmh+tsKXl520mo2+LXUz3TJyidrAQ== X-Received: by 2002:a9d:4e18:: with SMTP id p24mr7949849otf.190.1601267184954; Sun, 27 Sep 2020 21:26:24 -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 k51sm2620579otc.46.2020.09.27.21.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 21:26:24 -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 07/32] x86: Store the FADT so we can avoid searching for it Date: Sun, 27 Sep 2020 22:25:46 -0600 Message-Id: <20200928042611.1696178-6-sjg@chromium.org> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200928042611.1696178-1-sjg@chromium.org> References: <20200928042611.1696178-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 Put the FADT in global_data and access it as needed. Drop the functions which search for it. Signed-off-by: Simon Glass --- arch/x86/cpu/cpu.c | 6 ++-- arch/x86/include/asm/acpi.h | 9 ------ arch/x86/lib/acpi.c | 57 ------------------------------------- arch/x86/lib/acpi_table.c | 1 + include/dm/acpi.h | 2 ++ 5 files changed, 6 insertions(+), 69 deletions(-) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 5c33f02f034..6cbfc0c8488 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -199,13 +199,13 @@ __weak void board_final_cleanup(void) int last_stage_init(void) { - struct acpi_fadt __maybe_unused *fadt; + struct acpi_fadt *fadt; int ret; board_final_init(); if (IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)) { - fadt = acpi_find_fadt(); + fadt = gd->acpi_ctx->fadt; if (fadt && gd->arch.prev_sleep_state == ACPI_S3) acpi_resume(fadt); @@ -218,7 +218,7 @@ int last_stage_init(void) } if (IS_ENABLED(CONFIG_GENERATE_ACPI_TABLE)) { - fadt = acpi_find_fadt(); + fadt = gd->acpi_ctx->fadt; /* Don't touch ACPI hardware on HW reduced platforms */ if (fadt && !(fadt->flags & ACPI_FADT_HW_REDUCED_ACPI)) { diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 4475d046e8c..2023e2b0460 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h @@ -8,15 +8,6 @@ struct acpi_fadt; -/** - * acpi_find_fadt() - find ACPI FADT table in the system memory - * - * This routine parses the ACPI table to locate the ACPI FADT table. - * - * @return: a pointer to the ACPI FADT table in the system memory - */ -struct acpi_fadt *acpi_find_fadt(void); - /** * acpi_find_wakeup_vector() - find OS installed wake up vector address * diff --git a/arch/x86/lib/acpi.c b/arch/x86/lib/acpi.c index 155fffabf08..20f1bb79b35 100644 --- a/arch/x86/lib/acpi.c +++ b/arch/x86/lib/acpi.c @@ -9,63 +9,6 @@ #include #include -static struct acpi_rsdp *acpi_valid_rsdp(struct acpi_rsdp *rsdp) -{ - if (strncmp((char *)rsdp, RSDP_SIG, sizeof(RSDP_SIG) - 1) != 0) - return NULL; - - debug("Looking on %p for valid checksum\n", rsdp); - - if (table_compute_checksum((void *)rsdp, 20) != 0) - return NULL; - debug("acpi rsdp checksum 1 passed\n"); - - if ((rsdp->revision > 1) && - (table_compute_checksum((void *)rsdp, rsdp->length) != 0)) - return NULL; - debug("acpi rsdp checksum 2 passed\n"); - - return rsdp; -} - -struct acpi_fadt *acpi_find_fadt(void) -{ - char *p, *end; - struct acpi_rsdp *rsdp = NULL; - struct acpi_rsdt *rsdt; - struct acpi_fadt *fadt = NULL; - int i; - - /* Find RSDP */ - for (p = (char *)ROM_TABLE_ADDR; p < (char *)ROM_TABLE_END; p += 16) { - rsdp = acpi_valid_rsdp((struct acpi_rsdp *)p); - if (rsdp) - break; - } - - if (!rsdp) - return NULL; - - debug("RSDP found at %p\n", rsdp); - rsdt = (struct acpi_rsdt *)(uintptr_t)rsdp->rsdt_address; - - end = (char *)rsdt + rsdt->header.length; - debug("RSDT found at %p ends at %p\n", rsdt, end); - - for (i = 0; ((char *)&rsdt->entry[i]) < end; i++) { - fadt = (struct acpi_fadt *)(uintptr_t)rsdt->entry[i]; - if (strncmp((char *)fadt, "FACP", 4) == 0) - break; - fadt = NULL; - } - - if (!fadt) - return NULL; - - debug("FADT found at %p\n", fadt); - return fadt; -} - void *acpi_find_wakeup_vector(struct acpi_fadt *fadt) { struct acpi_facs *facs; diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index f0f342d8935..e0130ad5230 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -590,6 +590,7 @@ ulong write_acpi_tables(ulong start_addr) debug("ACPI: * FADT\n"); fadt = ctx->current; + ctx->fadt = fadt; acpi_inc_align(ctx, sizeof(struct acpi_fadt)); acpi_create_fadt(fadt, facs, dsdt); acpi_add_table(ctx, fadt); diff --git a/include/dm/acpi.h b/include/dm/acpi.h index e8b0336f6d8..a200305e640 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -46,6 +46,7 @@ enum acpi_dump_option { * adding a new table. The RSDP holds pointers to the RSDT and XSDT. * @rsdt: Pointer to the Root System Description Table * @xsdt: Pointer to the Extended System Description Table + * @fadt: Pointer to the Fixed ACPI Description Table * @nhlt: Intel Non-High-Definition-Audio Link Table (NHLT) pointer, used to * build up information that audio codecs need to provide in the NHLT ACPI * table @@ -58,6 +59,7 @@ struct acpi_ctx { struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; struct acpi_xsdt *xsdt; + struct acpi_fadt *fadt; struct nhlt *nhlt; char *len_stack[ACPIGEN_LENSTACK_SIZE]; int ltop;