From patchwork Wed Apr 19 14:39:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216988 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 C94A0C77B73 for ; Wed, 19 Apr 2023 14:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233382AbjDSOka (ORCPT ); Wed, 19 Apr 2023 10:40:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjDSOkP (ORCPT ); Wed, 19 Apr 2023 10:40:15 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B309D4498 for ; Wed, 19 Apr 2023 07:40:11 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079349" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079349" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232571" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232571" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:49 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 1/7] intel_idle: use pr_info instead of printk Date: Wed, 19 Apr 2023 17:39:41 +0300 Message-Id: <20230419143947.1342730-2-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy Substitute 'printk()' with 'pr_info()', because 'intel_idle' already uses 'pr_debug()', so using 'pr_info()' will be more consistent. In addition to this, this patch addresses the following checkpatch.pl warning: WARNING: printk() should include KERN_ facility level Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 938c17f25d94..726a361da422 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1895,7 +1895,7 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) drv->states[drv->state_count] = cpuidle_state_table[cstate]; if ((cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) { - printk("intel_idle: forced intel_idle_irq for state %d\n", cstate); + pr_info("forced intel_idle_irq for state %d\n", cstate); drv->states[drv->state_count].enter = intel_idle_irq; } From patchwork Wed Apr 19 14:39:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216990 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 835E7C77B75 for ; Wed, 19 Apr 2023 14:40:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233192AbjDSOkb (ORCPT ); Wed, 19 Apr 2023 10:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232327AbjDSOkP (ORCPT ); Wed, 19 Apr 2023 10:40:15 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAB249C4 for ; Wed, 19 Apr 2023 07:40:11 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079356" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079356" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232614" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232614" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:51 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 2/7] intel_idle: cleanup 'intel_idle_init_cstates_icpu()' Date: Wed, 19 Apr 2023 17:39:42 +0300 Message-Id: <20230419143947.1342730-3-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-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 after the been done. 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 --- drivers/idle/intel_idle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 Wed Apr 19 14:39:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216992 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 9906EC77B73 for ; Wed, 19 Apr 2023 14:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbjDSOke (ORCPT ); Wed, 19 Apr 2023 10:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233404AbjDSOkV (ORCPT ); Wed, 19 Apr 2023 10:40:21 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8D54C3A for ; Wed, 19 Apr 2023 07:40:14 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079362" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079362" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232656" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232656" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:52 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 3/7] intel_idle: further 'intel_idle_init_cstates_icpu()' cleanup Date: Wed, 19 Apr 2023 17:39:43 +0300 Message-Id: <20230419143947.1342730-4-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy Introduce a temporary 'state' variable for referencing the currently processed C-state in the 'intel_idle_init_cstates_icpu()' function. This makes code lines shorter and easier to read. Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 190410fc9ce5..73ddb1d8cfcf 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1871,6 +1871,7 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) } for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) { + struct cpuidle_state *state; unsigned int mwait_hint; if (intel_idle_max_cstate_reached(cstate)) @@ -1893,29 +1894,30 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) /* Structure copy. */ drv->states[drv->state_count] = cpuidle_state_table[cstate]; + state = &drv->states[drv->state_count]; - if ((drv->states[drv->state_count].flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) { + if ((state->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; + state->enter = intel_idle_irq; } if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && - 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; + state->flags & CPUIDLE_FLAG_IBRS) { + WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); + state->enter = intel_idle_ibrs; } - if (drv->states[drv->state_count].flags & CPUIDLE_FLAG_INIT_XSTATE) - drv->states[drv->state_count].enter = intel_idle_xstate; + if (state->flags & CPUIDLE_FLAG_INIT_XSTATE) + state->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) && - !(drv->states[drv->state_count].flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) - drv->states[drv->state_count].flags |= CPUIDLE_FLAG_OFF; + !(state->flags & CPUIDLE_FLAG_ALWAYS_ENABLE))) + state->flags |= CPUIDLE_FLAG_OFF; - if (intel_idle_state_needs_timer_stop(&drv->states[drv->state_count])) - drv->states[drv->state_count].flags |= CPUIDLE_FLAG_TIMER_STOP; + if (intel_idle_state_needs_timer_stop(state)) + state->flags |= CPUIDLE_FLAG_TIMER_STOP; drv->state_count++; } From patchwork Wed Apr 19 14:39:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216991 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 ADA97C6FD18 for ; Wed, 19 Apr 2023 14:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233319AbjDSOkd (ORCPT ); Wed, 19 Apr 2023 10:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233406AbjDSOkW (ORCPT ); Wed, 19 Apr 2023 10:40:22 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DB2F5FE9 for ; Wed, 19 Apr 2023 07:40:14 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079366" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079366" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232698" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232698" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:53 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 4/7] intel_idle: improve C-state flags handling robustness Date: Wed, 19 Apr 2023 17:39:44 +0300 Message-Id: <20230419143947.1342730-5-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy The following C-state flags are currently mutually-exclusive and should not be combined: * IRQ_ENABLE * IBRS * XSTATE There is a warning for the situation when the IRQ_ENABLE flag is combined with the IBRS flag, but no warnings for other combinations. This is inconsistent and prone to errors. Improve the situation by adding warnings for all the unexpected combinations. Add a couple of helpful commentaries too. Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 73ddb1d8cfcf..1de36df15d5a 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1896,20 +1896,28 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) drv->states[drv->state_count] = cpuidle_state_table[cstate]; state = &drv->states[drv->state_count]; - if ((state->flags & CPUIDLE_FLAG_IRQ_ENABLE) || force_irq_on) { - pr_info("forced intel_idle_irq for state %d\n", cstate); - state->enter = intel_idle_irq; - } - - if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && - state->flags & CPUIDLE_FLAG_IBRS) { + if (state->flags & CPUIDLE_FLAG_INIT_XSTATE) { + /* + * Combining with XSTATE with IBRS or IRQ_ENABLE flags + * is not currently supported but this driver. + */ + WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IBRS); + WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); + state->enter = intel_idle_xstate; + } else if (cpu_feature_enabled(X86_FEATURE_KERNEL_IBRS) && + state->flags & CPUIDLE_FLAG_IBRS) { + /* + * IBRS mitigation requires that C-states are entered + * with interrupts disabled. + */ WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); state->enter = intel_idle_ibrs; + } else if ((state->flags & CPUIDLE_FLAG_IRQ_ENABLE) || + force_irq_on) { + pr_info("forced intel_idle_irq for state %d\n", cstate); + state->enter = intel_idle_irq; } - if (state->flags & CPUIDLE_FLAG_INIT_XSTATE) - state->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) && From patchwork Wed Apr 19 14:39:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216993 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 AF84CC77B7C for ; Wed, 19 Apr 2023 14:40:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbjDSOke (ORCPT ); Wed, 19 Apr 2023 10:40:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbjDSOkW (ORCPT ); Wed, 19 Apr 2023 10:40:22 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DDD659D7 for ; Wed, 19 Apr 2023 07:40:15 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079374" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079374" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232730" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232730" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:55 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 5/7] intel_idle: fix confusing message Date: Wed, 19 Apr 2023 17:39:45 +0300 Message-Id: <20230419143947.1342730-6-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy By default, all non-POLL C-states are entered with interrupts disable. There are 2 ways to make 'intel_idle' enter C-states with interrupts enabled: 1. Mark the C-state with the 'CPUIDLE_FLAG_IRQ_ENABLE' flag. 2. Use the 'force_irq_on' module parameter. The former is the "proper" way of doing it, it is per-C-state and per-platform. The latter is for debugging purposes only. The problem is that 'intel_idle' prints the "forced intel_idle_irq" message in both cases, even though the former case does not needed this message, because nothing is forced there. This patch addresses the problem. Signed-off-by: Artem Bityutskiy Reviewed-by: Zhang Rui --- drivers/idle/intel_idle.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 1de36df15d5a..bff0d17aeda4 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1912,8 +1912,9 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) */ WARN_ON_ONCE(state->flags & CPUIDLE_FLAG_IRQ_ENABLE); state->enter = intel_idle_ibrs; - } else if ((state->flags & CPUIDLE_FLAG_IRQ_ENABLE) || - force_irq_on) { + } else if (state->flags & CPUIDLE_FLAG_IRQ_ENABLE) { + state->enter = intel_idle_irq; + } else if (force_irq_on) { pr_info("forced intel_idle_irq for state %d\n", cstate); state->enter = intel_idle_irq; } From patchwork Wed Apr 19 14:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216994 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 4C70CC77B75 for ; Wed, 19 Apr 2023 14:40:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233370AbjDSOkf (ORCPT ); Wed, 19 Apr 2023 10:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjDSOkX (ORCPT ); Wed, 19 Apr 2023 10:40:23 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995B4729C for ; Wed, 19 Apr 2023 07:40:15 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079385" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079385" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232761" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232761" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:56 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 6/7] intel_idle: do not sprinkle module parameters definitions around Date: Wed, 19 Apr 2023 17:39:46 +0300 Message-Id: <20230419143947.1342730-7-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-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 --- drivers/idle/intel_idle.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index bff0d17aeda4..9e4105b532da 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,8 @@ 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. + */ +module_param(force_irq_on, bool, 0444); From patchwork Wed Apr 19 14:39:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 13216995 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 6CF96C77B7E for ; Wed, 19 Apr 2023 14:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbjDSOkg (ORCPT ); Wed, 19 Apr 2023 10:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233381AbjDSOk3 (ORCPT ); Wed, 19 Apr 2023 10:40:29 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A099750 for ; Wed, 19 Apr 2023 07:40:21 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="325079394" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="325079394" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2023 07:39:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10685"; a="1021232784" X-IronPort-AV: E=Sophos;i="5.99,208,1677571200"; d="scan'208";a="1021232784" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005.fm.intel.com with ESMTP; 19 Apr 2023 07:39:58 -0700 From: Artem Bityutskiy To: "Rafael J. Wysocki" Cc: Linux PM Mailing List , Artem Bityutskiy Subject: [PATCH 7/7] intel_idle: mark few variables as '__read_mostly' Date: Wed, 19 Apr 2023 17:39:47 +0300 Message-Id: <20230419143947.1342730-8-dedekind1@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230419143947.1342730-1-dedekind1@gmail.com> References: <20230419143947.1342730-1-dedekind1@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Artem Bityutskiy The intention of this patch is to clean up the code and make it look a bit more consistent. Mark all unitialized module parameter variables as '__read_mostly', not just one of them. The other parameters are also read-mostly too. Signed-off-by: Artem Bityutskiy --- drivers/idle/intel_idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 9e4105b532da..1711cfdc45cc 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -66,8 +66,8 @@ static struct cpuidle_driver intel_idle_driver = { }; /* intel_idle.max_cstate=0 disables driver */ static int max_cstate = CPUIDLE_STATE_MAX - 1; -static unsigned int disabled_states_mask; -static unsigned int preferred_states_mask; +static unsigned int disabled_states_mask __read_mostly; +static unsigned int preferred_states_mask __read_mostly; static bool force_irq_on __read_mostly; static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;