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 EBA8CEB64DC for ; Fri, 21 Jul 2023 16:12:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 297AD8672B; Fri, 21 Jul 2023 18:12:33 +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="mUM0QJvv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 01371867C9; Fri, 21 Jul 2023 18:12:27 +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 52241865F3 for ; Fri, 21 Jul 2023 18:12:25 +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-666e3b15370so1518313b3a.0 for ; Fri, 21 Jul 2023 09:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689955943; x=1690560743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KyZuJOSF6T8lNy69JrpuLaYLXabbFhIhG6G9k0lWqeE=; b=mUM0QJvvZjCWTRm97xdXY6M9S9iDqZl9TLx/ev8jo0yOaW4iFMgvt4CmUNt2M+R9H3 TPQfT2jG3wzUKFhzg0JLc9RExsHQo9GAXmI1YyXKOkrotzr1Y60vQguTRxprVZFGakHg OlChtIpAK8EdS7TLjb3KAiO1g6bxe9SF1p4ByOHZNZL0MMuNGyUc5XIlJ5psgu0Q0e0a GZY+x8iPrsNpq4+S7BoxnztZ9aDR2MVpB9oH6Vf1U3MQvzRpxaNE5XScpNPsowUsdO4U BkVIi+qmWSgo0vMR4lb9q9oVPdcSuxEFh3PFbpfp4kvzvYj2gf7vh3JFY6prwD1eg2Us oIxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689955943; x=1690560743; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KyZuJOSF6T8lNy69JrpuLaYLXabbFhIhG6G9k0lWqeE=; b=LPT9kXGGOyVVquzLbmwW5dAp5a22IkQ/e9DR1VDtH8PEbqndtydOJo3YqCfR5RFIFN CeJAy6S7aNkTT/Ig4BIwFABH3jI62rB+PdjD/4QfbF5KCh/2B7HAvRJ9vrlC11mqpMGg FNP92gRkEcbUBGsD0oMoK3CkOBETScQzyYHPdlafZ+JbpIIjtV8gL0xaF3Td+K9bFCM1 wfQzbZXJ657E6A46Cu1wf5AcHEqbXNqke5hHVcwPB806wZHRFrsOIS1aSyAFnS808N+6 9DmaLgicoe6rZWBcj8LPzuMceWRL8ClX5g5bT+AAa0MzQVL4SD5jQ9RZX008A3Gp8TDs WENw== X-Gm-Message-State: ABy/qLZC2Lp21gBh2vZEo2yM384kqrEbAiX8roCwyG9D0dRCMWWR8U5k 46nthPFIKTZ0OoehSTJxGU0yBqqge3HNQIEj X-Google-Smtp-Source: APBJJlHBo+uKV6+dttsbjPWWnOq0Ue3IE3Tc6T0JahuPpPb0DWugXAl3hkKwpZHvDK/lEih2hdPvGg== X-Received: by 2002:a05:6a20:7f8a:b0:12d:7d21:eadf with SMTP id d10-20020a056a207f8a00b0012d7d21eadfmr2934996pzj.52.1689955943590; Fri, 21 Jul 2023 09:12:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 09:12:23 -0700 (PDT) From: Bin Meng To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH 2/5] video: broadwell: Use mtrr_set_next_var() for graphics memory Date: Sat, 22 Jul 2023 00:12:14 +0800 Message-Id: <20230721161217.904008-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230721161217.904008-1-bmeng.cn@gmail.com> References: <20230721161217.904008-1-bmeng.cn@gmail.com> 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 --- 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.34.1