From patchwork Wed Apr 8 18:57:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1268244 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=oIwf6fiC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 48yD7y3X0gz9sSM for ; Thu, 9 Apr 2020 04:58:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04C9180616; Wed, 8 Apr 2020 20:58:17 +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="oIwf6fiC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5793E81746; Wed, 8 Apr 2020 20:58:11 +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-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 160F58006B for ; Wed, 8 Apr 2020 20:58:06 +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-il1-x144.google.com with SMTP id t6so7797602ilj.8 for ; Wed, 08 Apr 2020 11:58:06 -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=U/DG5CxmexyvHI06NBBMOTGgIZ68Xvh45zpXhXwggTg=; b=oIwf6fiCcPQkmNZtoPRL/dNDQJq41Nq1/zdIYoXMUbs5/Djd5RB+dyJONVYUa9BwMM LudYVuULP1dEzmQ0A4yq8E7ocLfMWMEIV0AbwD11/2s3S4SzG4SbI/kBZKjLuXd/X96l y/gb+OPfYI2y+jbwj8xP8Sf1Bidx6lgOznS4c= 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=U/DG5CxmexyvHI06NBBMOTGgIZ68Xvh45zpXhXwggTg=; b=OBlnpAjPqYqO5WGW5gbHXiv4gjwlwMHvZG+JytYyXiRVp9pLeIobapPvwUf6hXzT35 oQ6GMr/c+GjkJWhUJ6bjyFJ6ZkwoVnKwusXUznIthOsfAgVv9rsoYLYEdGJusbD17h9a B1DMSGyKgP7CyPNrQE4skhtXbBkydLP7U9W6dPjxLyUQRLxLL6fU8SvqsWI+GJneOYZG q+dLArOEDOJYGJ3SMXNFOib2xExomN7bwAuLdwTGfazwKMLYjBlxU1q/qve8Twkx4sYX Dv6cr09C9WH3jtyOgHLPSGc0LIvNUp3WuIAGQ+waxbs9ChYz0TRvrYhLxvs/O4A9Ibkz OXTg== X-Gm-Message-State: AGi0Pubv2nFYi65PFYh0o1B+VaQfAj/Ab5QYxcPgCyOTW4z8beIhJrE7 DqcU9SwAUjpqfq/BDoBGAh1BvctAbczMzw== X-Google-Smtp-Source: APiQypJXth0Ei9vOanuRcKqqhkhb9xGIPeAYBBYiYckXyo37CTEnbt/F2FKlkEZxCb9s3dDMb5OaYw== X-Received: by 2002:a92:9e99:: with SMTP id s25mr9128144ilk.306.1586372285633; Wed, 08 Apr 2020 11:58:05 -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 e11sm8384382ilr.30.2020.04.08.11.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:05 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass Subject: [RESEND PATCH v3 1/7] x86: fsp: Allow skipping init code when chain loading Date: Wed, 8 Apr 2020 12:57:49 -0600 Message-Id: <20200408185755.116336-2-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean It is useful to be able to boot the same x86 image on a device with or without a first-stage bootloader. For example, with chromebook_coral, it is helpful for testing to be able to boot the same U-Boot (complete with FSP) on bare metal and from coreboot. It allows checking of things like CPU speed, comparing registers, ACPI tables and the like. When U-Boot is not the first-stage bootloader much of this code is not needed and can break booting. Add checks for this to the FSP code. Rather than checking for the amount of available SDRAM, just use 1GB in this situation, which should be safe. Using 2GB may run into a memory hole on some SoCs. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/x86/lib/fsp/fsp_dram.c | 8 ++++++++ arch/x86/lib/fsp/fsp_graphics.c | 3 +++ arch/x86/lib/fsp2/fsp_dram.c | 10 ++++++++++ arch/x86/lib/fsp2/fsp_init.c | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index 9ce0ddf0d3d..15e82de2fe1 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -44,6 +44,14 @@ int dram_init_banksize(void) phys_addr_t low_end; uint bank; + if (!ll_boot_init()) { + gd->bd->bi_dram[0].start = 0; + gd->bd->bi_dram[0].size = gd->ram_size; + + mtrr_add_request(MTRR_TYPE_WRBACK, 0, gd->ram_size); + return 0; + } + low_end = 0; for (bank = 1, hdr = gd->arch.hob_list; bank < CONFIG_NR_DRAM_BANKS && !end_of_hob(hdr); diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c index 226c7e66b3f..98b762209f9 100644 --- a/arch/x86/lib/fsp/fsp_graphics.c +++ b/arch/x86/lib/fsp/fsp_graphics.c @@ -78,6 +78,9 @@ static int fsp_video_probe(struct udevice *dev) struct vesa_mode_info *vesa = &mode_info.vesa; int ret; + if (!ll_boot_init()) + return 0; + printf("Video: "); /* Initialize vesa_mode_info structure */ diff --git a/arch/x86/lib/fsp2/fsp_dram.c b/arch/x86/lib/fsp2/fsp_dram.c index 90a238a2245..74835eebcea 100644 --- a/arch/x86/lib/fsp2/fsp_dram.c +++ b/arch/x86/lib/fsp2/fsp_dram.c @@ -12,11 +12,18 @@ #include #include #include +#include int dram_init(void) { int ret; + if (!ll_boot_init()) { + /* Use a small and safe amount of 1GB */ + gd->ram_size = SZ_1G; + + return 0; + } if (spl_phase() == PHASE_SPL) { #ifdef CONFIG_HAVE_ACPI_RESUME bool s3wake = gd->arch.prev_sleep_state == ACPI_S3; @@ -68,6 +75,9 @@ int dram_init(void) ulong board_get_usable_ram_top(ulong total_size) { + if (!ll_boot_init()) + return gd->ram_size; + #if CONFIG_IS_ENABLED(HANDOFF) struct spl_handoff *ho = gd->spl_handoff; diff --git a/arch/x86/lib/fsp2/fsp_init.c b/arch/x86/lib/fsp2/fsp_init.c index da9bd6b45cf..c7dc2ea2578 100644 --- a/arch/x86/lib/fsp2/fsp_init.c +++ b/arch/x86/lib/fsp2/fsp_init.c @@ -23,7 +23,7 @@ int arch_cpu_init_dm(void) int ret; /* Make sure pads are set up early in U-Boot */ - if (spl_phase() != PHASE_BOARD_F) + if (!ll_boot_init() || spl_phase() != PHASE_BOARD_F) return 0; /* Probe all pinctrl devices to set up the pads */ From patchwork Wed Apr 8 18:57:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1268243 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=cK1AjeIR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 48yD7k68fZz9sSM for ; Thu, 9 Apr 2020 04:58:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2154981803; Wed, 8 Apr 2020 20:58:14 +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="cK1AjeIR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C36FC815F4; Wed, 8 Apr 2020 20:58:11 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 3E5AC80616 for ; Wed, 8 Apr 2020 20:58:08 +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-xd42.google.com with SMTP id i19so1191898ioh.12 for ; Wed, 08 Apr 2020 11:58:08 -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=43tmjLsyVh7hpZoD7+6Onb4SnqLN1JkvV1BvK4v5DMU=; b=cK1AjeIRK2FD4cEtr/phpYHuGMx8fJU/zwtQaeOSYpMf/nStLGI5J/8OQvJfNrdweK PujulmA+plaXy634IgZhmMkK1e7rS1HvUvP/1MBf+nafOrrLe/DJEwsoArtSQ6JIZULl U4rAywFFf4eJf9doW76p5MvlEYdSkQ/gdYSJU= 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=43tmjLsyVh7hpZoD7+6Onb4SnqLN1JkvV1BvK4v5DMU=; b=Ppq5V/nK/wnGSSL/H+E3CJ86s5ulP/vP7AAs9hKuMBbU0Z9AcoSmPiZ9O1i7BT2Hei UWRLt26/YaJ4yT37lfUXzT+iIZ70D7ISPhDjsA6KBr4c67UP4PdUJczTY1zJ/vnmyu0v fZosIODO4YaFGRHg6r0e6FaIwRXODVkvsJDR80mLU3dZakyujHfQQvDn3dISlVXsB5gd coG/5MU5k/YprcVnQ3+5ZatoqXCMmK1tgXKyqZ2q9zfaiBP27ssDZx2MCK557iksI+nT ++cpW4ZwPXqpa6K47gVs9QUIDD6qXTluyxL5ZgZUgppN6/p+Xn6vO7BgyLkMmPi0K7XF 4R1w== X-Gm-Message-State: AGi0Pubv29+juhWZ3pHNBiHWYsVhJxaydG794WkI7Xk6HZB/j7t6ZASH vJXnSDK0uRUvYQzUqfQHHNL8zzmLHhGv0g== X-Google-Smtp-Source: APiQypJ/HfBWbBnyqyMPIkZNLu8FEyJM/2xR7MtY3yQdUPvc6b9r8OdzjH461z69mViBcq5h5TPgIQ== X-Received: by 2002:a5d:9a94:: with SMTP id c20mr1119057iom.166.1586372286517; Wed, 08 Apr 2020 11:58:06 -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 e11sm8384382ilr.30.2020.04.08.11.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:06 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass Subject: [RESEND PATCH v3 2/7] x86: apl: Skip init code when chain loading Date: Wed, 8 Apr 2020 12:57:50 -0600 Message-Id: <20200408185755.116336-3-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean When U-Boot is not the first-stage bootloader the FSP-S init must be skipped. Update it to add a check. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/x86/cpu/apollolake/fsp_s.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c index 1f22c1ea3c6..5d252b11116 100644 --- a/arch/x86/cpu/apollolake/fsp_s.c +++ b/arch/x86/cpu/apollolake/fsp_s.c @@ -566,6 +566,8 @@ int arch_fsp_init_r(void) struct udevice *dev, *itss; int ret; + if (!ll_boot_init()) + return 0; /* * This must be called before any devices are probed. Put any probing * into arch_fsps_preinit() above. From patchwork Wed Apr 8 18:57: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: 1268246 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=WMk3nIui; 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 48yD8K3qVTz9sSM for ; Thu, 9 Apr 2020 04:58:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80C3E8181D; Wed, 8 Apr 2020 20:58:22 +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="WMk3nIui"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BED1D81819; Wed, 8 Apr 2020 20:58:14 +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 1BB5B808E0 for ; Wed, 8 Apr 2020 20:58:09 +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 f19so1226487iog.5 for ; Wed, 08 Apr 2020 11:58:09 -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=GqeBQM2FyEWdFdHzmigXhNtsnBUTHf4CeP1RiPXk29k=; b=WMk3nIui2rXPaW1GW16RSLZufCvP9csIeJLbUsI0MqdShXmuJwL6i22qKEdawFFcVh ZLbP/v8uK9f2L4LlWViPKjaSgAquLE3z2qSdLtVvEJt9UcgeThkaARatOA+2q5vU4gw0 D3z/2yDbeISXfwz7nMLrvJBu/VGhyubyqhzes= 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=GqeBQM2FyEWdFdHzmigXhNtsnBUTHf4CeP1RiPXk29k=; b=Fq94z4B4nisZx5TGGeM4mDdarhl+9iThDP9HKo9ZWjr1Oyii1UhnGceI2fTyzsc+0U tVHPo0xHlVYUh6AeD28uq1uvWtgmjl5FvGKYvXYziiVVwSJV8BU2cIzLo1F85h7aFt2O GDuatqOsQFnoVbg3KzNs/b2x9RtVZYDlWJ1QD+Xoqw3uXnsQXumpumFAG6LZs+hKssdq MBQK3bLnyE1hb3Ol7fHTwVJZg2NjKPNCKhl+ZEe8bPQMob34hVpHVlTiI/KAea0uGJer 7kpw7HRx/+OQD7DeapKyaQp/qYo95+iduTD9SnXbjr1X80ubhQP9FLQYinGfiGMfJPge /7Fw== X-Gm-Message-State: AGi0PuZQYkhol9uREyfPe9oPG8IZcdRkFKDw+dY1EnHMPfXkRs+B3MpM DUCIxQa+kTG3wFErXDHlOZHYTVRdutvabA== X-Google-Smtp-Source: APiQypLY9uxhY9wSSR4q6J5aikNKufbdI4XykGGYRS0REDcel+2wvkRnTO8q30U33bjx/s+4OxBtUw== X-Received: by 2002:a02:716b:: with SMTP id n43mr1114956jaf.97.1586372287416; Wed, 08 Apr 2020 11:58:07 -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 e11sm8384382ilr.30.2020.04.08.11.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:07 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass , Heinrich Schuchardt , "Park, Aiden" , Vagrant Cascadian Subject: [RESEND PATCH v3 3/7] x86: cpu: Skip init code when chain loading Date: Wed, 8 Apr 2020 12:57:51 -0600 Message-Id: <20200408185755.116336-4-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean When U-Boot is not the first-stage bootloader the interrupt and cache init must be skipped, as well as init for various peripherals. Update the code to add checks for this. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Drop the other check in interrupt_init() which is not needed now arch/x86/cpu/cpu.c | 4 +++- arch/x86/cpu/i386/interrupt.c | 6 ++++-- arch/x86/lib/init_helpers.c | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index dae06949cc6..3db035c2c0e 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -239,8 +239,10 @@ int cpu_init_r(void) struct udevice *dev; int ret; - if (!ll_boot_init()) + if (!ll_boot_init()) { + uclass_first_device(UCLASS_PCI, &dev); return 0; + } ret = x86_init_cpus(); if (ret) diff --git a/arch/x86/cpu/i386/interrupt.c b/arch/x86/cpu/i386/interrupt.c index 4c7e9ea2151..e67a116ac1a 100644 --- a/arch/x86/cpu/i386/interrupt.c +++ b/arch/x86/cpu/i386/interrupt.c @@ -264,6 +264,9 @@ int interrupt_init(void) struct udevice *dev; int ret; + if (!ll_boot_init()) + return 0; + /* Try to set up the interrupt router, but don't require one */ ret = irq_first_device_type(X86_IRQT_BASE, &dev); if (ret && ret != -ENODEV) @@ -295,8 +298,7 @@ int interrupt_init(void) * TODO(sjg@chromium.org): But we don't handle these correctly when * booted from EFI. */ - if (ll_boot_init()) - enable_interrupts(); + enable_interrupts(); #endif return 0; diff --git a/arch/x86/lib/init_helpers.c b/arch/x86/lib/init_helpers.c index 5bb55e256fb..d906b528b35 100644 --- a/arch/x86/lib/init_helpers.c +++ b/arch/x86/lib/init_helpers.c @@ -30,6 +30,9 @@ int init_cache_f_r(void) return ret; } + if (!ll_boot_init()) + return 0; + /* Initialise the CPU cache(s) */ return init_cache(); } From patchwork Wed Apr 8 18:57:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1268245 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=K/yDrJ/E; 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 48yD884GB0z9sSM for ; Thu, 9 Apr 2020 04:58:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D78C8160C; Wed, 8 Apr 2020 20:58:20 +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="K/yDrJ/E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E8C3812F0; Wed, 8 Apr 2020 20:58:16 +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 F11CC812F0 for ; Wed, 8 Apr 2020 20:58:09 +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 n20so1241007ioa.4 for ; Wed, 08 Apr 2020 11:58:09 -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=Tjl13dsPfS+uwJ8kr/40M15pdeLzWZkK4K9RvdC9h3Q=; b=K/yDrJ/EK750DK/dcX7Vnbv+XbTNcRZyXqfi4fhvztu/gAPSaxN/la4UoV5iKwXb9G 3yi4Qk8FR0lK+AcRbUJ7fBuwljJVpjlMsboTB21vWtny5D+1ireGWmqDMDix3dYyHzMX cgKjZwbRw/QuIOa5yr3jcSB0857VVv7aBd4Eo= 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=Tjl13dsPfS+uwJ8kr/40M15pdeLzWZkK4K9RvdC9h3Q=; b=R9H2GEHxfpWalVjBrtB/yXhr7vdjbAHt9iesvictxxuJXq2c5/GGpkgkloM2jveCWh IakBw9HJwxQ0c7gCfIC62338UsNE+8PIgsJ16bFaivBFUwFB6Kj6IdcoNB8iN3O+Poti v/wCNlgqhtrX1/ZEMUnIvgGkWnryfLDnX3RlCJ8tk1D6gudRLlTrf19iWin0bErc7zQT AivFdTQNzApGZJRg1al6ocZDdNaAKg5F4J253U38D1+smfb4UYL8JEiS3A8YKnyiS4T7 zJygLedV/kNI6ZWE84NLOUVhUAzZ39ev4WKhHi3BI6LQR65LFvSasxJd09JigV8sYtdY zXdA== X-Gm-Message-State: AGi0PuaPdDXlwBlcT1MTc24aBekJorvDzdPf2tzYVt2Nmu97hIGTh+JH XCm7Sr8Y5/p8ReqUClIPeSUSrpLuYvEmeg== X-Google-Smtp-Source: APiQypIGpx8AS4ufe+o95obBBaz6QeXcYwu5llg523/dS7DWBFNnBRz+RVMKJxMscMDBaou1ATJSWg== X-Received: by 2002:a02:c913:: with SMTP id t19mr8401630jao.17.1586372288520; Wed, 08 Apr 2020 11:58:08 -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 e11sm8384382ilr.30.2020.04.08.11.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:08 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass , Alex Marginean , =?utf-8?q?Marek_Beh=C3=BAn?= , Michael Walle , Thierry Reding Subject: [RESEND PATCH v3 4/7] pci: Avoid auto-config when chain loading Date: Wed, 8 Apr 2020 12:57:52 -0600 Message-Id: <20200408125746.RESEND.v3.4.Idfdc61ea876ea7aeafb2370394ac2c922344f9b4@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean When U-Boot is not the first-stage bootloader we don't want to re-configure the PCI devices, since this has already been done. Add a check to avoid this. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Drop patch 'dm: Avoid initing built-in devices when chain loading' drivers/pci/pci-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index e2882e3b634..94733662b12 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1007,7 +1007,7 @@ static int pci_uclass_post_probe(struct udevice *bus) if (ret) return ret; - if (CONFIG_IS_ENABLED(PCI_PNP) && + if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() && (!hose->skip_auto_config_until_reloc || (gd->flags & GD_FLG_RELOC))) { ret = pci_auto_config_devices(bus); @@ -1029,7 +1029,7 @@ static int pci_uclass_post_probe(struct udevice *bus) * Note we only call this 1) after U-Boot is relocated, and 2) * root bus has finished probing. */ - if ((gd->flags & GD_FLG_RELOC) && (bus->seq == 0)) { + if ((gd->flags & GD_FLG_RELOC) && bus->seq == 0 && ll_boot_init()) { ret = fsp_init_phase_pci(); if (ret) return ret; From patchwork Wed Apr 8 18:57: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: 1268247 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=kDME5Vus; 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 48yD8X1C1Gz9sSM for ; Thu, 9 Apr 2020 04:59:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01E25818C1; Wed, 8 Apr 2020 20:58:24 +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="kDME5Vus"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 271C2817EA; Wed, 8 Apr 2020 20:58:17 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 0874B8163D for ; Wed, 8 Apr 2020 20:58:11 +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-xd44.google.com with SMTP id i19so1192065ioh.12 for ; Wed, 08 Apr 2020 11:58:10 -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=seR9Iik+SotH0hQLxoVQU42AcDn7Yxen0CKpGO7Z7gs=; b=kDME5Vus7QOZ2E/W/vVg52d/zhEP6ITQK/WCBJImOjruUwX5eeaOUcZ+D9XdGQmbWa HvJ3fjsCHUgijLmNjC43mK+fYLj4yxr0L6wvHauy4Fu0TUZpSYOQfNboVycqkKJlxq53 3t/3T6rPghy7QQu6QMsvAUAgBkInPfKQ0wvGc= 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=seR9Iik+SotH0hQLxoVQU42AcDn7Yxen0CKpGO7Z7gs=; b=ctQKWjsHZX9EaR9JalKpLKi0y+l3J+zxREmGHXMQlM2pfynjWMiy+s9IOhlfrTLkO8 n3m+GiouLUZd3zqauTLU8p5tfBbPdg+m7UWB5WjXhMedRANM/hc4IZyEcsWx8jPYmbv0 CIr2c13Lh8CR3isPkmeQTxYVWenwpwawcBerN7A1G+CwO+tQ8EZZiW9w5PQMsorB7OVm rRQra1xdocyba1B6sq2TI3PdJLMesVxYc6KfIJ7Ctu7BCQLr5EzQYb+WiD+uxXYdPz4Y 88BIceyaaVpPLpsh0hPEZolQydz3EBtJgwiK3hz/4bv1o0qpbMKH7TUw9OjYsQAs/nZA Ma7g== X-Gm-Message-State: AGi0PubDAJE1OQlbbF0Sw0L5nzPQawzxWJDk3d3LjAzixtcUizYTtuzB HOO49jwUckgL0YJO4CGEPesqFflqQtGZgA== X-Google-Smtp-Source: APiQypKRYhxnOpgeRV9alVWgytevAniXIu/2KUQR96KNZYWN3eYKMCAyxzg7CJOvYYo9BL1Ijp9koQ== X-Received: by 2002:a5e:8a4d:: with SMTP id o13mr8496560iom.31.1586372289647; Wed, 08 Apr 2020 11:58:09 -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 e11sm8384382ilr.30.2020.04.08.11.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:09 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass , Baruch Siach , Daniel Schwierzeck , Heiko Schocher , Marek Vasut , Simon Goldschmidt , Stefan Roese Subject: [RESEND PATCH v3 5/7] board: Add a gd flag for chain loading Date: Wed, 8 Apr 2020 12:57:53 -0600 Message-Id: <20200408185755.116336-5-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean When U-Boot is run from another boot loader, much of the low-level init needs to be skipped. Add a flag for this and adjust ll_boot_init() to use it. Signed-off-by: Simon Glass --- Changes in v3: - Add a new patch with a gd flag for chain loading Changes in v2: None include/asm-generic/global_data.h | 1 + include/init.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 5d027329fe0..3dc51e49ef7 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -166,5 +166,6 @@ typedef struct global_data { #define GD_FLG_SPL_EARLY_INIT 0x04000 /* Early SPL init is done */ #define GD_FLG_LOG_READY 0x08000 /* Log system is ready for use */ #define GD_FLG_WDT_READY 0x10000 /* Watchdog is ready for use */ +#define GD_FLG_NO_LL_INIT 0x20000 /* Don't perform low-level init */ #endif /* __ASM_GENERIC_GBL_DATA_H */ diff --git a/include/init.h b/include/init.h index 2a33a3fd1e4..64fdf124916 100644 --- a/include/init.h +++ b/include/init.h @@ -20,7 +20,7 @@ struct global_data; #ifdef CONFIG_EFI_STUB #define ll_boot_init() false #else -#define ll_boot_init() true +#define ll_boot_init() (!(gd->flags & GD_FLG_NO_LL_INIT)) #endif /* From patchwork Wed Apr 8 18:57:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1268249 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=cbge0G0i; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 48yD8w2cxRz9sSc for ; Thu, 9 Apr 2020 04:59:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 102D081944; Wed, 8 Apr 2020 20:58: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="cbge0G0i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 843CD81834; Wed, 8 Apr 2020 20:58:16 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 EECA38006B for ; Wed, 8 Apr 2020 20:58:11 +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-xd44.google.com with SMTP id h6so1183762iok.11 for ; Wed, 08 Apr 2020 11:58:11 -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=ruwSILQLoIh6+vc15j4bIeQfpW+z985gcO3HXrjbL1U=; b=cbge0G0iGbV+Yq0Yb3zZuxxJ5FQgRXR96XVB93h4pIxWZdO+hv5mzNOGV+10oWB/OH uslCKnFEnlP9g2UE8Di8q/1UwT4v1Vb3QIrxkTgAKpzVt3alkN7ET/lGtCIM7Gr2Py1R 1azSvlzTFOJECCJFLm/Jr7q6/6iXMMFdVS3Ps= 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=ruwSILQLoIh6+vc15j4bIeQfpW+z985gcO3HXrjbL1U=; b=DNUuLGaH5Q6hqdpVmYT5ww97GboPSEL9MQ0NXqg34RLd1KXFVUGvhapZHCGPejdct7 7pnpxB+TwKCC8lAep0KZdztnV8O+URUOO5GprTSxrjk1QrhlznLfx7Sps6hsGywvsMTB TIu5kqV7BC5laaiMm2x+bgoV07rykETJUpRSre3hyz9+tPWLIfENP927AB+idLnRgK3V eo3Dg4zWTUi9Gx7FyuldDwsScx53GOPSZqJLo5maZ1i4iUfa4bJyfHJeQDWYs1ja8qeo csFR/WAAZ3S3YMrtkJ+mR+eA5RVG8F5MSlfODfupT1nE3+Qd8ucjwVEeYb/ZPprwKEpv Ww6g== X-Gm-Message-State: AGi0PubJg6vA9zMX/FP6yb40N2hFSo2ZAoUUJH/DPvcyFO/3D4jHF95F xihBm9H5aoJvMgAjws5TnwEFAmDYA4gPOA== X-Google-Smtp-Source: APiQypKlGJa9kzAAfxLwFnQYdmroJ2wQWg+tXdSKaqekPzfiK0+AP61R+vORbhPZ3hJHWpdAR37Kbw== X-Received: by 2002:a05:6638:22a:: with SMTP id f10mr8469474jaq.59.1586372290667; Wed, 08 Apr 2020 11:58:10 -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 e11sm8384382ilr.30.2020.04.08.11.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass , Masahiro Yamada Subject: [RESEND PATCH v3 6/7] x86: Add a way to detect running from coreboot Date: Wed, 8 Apr 2020 12:57:54 -0600 Message-Id: <20200408185755.116336-6-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean If U-Boot is running from coreboot we need to skip low-level init. Add an way to detect this and to set the gd flag. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch to detect running from coreboot Changes in v2: None arch/x86/cpu/i386/cpu.c | 15 +++++++++++++++ arch/x86/include/asm/u-boot-x86.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c index c8da7f10e9b..e43444c090b 100644 --- a/arch/x86/cpu/i386/cpu.c +++ b/arch/x86/cpu/i386/cpu.c @@ -447,10 +447,25 @@ int x86_cpu_init_f(void) return 0; } +bool x86_detect_coreboot(void) +{ + u32 *ptr, *end; + + /* We look for LBIO in the first 4K of RAM */ + for (ptr = NULL, end = ptr + 0x400; ptr < end; ptr += 4) { + if (*ptr == 0x4f49424c) /* "LBIO" */ + return true; + } + + return false; +} + int x86_cpu_reinit_f(void) { setup_identity(); setup_pci_ram_top(); + if (x86_detect_coreboot()) + gd->flags |= GD_FLG_NO_LL_INIT; return 0; } diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index 3e5d56d0757..654880f91cb 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -43,6 +43,13 @@ int x86_cpu_reinit_f(void); */ int x86_cpu_init_tpl(void); +/** + * x86_detect_coreboot() - See if U-Boot is being started from coreboot + * + * @return true if coreboot is running, false if U-Boot is running 'bare-metal' + */ +bool x86_detect_coreboot(void); + int cpu_init_f(void); void setup_gdt(struct global_data *id, u64 *gdt_addr); /* From patchwork Wed Apr 8 18:57:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1268248 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=bkOLSN5h; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 48yD8k0t41z9sSc for ; Thu, 9 Apr 2020 04:59:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E560D81903; Wed, 8 Apr 2020 20:58:25 +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="bkOLSN5h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF38981810; Wed, 8 Apr 2020 20:58:16 +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 0DA3380616 for ; Wed, 8 Apr 2020 20:58:13 +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 h6so1183813iok.11 for ; Wed, 08 Apr 2020 11:58:12 -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=ZquL1EGvN5vkRQ8vFZKmwKOr91GwVR9au3GDKytKjAA=; b=bkOLSN5hqR2+nFZp3aJrb6XJui+mQF+nT/1H37fDJrg8rMAsHbutv5BObtOAGtNxgK rI6qochxRZVBPYFRcC1C8lg+dJ8Pt7utbBMKUIGQIw1MkOrYupyJhWVmIPPGkHRK+e2h DfKA6pL+vzPfoH3hY2UpIvzLVIB5iM9e4ucoE= 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=ZquL1EGvN5vkRQ8vFZKmwKOr91GwVR9au3GDKytKjAA=; b=gHG8JAjBfGwnxw5a1PfsgfJxZ/dZc3AS8zWnsyCzv3IVKjS7ZFRCOhjqKsLmJFH+ue ndia59NhW63/HBVR00yOfZhEnzQHQlKGNGnCOqlaXemLohwq2AdrmBnOxMwNWQ+aaUhK j2IYEjLywrtnHtqnjMHAF/WIpVbfZiQAwuJUBgcr0NNafNgNsiT1QaInKks4y1iqbujd bIkvrxAhbPg4OjLr6e4l0CfH8XnncNkwdYH6O5TBefe8QOJ9sA7qW+91zo0j+Y8z4FXp j7O6qvUqQxVNvwJ73z+eG1kTDdQGdIVzwJOu9djN5elas5BOztdN5Piwg7cg2ZpiU6FN aKdg== X-Gm-Message-State: AGi0Pua3pje/9+Rdk3XP6BWtfdW3c0cl0mXhRUKXKTqQTowTnAWo9goE knrjP9b23XU/yKxC61wxqvU3H28kxm0zkg== X-Google-Smtp-Source: APiQypL5Q7a0ImdI+xu/iRxbRPR63ADCTdF14LthpmrspzPdqPj7yMoxJxcmcPjS9rPbmtXIk/Qy/Q== X-Received: by 2002:a02:69d4:: with SMTP id e203mr8053427jac.12.1586372291532; Wed, 08 Apr 2020 11:58:11 -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 e11sm8384382ilr.30.2020.04.08.11.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 11:58:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Simon Glass Subject: [RESEND PATCH v3 7/7] x86: Use the existing stack when chain-loading Date: Wed, 8 Apr 2020 12:57:55 -0600 Message-Id: <20200408185755.116336-7-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408185755.116336-1-sjg@chromium.org> References: <20200408185755.116336-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean With chromebook_coral we normally run TPL->SPL->U-Boot. This is the 'bare metal' case. When running from coreboot we put u-boot.bin in the RW_LEGACY portion of the image, e.g. with: cbfstool image-coral.serial.bin add-flat-binary -r RW_LEGACY \ -f /tmp/b/chromebook_coral/u-boot.bin -n altfw/u-boot \ -c lzma -l 0x1110000 -e 0x1110000 In this case U-Boot is run from coreboot (actually Depthcharge, its payload) so we cannot access CAR. Use the existing stack instead. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None arch/x86/cpu/start_from_spl.S | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/x86/cpu/start_from_spl.S b/arch/x86/cpu/start_from_spl.S index 22cab2dd6ce..75c328fd7a8 100644 --- a/arch/x86/cpu/start_from_spl.S +++ b/arch/x86/cpu/start_from_spl.S @@ -14,18 +14,30 @@ .globl _start .type _start, @function _start: - /* Set up memory using the existing stack */ + /* + * If running from coreboot, CAR is no-longer available. Use the + * existing stack, which is large enough. + */ + call x86_detect_coreboot + cmp $0, %eax + jne use_existing_stack + movl $(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE - 4), %eax #ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE subl $CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %eax #endif + jmp 2f /* - * We don't subject CONFIG_DCACHE_RAM_MRC_VAR_SIZE since memory is + * We don't subtract CONFIG_DCACHE_RAM_MRC_VAR_SIZE since memory is * already set up. This has the happy side-effect of putting gd in a * new place separate from SPL, so the memset() in * board_init_f_init_reserve() does not cause any problems (otherwise * it would zero out the gd and crash) */ + /* Set up memory using the existing stack */ +use_existing_stack: + mov %esp, %eax +2: call board_init_f_alloc_reserve mov %eax, %esp