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 15AFAC001E0 for ; Fri, 21 Jul 2023 16:13:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6229867FC; Fri, 21 Jul 2023 18:12:43 +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="sF71/NA7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B180867CC; Fri, 21 Jul 2023 18:12:33 +0200 (CEST) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 3041A8638D for ; Fri, 21 Jul 2023 18:12:30 +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-pl1-x62f.google.com with SMTP id d9443c01a7336-1b8bbcfd89aso12801515ad.1 for ; Fri, 21 Jul 2023 09:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689955948; x=1690560748; 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=8DHbYqAolWq4ZSVZUqlV8JOtjI2LJR46D0B/JwWVDvI=; b=sF71/NA7cbAWCVpOsdBbCXO6Z5WwAa7a6EX2A5m4Gvb7QoVSHHk27pViCJUNGa60k0 ByhrasQWyFGrU3GSbC6tpybyfiQtLuUD16zp9gSuYZiFeQAgDjl45oarHM9gBLG8VMqN 6oxcuRl27K3P4sVFkheU50SAB6E4Sso7WUkQb5EYUK1FOY1Z/19JGcZBLKzCWIzTFXxj GwRntLCgmU2MietChKwmKKSRD7UscRCEHZKxMW9+zqO3ypROZ7da7GHB+XCPNhde02Sa 8xOGSPVrJOxd9jcXr1ENpuOCKFFMElNtCIV3O7oj0ig1P1ctFAb23372ACyIwLWv1XYz FzWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689955948; x=1690560748; 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=8DHbYqAolWq4ZSVZUqlV8JOtjI2LJR46D0B/JwWVDvI=; b=c7R51Pt1HCU07+UeGRwC+Dt6CIkBc1aokqh7qVSD6CLPSP0gseowvOJj73co4PoOf4 9L9NPyeYRb0oCe1WM67hcFwnCEp1sNDve/t630Opn3vouJLgXt2w5tItQ/oQWt8nTp4C SFidZFn3ljPPka8/vxMHBjDGGT6U2P6NLzG1FJ5XLImyN0SOCqmHGjMwlV8jR8XbigCf HwcDte9mUwpsjS+vvRs4PXjQ1AEZySLcC1MewU4IjEfT+haESn9V8fEg+hBqNwhTvqYu K+wnolN4MtNM9u5p4NemgElK5IJ37Vz+wMD8X2eSGXovX8bhP3vTQ09EQ7gC3zIydHlA a3zw== X-Gm-Message-State: ABy/qLY8/QHEBtxphAHwf9TzDQ0LJKda98ozXPYizRqFLBZq34LR+yEV 1FID+SaHRe4VJi3VHeo9Wwte/tcMbCKZKoLU X-Google-Smtp-Source: APBJJlFvqtS7t3XGNwJ1e8/ZhcDXmfIYynBCTh1E0tUfew2Zc91+6Ze9Whnd9jCveySJkc1eesUjsg== X-Received: by 2002:a17:903:18a:b0:1b5:26d4:517d with SMTP id z10-20020a170903018a00b001b526d4517dmr2421795plg.29.1689955948527; Fri, 21 Jul 2023 09:12:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 09:12:28 -0700 (PDT) From: Bin Meng To: Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH 5/5] x86: Return mtrr_add_request() to its old purpose Date: Sat, 22 Jul 2023 00:12:17 +0800 Message-Id: <20230721161217.904008-5-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 From: Simon Glass This function used to be for adding a list of requests to be actioned on relocation. Revert it back to this purpose, to avoid problems with boards which need control of their MTRRs (i.e. those which don't use FSP). The mtrr_set_next_var() function is available when the next free variable-MTRR must be set, so this can be used instead. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Fixes: 3bcd6cf89ef ("x86: mtrr: Skip MSRs that were already programmed..") Fixes: 596bd0589ad ("x86: mtrr: Do not clear the unused ones..") Signed-off-by: Bin Meng --- arch/x86/cpu/mtrr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c index d57fcface0..9c24ae984e 100644 --- a/arch/x86/cpu/mtrr.c +++ b/arch/x86/cpu/mtrr.c @@ -166,8 +166,12 @@ int mtrr_commit(bool do_caches) debug("open done\n"); qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr); for (i = 0; i < gd->arch.mtrr_req_count; i++, req++) - mtrr_set_next_var(req->type, req->start, req->size); + set_var_mtrr(i, req->type, req->start, req->size); + /* Clear the ones that are unused */ + debug("clear\n"); + for (; i < mtrr_get_var_count(); i++) + wrmsrl(MTRR_PHYS_MASK_MSR(i), 0); debug("close\n"); mtrr_close(&state, do_caches); debug("mtrr done\n"); -- 2.34.1