From patchwork Mon Aug 2 07:06:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1512301 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; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=MHtcr1V3; 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 4GdTZk0d5zz9sT6 for ; Mon, 2 Aug 2021 17:06:54 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7FF0F82C11; Mon, 2 Aug 2021 09:06:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MHtcr1V3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D76128336B; Mon, 2 Aug 2021 09:06: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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 A5C0082E3F for ; Mon, 2 Aug 2021 09:06:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-ej1-x62d.google.com with SMTP id qk33so29219391ejc.12 for ; Mon, 02 Aug 2021 00:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ozgkfyzx4YOp0PJgQTqIZHK36lr3WX6jVweXhVOQD0w=; b=MHtcr1V3zFSek2P5nakY+954C5GfQ5bC+p8OhzIIDwNNKP9snFqI9eC3RFIxzGWyGC U7r9JGg5hSJxvefjuMMSBZDtIDZNtNsxOgNica68iqcvxaWQ1MFPj88xPzwdBiMOiInN Oxwe6B4Vjt5qExXXwRVnvkjGVO67i5ytlE1WN3DImQDBE0C9IiCECqMDLclp7U3H9V5b eoqQFl5M8u7NFuGlV/j30E7Qva7ugzFDH4ENs1QfNmKShNKTbvriVElKw8KIIb8y4pGu DPXDmx6+EuOGZuSqfJ7RUeVoGZDtgiT1eh3AwVECVJwI2dye/L9rZd+5snoEds7IAFhf q7uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ozgkfyzx4YOp0PJgQTqIZHK36lr3WX6jVweXhVOQD0w=; b=OZUmSpiNIvKllFNQnrTBucQKr26/eVHWM9efj8DnBKSfZu2EloP3Vx31+d1RQud7jD t17kyaOSTQHtcfbGKSYilPYWZ2Kl29WNxqU4+4rQ8sdZV/d+zV7Wvnfo/0j3GvmYtuI5 +MctBYg7u/68DO4/SNb9zXBlAn8791n3uGonkO2AL/x8eJfKLBie8oIQ7tY3PvkVi3Mc aCO3wqhG8VPttqf/+CqdoSgc7OnzVgGnYh2ItRLCmDOZJy7aCPWZTeWQQhUbZKr2O2RE Mxxw0E2KrpbSK8692IP1LpGJ7OmN60I3us6VYLDtTgiHGOnQKpiKe5gby/iBXtImCAQM gb/A== X-Gm-Message-State: AOAM531cd/hfbEpSgBSEIFZE+rNT350vluWy7wTaI7/s942n+vjpSRDg H1YXFp5XDBxJ2Hwskzwe2WkPeroLATFR7A== X-Google-Smtp-Source: ABdhPJxyo2eMfZz2Pwx/068uBseavpUhEZWGdudSSCkgF2F7vnkZOvlXAm2D9QtZTVG8sjyviCL1Xg== X-Received: by 2002:a17:906:a08a:: with SMTP id q10mr14041146ejy.100.1627888005176; Mon, 02 Aug 2021 00:06:45 -0700 (PDT) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id b17sm1101824edd.27.2021.08.02.00.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 00:06:44 -0700 (PDT) From: Bin Meng To: u-boot@lists.denx.de, Simon Glass Subject: [PATCH v2 1/2] x86: fsp: Don't program MTRR for DRAM for FSP1 Date: Mon, 2 Aug 2021 15:06:38 +0800 Message-Id: <20210802070639.758606-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 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.103.2 at phobos.denx.de X-Virus-Status: Clean There are several outstanding issues as to why this does not apply to FSP1: * For FSP1, the system memory and reserved memory used by FSP are already programmed in the MTRR by FSP. * The 'mtrr_top' mistakenly includes TSEG memory range that has the same RES_MEM_RESERVED resource type. Its address is programmed and reported by FSP to be near the top of 4 GiB space, which is not what we want for SDRAM. * The call to mtrr_add_request() is not guaranteed to have its size to be exactly the power of 2. This causes reserved bits of the IA32_MTRR_PHYSMASK register to be written which generates #GP. For FSP2, it seems this is necessary as without this, U-Boot boot process on Chromebook Coral goes very slowly. Signed-off-by: Bin Meng --- Changes in v2: - Keep programing MTRR to FSP2 only arch/x86/lib/fsp/fsp_dram.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index 8ad9aeedac..2bd408d0c5 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -48,12 +48,28 @@ int dram_init_banksize(void) phys_addr_t mtrr_top; phys_addr_t low_end; uint bank; + bool update_mtrr; + + /* + * For FSP1, the system memory and reserved memory used by FSP are + * already programmed in the MTRR by FSP. Also it is observed that + * FSP on Intel Queensbay platform reports the TSEG memory range + * that has the same RES_MEM_RESERVED resource type whose address + * is programmed by FSP to be near the top of 4 GiB space, which is + * not what we want for DRAM. + * + * However it seems FSP2's behavior is different. We need to add the + * DRAM range in MTRR otherwise the boot process goes very slowly, + * which was observed on Chrromebook Coral with FSP2. + */ + update_mtrr = CONFIG_IS_ENABLED(FSP_VERSION2); 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); + if (update_mtrr) + mtrr_add_request(MTRR_TYPE_WRBACK, 0, gd->ram_size); return 0; } @@ -76,8 +92,10 @@ int dram_init_banksize(void) } else { gd->bd->bi_dram[bank].start = res_desc->phys_start; gd->bd->bi_dram[bank].size = res_desc->len; - mtrr_add_request(MTRR_TYPE_WRBACK, res_desc->phys_start, - res_desc->len); + if (update_mtrr) + mtrr_add_request(MTRR_TYPE_WRBACK, + res_desc->phys_start, + res_desc->len); log_debug("ram %llx %llx\n", gd->bd->bi_dram[bank].start, gd->bd->bi_dram[bank].size); @@ -92,7 +110,8 @@ int dram_init_banksize(void) * Set up an MTRR to the top of low, reserved memory. This is necessary * for graphics to run at full speed in U-Boot. */ - mtrr_add_request(MTRR_TYPE_WRBACK, 0, mtrr_top); + if (update_mtrr) + mtrr_add_request(MTRR_TYPE_WRBACK, 0, mtrr_top); return 0; } From patchwork Mon Aug 2 07:06:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1512302 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; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=AC+umjie; 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 4GdTZv4gPMz9sT6 for ; Mon, 2 Aug 2021 17:07:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3411583357; Mon, 2 Aug 2021 09:06:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AC+umjie"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 131F48336C; Mon, 2 Aug 2021 09:06:53 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 8108983357 for ; Mon, 2 Aug 2021 09:06:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-ed1-x535.google.com with SMTP id z11so655714edb.11 for ; Mon, 02 Aug 2021 00:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2jKIBESt0l0AVgjGbPCS+5MSU1EvT5Ic7g0z6UQzhic=; b=AC+umjie/xNipfbJm5qiVi8XpvqPtpNwjkUp7H//aaobmq2+jOeX9plfVnUhpLeBDl YYIOcas9PHFBbddbBRgVjpRBKAulEGdMzJQ4jFdCaRR9RLTP3Sz5CY5llPRCr2tBekgt loqWxgqvv/8dlqhAz4SndAPRk84OHoebAxwD0Em2f3Rz7pNwqLjfVcboF7PbwUsj3QYE gQiblTqZR8npm8sSqPbDp40k5xu0bU61yzYoAUMQv8pnI0VvaUuhOeGQhw3IvK6dobLK kNfN/goMYnSFELnhDkKhRuasn5o1RP+iGSsavy4hzawOxCU54kdipCDPVhtsnBxAhB4p Tx0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2jKIBESt0l0AVgjGbPCS+5MSU1EvT5Ic7g0z6UQzhic=; b=PW7RnyvbfkdHcEcwhLZNXO4QeSLmMjOL+I51iXbfzf8PClbYGCe0xqw/ZMPO2f62Lo 7drQJ+ujSZEFdy05DVTuAKGoD3n9LJzrBqHZ9+ibzuDUMZt+UVUm3uSnFyEbmkuRP6M2 AnakK7iUzk3y8yMwH+WwbFSUHLmTLHS7/Fyb6R1npT/Ik64xsBVbL8vSVz/bfOAV1BZ9 EllaDi4hsuRGQtzTTw77NjR4pWbhjLxN2YjqNvHcWb5VYRakNwkktyhlgfAZlAQXqbUI +rRt50lxI7oHt6ev2TfC7qjXI2PE1dxh7T/e5eWltiLonCRGYqkFEHAnIduh3xn/y33D Derw== X-Gm-Message-State: AOAM5309xi2xlkThlJFlmEmmRSxb9Q9FpWgp3prJpjWmklHZfJu9j3fk o9inlFEpqvimj7HGzjl+lqj/17Z0eM/ZnQ== X-Google-Smtp-Source: ABdhPJwetyZZL7NCKR2q1FlfYE5RIsHuGTaVA+K8ovvroVFd1VOpL8Nlfb60OZAulQ4yyYE39DvUHQ== X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr17291901edb.290.1627888008014; Mon, 02 Aug 2021 00:06:48 -0700 (PDT) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id b17sm1101824edd.27.2021.08.02.00.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 00:06:47 -0700 (PDT) From: Bin Meng To: u-boot@lists.denx.de, Simon Glass Subject: [PATCH v2 2/2] x86: fsp: Only FSP2 has INIT_PHASE_END_FIRMWARE Date: Mon, 2 Aug 2021 15:06:39 +0800 Message-Id: <20210802070639.758606-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210802070639.758606-1-bmeng.cn@gmail.com> References: <20210802070639.758606-1-bmeng.cn@gmail.com> 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.103.2 at phobos.denx.de X-Virus-Status: Clean For FSP1, there is no such INIT_PHASE_END_FIRMWARE. Move board_final_cleanup() to fsp2 directory. Fixes: 7c73cea44290 ("x86: Notify the FSP of the 'end firmware' event") Signed-off-by: Bin Meng --- Changes in v2: - Move board_final_cleanup() to fsp2 directory arch/x86/lib/fsp/fsp_common.c | 16 ---------------- arch/x86/lib/fsp2/fsp_common.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c index 6365b0a50a..82f7d3ab5f 100644 --- a/arch/x86/lib/fsp/fsp_common.c +++ b/arch/x86/lib/fsp/fsp_common.c @@ -61,22 +61,6 @@ void board_final_init(void) debug("OK\n"); } -void board_final_cleanup(void) -{ - u32 status; - - /* TODO(sjg@chromium.org): This causes Linux to crash */ - return; - - /* call into FspNotify */ - debug("Calling into FSP (notify phase INIT_PHASE_END_FIRMWARE): "); - status = fsp_notify(NULL, INIT_PHASE_END_FIRMWARE); - if (status) - debug("fail, error code %x\n", status); - else - debug("OK\n"); -} - int fsp_save_s3_stack(void) { struct udevice *dev; diff --git a/arch/x86/lib/fsp2/fsp_common.c b/arch/x86/lib/fsp2/fsp_common.c index f69456e43a..16567f9c85 100644 --- a/arch/x86/lib/fsp2/fsp_common.c +++ b/arch/x86/lib/fsp2/fsp_common.c @@ -11,3 +11,19 @@ int arch_fsp_init(void) { return 0; } + +void board_final_cleanup(void) +{ + u32 status; + + /* TODO(sjg@chromium.org): This causes Linux to crash */ + return; + + /* call into FspNotify */ + debug("Calling into FSP (notify phase INIT_PHASE_END_FIRMWARE): "); + status = fsp_notify(NULL, INIT_PHASE_END_FIRMWARE); + if (status) + debug("fail, error code %x\n", status); + else + debug("OK\n"); +}