Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3626565rwi; Wed, 2 Nov 2022 00:53:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44o9uKOMQV88Zez9DqlNSeHaeDlkpNq+8R9ExDxXGaN5H27MlYhgcmJeQZDWGS/OiLU6aY X-Received: by 2002:a17:907:6e87:b0:78f:a596:5cf6 with SMTP id sh7-20020a1709076e8700b0078fa5965cf6mr22140767ejc.398.1667375617784; Wed, 02 Nov 2022 00:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667375617; cv=none; d=google.com; s=arc-20160816; b=XNtQ49zyzhBZUNJaOfYzxwW9ZVtUqAOfL/U7xc1AJU2CrVBKNnGk0DsA9v4j04B7rI 16s7BilyMQcEOnS5qNyEOH9gaxh1243CR1u+F9Pnxz/hLcpM1BNTaFzaTvOzZ4uWNdDg WfMOpMjkX06EjoOTsQZ1diapliHkZgkwbaDdMnwViU7y5r4Mzaeg0xfERM2MZKW/hPQQ JYGdk2YvH2MVaPv9Z3e8hiVMSg9MPQ9XIO9sUn37xgU95DBs7ONocpgiij2W4mAjDg1j dDuy9+aT5nU+OKJSLFLdaCjAKLYRc6RmlWeQ7YWpNsjRbuhFSOtrpPrzNT4boX1seme2 K7+A== 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=Ux8/e9Woh3s8p0UvLOFok/6CxUvIyieZjB6VEj7G4a8=; b=ngJYswzkNBlDL+4zRV4MMD0zy9lMfvQxrWrRZ/nMtFxj4n6zphS0I/7r5EBzMPeXE9 fxKZ1P/dbfkhu+gKK6u3tLUaydclefORSphY7Nw2joFE+rxCiETErsxWujDs2G2mwiEG +7DLf2IQL8Ov+Rik1EiLaZ/ris5fZWwcv+wRhrMAtlL5+9KLa6nZIiV9DkBDmBNw1HQA DI7HK8M/CpZbQlo/Mz6LmUEWio93QKUS680R5mnO22z9MLhwB9JplXT/laRx8nWBV81S 8irQQulYLCXTWa8Un5xo4tGXaTTDqvAYV3E8hbdSovpjTf3QaXJfHMgcmCDLfGF8VqmR lHvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=BIorFGSD; 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 t19-20020a170906179300b0073d581b0906si11836561eje.278.2022.11.02.00.53.14; Wed, 02 Nov 2022 00:53:37 -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=BIorFGSD; 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 S230499AbiKBHsf (ORCPT + 96 others); Wed, 2 Nov 2022 03:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiKBHsO (ORCPT ); Wed, 2 Nov 2022 03:48:14 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 850F62715C for ; Wed, 2 Nov 2022 00:48:13 -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-out2.suse.de (Postfix) with ESMTPS id 464841F90F; Wed, 2 Nov 2022 07:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1667375292; 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=Ux8/e9Woh3s8p0UvLOFok/6CxUvIyieZjB6VEj7G4a8=; b=BIorFGSD6wNJyIneTrGhMbM4cpdb9OTImr4C9otIkeQZVL7lnzgyvPA8CsLuyN0l2YqmHM nGYCHKnnM3D3c6q7keXpI43++4UBPl2PSwnPM4alZ0kEpqRScZt9i0vYpgGtp4GVwvzrRf 5O76h1edklbFA2nKkv0ZVGlxJwBCvKM= 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 071DA1376E; Wed, 2 Nov 2022 07:48:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Cb9oALwgYmP/cgAAMHmgww (envelope-from ); Wed, 02 Nov 2022 07:48:12 +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 v5 10/16] x86/mtrr: get rid of __mtrr_enabled bool Date: Wed, 2 Nov 2022 08:47:07 +0100 Message-Id: <20221102074713.21493-11-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221102074713.21493-1-jgross@suse.com> References: <20221102074713.21493-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 V5: - rebase --- arch/x86/kernel/cpu/mtrr/mtrr.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index a468be5d778f..f671be9823b6 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -59,11 +59,9 @@ #define MTRR_TO_PHYS_WC_OFFSET 1000 u32 num_var_ranges; -static bool __mtrr_enabled; - static bool mtrr_enabled(void) { - return __mtrr_enabled; + return !!mtrr_if; } unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES]; @@ -755,18 +753,17 @@ void __init mtrr_bp_init(void) } } - if (mtrr_if) { - __mtrr_enabled = true; + if (mtrr_enabled()) { 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; } } } -- 2.35.3