From patchwork Mon Nov 25 13:20:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patryk Wlazlyn X-Patchwork-Id: 13884900 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF3221B393E; Mon, 25 Nov 2024 13:21:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732540876; cv=none; b=uf7KC2LtA21BmObzHeKbDCQJpYIZIkRpEBSzNW+xAXRMovfw2rwwxiP2qN+LHHOQDVk9zNo9mB4rIgsOKWJTA1iyyeAdcS1YLWOxyXOQ9QwvmatXNf04Ex/p0B2QEm5ruJlApMCZQ/wgMTGEuDmHwtl3e30gE6DEgTS6XfJMg6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732540876; c=relaxed/simple; bh=VF9mEYDyF8AVV2/MlyLqhDnzQPABSbqh+jPmpb/z4GA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8h4T9Y+3rXr10wrB10iAasfm+ef6AP/+Aggmemue6kLJKyF7r7SB4hdHhPM4/FEQLaRvZJrS/MoIO3MbPFAej3i2PbreMvtHMXC8Z/L2JAVrbEsLO3avXpZqBRlRpHlkb3ny/N0YnlJGCL6RcVSG4deFdy/1jZqQw1OyiDAGZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=cGDYSa7f; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cGDYSa7f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732540875; x=1764076875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VF9mEYDyF8AVV2/MlyLqhDnzQPABSbqh+jPmpb/z4GA=; b=cGDYSa7f2oPqofrr8/Om0efVj2cVqmABSYveCIWtJbJ+Q1c0FxxiWzcL PZP7wZ+2Hshn7CDbfCbUakYqTwe0kXez6SfB2DFHIjHWANCvpEZD5Mg3f KQKG99nxCSKPEz6Jc8W+n7QJLgPqID4OB6pT1/c5i4Q8dk8m9n6lTE52S bFxMS0+KDd9DJv92JLvb3Vp9pyTRYQkbwLG6H94lmK3JNRx+Cb2Ul0Lk9 m4rDjdrlM6R4CFNkUM3aagCsR0BAB7+L1i0Dc3UitC2ywxUdrE6fIj8uS sxuBXQtsICv3W2/FJwj7eynAfXsYoKiMJ4JiYd5/zRzReRuPPe+N3YciT w==; X-CSE-ConnectionGUID: J9rbj7tZRlOCw8EDpVnAhg== X-CSE-MsgGUID: DdMXJPivRCuwD2Skdq2tTQ== X-IronPort-AV: E=McAfee;i="6700,10204,11267"; a="43145502" X-IronPort-AV: E=Sophos;i="6.12,182,1728975600"; d="scan'208";a="43145502" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2024 05:21:15 -0800 X-CSE-ConnectionGUID: aW1aLRTmT+iMba12+wKY7g== X-CSE-MsgGUID: +RaUdqgcSEWsApBy7VKLQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,182,1728975600"; d="scan'208";a="91161778" Received: from bergbenj-mobl1.ger.corp.intel.com (HELO pwlazlyn-mobl1.intel.com) ([10.245.245.34]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2024 05:21:10 -0800 From: Patryk Wlazlyn 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 Message-ID: <20241125132029.7241-8-patryk.wlazlyn@linux.intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241125132029.7241-1-patryk.wlazlyn@linux.intel.com> References: <20241125132029.7241-1-patryk.wlazlyn@linux.intel.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Patryk Wlazlyn --- 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,