linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported
@ 2022-03-16 12:35 Rafael J. Wysocki
  2022-03-16 12:37 ` [PATCH v1 1/2] Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag" Rafael J. Wysocki
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-03-16 12:35 UTC (permalink / raw)
  To: Linux ACPI
  Cc: Linux PM, LKML, Mika Westerberg, Hans de Goede, Mario Limonciello

Hi All,

The following two patches revert a commit that caused the handling of
platform-level _OSC to fail in some legitimate cases and address the
CPPC handling breakage that was the motivation for the reverted commit.

Please refer to the patch changelogs for details.

Thanks!




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/2] Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag"
  2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
@ 2022-03-16 12:37 ` Rafael J. Wysocki
  2022-03-16 12:39 ` [PATCH v1 2/2] ACPI: bus: Avoid using CPPC if not supported by firmware Rafael J. Wysocki
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-03-16 12:37 UTC (permalink / raw)
  To: Linux ACPI
  Cc: Linux PM, LKML, Mika Westerberg, Hans de Goede, Mario Limonciello

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Revert commit 159d8c274fd9 ("ACPI: Pass the same capabilities to the
_OSC regardless of the query flag") which caused legitimate usage
scenarios (when the platform firmware does not want the OS to control
certain platform features controlled by the system bus scope _OSC) to
break and was misguided by some misleading language in the _OSC
definition in the ACPI specification (in particular, Section 6.2.11.1.3
"Sequence of _OSC Calls" that contradicts other perts of the _OSC
definition).

Link: https://lore.kernel.org/linux-acpi/CAJZ5v0iStA0JmO0H3z+VgQsVuQONVjKPpw0F5HKfiq=Gb6B5yw@mail.gmail.com
Reported-by: Mario Limonciello <Mario.Limonciello@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/bus.c |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

Index: linux-pm/drivers/acpi/bus.c
===================================================================
--- linux-pm.orig/drivers/acpi/bus.c
+++ linux-pm/drivers/acpi/bus.c
@@ -333,21 +333,32 @@ static void acpi_bus_osc_negotiate_platf
 	if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
 		return;
 
-	kfree(context.ret.pointer);
+	capbuf_ret = context.ret.pointer;
+	if (context.ret.length <= OSC_SUPPORT_DWORD) {
+		kfree(context.ret.pointer);
+		return;
+	}
 
-	/* Now run _OSC again with query flag clear */
+	/*
+	 * Now run _OSC again with query flag clear and with the caps
+	 * supported by both the OS and the platform.
+	 */
 	capbuf[OSC_QUERY_DWORD] = 0;
+	capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
+	kfree(context.ret.pointer);
 
 	if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
 		return;
 
 	capbuf_ret = context.ret.pointer;
-	osc_sb_apei_support_acked =
-		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
-	osc_pc_lpi_support_confirmed =
-		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
-	osc_sb_native_usb4_support_confirmed =
-		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
+	if (context.ret.length > OSC_SUPPORT_DWORD) {
+		osc_sb_apei_support_acked =
+			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
+		osc_pc_lpi_support_confirmed =
+			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
+		osc_sb_native_usb4_support_confirmed =
+			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
+	}
 
 	kfree(context.ret.pointer);
 }




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 2/2] ACPI: bus: Avoid using CPPC if not supported by firmware
  2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
  2022-03-16 12:37 ` [PATCH v1 1/2] Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag" Rafael J. Wysocki
@ 2022-03-16 12:39 ` Rafael J. Wysocki
  2022-03-16 15:44 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Limonciello, Mario
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-03-16 12:39 UTC (permalink / raw)
  To: Linux ACPI
  Cc: Linux PM, LKML, Mika Westerberg, Hans de Goede, Mario Limonciello

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

If the platform firmware indicates that it does not support CPPC by
clearing the OSC_SB_CPC_SUPPORT and OSC_SB_CPCV2_SUPPORT bits in the
platform _OSC capabilities mask, avoid attempting to evaluate _CPC
which may fail in that case.

Because the OSC_SB_CPC_SUPPORT and OSC_SB_CPCV2_SUPPORT bits are only
added to the supported platform capabilities mask on x86, when
X86_FEATURE_HWP is supported, allow _CPC to be evaluated regardless
in the other cases.

Link: https://lore.kernel.org/linux-acpi/CAJZ5v0i=ecAksq0TV+iLVObm-=fUfdqPABzzkgm9K6KxO1ZCcg@mail.gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/bus.c       |    8 ++++++++
 drivers/acpi/cppc_acpi.c |    3 +++
 include/linux/acpi.h     |    1 +
 3 files changed, 12 insertions(+)

Index: linux-pm/drivers/acpi/bus.c
===================================================================
--- linux-pm.orig/drivers/acpi/bus.c
+++ linux-pm/drivers/acpi/bus.c
@@ -284,6 +284,8 @@ EXPORT_SYMBOL_GPL(osc_pc_lpi_support_con
 bool osc_sb_native_usb4_support_confirmed;
 EXPORT_SYMBOL_GPL(osc_sb_native_usb4_support_confirmed);
 
+bool osc_sb_cppc_not_supported;
+
 static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
 static void acpi_bus_osc_negotiate_platform_control(void)
 {
@@ -339,6 +341,12 @@ static void acpi_bus_osc_negotiate_platf
 		return;
 	}
 
+#ifdef CONFIG_X86
+	if (boot_cpu_has(X86_FEATURE_HWP))
+		osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD] &
+				(OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT));
+#endif
+
 	/*
 	 * Now run _OSC again with query flag clear and with the caps
 	 * supported by both the OS and the platform.
Index: linux-pm/drivers/acpi/cppc_acpi.c
===================================================================
--- linux-pm.orig/drivers/acpi/cppc_acpi.c
+++ linux-pm/drivers/acpi/cppc_acpi.c
@@ -656,6 +656,9 @@ int acpi_cppc_processor_probe(struct acp
 	acpi_status status;
 	int ret = -EFAULT;
 
+	if (osc_sb_cppc_not_supported)
+		return -ENODEV;
+
 	/* Parse the ACPI _CPC table for this CPU. */
 	status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
 			ACPI_TYPE_PACKAGE);
Index: linux-pm/include/linux/acpi.h
===================================================================
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -580,6 +580,7 @@ acpi_status acpi_run_osc(acpi_handle han
 extern bool osc_sb_apei_support_acked;
 extern bool osc_pc_lpi_support_confirmed;
 extern bool osc_sb_native_usb4_support_confirmed;
+extern bool osc_sb_cppc_not_supported;
 
 /* USB4 Capabilities */
 #define OSC_USB_USB3_TUNNELING			0x00000001




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported
  2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
  2022-03-16 12:37 ` [PATCH v1 1/2] Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag" Rafael J. Wysocki
  2022-03-16 12:39 ` [PATCH v1 2/2] ACPI: bus: Avoid using CPPC if not supported by firmware Rafael J. Wysocki
@ 2022-03-16 15:44 ` Limonciello, Mario
  2022-03-17  8:08 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supportedg Huang Rui
  2022-03-17 11:43 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Mika Westerberg
  4 siblings, 0 replies; 6+ messages in thread
From: Limonciello, Mario @ 2022-03-16 15:44 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux ACPI
  Cc: Linux PM, LKML, Mika Westerberg, Hans de Goede, Huang, Ray

[Public]

> -----Original Message-----
> From: Rafael J. Wysocki <rjw@rjwysocki.net>
> Sent: Wednesday, March 16, 2022 07:35
> To: Linux ACPI <linux-acpi@vger.kernel.org>
> Cc: Linux PM <linux-pm@vger.kernel.org>; LKML <linux-
> kernel@vger.kernel.org>; Mika Westerberg
> <mika.westerberg@linux.intel.com>; Hans de Goede
> <hdegoede@redhat.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>
> Subject: [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and
> avoid CPPC is not supported
> 
> Hi All,
> 
> The following two patches revert a commit that caused the handling of
> platform-level _OSC to fail in some legitimate cases and address the
> CPPC handling breakage that was the motivation for the reverted commit.
> 
> Please refer to the patch changelogs for details.
> 
> Thanks!
> 
> 

Thanks!  For both patches:
Tested-by: Mario Limonciello <mario.limonciello@amd.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supportedg
  2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2022-03-16 15:44 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Limonciello, Mario
@ 2022-03-17  8:08 ` Huang Rui
  2022-03-17 11:43 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Mika Westerberg
  4 siblings, 0 replies; 6+ messages in thread
From: Huang Rui @ 2022-03-17  8:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux ACPI, Linux PM, LKML, Mika Westerberg, Hans de Goede,
	Mario Limonciello

On Wed, Mar 16, 2022 at 01:35:23PM +0100, Rafael J. Wysocki wrote:
> Hi All,
> 
> The following two patches revert a commit that caused the handling of
> platform-level _OSC to fail in some legitimate cases and address the
> CPPC handling breakage that was the motivation for the reverted commit.
> 
> Please refer to the patch changelogs for details.
> 

Series are Acked-by: Huang Rui <ray.huang@amd.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported
  2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2022-03-17  8:08 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supportedg Huang Rui
@ 2022-03-17 11:43 ` Mika Westerberg
  4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2022-03-17 11:43 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Linux ACPI, Linux PM, LKML, Hans de Goede, Mario Limonciello

Hi Rafael,

On Wed, Mar 16, 2022 at 01:35:23PM +0100, Rafael J. Wysocki wrote:
> Hi All,
> 
> The following two patches revert a commit that caused the handling of
> platform-level _OSC to fail in some legitimate cases and address the
> CPPC handling breakage that was the motivation for the reverted commit.
> 
> Please refer to the patch changelogs for details.

For both,

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-17 11:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 12:35 [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Rafael J. Wysocki
2022-03-16 12:37 ` [PATCH v1 1/2] Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag" Rafael J. Wysocki
2022-03-16 12:39 ` [PATCH v1 2/2] ACPI: bus: Avoid using CPPC if not supported by firmware Rafael J. Wysocki
2022-03-16 15:44 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Limonciello, Mario
2022-03-17  8:08 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supportedg Huang Rui
2022-03-17 11:43 ` [PATCH v1 0/2] ACPI: bus: Fix platform-level _OSC handling and avoid CPPC is not supported Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).