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 DBA47C001DC for ; Mon, 31 Jul 2023 06:05:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26A92867E9; Mon, 31 Jul 2023 08:05:50 +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 96BA886988; Mon, 31 Jul 2023 08:05:48 +0200 (CEST) Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) (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 ADFA5866DA for ; Mon, 31 Jul 2023 08:05:45 +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: bizesmtp75t1690783536tcaoyj0y Received: from pek-vx-bsp2.wrs.com ( [60.247.85.88]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 31 Jul 2023 14:05:35 +0800 (CST) X-QQ-SSF: 01200000000000F0H000000A0000000 X-QQ-FEAT: C46Rb8GPIEfsamA4tMn17M+RHdAQeJb9lS6q4ru5FTqG3vK84SCVwmOyS/AlV /BVw9JOFmyQGfaVdamLeFKuurSZpHKYpRLlnHQhcC741P6/XG+3fdxuPC+yAuN8wmYyIpMN rV9vAfk02VBqPuioQGebaqP4cM8Ocm0M3IMZReKf7yPlB7EupOBF9hrCs30387iyDpbnmND wcYde5NN8YYMbSpeKLfOPQPl5wqnEF7DqXzwrhvjZbtEa3esQupx8MYSX86Mr9V03Z7c7VZ tiEttUkbO1x6/iA4CMpq+9+tl6mHgGScn4PvUTmFNPic/lQOQmiKJ+B4Xb2n2rq6U0b/V8j tKZgdyT7ZpknfM3rnyfMSzJ0Zz2+sGe8xE0lbdOWIISj8q9Qys= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15529754980083895088 From: Bin Meng To: Simon Glass , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v2 5/6] video: vesa: Use mtrr_set_next_var() for graphics memory Date: Mon, 31 Jul 2023 14:01:07 +0800 Message-Id: <20230731060108.577470-5-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/vesa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/vesa.c b/drivers/video/vesa.c index cac3bb0c33..50912c5c8b 100644 --- a/drivers/video/vesa.c +++ b/drivers/video/vesa.c @@ -23,8 +23,7 @@ static int vesa_video_probe(struct udevice *dev) /* Use write-combining for the graphics memory, 256MB */ fbbase = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base; - mtrr_add_request(MTRR_TYPE_WRCOMB, fbbase, 256 << 20); - mtrr_commit(true); + mtrr_set_next_var(MTRR_TYPE_WRCOMB, fbbase, 256 << 20); return 0; } -- 2.25.1