Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp158892rwb; Tue, 4 Oct 2022 02:03:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4TdqEi5jaVMbR04/nnTFC/EyeLoTYSWc/MsOTXqnZ7pg5/Bh+8tLt33CMsWfNogDI7atr3 X-Received: by 2002:a62:5543:0:b0:55f:fff0:966e with SMTP id j64-20020a625543000000b0055ffff0966emr14126719pfb.77.1664874231508; Tue, 04 Oct 2022 02:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664874231; cv=none; d=google.com; s=arc-20160816; b=bjV0NeqyJVFNDV1NuNrlynUAiEAH0yjXnahpqm3VRfY9mtIL4uGhq2CaevlHyIH8w5 2N+DjNa58Qr3br3wGOabUNNyLVYkOceOwLKIfg8sI4QHv7iDpvpBvavwG7zX2tPnWAgB RfrJ7y/Z0hCMSuMsx4ep63PJG2ueUOBrBgEzD0U9Hl8CSLIC/pUPQUQXjMIUm5VBMy7S uLOI0vL7gdchpLmcCvvkfZC6N4nOrJ/yXyt5n3cgUmhgz8xjQ6uCCM713j8d+uh+/j4t RaX8JS+zhqO2OFmIXIN3sBTssDU+hUBorGa3jt7e62CIx1/ZuLQh8N51JjJsumAMWKvZ oEpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tj4aELXaya1CaSjViiaKMXOfNXjJijcbMqgP3t4oiQA=; b=NkE4ceB/50tQd+V+5S95THmdEbBB6GPYjc2FeeO8WOjQbEPwAgbrd9/lU8UM0LILNB ECCYpAdNTsfjJoq5UB4eb9ReugvzPG1rU+olUphO+VSodj6yvfwLHfHQzqIkg7kE20hi HkFCs1iJdBwUTdGsSV1AHTY658itHF6S87+rkQlCAv+2tWXAV9vcnN0u2WvkZ3L9uFB0 rp73XmnYH9RG6hSPYUt/zZ/mjmYGohNvdbILlPjoqjZhvJDp5dUiRyf7bSGo4dXnlvtn /uRb7FXSPIoHhYwNXJcF8xFYgqp2NJJbRJkWCNf2rtnyFofotXqDoR2Z4mJxAdNuBukY ZzuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HVmgXUg+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u35-20020a634723000000b004398d2dfab8si12435341pga.481.2022.10.04.02.03.38; Tue, 04 Oct 2022 02:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HVmgXUg+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbiJDIM4 (ORCPT + 99 others); Tue, 4 Oct 2022 04:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbiJDIL4 (ORCPT ); Tue, 4 Oct 2022 04:11:56 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F9010FE5 for ; Tue, 4 Oct 2022 01:11:25 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 85098219B0; Tue, 4 Oct 2022 08:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1664871083; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tj4aELXaya1CaSjViiaKMXOfNXjJijcbMqgP3t4oiQA=; b=HVmgXUg+EIcCSmyVSFKEIollTXBD3At3iVM/zHCr25HtbpymoSptLLUWjnA0/Be+iOT1Tc ++I16uI7wsxXrt8/PKZvURJRNN98Kx0z3rLS6O6a9gZ7n4miZlcshAOLB/JODEsblBGbFz vxy5n8J7L55Bo34U6G74wbfBJEkjW0I= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4BE01139EF; Tue, 4 Oct 2022 08:11:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 16syEavqO2OGSAAAMHmgww (envelope-from ); Tue, 04 Oct 2022 08:11:23 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH v4 10/16] x86/mtrr: get rid of mtrr_enabled bool Date: Tue, 4 Oct 2022 10:10:17 +0200 Message-Id: <20221004081023.32402-11-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221004081023.32402-1-jgross@suse.com> References: <20221004081023.32402-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no need for keeping mtrr_enabled, as it can easily be replaced by testing mtrr_if to be not NULL. Signed-off-by: Juergen Gross --- V4: - new patch --- arch/x86/kernel/cpu/mtrr/mtrr.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 9e1b478ac896..7eed5387e828 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -59,7 +59,6 @@ #define MTRR_TO_PHYS_WC_OFFSET 1000 u32 num_var_ranges; -static bool mtrr_enabled; unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES]; static DEFINE_MUTEX(mtrr_mutex); @@ -299,7 +298,7 @@ int mtrr_add_page(unsigned long base, unsigned long size, int i, replace, error; mtrr_type ltype; - if (!mtrr_enabled) + if (!mtrr_if) return -ENXIO; error = mtrr_if->validate_add_page(base, size, type); @@ -447,7 +446,7 @@ static int mtrr_check(unsigned long base, unsigned long size) int mtrr_add(unsigned long base, unsigned long size, unsigned int type, bool increment) { - if (!mtrr_enabled) + if (!mtrr_if) return -ENODEV; if (mtrr_check(base, size)) return -EINVAL; @@ -476,7 +475,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) unsigned long lbase, lsize; int error = -EINVAL; - if (!mtrr_enabled) + if (!mtrr_if) return -ENODEV; max = num_var_ranges; @@ -536,7 +535,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) */ int mtrr_del(int reg, unsigned long base, unsigned long size) { - if (!mtrr_enabled) + if (!mtrr_if) return -ENODEV; if (mtrr_check(base, size)) return -EINVAL; @@ -562,7 +561,7 @@ int arch_phys_wc_add(unsigned long base, unsigned long size) { int ret; - if (pat_enabled() || !mtrr_enabled) + if (pat_enabled() || !mtrr_if) return 0; /* Success! (We don't need to do anything.) */ ret = mtrr_add(base, size, MTRR_TYPE_WRCOMB, true); @@ -751,22 +750,21 @@ void __init mtrr_bp_init(void) } if (mtrr_if) { - mtrr_enabled = true; set_num_var_ranges(mtrr_if == &generic_mtrr_ops); init_table(); if (mtrr_if == &generic_mtrr_ops) { /* BIOS may override */ - mtrr_enabled = get_mtrr_state(); - - if (mtrr_enabled) { + if (get_mtrr_state()) { memory_caching_control |= CACHE_MTRR | CACHE_PAT; changed_by_mtrr_cleanup = mtrr_cleanup(phys_addr); cache_cpu_init(); + } else { + mtrr_if = NULL; } } } - if (!mtrr_enabled) { + if (!mtrr_if) { pr_info("Disabled\n"); /* @@ -807,7 +805,7 @@ void mtrr_save_state(void) { int first_cpu; - if (!mtrr_enabled) + if (!mtrr_if) return; first_cpu = cpumask_first(cpu_online_mask); @@ -852,7 +850,7 @@ void mtrr_bp_restore(void) static int __init mtrr_init_finialize(void) { - if (!mtrr_enabled) + if (!mtrr_if) return 0; if (memory_caching_control & CACHE_MTRR) { -- 2.35.3