Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp550364ybl; Fri, 10 Jan 2020 02:59:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwk43VqKoy2oM+02xC02zoVJapuMSr1D59vaCDtEBXrc5RA9KNoSVvxs3JHVKXT2AQ4hlSn X-Received: by 2002:aca:4d58:: with SMTP id a85mr1627106oib.35.1578653997993; Fri, 10 Jan 2020 02:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578653997; cv=none; d=google.com; s=arc-20160816; b=T96Wyr7nKonBk+ogWcjyKhb3tUkjDkjlKdYfXyszwYVZE10qg/81gonQE9HGB45M67 iDknkz4+Ocy2Gmvq5ez21XS/cEFa+zf8kBfstrZhNg/5FYwQVnH3siktDJKOJFfsQyrB GqoZf6M/uPoHo/J32vHk9V5imH6v06OWamzbsbldVO6fLku/QSZs800r7DeNtAeX3YdP vqo5tU9S0ChkOzbAAkow+drEVzQHRkLr03NCGA+Pf5Fvc8UyGDtwX2sjlcC0XlYh5AsF sHGp9SuLv3r0G/AMyZWuP5vsbd3LHO2U3Ivn0AhdHQclgQMu0fyiXmO7ABmT1mGLwXeZ ZoyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XagHk/EbdRUpNpd6LFfM3iFTOt9vsRqsDwdX23J8MWY=; b=dDwN/qxFWJ5diEPjXiS6vspgGd8TSCi6kW+/6ghfIHctiJTciKL3Rrtzsi1giVp5Qm 4msj7lVRbcwq/sqy2A2X/nTkFo2yiXKNkYFJ647/SlBAt1rIlKm4dCkxmJiPRnBnqpRv FLBCJEKHFZuwT8r7bG0Oxz6LKlMEx6IXksETEhsrtHoEwYdEQZlcGqQ1ztEPj7aKgD0q 64V8KPLZSooyjm/f+MWHjew9+OuNxO3DXX6jV+4hdjRYgYOWLYCfN++P3OT+LVpiqSjB P8NVpkTMD3s4XxNxUlB1CKaROZXZK1WOUf2jTimX1eKADyzCJGnf1VrJoPLzg7O/wrLv dUuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si987977otk.251.2020.01.10.02.59.47; Fri, 10 Jan 2020 02:59:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727761AbgAJK6B (ORCPT + 99 others); Fri, 10 Jan 2020 05:58:01 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:59944 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbgAJK54 (ORCPT ); Fri, 10 Jan 2020 05:57:56 -0500 Received: from 79.184.255.90.ipv4.supernova.orange.pl (79.184.255.90) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.320) id f8a495c79c98f501; Fri, 10 Jan 2020 11:57:53 +0100 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Len Brown , Zhang Rui Subject: [PATCH 7/8] intel_idle: Move 3 functions closer to their callers Date: Fri, 10 Jan 2020 11:52:32 +0100 Message-ID: <25912277.QUMiHIpAT5@kreacher> In-Reply-To: <14127826.m9lEolTOYu@kreacher> References: <14127826.m9lEolTOYu@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Move intel_idle_verify_cstate(), auto_demotion_disable() and c1e_promotion_disable() closer to their callers. While at it, annotate intel_idle_verify_cstate() with __init, as it is only used during the initialization of the driver. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/idle/intel_idle.c | 67 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 33 deletions(-) Index: linux-pm/drivers/idle/intel_idle.c =================================================================== --- linux-pm.orig/drivers/idle/intel_idle.c +++ linux-pm/drivers/idle/intel_idle.c @@ -951,39 +951,6 @@ static void intel_idle_s2idle(struct cpu mwait_idle_with_hints(eax, ecx); } -static bool intel_idle_verify_cstate(unsigned int mwait_hint) -{ - unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1; - unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) & - MWAIT_SUBSTATE_MASK; - - /* Ignore the C-state if there are NO sub-states in CPUID for it. */ - if (num_substates == 0) - return false; - - if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) - mark_tsc_unstable("TSC halts in idle states deeper than C2"); - - return true; -} - -static void auto_demotion_disable(void) -{ - unsigned long long msr_bits; - - rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); - msr_bits &= ~(icpu->auto_demotion_disable_flags); - wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); -} -static void c1e_promotion_disable(void) -{ - unsigned long long msr_bits; - - rdmsrl(MSR_IA32_POWER_CTL, msr_bits); - msr_bits &= ~0x2; - wrmsrl(MSR_IA32_POWER_CTL, msr_bits); -} - static const struct idle_cpu idle_cpu_nehalem = { .state_table = nehalem_cstates, .auto_demotion_disable_flags = NHM_C1_AUTO_DEMOTE | NHM_C3_AUTO_DEMOTE, @@ -1434,6 +1401,22 @@ static void __init sklh_idle_state_table skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */ } +static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) +{ + unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1; + unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) & + MWAIT_SUBSTATE_MASK; + + /* Ignore the C-state if there are NO sub-states in CPUID for it. */ + if (num_substates == 0) + return false; + + if (mwait_cstate > 2 && !boot_cpu_has(X86_FEATURE_NONSTOP_TSC)) + mark_tsc_unstable("TSC halts in idle states deeper than C2"); + + return true; +} + static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) { int cstate; @@ -1503,6 +1486,24 @@ static void __init intel_idle_cpuidle_dr intel_idle_init_cstates_acpi(drv); } +static void auto_demotion_disable(void) +{ + unsigned long long msr_bits; + + rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); + msr_bits &= ~(icpu->auto_demotion_disable_flags); + wrmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr_bits); +} + +static void c1e_promotion_disable(void) +{ + unsigned long long msr_bits; + + rdmsrl(MSR_IA32_POWER_CTL, msr_bits); + msr_bits &= ~0x2; + wrmsrl(MSR_IA32_POWER_CTL, msr_bits); +} + /* * intel_idle_cpu_init() * allocate, initialize, register cpuidle_devices