Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6448EC001DC for ; Mon, 31 Jul 2023 06:02:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE66A86988; Mon, 31 Jul 2023 08:02:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F125286990; Mon, 31 Jul 2023 08:02:36 +0200 (CEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.221.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1E0408638D for ; Mon, 31 Jul 2023 08:02:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinylab.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng@tinylab.org X-QQ-mid: bizesmtp83t1690783346tcn7yms0 Received: from pek-vx-bsp2.wrs.com ( [60.247.85.88]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 31 Jul 2023 14:02:24 +0800 (CST) X-QQ-SSF: 01200000000000F0H000000A0000000 X-QQ-FEAT: cvpDInk2tjUIpfNRVrZNVwTq5Zmfb0HRj3enJgP2eb5bBl40+GnoqLOIXk2VG yaaVG3OY4PCeotBAUUopQyiJjPvXBzndyWanh0K6MmbmjtQNcvqcWekWR839cgjnc9+pmuP uZal5dnwqg9Cvq1KLpTdIE2imBzXTJILDCIHazhwDq9UIWcjMf3M6QMvn3WcX66jxoWhQt0 F80lNAppFZfTef7ljKd54LCwNM/4EDSBaLfImvSNAT2OuruO9sGAWrQ5AzVXIenOku7zBPG Zlc4aSWoQ087imvPi2e7dTvIjMQVGwV735nv1amLFuHTTptAxUZU6rkvhNe/JE9rmxREyPX 7GGs6o6SuZLgKCeGIyO9Y2fcWgaJrxqXiBwiRXM X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15885626717509289604 From: Bin Meng To: Simon Glass , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v2 2/6] x86: fsp: Use mtrr_set_next_var() for graphics memory Date: Mon, 31 Jul 2023 14:01:04 +0800 Message-Id: <20230731060108.577470-2-bmeng@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230731060108.577470-1-bmeng@tinylab.org> References: <20230731060108.577470-1-bmeng@tinylab.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz7a-0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean From: Bin Meng At present this uses mtrr_add_request() & mtrr_commit() combination to program the MTRR for graphics memory. This usage has two major issues as below: - mtrr_commit() will re-initialize all MTRR registers from index 0, using the settings previously added by mtrr_add_request() and saved in gd->arch.mtrr_req[], which won't cause any issue but is unnecessary - The way such combination works is based on the assumption that U-Boot has full control with MTRR programming (e.g.: U-Boot without any blob that does all low-level initialization on its own, or using FSP2 which does not touch MTRR), but this is not the case with FSP. FSP programs some MTRRs during its execution but U-Boot does not have the settings saved in gd->arch.mtrr_req[] and when doing mtrr_commit() it will corrupt what was already programmed previously. Correct this to use mtrr_set_next_var() instead. Signed-off-by: Bin Meng --- (no changes since v1) arch/x86/lib/fsp/fsp_graphics.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c index 2bcc49f605..09d5da8c84 100644 --- a/arch/x86/lib/fsp/fsp_graphics.c +++ b/arch/x86/lib/fsp/fsp_graphics.c @@ -110,8 +110,7 @@ static int fsp_video_probe(struct udevice *dev) if (ret) goto err; - mtrr_add_request(MTRR_TYPE_WRCOMB, vesa->phys_base_ptr, 256 << 20); - mtrr_commit(true); + mtrr_set_next_var(MTRR_TYPE_WRCOMB, vesa->phys_base_ptr, 256 << 20); printf("%dx%dx%d @ %x\n", uc_priv->xsize, uc_priv->ysize, vesa->bits_per_pixel, vesa->phys_base_ptr); -- 2.25.1