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 78787C001DC for ; Mon, 31 Jul 2023 06:03:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 86EE386988; Mon, 31 Jul 2023 08:03:42 +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 E03E786990; Mon, 31 Jul 2023 08:03:40 +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 C4B138638D for ; Mon, 31 Jul 2023 08:03:37 +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: bizesmtp89t1690783409t3jk211f Received: from pek-vx-bsp2.wrs.com ( [60.247.85.88]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 31 Jul 2023 14:03:28 +0800 (CST) X-QQ-SSF: 01200000000000F0H000000A0000000 X-QQ-FEAT: zT6n3Y95oi25aJyF9YVGa+Thwxxr7s8ouEK0/dpd+2RIZ/OKw+VwWeM0Q+92H Y9ISXHRm2hBQDjnUamvC2XZy3BVzAyM74XA7/FwVKQLOIoEGu3l8MhcyV+xMHC/il+QXLG9 oSNqXrdEl6PJbtPwujEA4NnavWZpw0J4XX++cY+36Ya+q7SHE15Yk2E7uE+j/tlznMYXUZT rT5m86Y/OpI1UNv0Cl3JezzNbyJj/3zxDhmY/99ZzYQYIq3qIwzAwuS3IM3B4VQe6urusun ZCLAj9L1UWQaXir1n3NzUTlYamlmGwb/85V34P/ZxEg8FdPNMzGF8ZzB7g4TEpCGfHd9GOW IqToid1qfbT7Ps9kyMwUqqQ1vMFaJOl6kcQN5Dxgg1C3JAJtRo= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8121912224940807694 From: Bin Meng To: Simon Glass , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v2 3/6] video: broadwell: Use mtrr_set_next_var() for graphics memory Date: Mon, 31 Jul 2023 14:01:05 +0800 Message-Id: <20230731060108.577470-3-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) drivers/video/broadwell_igd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/video/broadwell_igd.c b/drivers/video/broadwell_igd.c index 6aa4e27071..83b6c908a8 100644 --- a/drivers/video/broadwell_igd.c +++ b/drivers/video/broadwell_igd.c @@ -693,13 +693,9 @@ static int broadwell_igd_probe(struct udevice *dev) /* Use write-combining for the graphics memory, 256MB */ fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base; - ret = mtrr_add_request(MTRR_TYPE_WRCOMB, fbbase, 256 << 20); - if (!ret) - ret = mtrr_commit(true); - if (ret && ret != -ENOSYS) { - printf("Failed to add MTRR: Display will be slow (err %d)\n", - ret); - } + ret = mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20); + if (ret) + printf("Failed to add MTRR: Display will be slow (err %d)\n", ret); debug("fb=%lx, size %x, display size=%d %d %d\n", plat->base, plat->size, uc_priv->xsize, uc_priv->ysize, uc_priv->bpix); -- 2.25.1