From patchwork Mon Jul 17 15:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 704280 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 6ACF5EB64DC for ; Mon, 17 Jul 2023 15:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjGQPUN (ORCPT ); Mon, 17 Jul 2023 11:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbjGQPTn (ORCPT ); Mon, 17 Jul 2023 11:19:43 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD850199F for ; Mon, 17 Jul 2023 08:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689607170; x=1721143170; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=V8q4dzA/0PGXASxpKzhr8IPLwXqNp2DK9Naa0xXzuPA=; b=elqhmp3OU5mJ+Ep5YhwDuEASaUoTskWkj4DRJLvMEfQVeueUZpRzlFF1 AOQasAdJFlBTosY38ofiblqFxb3a5KAiqE7554jDb9SmUTeT1z9USaE3e GeEoZCOorOsmQyzJ2fE/xugp0+qfGiaKewRAjjLDAQyaji2zkw75doz1C qSZ66D7mznHy/agwesFwoKfqdBKfYPQAXxGqPPjUWR0gm5f5t3h4dvQv0 8/7qhqNZMPnZAgGPmmFjcGURk3kaEB6nsQhL1ZJR6oNv1TWJGzsh/ybOb iayYBF5rZqKMY8wdIeaQivAw133cag14sTWAkEOohA78ruIL85Bsp5sYU Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="429716535" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="429716535" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="726581560" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="726581560" Received: from arjan-box.jf.intel.com ([10.54.74.119]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:07 -0700 From: arjan@linux.intel.com To: linux-pm@vger.kernel.org Cc: rafael@kernel.org, Arjan van de Ven Subject: [PATCH 1/4] intel_idle: refactor and split out model specific fixups into its own function Date: Mon, 17 Jul 2023 15:18:53 +0000 Message-ID: <20230717151856.2529029-1-arjan@linux.intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Arjan van de Ven As this list has been growing over time, lets split it into its own function. That also makes it possible to move other hw workarounds into this function over time. Signed-off-by: Arjan van de Ven --- drivers/idle/intel_idle.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index b930036edbbe..3bab6500697a 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1955,10 +1955,8 @@ static bool should_verify_mwait(struct cpuidle_state *state) return true; } -static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) +static void __init model_specific_fixups(void) { - int cstate; - switch (boot_cpu_data.x86_model) { case INTEL_FAM6_IVYBRIDGE_X: ivt_idle_state_table_update(); @@ -1983,6 +1981,13 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) adl_idle_state_table_update(); break; } +} + +static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) +{ + int cstate; + + model_specific_fixups(); for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) { struct cpuidle_state *state; From patchwork Mon Jul 17 15:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 703971 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 0C3D5C00528 for ; Mon, 17 Jul 2023 15:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbjGQPUg (ORCPT ); Mon, 17 Jul 2023 11:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjGQPUN (ORCPT ); Mon, 17 Jul 2023 11:20:13 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D2312D for ; Mon, 17 Jul 2023 08:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689607181; x=1721143181; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ev0NLhqMBppSxPvvDd1BJ7d4+xX0IL28bOamUgRNnbc=; b=LbFoZwY2e3A+UOdFnzg5mvvQip75hHkJ8M6dXzhYSRQ9s/HFNJauqp5j OZxwYLKDI/XtXqPaPelGT2haoXJMYDTa8GZ1cD5RIm/QB0J00mj/PeKOJ LiDk5ydr9DBBM378+56/NdtFalbXLwf6Jp0d7YAC2tiY2/mjd5N6aJTLb bNgd1fptsNG2JnHJ1ek+Zer8Ijy/FL7jCtFG9IKvdyqYszPN2W2WQtGQb Pn/Zavu4HvaU/aTxIpqFeTDqdFFxww8X7VAtQHYFBXvmiRY+dG1UwEcHu BNSEW1pJZ2sZYhqTzbMbW8wWNXwxwvDfPEZLL7oITSKX52kivmnVrPnKx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="429716542" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="429716542" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="726581585" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="726581585" Received: from arjan-box.jf.intel.com ([10.54.74.119]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:09 -0700 From: arjan@linux.intel.com To: linux-pm@vger.kernel.org Cc: rafael@kernel.org, Arjan van de Ven Subject: [PATCH 2/4] intel_idle: move one more model specific workaround into the newly created seperate function Date: Mon, 17 Jul 2023 15:18:54 +0000 Message-ID: <20230717151856.2529029-2-arjan@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717151856.2529029-1-arjan@linux.intel.com> References: <20230717151856.2529029-1-arjan@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Arjan van de Ven byt_auto_demotion_disable_flag (for baytrail) handling can now be moved into the newly created model_specific_fixups() function. This frees up intel_idle_init_cstates_icpu() from containing model specific information direclty Signed-off-by: Arjan van de Ven --- drivers/idle/intel_idle.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 3bab6500697a..f3eba9b147d2 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1981,6 +1981,11 @@ static void __init model_specific_fixups(void) adl_idle_state_table_update(); break; } + + if (icpu->byt_auto_demotion_disable_flag) { + wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0); + wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0); + } } static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) @@ -2030,10 +2035,6 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv) drv->state_count++; } - if (icpu->byt_auto_demotion_disable_flag) { - wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0); - wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0); - } } /** From patchwork Mon Jul 17 15:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 703972 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 855C9C001DF for ; Mon, 17 Jul 2023 15:20:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbjGQPUB (ORCPT ); Mon, 17 Jul 2023 11:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjGQPTl (ORCPT ); Mon, 17 Jul 2023 11:19:41 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 435021739 for ; Mon, 17 Jul 2023 08:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689607169; x=1721143169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HDyxnFMW6ToDi+AVUzlUAgIJLjyTYn/1ND+QK+JrqIk=; b=UMq2iuZo9kid36PgF48qyE8kYaC926BtR1WUPWe6pXArE6l9KiZYOhKq xZHP/cBVn01UW98cmc4cq4aw1COTAqtvSANsTHazRl7075b4USsb99f5l I+pKyauAwaCMhGtUon67IKDePrpu1qFVQ6X6d5dZkIglpRNwbkd9hgGcF BIEIP88p6BvTPc6L0VD1q0m1ntV5599CxXr2+5bndjJJWpfTHasZlvkCH 4Szoz5o+4lsVIQEEzL5TBBPgPAYkVIfbgOz13XbnTu1lkni1LgBkmeZK/ UPRLbZJTScboMrVHYYBnz+50igVrtTz3KaruZpz70kK3m1STRIFtSjxAp A==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="429716547" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="429716547" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="726581590" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="726581590" Received: from arjan-box.jf.intel.com ([10.54.74.119]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:11 -0700 From: arjan@linux.intel.com To: linux-pm@vger.kernel.org Cc: rafael@kernel.org, Arjan van de Ven Subject: [PATCH 3/4] intel_idle: add VM guest (non)handling to model_specific_fixups Date: Mon, 17 Jul 2023 15:18:55 +0000 Message-ID: <20230717151856.2529029-3-arjan@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717151856.2529029-1-arjan@linux.intel.com> References: <20230717151856.2529029-1-arjan@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Arjan van de Ven The model specific fixups don't make sense in a VM guest; all the MSR accesses at best will be fiction, and at worse cause logspam Signed-off-by: Arjan van de Ven --- drivers/idle/intel_idle.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index f3eba9b147d2..4dd8081d2406 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1957,6 +1957,10 @@ static bool should_verify_mwait(struct cpuidle_state *state) static void __init model_specific_fixups(void) { + /* when running in a hypervisor, none of these fixups will work */ + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) + return; + switch (boot_cpu_data.x86_model) { case INTEL_FAM6_IVYBRIDGE_X: ivt_idle_state_table_update(); From patchwork Mon Jul 17 15:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjan van de Ven X-Patchwork-Id: 704279 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 9761CC04A6A for ; Mon, 17 Jul 2023 15:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbjGQPUh (ORCPT ); Mon, 17 Jul 2023 11:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjGQPUO (ORCPT ); Mon, 17 Jul 2023 11:20:14 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D9C010C8 for ; Mon, 17 Jul 2023 08:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689607183; x=1721143183; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bUOTX5dw2G75UiT+4rr7b+HzDjYK2xl9bzYO8LnFtu0=; b=KbY/BcbEBRDnH12wVFrDdE2lQYYzydTnmMxcXRgrczc9kIaa9u6H/SXK K/dwHiuQH5gSok45BkSwFS5HTfVWYDyF/tnMQeA4gn85GsNBJl1CGl4hU QQc63eaGokzYTgMySqkd0ptK7iinz8Zj9g6A5ezGP+KmrIv+aOlOraXZa BM//XZ5fVgZVbO0bFA6iS6ZrA0Z87DPJ0veCK+dPnqNGMlyj/dnvGZLFt sskr2F74xGRL6srcYf4csqX+M5y3sP20GpGGXSLwnbmKUgYE6EA5J1vad zvsuvPJvd77YKwumFBMF8NFWlS9rqCpe6h8sNyoy3hGneB3L2KiEA4r1/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="429716552" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="429716552" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10774"; a="726581596" X-IronPort-AV: E=Sophos;i="6.01,211,1684825200"; d="scan'208";a="726581596" Received: from arjan-box.jf.intel.com ([10.54.74.119]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2023 08:19:12 -0700 From: arjan@linux.intel.com To: linux-pm@vger.kernel.org Cc: rafael@kernel.org, Arjan van de Ven Subject: [PATCH 4/4] intel_idle: remove intel_idle_hlt_irq_on Date: Mon, 17 Jul 2023 15:18:56 +0000 Message-ID: <20230717151856.2529029-4-arjan@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717151856.2529029-1-arjan@linux.intel.com> References: <20230717151856.2529029-1-arjan@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Arjan van de Ven PeterZ pointed out that the whole function is redundant as for hlt, it's always "irq on" Signed-off-by: Arjan van de Ven --- drivers/idle/intel_idle.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 4dd8081d2406..038322c23e34 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -224,17 +224,6 @@ static __cpuidle int intel_idle_hlt(struct cpuidle_device *dev, return __intel_idle_hlt(dev, drv, index); } -static __cpuidle int intel_idle_hlt_irq_on(struct cpuidle_device *dev, - struct cpuidle_driver *drv, int index) -{ - int ret; - - raw_local_irq_enable(); - ret = __intel_idle_hlt(dev, drv, index); - raw_local_irq_disable(); - - return ret; -} /** * intel_idle_s2idle - Ask the processor to enter the given idle state. @@ -1897,15 +1886,8 @@ static bool __init intel_idle_verify_cstate(unsigned int mwait_hint) static void state_update_enter_method(struct cpuidle_state *state, int cstate) { - if (state->enter == intel_idle_hlt) { - if (force_irq_on) { - pr_info("forced intel_idle_irq for state %d\n", cstate); - state->enter = intel_idle_hlt_irq_on; - } + if (state->enter == intel_idle_hlt) return; - } - if (state->enter == intel_idle_hlt_irq_on) - return; /* no update scenarios */ if (state->flags & CPUIDLE_FLAG_INIT_XSTATE) { /* @@ -1949,8 +1931,6 @@ static bool should_verify_mwait(struct cpuidle_state *state) { if (state->enter == intel_idle_hlt) return false; - if (state->enter == intel_idle_hlt_irq_on) - return false; return true; }