From patchwork Wed Nov 2 07:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 14058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3469745wru; Wed, 2 Nov 2022 00:52:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5p30onE3pcNilY6dymMeY9LWNyI5WJ8+makIvy8YBTzO5SNJM8n9mtjCnvsLhjpIRHbo7A X-Received: by 2002:a17:907:3f23:b0:78e:260a:fc33 with SMTP id hq35-20020a1709073f2300b0078e260afc33mr22949128ejc.152.1667375543677; Wed, 02 Nov 2022 00:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667375543; cv=none; d=google.com; s=arc-20160816; b=c+lzkA1radmSlLuHrJfbZc6llchGtVIGL7X8fuyj5emeoCvsI2S5Ild8fkb9zLyFLg gUkLQfKOoirgYwbLyLtT2BcvagyZswJR5hieHxhpwOgjpFZMRI/KrgE3bZCWdomQtq0V cwARPD3XwMsQ4ang5MguQ7MejO6YvR91hzaGkspVeKmEC27UFybDJpEvMYeMde28t/mF gz3tYhC+yY8xyC5cwaCYYlBedr1CAtvP9hvypEP7qDNyzRUhsRGYn8/jrn90XnYDKrZv K4Gu5DS79Xw8ZGuii3V3/40sDpQKucBy+Yf1xwRdv74sJ+FvSFbZ4W30NJdTcdNDH+1z r1Sg== 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 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.51.59; Wed, 02 Nov 2022 00:52:23 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748369977861146557?= X-GMAIL-MSGID: =?utf-8?q?1748369977861146557?= 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; } } }