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 A8B41EB64DD for ; Fri, 21 Jul 2023 16:12:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E27E8867BC; Fri, 21 Jul 2023 18:12:27 +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="dCgniGC9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 532718672B; Fri, 21 Jul 2023 18:12:26 +0200 (CEST) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (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 B381C862B6 for ; Fri, 21 Jul 2023 18:12:23 +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-pf1-x42b.google.com with SMTP id d2e1a72fcca58-666e64e97e2so1372783b3a.1 for ; Fri, 21 Jul 2023 09:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689955942; x=1690560742; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QsYnUJfAus48diM0MGGn+aE0RqG63IMyfiWxwqEhlYc=; b=dCgniGC9Ex/4MBrOVWemWOUleulm2wiX5sRaknNSK1ad6b/vRAYpXl8paw/J8oN+JN e6M01KGn+23NjSRKOvsfTfO4ArmJOOE7ucWiHogwgzQcXnsViyu1L3ZxWUaIuzjTT9xl h5JN09BRRxVC6iAXlM6zjmoFld6Bbm/YL4rB1timXVb6yovF1+8CmcAp6tza3g9T6v4J 4alKlghrwpqZh0YrvZLroWX1sXwY8IdSXfI0Ld68RScVSjtPyFw8irnGR+TkjQbApiP8 jS5KPvLALcK8O+DHgdOUBQ5K28lpyV6T5akKQDEXztuQrW5/1XCiSs1aHlecAnSN/DbG n7LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689955942; x=1690560742; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QsYnUJfAus48diM0MGGn+aE0RqG63IMyfiWxwqEhlYc=; b=Rs6u1T4oNJ/5z29Nu2CAXcWcmyCxnLwZRBDPoSeOILkI+EuiOHuK12KCj5FoFtP4G+ ob3gQAKgRI4vaEDyf+DcoJuuyMPlQdX4w4VQpyFsTMSWl1xxXaKkLbz55jDpFVk6rvyI hLL2sUuo5KTTzSG1d09+N7/JYNr92TvTd1sgug+UYtZ65PVY6YWrBed/yYOhrHMSK2lf xinU1Jb0ABYBc/YMPSaOTHShsaupeUfahTGTpqWp+a5p3ekarEXKYAXeDMaEzC950sA7 XRFEY+/ImAWuMn3eOCDBkpp2zt8O39cIhU65+FvjyMIkt2KvJKVkhJE+D93DduOO41ad 0zrA== X-Gm-Message-State: ABy/qLZ7J894WGSLtI9y6Oe88optIs4QkKfciMIXVLNABr7IPgyqG66D ScBqn1F0XbWbuo5tmJjLsT8= X-Google-Smtp-Source: APBJJlHKpqI68d9dC8g3JfJeghlicb1fRioSFuvPUqIZqtu9rWu+ZRu8PFVsuK99sDupES9M/UbIiQ== X-Received: by 2002:a05:6a20:12c1:b0:137:2101:6578 with SMTP id v1-20020a056a2012c100b0013721016578mr2368651pzg.41.1689955941868; Fri, 21 Jul 2023 09:12:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id jw22-20020a170903279600b001b9da42cd7dsm3658239plb.279.2023.07.21.09.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 09:12:21 -0700 (PDT) From: Bin Meng To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH 1/5] x86: fsp: Use mtrr_set_next_var() for graphics memory Date: Sat, 22 Jul 2023 00:12:13 +0800 Message-Id: <20230721161217.904008-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- 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.34.1