public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	rafael.j.wysocki@intel.com, len.brown@intel.com,
	artem.bityutskiy@linux.intel.com, dave.hansen@linux.intel.com,
	patryk.wlazlyn@linux.intel.com, peterz@infradead.org,
	tglx@linutronix.de, gautham.shenoy@amd.com
Subject: [RFC PATCH v4 7/8] acpi_idle: Add FFH cstate handling
Date: Mon, 25 Nov 2024 14:20:27 +0100	[thread overview]
Message-ID: <20241125132029.7241-8-patryk.wlazlyn@linux.intel.com> (raw)
In-Reply-To: <20241125132029.7241-1-patryk.wlazlyn@linux.intel.com>

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kernel/acpi/cstate.c      | 9 +++++++++
 drivers/acpi/processor_idle.c      | 2 ++
 include/acpi/processor.h           | 5 +++++
 4 files changed, 17 insertions(+)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index ea33439a5d00..1da5e08de257 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -236,6 +236,7 @@
 #define X86_FEATURE_PVUNLOCK		( 8*32+20) /* PV unlock function */
 #define X86_FEATURE_VCPUPREEMPT		( 8*32+21) /* PV vcpu_is_preempted function */
 #define X86_FEATURE_TDX_GUEST		( 8*32+22) /* "tdx_guest" Intel Trust Domain Extensions Guest */
+#define X86_FEATURE_NO_MWAIT_OFFLINE    ( 8*32+23) /* Don't use MWAIT states for offlined CPUs */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
 #define X86_FEATURE_FSGSBASE		( 9*32+ 0) /* "fsgsbase" RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index f3ffd0a3a012..c80a3e6dba5f 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -204,6 +204,15 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
 }
 EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
 
+void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx)
+{
+	unsigned int cpu = smp_processor_id();
+	struct cstate_entry *percpu_entry;
+
+	percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
+	mwait_play_dead_with_hint(percpu_entry->states[cx->index].eax);
+}
+
 void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
 {
 	unsigned int cpu = smp_processor_id();
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 698897b29de2..586cc7d1d8aa 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -590,6 +590,8 @@ static void acpi_idle_play_dead(struct cpuidle_device *dev, int index)
 			raw_safe_halt();
 		else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
 			io_idle(cx->address);
+		} else if (cx->entry_method == ACPI_CSTATE_FFH) {
+			acpi_processor_ffh_play_dead(cx);
 		} else
 			return;
 	}
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index a17e97e634a6..63a37e72b721 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -280,6 +280,7 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
 				    struct acpi_processor_cx *cx,
 				    struct acpi_power_register *reg);
 void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
+void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx);
 #else
 static inline void acpi_processor_power_init_bm_check(struct
 						      acpi_processor_flags
@@ -300,6 +301,10 @@ static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
 {
 	return;
 }
+static inline void acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx)
+{
+	return;
+}
 #endif
 
 static inline int call_on_cpu(int cpu, long (*fn)(void *), void *arg,
-- 
2.47.0


  parent reply	other threads:[~2024-11-25 13:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 13:20 [RFC PATCH v4 0/8] SRF: Fix offline CPU preventing pc6 entry Patryk Wlazlyn
2024-11-25 13:20 ` [RFC PATCH v4 1/8] cpuidle: Do not return from cpuidle_play_dead() on callback failures Patryk Wlazlyn
2024-11-25 13:26   ` Rafael J. Wysocki
2024-11-25 14:36     ` Patryk Wlazlyn
2024-11-25 13:20 ` [RFC PATCH v4 2/8] cpuidle: Change :enter_dead() driver callback return type to void Patryk Wlazlyn
2024-11-25 13:20 ` [RFC PATCH v4 3/8] ACPI: processor_idle: Use acpi_idle_play_dead() for all C-states Patryk Wlazlyn
2024-11-25 13:24   ` Rafael J. Wysocki
2024-11-25 14:39     ` Patryk Wlazlyn
2024-11-25 14:36   ` Gautham R. Shenoy
2024-11-25 13:20 ` [RFC PATCH v4 4/8] x86/smp: Allow calling mwait_play_dead with arbitrary hint Patryk Wlazlyn
2024-11-25 14:39   ` Rafael J. Wysocki
2024-11-26 11:36     ` Patryk Wlazlyn
2024-11-26 11:45       ` Rafael J. Wysocki
2024-11-25 13:20 ` [RFC PATCH v4 5/8] x86/smp native_play_dead: Prefer cpuidle_play_dead() over mwait_play_dead() Patryk Wlazlyn
2024-11-25 13:45   ` Peter Zijlstra
2024-11-25 13:56   ` Rafael J. Wysocki
2024-11-25 14:43     ` Patryk Wlazlyn
2024-11-25 14:48       ` Rafael J. Wysocki
2024-11-26 11:56         ` Patryk Wlazlyn
2024-11-26 12:04           ` Rafael J. Wysocki
2024-11-26 13:10             ` Patryk Wlazlyn
2024-11-26 13:38               ` Rafael J. Wysocki
2024-11-25 13:20 ` [RFC PATCH v4 6/8] intel_idle: Provide enter_dead() handler for SRF Patryk Wlazlyn
2024-11-25 13:44   ` Rafael J. Wysocki
2024-11-25 14:48     ` Patryk Wlazlyn
2024-11-25 14:50       ` Rafael J. Wysocki
2024-11-25 13:53   ` Peter Zijlstra
2024-11-25 13:58     ` Rafael J. Wysocki
2024-11-25 14:12       ` Peter Zijlstra
2024-11-25 14:19         ` Rafael J. Wysocki
2024-11-25 13:20 ` Patryk Wlazlyn [this message]
2024-11-25 13:41   ` [RFC PATCH v4 7/8] acpi_idle: Add FFH cstate handling Rafael J. Wysocki
2024-11-25 14:00     ` Rafael J. Wysocki
2024-11-25 15:14   ` Gautham R. Shenoy
2024-11-26 12:03     ` Patryk Wlazlyn
2024-11-25 13:20 ` [RFC PATCH v4 8/8] acpi_idle: Disallow play_dead with FFH cstate on AMD platforms Patryk Wlazlyn
2024-11-25 13:46   ` Rafael J. Wysocki
2024-11-25 13:54   ` Peter Zijlstra
2024-11-25 14:56     ` Patryk Wlazlyn
2024-11-25 15:17       ` Gautham R. Shenoy
2024-11-25 15:15   ` Gautham R. Shenoy
2024-11-26 12:05     ` Patryk Wlazlyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241125132029.7241-8-patryk.wlazlyn@linux.intel.com \
    --to=patryk.wlazlyn@linux.intel.com \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=gautham.shenoy@amd.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox