From patchwork Thu Apr 20 06:47:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13217948 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A0FC77B72 for ; Thu, 20 Apr 2023 06:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231797AbjDTGrY (ORCPT ); Thu, 20 Apr 2023 02:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjDTGrX (ORCPT ); Thu, 20 Apr 2023 02:47:23 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00CC269E for ; Wed, 19 Apr 2023 23:47:21 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="410886294" X-IronPort-AV: E=Sophos;i="5.99,211,1677571200"; d="scan'208";a="410886294" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 23:47:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="691788707" X-IronPort-AV: E=Sophos;i="5.99,211,1677571200"; d="scan'208";a="691788707" Received: from powerlab.fi.intel.com ([10.237.71.25]) by orsmga002.jf.intel.com with ESMTP; 19 Apr 2023 23:47:19 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Rui Zhang , Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH v2 2/7] intel_idle: cleanup 'intel_idle_init_cstates_icpu()' Date: Thu, 20 Apr 2023 09:47:18 +0300 Message-Id: <20230420064718.1981936-1-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-3-dedekind1@gmail.com> References: <20230419143947.1342730-3-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy The 'intel_idle_init_cstates_icpu()' function includes a loop that iterates over every C-state. Inside the loop, the same C-state data is referenced 2 ways: 1. as 'cpuidle_state_table[cstate]' 2. as 'drv->states[drv->state_count]' (but it is a copy of #1, not the same object). Make the code be more consistent and easier to read by using only the 2nd way. So the code structure would be as follows. 1. Use 'cpuidle_state_table[cstate]' 2. Copy ''cpuidle_state_table[cstate]' to 'drv->states[drv->state_count]' 3. Use only 'drv->states[drv->state_count]' from this point. Note, this change introduces a checkpatch.pl warning (too long line), but it will be addressed in the next patch. Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) Changelog * v2 - Adjust commit message (feedback from Rui Zhang). diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 726a361da422..190410fc9ce5 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1894,24 +1894,24 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) /* Structure copy. */ drv->states[drv->state_count] = cpuidle_state_table[cstate]; - if ((cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) { + if ((drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) { pr_info("forced intel_idle_irq for state %d\n", cstate); drv->states[drv->state_count].enter = intel_idle_irq; } if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && - cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IBRS) { - WARN_ON_ONCE(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE); + drv->states[drv->state_count].flags & CPUIDLE_FLAG_IBRS) { + WARN_ON_ONCE(drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE); drv->states[drv->state_count].enter = intel_idle_ibrs; } - if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_INIT_XSTATE) + if (drv->states[drv->state_count].flags & CPUIDLE_FLAG_INIT_XSTATE) drv->states[drv->state_count].enter = intel_idle_xstate; if ((disabled_states_mask & BIT(drv->state_count)) || ((icpu->use_acpi || force_use_acpi) && intel_idle_off_by_default(mwait_hint) && - !(cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) + !(drv->states[drv->state_count].flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF; if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count])) From patchwork Thu Apr 20 06:47:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13217949 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 908D1C77B73 for ; Thu, 20 Apr 2023 06:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232606AbjDTGrZ (ORCPT ); Thu, 20 Apr 2023 02:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjDTGrZ (ORCPT ); Thu, 20 Apr 2023 02:47:25 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C9E269E for ; Wed, 19 Apr 2023 23:47:24 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="410886309" X-IronPort-AV: E=Sophos;i="5.99,211,1677571200"; d="scan'208";a="410886309" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 23:47:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="691788727" X-IronPort-AV: E=Sophos;i="5.99,211,1677571200"; d="scan'208";a="691788727" Received: from powerlab.fi.intel.com ([10.237.71.25]) by orsmga002.jf.intel.com with ESMTP; 19 Apr 2023 23:47:22 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Rui Zhang , Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH v2 6/7] intel_idle: do not sprinkle module parameters definitions around Date: Thu, 20 Apr 2023 09:47:21 +0300 Message-Id: <20230420064721.1981956-1-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-7-dedekind1@gmail.com> References: <20230419143947.1342730-7-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy This is a cleanup which improves code consistency. Move the 'force_irq_on' module parameter variable and definition to the same place where we have variables and definitions for other module parameters. Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) Changelog * v2 - Mention 'XSTATE' and 'IBRS' flags in the 'force_irq_on' commentary (feedback from Rui Zhang). diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index bff0d17aeda4..35bd284f7763 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -68,6 +68,7 @@ static struct cpuidle_driver intel_idle_driver = { static int max_cstate = CPUIDLE_STATE_MAX - 1; static unsigned int disabled_states_mask; static unsigned int preferred_states_mask; +static bool force_irq_on __read_mostly; static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; @@ -1838,9 +1839,6 @@ static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) return true; } -static bool force_irq_on __read_mostly; -module_param(force_irq_on, bool, 0444); - static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) { int cstate; @@ -2157,3 +2155,9 @@ MODULE_PARM_DESC(states_off, "Mask of disabled idle states"); */ module_param_named(preferred_cstates, preferred_states_mask, uint, 0444); MODULE_PARM_DESC(preferred_cstates, "Mask of preferred idle states"); +/* + * Debugging option that forces the driver to enter all C-states with + * interrupts enabled. Does not apply to C-states with + * 'CPUIDLE_FLAG_INIT_XSTATE' and 'CPUIDLE_FLAG_IBRS' flags. + */ +module_param(force_irq_on, bool, 0444);