ACPI: bus: For platform OSC negotiate capabilities
PATCH v6 1/1 ACPI: bus: For platform OSC negotiate capabilities
According to the ACPI 6.4 spec:
It is strongly recommended that the OS evaluate _OSC with the Query Support Flag set until _OSC returns the Capabilities Masked bit clear, to negotiate the set of features to be granted to the OS for native support; a platform may require a specific combination of features to be supported natively by an OS before granting native control of a given feature. After negotiation with the query flag set, the OS should evaluate without it so that any negotiated values can be made effective to hardware.
Currently the code sends the exact same values in both executions of the _OSC and this leads to some problems on some AMD platforms in certain configurations.
The following notable capabilities are set by OSPM when query is enabled:
* OSC_SB_PR3_SUPPORT
* OSC_SB_PCLPI_SUPPORT
* OSC_SB_NATIVE_USB4_SUPPORT
The first call to the platform OSC returns back a masked capabilities error because the firmware did not acknowledge OSC_SB_PCLPI_SUPPORT but it acknolwedged the others.
The second call to the platform _OSC without the query flag set then fails because the OSPM still sent the exact same values. This leads to not acknowledging OSC_SB_NATIVE_USB4_SUPPORT and later USB4 PCIe tunnels can't be authorized.
This problem was first introduced by commit 159d8c274fd9 ("ACPI: Pass the same capabilities to the _OSC regardless of the query flag") which subtly adjusted the behavior from 719e1f5 ("ACPI: Execute platform _OSC also with query bit clear").
The _OSC was called exactly 2 times:
* Once to query and request from firmware
* Once to commit to firmware without query
To fix this problem, continue to call the _OSC until the firmware has indicated that capabilities are no longer masked.
Furthermore, to avoid the problem that commit 159d8c274fd9 ("ACPI: Pass the same capabilities to the _OSC regardless of the query flag") introduced, explicitly mark support for CPC and CPPCv2 even if they were masked by the series of query calls due to table loading order on some systems.
changes from v5->v6
* drop mika's tag due to changes
* negotiate until support result is empty
--- drivers/acpi/bus.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/acpi/bus.c +20 -5
@@ -330,14 +330,29 @@ static void acpi_bus_osc_negotiate_platform_control(void)if (ACPI_FAILURE (acpi_get_handle (NULL ,"\\_SB" , &handle)))return ; -if (ACPI_FAILURE (acpi_run_osc (handle, &context))) -return ; -kfree (context.ret.pointer); +do { +if (ACPI_FAILURE (acpi_run_osc (handle, &context))) +return ; + capbuf_ret = context.ret.pointer; +if (capbuf[OSC_SUPPORT_DWORD ] == capbuf_ret[OSC_SUPPORT_DWORD ]) + capbuf[OSC_QUERY_DWORD ] =0 ; + capbuf[OSC_SUPPORT_DWORD ] = capbuf_ret[OSC_SUPPORT_DWORD ]; +kfree (context.ret.pointer); + }while (capbuf[OSC_QUERY_DWORD ] && capbuf[OSC_SUPPORT_DWORD ]); -/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating +* support for CPPC even if it was masked. +*/ +#ifdef CONFIG_X86 +if (boot_cpu_has (X86_FEATURE_HWP )) { + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; + } +#endif +/* Now run _OSC again with query flag clear */ if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ;
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerQuoted 66 lines · Mario Limonciello
According to the ACPI 6.4 spec:
It is strongly recommended that the OS evaluate_OSCwith the Query Support Flag set until_OSCreturns the Capabilities Masked bit clear, to negotiate the set of features to be granted to the OS for native support; a platform may require a specific combination of features to be supported natively by an OS before granting native control of a given feature. After negotiation with the query flag set, the OS should evaluate without it so that any negotiated values can be made effective to hardware.Currently the code sends the exact same values in both executions of the
_OSCand this leads to some problems on some AMD platforms in certain configurations.The following notable capabilities are set by OSPM when query is enabled:
*OSC_SB_PR3_SUPPORT
*OSC_SB_PCLPI_SUPPORT
*OSC_SB_NATIVE_USB4_SUPPORTThe first call to the platform OSC returns back a masked capabilities error because the firmware did not acknowledge
OSC_SB_PCLPI_SUPPORTbut it acknolwedged the others.The second call to the platform
_OSCwithout the query flag set then fails because the OSPM still sent the exact same values. This leads to not acknowledgingOSC_SB_NATIVE_USB4_SUPPORTand later USB4 PCIe tunnels can't be authorized.This problem was first introduced by commit
159d8c274fd9("ACPI: Pass the same capabilities to the_OSCregardless of the query flag") which subtly adjusted the behavior from 719e1f5 ("ACPI: Execute platform_OSCalso with query bit clear").The
_OSCwas called exactly 2 times:
* Once to query and request from firmware
* Once to commit to firmware without queryTo fix this problem, continue to call the
_OSCuntil the firmware has indicated that capabilities are no longer masked.Furthermore, to avoid the problem that commit
159d8c274fd9("ACPI: Pass the same capabilities to the_OSCregardless of the query flag") introduced, explicitly mark support for CPC and CPPCv2 even if they were masked by the series of query calls due to table loading order on some systems.Fixes 159d8c274fd9 ("ACPI: Pass the same capabilities to the _OSC regardless of the query flag")Signed-off-by Mario Limonciello <[email protected]>changes from
v5->v6
* drop mika's tag due to changes
* negotiate until support result is empty--- drivers/acpi/bus.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)drivers/acpi/bus.c +0
-1@@ -330,14 +330,29 @@ static void acpi_bus_osc_negotiate_platform_control(void)if (ACPI_FAILURE (acpi_get_handle (NULL ,"\\_SB" , &handle)))return ; -if (ACPI_FAILURE (acpi_run_osc (handle, &context)))
drivers/acpi/bus.c static void acpi_bus_osc_negotiate_platform_control(void) · line 340
Quoted 10 lines
drivers/acpi/bus.c +7
-2-return ; -kfree (context.ret.pointer); + do { + if (ACPI_FAILURE(acpi_run_osc(handle, &context))) + return; + capbuf_ret = context.ret.pointer; + if (capbuf[OSC_SUPPORT_DWORD] == capbuf_ret[OSC_SUPPORT_DWORD]) + capbuf[OSC_QUERY_DWORD] = 0; + capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
I would do
if (capbuf[OSC_SUPPORT_DWORD] == capbuf_ret[OSC_SUPPORT_DWORD])
capbuf[OSC_QUERY_DWORD] = 0;
else
capbuf[OSC_SUPPORT_DWORD] &= capbuf_ret[OSC_SUPPORT_DWORD];so that the loop terminates even if the firmware does strange things and then it would only be necessary to check capbuf[OSC_QUERY_DWORD] in the loop termination condition.
Would that work?
drivers/acpi/bus.c static void acpi_bus_osc_negotiate_platform_control(void) · line 346
Quoted 8 lines
drivers/acpi/bus.c +5
-2+kfree (context.ret.pointer); + }while (capbuf[OSC_QUERY_DWORD ] && capbuf[OSC_SUPPORT_DWORD ]); -/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating +* support for CPPC even if it was masked.
What exactly do you mean by "BIOS dynamically loading tables"?
Quoted 15 lines
drivers/acpi/bus.c +8
-1+*/ +#ifdef CONFIG_X86 +if (boot_cpu_has (X86_FEATURE_HWP )) { + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; + } +#endif +/* Now run _OSC again with query flag clear */ if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; --2.34.1
[Public]
Quoted 7 lines
I would do
if (capbuf[OSC_SUPPORT_DWORD] == capbuf_ret[OSC_SUPPORT_DWORD])
capbuf[OSC_QUERY_DWORD] = 0; else capbuf[OSC_SUPPORT_DWORD] &= capbuf_ret[OSC_SUPPORT_DWORD];
Quoted 6 lines
so that the loop terminates even if the firmware does strange things and then it would only be necessary to check capbuf[OSC_QUERY_DWORD] in the loop termination condition.
Would that work?
I think it will. I'll try it and send up a v7 if so.
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kfree(context.ret.pointer); + } while (capbuf[OSC_QUERY_DWORD] &&capbuf[OSC_SUPPORT_DWORD]);
drivers/acpi/bus.c static void acpi_bus_osc_negotiate_platform_control(void) · line 346
Quoted 6 lines
drivers/acpi/bus.c +3
-2-/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating +* support for CPPC even if it was masked. What exactly do you mean by "BIOS dynamically loading tables"?
As mentioned in commit 159d8c274fd9:
On certain systems the BIOS loads SSDT tables dynamically based on the capabilities the OS claims to support. However, on these systems the _OSC actually clears some of the bits (under certain conditions) so what happens is that now when we call the _OSC twice the second time we pass the cleared values and that results errors like below to appear on the system log:
ACPI BIOS Error (bug): Could not resolve symbol [\_PR.PR00._CPC], AE_NOT_FOUND (20210105/psargs-330) ACPI Error: Aborting method \_PR.PR01._CPC due to previous error (AE_NOT_FOUND) (20210105/psparse-529)
This block is to avoid regressing that again by forcing it on these systems.
Quoted 16 lines
Quoted 16 lines
drivers/acpi/bus.c +8
-1+*/ +#ifdef CONFIG_X86 +if (boot_cpu_has (X86_FEATURE_HWP )) { + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; + } +#endif +/* Now run _OSC again with query flag clear */ if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; --2.34.1
Rafael J. Wysocki
maintainerQuoted 40 lines · Mario
[Public]
Quoted 7 lines
I would do
if (capbuf[OSC_SUPPORT_DWORD] == capbuf_ret[OSC_SUPPORT_DWORD])
capbuf[OSC_QUERY_DWORD] = 0; else capbuf[OSC_SUPPORT_DWORD] &= capbuf_ret[OSC_SUPPORT_DWORD];Quoted 6 lines
so that the loop terminates even if the firmware does strange things and then it would only be necessary to check capbuf[OSC_QUERY_DWORD] in the loop termination condition.
Would that work?
I think it will. I'll try it and send up a v7 if so.
Quoted 11 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kfree(context.ret.pointer); + } while (capbuf[OSC_QUERY_DWORD] &&capbuf[OSC_SUPPORT_DWORD]);
drivers/acpi/bus.c static void acpi_bus_osc_negotiate_platform_control(void) · line 346
Quoted 6 lines
drivers/acpi/bus.c +3
-2-/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating +* support for CPPC even if it was masked. What exactly do you mean by "BIOS dynamically loading tables"?
As mentioned in commit
159d8c274fd9:On certain systems the BIOS loads SSDT tables dynamically based on the capabilities the OS claims to support. However, on these systems the
_OSCactually clears some of the bits (under certain conditions) so what happens is that now when we call the_OSCtwice the second time we pass the cleared values and that results errors like below to appear on the system log:
Quoted 4 lines
ACPI BIOS Error (bug): Could not resolve symbol [\_PR.PR00._CPC],
AE_NOT_FOUND(20210105/psargs-330) ACPI Error: Aborting method \_PR.PR01._CPC due to previous error (AE_NOT_FOUND) (20210105/psparse-529)This block is to avoid regressing that again by forcing it on these systems.
Well, this means that the code before and after the patch is not actually following the spec.
First off, as mentioned in the changelog of commit 159d8c274fd9 (in the part that has not been quoted above), the OS is required to pass the same set of capabilities every time _OSC is evaluated. This doesn't happen after the change.
Second, acpi_bus_osc_negotiate_platform_control() should take the capabilities mask returned by the platform which it doesn't do without the patch.
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling acpi_run_osc() with the query flag set for multiple times.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/acpi/bus.c +8
-1+*/ +#ifdef CONFIG_X86 +if (boot_cpu_has (X86_FEATURE_HWP )) { + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; + } +#endif +/* Now run _OSC again with query flag clear */ if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; --2.34.1
[AMD Official Use Only]
Quoted 69 lines
-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Monday, March 14, 2022 15:01
To: Limonciello, Mario <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>; Rafael J . Wysocki <[email protected]>; ACPI Devel Maling List <[email protected]>; Mika Westerberg <[email protected]>; Hou, Xiaomeng (Matthew) <[email protected]>; Liu, Aaron <[email protected]>; Huang, Ray <[email protected]>; Hans de Goede <[email protected]>
Subject: Re: [PATCH v6] ACPI: bus: For platform OSC negotiate capabilitiesQuoted 6 lines · Mario
[Public]
Quoted 3 lines
I would do
if (capbuf[OSC_SUPPORT_DWORD] ==
capbuf_ret[OSC_SUPPORT_DWORD])
Quoted 3 lines
Quoted 3 lines
capbuf[OSC_QUERY_DWORD] = 0;else
capbuf[OSC_SUPPORT_DWORD] &=capbuf_ret[OSC_SUPPORT_DWORD];
Quoted 3 lines
Quoted 3 lines
so that the loop terminates even if the firmware does strange things and then it would only be necessary to check
capbuf[OSC_QUERY_DWORD]
Quoted 15 lines
Quoted 4 lines
in the loop termination condition.
Would that work?
I think it will. I'll try it and send up a v7 if so.
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kfree(context.ret.pointer); + } while (capbuf[OSC_QUERY_DWORD] &&capbuf[OSC_SUPPORT_DWORD]);
Quoted 5 lines
drivers/acpi/bus.c +2
-2-/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
+ * support for CPPC even if it was masked.
What exactly do you mean by "BIOS dynamically loading tables"?
As mentioned in commit
159d8c274fd9:On certain systems the BIOS loads SSDT tables dynamically based on the capabilities the OS claims to support. However, on these systems the
_OSCactually clears some of the bits (under certain conditions) so what happens is that now when we call the_OSCtwice the second time wepass
Quoted 4 lines
the cleared values and that results errors like below to appear on the system log:
ACPI BIOS Error (bug): Could not resolve symbol [\_PR.PR00._CPC],
AE_NOT_FOUND(20210105/psargs-330)Quoted 1 line
ACPI Error: Aborting method \_PR.PR01._CPC due to previous error
(
AE_NOT_FOUND) (20210105/psparse-529)Quoted 2 lines
This block is to avoid regressing that again by forcing it on these systems.
Well, this means that the code before and after the patch is not actually following the spec.
Quoted 8 lines
First off, as mentioned in the changelog of commit
159d8c274fd9(in the part that has not been quoted above), the OS is required to pass the same set of capabilities every time_OSCis evaluated. This doesn't happen after the change.Second,
acpi_bus_osc_negotiate_platform_control()should take the capabilities mask returned by the platform which it doesn't do without the patch.
Right on both points.
Quoted 4 lines
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling
acpi_run_osc()with the query flag set for multiple times.
I think just taking the results will re-introduce the CPC bug though won't it? So how to avoid it but also to take the results?
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
drivers/acpi/bus.c static void acpi_bus_osc_negotiate_platform_control(void)
Quoted 8 lines
drivers/acpi/bus.c +5
-0+*/ +#ifdef CONFIG_X86 +if (boot_cpu_has (X86_FEATURE_HWP )) { + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD] |=
OSC_SB_CPCV2_SUPPORT;Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/acpi/bus.c +3
-1+ } +#endif +/* Now run _OSC again with query flag clear */ if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; --2.34.1
Rafael J. Wysocki
maintainerQuoted 86 lines · Mario
[AMD Official Use Only]
Quoted 69 lines
-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Monday, March 14, 2022 15:01
To: Limonciello, Mario <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>; Rafael J . Wysocki <[email protected]>; ACPI Devel Maling List <[email protected]>; Mika Westerberg <[email protected]>; Hou, Xiaomeng (Matthew) <[email protected]>; Liu, Aaron <[email protected]>; Huang, Ray <[email protected]>; Hans de Goede <[email protected]>
Subject: Re: [PATCH v6] ACPI: bus: For platform OSC negotiate capabilitiesQuoted 6 lines · Mario
[Public]
Quoted 3 lines
I would do
if (capbuf[OSC_SUPPORT_DWORD] ==
capbuf_ret[OSC_SUPPORT_DWORD])
Quoted 3 lines
Quoted 3 lines
capbuf[OSC_QUERY_DWORD] = 0;else
capbuf[OSC_SUPPORT_DWORD] &=capbuf_ret[OSC_SUPPORT_DWORD];
Quoted 3 lines
Quoted 3 lines
so that the loop terminates even if the firmware does strange things and then it would only be necessary to check
capbuf[OSC_QUERY_DWORD]
Quoted 15 lines
Quoted 4 lines
in the loop termination condition.
Would that work?
I think it will. I'll try it and send up a v7 if so.
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kfree(context.ret.pointer); + } while (capbuf[OSC_QUERY_DWORD] &&capbuf[OSC_SUPPORT_DWORD]);
Quoted 5 lines
drivers/acpi/bus.c +2
-2-/* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD ] =0 ; +/* +* Avoid problems with BIOS dynamically loading tables by indicating
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
+ * support for CPPC even if it was masked.
What exactly do you mean by "BIOS dynamically loading tables"?
As mentioned in commit
159d8c274fd9:On certain systems the BIOS loads SSDT tables dynamically based on the capabilities the OS claims to support. However, on these systems the
_OSCactually clears some of the bits (under certain conditions) so what happens is that now when we call the_OSCtwice the second time wepass
Quoted 4 lines
the cleared values and that results errors like below to appear on the system log:
ACPI BIOS Error (bug): Could not resolve symbol [\_PR.PR00._CPC],
AE_NOT_FOUND(20210105/psargs-330)Quoted 1 line
ACPI Error: Aborting method \_PR.PR01._CPC due to previous error
(
AE_NOT_FOUND) (20210105/psparse-529)Quoted 2 lines
This block is to avoid regressing that again by forcing it on these systems.
Well, this means that the code before and after the patch is not actually following the spec.
Quoted 8 lines
First off, as mentioned in the changelog of commit
159d8c274fd9(in the part that has not been quoted above), the OS is required to pass the same set of capabilities every time_OSCis evaluated. This doesn't happen after the change.Second,
acpi_bus_osc_negotiate_platform_control()should take the capabilities mask returned by the platform which it doesn't do without the patch.Right on both points.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling
acpi_run_osc()with the query flag set for multiple times.I think just taking the results will re-introduce the CPC bug though won't it? So how to avoid it but also to take the results?
I think that the OS should not ask for the control of the CPPC bits if they are masked by the firmware and it should avoid invoking _CPC then.
Otherwise we risk breaking legitimate cases in which the firmware actually doesn't want the OS to control those bits.
Rafael J. Wysocki
maintainerQuoted 96 lines · Rafael J. Wysocki
Quoted 86 lines · Mario
[AMD Official Use Only]
Quoted 69 lines
-----Original Message-----
From: Rafael J. Wysocki <[email protected]>
Sent: Monday, March 14, 2022 15:01
To: Limonciello, Mario <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>; Rafael J . Wysocki <[email protected]>; ACPI Devel Maling List <[email protected]>; Mika Westerberg <[email protected]>; Hou, Xiaomeng (Matthew) <[email protected]>; Liu, Aaron <[email protected]>; Huang, Ray <[email protected]>; Hans de Goede <[email protected]>
Subject: Re: [PATCH v6] ACPI: bus: For platform OSC negotiate capabilitiesQuoted 6 lines · Mario
[Public]
Quoted 3 lines
I would do
if (capbuf[OSC_SUPPORT_DWORD] ==
capbuf_ret[OSC_SUPPORT_DWORD])
Quoted 3 lines
Quoted 3 lines
capbuf[OSC_QUERY_DWORD] = 0;else
capbuf[OSC_SUPPORT_DWORD] &=capbuf_ret[OSC_SUPPORT_DWORD];
Quoted 3 lines
Quoted 3 lines
so that the loop terminates even if the firmware does strange things and then it would only be necessary to check
capbuf[OSC_QUERY_DWORD]
Quoted 15 lines
Quoted 4 lines
in the loop termination condition.
Would that work?
I think it will. I'll try it and send up a v7 if so.
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ kfree(context.ret.pointer); + } while (capbuf[OSC_QUERY_DWORD] &&capbuf[OSC_SUPPORT_DWORD]);
Quoted 5 lines
(quoted diff) +2
-2- /* Now run _OSC again with query flag clear */ - capbuf[OSC_QUERY_DWORD] = 0; + /* + * Avoid problems with BIOS dynamically loading tables byindicating
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
+ * support for CPPC even if it was masked.
What exactly do you mean by "BIOS dynamically loading tables"?
As mentioned in commit
159d8c274fd9:On certain systems the BIOS loads SSDT tables dynamically based on the capabilities the OS claims to support. However, on these systems the
_OSCactually clears some of the bits (under certain conditions) so what happens is that now when we call the_OSCtwice the second time wepass
Quoted 4 lines
the cleared values and that results errors like below to appear on the system log:
ACPI BIOS Error (bug): Could not resolve symbol [\_PR.PR00._CPC],
AE_NOT_FOUND(20210105/psargs-330)Quoted 1 line
ACPI Error: Aborting method \_PR.PR01._CPC due to previous error
(
AE_NOT_FOUND) (20210105/psparse-529)Quoted 2 lines
This block is to avoid regressing that again by forcing it on these systems.
Well, this means that the code before and after the patch is not actually following the spec.
Quoted 8 lines
First off, as mentioned in the changelog of commit
159d8c274fd9(in the part that has not been quoted above), the OS is required to pass the same set of capabilities every time_OSCis evaluated. This doesn't happen after the change.Second,
acpi_bus_osc_negotiate_platform_control()should take the capabilities mask returned by the platform which it doesn't do without the patch.Right on both points.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling
acpi_run_osc()with the query flag set for multiple times.I think just taking the results will re-introduce the CPC bug though won't it? So how to avoid it but also to take the results?
Quoted 6 lines
I think that the OS should not ask for the control of the CPPC bits if they are masked by the firmware and it should avoid invoking
_CPCthen.Otherwise we risk breaking legitimate cases in which the firmware actually doesn't want the OS to control those bits.
I'm basically talking about reverting commit 159d8c274fd9, as the part of the _OSC definition in the spec it is based on appears to be bogus (that will be addressed separately via the ACPI spec process), and applying the attached change on top of that.
If this looks good to you, I'll take care of it.
--- drivers/acpi/bus.c | 4 ++++ drivers/acpi/cppc_acpi.c | 3 +++ include/linux/acpi.h | 1 + 3 files changed, 8 insertions(+)
drivers/acpi/bus.c +4 -0
@@ -278,6 +278,8 @@ bool osc_sb_apei_support_acked;bool osc_pc_lpi_support_confirmed;EXPORT_SYMBOL_GPL (osc_pc_lpi_support_confirmed); +bool osc_sb_cppc_control_granted; +/* * ACPI 6.4 Operating System Capabilities for USB. */
@@ -346,6 +348,8 @@ static void acpi_bus_osc_negotiate_platf 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_cppc_control_granted = capbuf_ret[OSC_SUPPORT_DWORD ] & + (OSC_SB_CPC_SUPPORT |OSC_SB_CPCV2_SUPPORT ); osc_sb_native_usb4_support_confirmed = capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_NATIVE_USB4_SUPPORT ;
drivers/acpi/cppc_acpi.c +3 -0
@@ -656,6 +656,9 @@ int acpi_cppc_processor_probe(struct acpacpi_status status;int ret = -EFAULT ; +if (!osc_sb_cppc_control_granted) +return -ENODEV ; +/* Parse the ACPI _CPC table for this CPU. */ status =acpi_evaluate_object_typed (handle,"_CPC" ,NULL , &output,ACPI_TYPE_PACKAGE );
include/linux/acpi.h +1 -0
@@ -579,6 +579,7 @@ acpi_status acpi_run_osc(acpi_handle hanextern bool osc_sb_apei_support_acked;extern bool osc_pc_lpi_support_confirmed; +extern bool osc_sb_cppc_control_granted;extern bool osc_sb_native_usb4_support_confirmed;/* USB4 Capabilities */
[Public]
Quoted 14 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling
acpi_run_osc()with the query flag set for multiple times.I think just taking the results will re-introduce the CPC bug though won't it? So how to avoid it but also to take the results?
Quoted 6 lines
I think that the OS should not ask for the control of the CPPC bits if they are masked by the firmware and it should avoid invoking
_CPCthen.Otherwise we risk breaking legitimate cases in which the firmware actually doesn't want the OS to control those bits.
Quoted 6 lines
I'm basically talking about reverting commit
159d8c274fd9, as the part of the_OSCdefinition in the spec it is based on appears to be bogus (that will be addressed separately via the ACPI spec process), and applying the attached change on top of that.If this looks good to you, I'll take care of it.
Yes, that looks great and I checked with 159d8c274fd9 reverted and that applying the problem does not exist. I do think it has the possibility to cause CPPC to not be enabled outside of Intel though since HWP is only set there so I would suggest this other change on top of it:
drivers/acpi/bus.c +2 -4
@@ -314,10 +314,8 @@ static void acpi_bus_osc_negotiate_platform_control(void)#endif #ifdef CONFIG_X86 capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_GENERIC_INITIATOR_SUPPORT ; -if (boot_cpu_has (X86_FEATURE_HWP )) { - capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; - capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; - } + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ;#endif if (IS_ENABLED (CONFIG_SCHED_MC_PRIO ))
Rafael J. Wysocki
maintainerQuoted 22 lines · Mario
[Public]
Quoted 19 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
That latter piece appears to be the bug in question here and IMO fixing it doesn't even require calling
acpi_run_osc()with the query flag set for multiple times.I think just taking the results will re-introduce the CPC bug though won't it? So how to avoid it but also to take the results?
Quoted 6 lines
I think that the OS should not ask for the control of the CPPC bits if they are masked by the firmware and it should avoid invoking
_CPCthen.Otherwise we risk breaking legitimate cases in which the firmware actually doesn't want the OS to control those bits.
I'm basically talking about reverting commit
159d8c274fd9, as the part of the_OSCdefinition in the spec it is based on appears to be bogus (that will be addressed separately via the ACPI spec process), and applying the attached change on top of that.
Quoted 6 lines
Quoted 1 line
If this looks good to you, I'll take care of it.
Yes, that looks great and I checked with
159d8c274fd9reverted and that applying the problem does not exist. I do think it has the possibility to cause CPPC to not be enabled outside of Intel though since HWP is only set there so I would suggest this other change on top of it:
Good point.
I'll make it x86-specific for the time being and that can be changed later.
Quoted 17 lines
drivers/acpi/bus.c +2
-4@@ -314,10 +314,8 @@ static void acpi_bus_osc_negotiate_platform_control(void)#endif #ifdef CONFIG_X86 capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_GENERIC_INITIATOR_SUPPORT ; -if (boot_cpu_has (X86_FEATURE_HWP )) { - capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; - capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ; - } + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPC_SUPPORT ; + capbuf[OSC_SUPPORT_DWORD ] |=OSC_SB_CPCV2_SUPPORT ;#endif if (IS_ENABLED (CONFIG_SCHED_MC_PRIO ))