acpi: pci_root: Add quirks table for _OSC support
PATCH 1/1 acpi: pci_root: Add quirks table for _OSC support
The MSI Claw A8 hard-locks on resume from s2idle whenever an SD/MMC card is present in the RTS525A card reader (10ec:525a, PCI ID). This issue is not present on the Lenovo Legion Go with the same card reader. The primary difference is that the Claw A8 withholds LTR and DPC while granting ASPM control to the OS, leading to a split ownership. The issue can be mitigated by passing pcie_asmp=off, but quirking on the pci_dev in pci/quirks has no effect.
Attempted quirks included use of pci_disable_link_state(), dev->link_state = NULL, manually zeroing aspm_l0s_support/aspm_l1_support via DECLARE_PCI_FIXUP_FINAL, and pcie_aspm_remove_cap() on DECLARE_PCI_FIXUP_HEADER. Only by disabling ASPM on the root hub is the system able to resume successfully. This strongly suggests a race between the OS resuming the link under its own ASPM assumptions and firmware independently acting on the same link based on state it never relinquished.
As an attempt to localize the workaround to as low level as possible while also being effective, introduce a quirk system to the existing acpi pci_root calculate_support() mechanism.
--- drivers/acpi/pci_root.c | 68 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-)
drivers/acpi/pci_root.c +66 -2
@@ -422,7 +422,69 @@ static acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask,return AE_OK ; } -static u32 calculate_support (void ) +/* +* Some platforms advertise ASPM support in _OSC but withhold related +* control (e.g. LTR, DPC) from the OS on a specific root complex. The +* resulting split ownership between OS-managed ASPM and firmware-owned +* LTR/DPC can cause resume failures on s2idle. Rather than disabling +* ASPM system-wide, strip the offending support bits only on the +* affected root bridge so the OS abstains from requesting _OSC control +* there, leaving every other root complex on the system unaffected. +*/ +struct osc_support_quirk { +const struct dmi_system_id dmi_match[2 ]; +u16 segment; +u8 bus; +u32 strip_support; +}; + +static const struct osc_support_quirk osc_support_quirks[] = { +/* +* MSI Claw A8 (MS-1T8K): firmware withholds LTR/DPC control on +* the primary root complex despite advertising ASPM support, +* causing a hard lock on s2idle resume when the onboard RTS525A +* SD card reader is populated. +*/ + { + .dmi_match = { + { + .ident ="MSI Claw A8 BZ2EM" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"Micro-Star International Co., Ltd." ), +DMI_MATCH (DMI_BOARD_NAME ,"MS-1T8K" ), + }, + }, + {} + }, + .segment =0 , + .bus =0 , + .strip_support =OSC_PCI_ASPM_SUPPORT |OSC_PCI_CLOCK_PM_SUPPORT , + }, +}; + +static u32 pci_osc_support_quirk_mask (struct acpi_pci_root *root) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (osc_support_quirks); i++) { +const struct osc_support_quirk *q = &osc_support_quirks[i]; + +if (dmi_first_match (q->dmi_match) && + root->segment == q->segment && + root->secondary.start == q->bus) { +dev_info (&root->device->dev, +"PCI Root Bridge [%04x:%02x] _OSC quirk: stripping support 0x%08x (%s)\n" , + root->segment, (unsigned int )root->secondary.start, + q->strip_support, q->dmi_match[0 ].ident); +return ~q->strip_support; + } + } + +return ~0 ; +} + +static u32 calculate_support (struct acpi_pci_root *root) {u32 support;
@@ -441,6 +503,8 @@ static u32 calculate_support(void)if (IS_ENABLED (CONFIG_PCIE_EDR )) support |=OSC_PCI_EDR_SUPPORT ; + support &=pci_osc_support_quirk_mask (root); +return support; }
@@ -571,7 +635,7 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)return ; } - support =calculate_support (); + support =calculate_support (root);decode_osc_support (root,"OS supports" , support);
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The patch bypasses the global ASPM disablement path, causing the OS to illegally configure ASPM…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch bypasses the global ASPM disablement path, causing the OS to illegally configure ASPM registers on the root bridge without acquiring _OSC control from the firmware. --
--- Patch [1]: [PATCH] acpi: pci_root: Add quirks table for _OSC support --- commit ae1792c3abcd3cde32bf0136c38058905b107a50
Author: Derek J. Clark <[email protected]>
acpi: pci_root: Add quirks table for _OSC support
This patch introduces a quirk table to dynamically strip specific _OSC support bits (like ASPM) from certain root complexes. It aims to fix a hard lock on s2idle resume for the MSI Claw A8 by preventing the OS from requesting _OSC control when an SD card is present.
Quoted 4 lines
drivers/acpi/pci_root.c +0
-0
[ ... ]
drivers/acpi/pci_root.c static u32 calculate_support(void) · line 517
Quoted 6 lines
drivers/acpi/pci_root.c +2
-0@@ -451,6 +513,8 @@ static u32 calculate_support(void)if (IS_ENABLED (CONFIG_PCIE_EDR )) support |=OSC_PCI_EDR_SUPPORT ; + support &=pci_osc_support_quirk_mask (root); +
[Severity: High]
Does stripping the ASPM support bit here bypass the global ASPM disablement path?
When this quirk strips OSC_PCI_ASPM_SUPPORT, os_control_query_checks() will fail because the mask lacks ACPI_PCIE_REQ_SUPPORT:
drivers/acpi/pci_root.c:os_control_query_checks() {
if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
decode_osc_support(root, "not requesting OS control; OS requires",
ACPI_PCIE_REQ_SUPPORT);
return false;
}
...
}This causes the requested control to default to 0. When acpi_pci_osc_control_set() is called with ctrl = 0, it hits an early exit and returns AE_OK:
drivers/acpi/pci_root.c:acpi_pci_osc_control_set() {
/* No need to request _OSC if the control was already granted. */
if ((root->osc_control_set & ctrl) == ctrl &&
(root->osc_ext_control_set & cxl_ctrl) == cxl_ctrl)
return AE_OK;
...
}Because AE_OK is returned, negotiate_os_control() treats this as a success and bypasses the failure path that sets *no_aspm = 1:
drivers/acpi/pci_root.c:negotiate_os_control() {
status = acpi_pci_osc_control_set(handle, &control, support,
&cxl_control, cxl_support);
if (ACPI_SUCCESS(status)) {
...
} else {
*no_aspm = 1;
...
}
}With the global aspm_disabled flag remaining false, won't the ASPM core proceed to actively configure ASPM on the root bridge in pcie_aspm_init_link_state() without actually acquiring _OSC control from the firmware?
Quoted 3 lines
drivers/acpi/pci_root.c +0
-0return support; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rafael J. Wysocki (Intel)
maintainerQuoted 7 lines · Derek J. Clark
The MSI Claw A8 hard-locks on resume from s2idle whenever an SD/MMC card is present in the RTS525A card reader (10ec:525a, PCI ID). This issue is not present on the Lenovo Legion Go with the same card reader. The primary difference is that the Claw A8 withholds LTR and DPC while granting ASPM control to the OS, leading to a split ownership. The issue can be mitigated by passing pcie_asmp=off, but quirking on the
pci_dev
You mean pcie_aspm=off I suppose.
Quoted 7 lines
in pci/quirks has no effect.
Attempted quirks included use of
pci_disable_link_state(),dev->link_state= NULL, manually zeroing aspm_l0s_support/aspm_l1_support viaDECLARE_PCI_FIXUP_FINAL, andpcie_aspm_remove_cap()onDECLARE_PCI_FIXUP_HEADER. Only by disabling ASPM on the root hub is the system able to resume successfully.
So if there is a clash between the firmware and the OS, the question is why it only happens during system resume and only for this specific device in this specific configuration.
If disabling ASPM globally makes the symptom go away, it certainly is related to ASPM, but it is kind of hard to say what exactly the relationship is at this point.
Quoted 4 lines
This strongly suggests a race between
the OS resuming the link under its own ASPM assumptions and firmware independently acting on the same link based on state it never relinquished.
I'd like to see a boot log from the affected platform including the entire PCI _OSC negotiation.
There actually is no way for the firmware to grant or refuse the ASPM control to the OS separately. It is part of the PCI Express Capability Structure covered by OSC_PCI_EXPRESS_CAPABILITY_CONTROL, so if that control bit is acknowledged via _OSC, the OS is supposed to control ASPM (among other things).
The LTR and DPC are extended capabilities, so in principle they may be controlled separately, if the OS controls the PCI Express Capability structure, and there is no formal requirement to grant control of any of them for ASPM to work.
Quoted 3 lines
As an attempt to localize the workaround to as low level as possible while also being effective, introduce a quirk system to the existing acpi
pci_rootcalculate_support()mechanism.
I'm not sure if there is a need to tell the firmware that ASPM is not supported. You may as well avoid asking for OSC_PCI_EXPRESS_CAPABILITY_CONTROL on the affected platform.
Quoted 90 lines
Signed-off-by Derek J. Clark <[email protected]>--- drivers/acpi/pci_root.c | 68 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-)drivers/acpi/pci_root.c +65
-1@@ -422,7 +422,69 @@ static acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask,return AE_OK ; } -static u32 calculate_support (void ) +/* +* Some platforms advertise ASPM support in _OSC but withhold related +* control (e.g. LTR, DPC) from the OS on a specific root complex. The +* resulting split ownership between OS-managed ASPM and firmware-owned +* LTR/DPC can cause resume failures on s2idle. Rather than disabling +* ASPM system-wide, strip the offending support bits only on the +* affected root bridge so the OS abstains from requesting _OSC control +* there, leaving every other root complex on the system unaffected. +*/ +struct osc_support_quirk { +const struct dmi_system_id dmi_match[2 ]; +u16 segment; +u8 bus; +u32 strip_support; +}; + +static const struct osc_support_quirk osc_support_quirks[] = { +/* +* MSI Claw A8 (MS-1T8K): firmware withholds LTR/DPC control on +* the primary root complex despite advertising ASPM support, +* causing a hard lock on s2idle resume when the onboard RTS525A +* SD card reader is populated. +*/ + { + .dmi_match = { + { + .ident ="MSI Claw A8 BZ2EM" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR , +"Micro-Star International Co., Ltd." ), +DMI_MATCH (DMI_BOARD_NAME ,"MS-1T8K" ), + }, + }, + {} + }, + .segment =0 , + .bus =0 , + .strip_support =OSC_PCI_ASPM_SUPPORT |OSC_PCI_CLOCK_PM_SUPPORT , + }, +}; + +static u32 pci_osc_support_quirk_mask (struct acpi_pci_root *root) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (osc_support_quirks); i++) { +const struct osc_support_quirk *q = &osc_support_quirks[i]; + +if (dmi_first_match (q->dmi_match) && + root->segment == q->segment && + root->secondary.start == q->bus) { +dev_info (&root->device->dev, +"PCI Root Bridge [%04x:%02x] _OSC quirk: stripping support 0x%08x (%s)\n" , + root->segment, (unsigned int )root->secondary.start, + q->strip_support, q->dmi_match[0 ].ident); +return ~q->strip_support; + } + } + +return ~0 ; +} + +static u32 calculate_support (struct acpi_pci_root *root) {u32 support;@@ -441,6 +503,8 @@ static u32 calculate_support(void)if (IS_ENABLED (CONFIG_PCIE_EDR )) support |=OSC_PCI_EDR_SUPPORT ; + support &=pci_osc_support_quirk_mask (root); +return support; }
drivers/acpi/pci_root.c static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) · line 638
Quoted 5 lines
drivers/acpi/pci_root.c +1
-1@@ -571,7 +635,7 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm)return ; } - support =calculate_support (); + support =calculate_support (root);
This will delay the initialization of any system, not just the quirky one. Is there any way to avoid that?
Quoted 3 lines
drivers/acpi/pci_root.c +0
-1decode_osc_support (root,"OS supports" , support); --
Rafael J. Wysocki (Intel)
maintainerQuoted 21 lines · Rafael J. Wysocki (Intel)
Quoted 7 lines · Derek J. Clark
The MSI Claw A8 hard-locks on resume from s2idle whenever an SD/MMC card is present in the RTS525A card reader (10ec:525a, PCI ID). This issue is not present on the Lenovo Legion Go with the same card reader. The primary difference is that the Claw A8 withholds LTR and DPC while granting ASPM control to the OS, leading to a split ownership. The issue can be mitigated by passing pcie_asmp=off, but quirking on the
pci_devYou mean pcie_aspm=off I suppose.
Quoted 7 lines
in pci/quirks has no effect.
Attempted quirks included use of
pci_disable_link_state(),dev->link_state= NULL, manually zeroing aspm_l0s_support/aspm_l1_support viaDECLARE_PCI_FIXUP_FINAL, andpcie_aspm_remove_cap()onDECLARE_PCI_FIXUP_HEADER. Only by disabling ASPM on the root hub is the system able to resume successfully.
Quoted 7 lines
So if there is a clash between the firmware and the OS, the question is why it only happens during system resume and only for this specific device in this specific configuration.
If disabling ASPM globally makes the symptom go away, it certainly is related to ASPM, but it is kind of hard to say what exactly the relationship is at this point.
Besides, does disabling ASPM globally affect what happens to LTR and DPC? I think so.
If that is the case, maybe the suspend-resume code paths skip LTR and DPC if ASPM is disabled and they do something to those capabilities otherwise? LTR and DPC generally should not be touched by the system suspend-resume paths if native_ltr and native_dpc are zero, respectively.
Quoted 14 lines · Rafael J. Wysocki (Intel)
Quoted 11 lines · Rafael J. Wysocki (Intel)
Quoted 7 lines · Derek J. Clark
The MSI Claw A8 hard-locks on resume from s2idle whenever an SD/MMC card is present in the RTS525A card reader (10ec:525a, PCI ID). This issue is not present on the Lenovo Legion Go with the same card reader. The primary difference is that the Claw A8 withholds LTR and DPC while granting ASPM control to the OS, leading to a split ownership. The issue can be mitigated by passing pcie_asmp=off, but quirking on the
pci_dev
Quoted 2 lines
Quoted 2 lines
You mean pcie_aspm=off I suppose.
Hi Rafael,
Indeed, that was a typo.
Quoted 16 lines
Quoted 8 lines
Quoted 7 lines
in pci/quirks has no effect.
Attempted quirks included use of
pci_disable_link_state(),dev->link_state= NULL, manually zeroing aspm_l0s_support/aspm_l1_support viaDECLARE_PCI_FIXUP_FINAL, andpcie_aspm_remove_cap()onDECLARE_PCI_FIXUP_HEADER. Only by disabling ASPM on the root hub is the system able to resume successfully.Quoted 7 lines
So if there is a clash between the firmware and the OS, the question is why it only happens during system resume and only for this specific device in this specific configuration.
If disabling ASPM globally makes the symptom go away, it certainly is related to ASPM, but it is kind of hard to say what exactly the relationship is at this point.
Quoted 8 lines
Besides, does disabling ASPM globally affect what happens to LTR and DPC? I think so.
If that is the case, maybe the suspend-resume code paths skip LTR and DPC if ASPM is disabled and they do something to those capabilities otherwise? LTR and DPC generally should not be touched by the system suspend-resume paths if
native_ltrandnative_dpcare zero, respectively.
I'll be up-front that _OSC handling isn't in my wheelhouse of things I have troubleshot before. After reviewing your feedback I re-investigated my assumptions to get a better handle on exactly what the mechanism was that was resolved by the quirk and found some interesting results. The LTR/DPC asymmetry and ASPM disablement were masking the real root cause of the failure. Upon looking at my dmesg again I noted that the quirk caused _OSC negotiation to alter the PCIeHotPlug control state.
Normal boot:
Aug 04 14:33:12 clawa8 kernel: acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI EDR HPX-Type3] Aug 04 14:33:12 clawa8 kernel: acpi PNP0A08:00: _OSC: platform does not support [SHPCHotplug AER LTR DPC] Aug 04 14:33:12 clawa8 kernel: acpi PNP0A08:00: _OSC: OS now controls
[PCIeHotplug PME PCIeCapability]
Quirked boot:
Aug 04 14:37:48 clawa8 kernel: acpi PNP0A08:00: PCI Root Bridge [0000:00] _OSC quirk: stripping support 0x00000006 (MSI Claw A8 BZ2EM) Aug 04 14:37:48 clawa8 kernel: acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig Segments MSI EDR HPX-Type3] Aug 04 14:37:48 clawa8 kernel: acpi PNP0A08:00: _OSC: not requesting
OS control; OS requires [ExtendedConfig ASPM ClockPM MSI]
I then tested pcie_ports=compat and also was able to resume. After a bit of back and forth I found that using pci/quirks.c and setting native_pcie_hotplug = false on the root bridge in a HEADER quirk, I was able to resolve this issue more cleanlyl. Given that, I'll be sending a different patch to resolve this once I've more thoroughly tested it to see if I can isolate it to the device itself and/or root hub. Considering the possible performance hit you described, I think that is a better path.
Thanks,
Derek