PCI: Avoid FLR for Mediatek MT7922 WiFi
Subsystems (3)
PATCH 1/1 PCI: Avoid FLR for Mediatek MT7922 WiFi
From: Bjorn Helgaas <[email protected]>
The Mediatek MT7922 WiFi device advertises FLR support, but it apparently does not work, and all subsequent config reads return ~0:
pci 0000:01:00.0: [14c3:0616] type 00 class 0x028000 PCIe Endpoint pciback 0000:01:00.0: not ready 65535ms after FLR; giving up
After an FLR, pci_dev_wait() waits for the device to become ready. Prior to d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS"), it polls PCI_COMMAND until it is something other that PCI_POSSIBLE_ERROR (~0). If it times out, pci_dev_wait() returns -ENOTTY and __pci_reset_function_locked() tries the next available reset method. Typically this is Secondary Bus Reset, which does work, so the MT7922 is eventually usable.
After d591f6804e7e, if Configuration Request Retry Status Software Visibility (RRS SV) is enabled, pci_dev_wait() polls PCI_VENDOR_ID until it is something other than the special 0x0001 Vendor ID that indicates a completion with RRS status.
When RRS SV is enabled, reads of PCI_VENDOR_ID should return either 0x0001, i.e., the config read was completed with RRS, or a valid Vendor ID. On the MT7922, it seems that all config reads after FLR return ~0 indefinitely. When pci_dev_wait() reads PCI_VENDOR_ID and gets 0xffff, it assumes that's a valid Vendor ID and the device is now ready, so it returns with success.
After pci_dev_wait() returns success, we restore config space and continue. Since the MT7922 is not actually ready after the FLR, the restore fails and the device is unusable.
We considered changing pci_dev_wait() to continue polling if a PCI_VENDOR_ID read returns either 0x0001 or 0xffff. This "works" as it did before d591f6804e7e, although we have to wait for the timeout and then fall back to SBR. But it doesn't work for SR-IOV VFs, which *always* return 0xffff as the Vendor ID.
Mark Mediatek MT7922 WiFi devices to avoid the use of FLR completely. This will cause fallback to another reset method, such as SBR.
--- drivers/pci/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/quirks.c +2 -1
@@ -5522,7 +5522,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap);* AMD Matisse USB 3.0 Host Controller 0x149c * Intel 82579LM Gigabit Ethernet Controller 0x1502 * Intel 82579V Gigabit Ethernet Controller 0x1503 -* +* Mediatek MT7922 802.11ax PCI Express Wireless Network Adapter */ static void quirk_no_flr (struct pci_dev *dev) {
@@ -5534,6 +5534,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x149c, quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x7901 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_MEDIATEK ,0x0616 , quirk_no_flr);/* FLR may cause the SolidRun SNET DPU (rev 0x1) to hang */ static void quirk_no_flr_snet (struct pci_dev *dev)
Signature · 1 line
2.34.1
Quoted 37 lines · Bjorn Helgaas
From: Bjorn Helgaas <[email protected]>
The Mediatek MT7922 WiFi device advertises FLR support, but it apparently does not work, and all subsequent config reads return ~0:
pci 0000:01:00.0: [14c3:0616] type 00 class
0x028000PCIe Endpoint pciback 0000:01:00.0: not ready 65535ms after FLR; giving upAfter an FLR,
pci_dev_wait()waits for the device to become ready. Prior tod591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), it pollsPCI_COMMANDuntil it is something other thatPCI_POSSIBLE_ERROR(~0). If it times out,pci_dev_wait()returns-ENOTTYand__pci_reset_function_locked()tries the next available reset method. Typically this is Secondary Bus Reset, which does work, so the MT7922 is eventually usable.After
d591f6804e7e, if Configuration Request Retry Status Software Visibility (RRS SV) is enabled,pci_dev_wait()pollsPCI_VENDOR_IDuntil it is something other than the special0x0001Vendor ID that indicates a completion with RRS status.When RRS SV is enabled, reads of
PCI_VENDOR_IDshould return either0x0001, i.e., the config read was completed with RRS, or a valid Vendor ID. On the MT7922, it seems that all config reads after FLR return ~0 indefinitely. Whenpci_dev_wait()readsPCI_VENDOR_IDand gets0xffff, it assumes that's a valid Vendor ID and the device is now ready, so it returns with success.After
pci_dev_wait()returns success, we restore config space and continue. Since the MT7922 is not actually ready after the FLR, the restore fails and the device is unusable.We considered changing
pci_dev_wait()to continue polling if aPCI_VENDOR_IDread returns either0x0001or0xffff. This "works" as it did befored591f6804e7e, although we have to wait for the timeout and then fall back to SBR. But it doesn't work for SR-IOV VFs, which *always* return0xffffas the Vendor ID.
Quoted 7 lines
Mark Mediatek MT7922 WiFi devices to avoid the use of FLR completely. This will cause fallback to another reset method, such as SBR.
Fixes d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS")Signed-off-by Bjorn Helgaas <[email protected]>
It works, thanks!
Quoted 28 lines
--- drivers/pci/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/pci/quirks.c +2
-1@@ -5522,7 +5522,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap);* AMD Matisse USB 3.0 Host Controller 0x149c * Intel 82579LM Gigabit Ethernet Controller 0x1502 * Intel 82579V Gigabit Ethernet Controller 0x1503 -* +* Mediatek MT7922 802.11ax PCI Express Wireless Network Adapter */ static void quirk_no_flr (struct pci_dev *dev) {@@ -5534,6 +5534,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x149c, quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x7901 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_MEDIATEK ,0x0616 , quirk_no_flr);/* FLR may cause the SolidRun SNET DPU (rev 0x1) to hang */ static void quirk_no_flr_snet (struct pci_dev *dev)Signature · 1 line
2.34.1
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 37 lines · Bjorn Helgaas
From: Bjorn Helgaas <[email protected]>
The Mediatek MT7922 WiFi device advertises FLR support, but it apparently does not work, and all subsequent config reads return ~0:
pci 0000:01:00.0: [14c3:0616] type 00 class
0x028000PCIe Endpoint pciback 0000:01:00.0: not ready 65535ms after FLR; giving upAfter an FLR,
pci_dev_wait()waits for the device to become ready. Prior tod591f6804e7e("PCI: Wait for device readiness with Configuration RRS"), it pollsPCI_COMMANDuntil it is something other thatPCI_POSSIBLE_ERROR(~0). If it times out,pci_dev_wait()returns-ENOTTYand__pci_reset_function_locked()tries the next available reset method. Typically this is Secondary Bus Reset, which does work, so the MT7922 is eventually usable.After
d591f6804e7e, if Configuration Request Retry Status Software Visibility (RRS SV) is enabled,pci_dev_wait()pollsPCI_VENDOR_IDuntil it is something other than the special0x0001Vendor ID that indicates a completion with RRS status.When RRS SV is enabled, reads of
PCI_VENDOR_IDshould return either0x0001, i.e., the config read was completed with RRS, or a valid Vendor ID. On the MT7922, it seems that all config reads after FLR return ~0 indefinitely. Whenpci_dev_wait()readsPCI_VENDOR_IDand gets0xffff, it assumes that's a valid Vendor ID and the device is now ready, so it returns with success.After
pci_dev_wait()returns success, we restore config space and continue. Since the MT7922 is not actually ready after the FLR, the restore fails and the device is unusable.We considered changing
pci_dev_wait()to continue polling if aPCI_VENDOR_IDread returns either0x0001or0xffff. This "works" as it did befored591f6804e7e, although we have to wait for the timeout and then fall back to SBR. But it doesn't work for SR-IOV VFs, which *always* return0xffffas the Vendor ID.
Quoted 7 lines
Mark Mediatek MT7922 WiFi devices to avoid the use of FLR completely. This will cause fallback to another reset method, such as SBR.
Fixes d591f6804e7e ("PCI: Wait for device readiness with Configuration RRS")Signed-off-by Bjorn Helgaas <[email protected]>
Applied with Marek's tested-by to pci/for-linus for v6.14.
I also added a cc: stable tag.
Quoted 28 lines
--- drivers/pci/quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/pci/quirks.c +2
-1@@ -5522,7 +5522,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap);* AMD Matisse USB 3.0 Host Controller 0x149c * Intel 82579LM Gigabit Ethernet Controller 0x1502 * Intel 82579V Gigabit Ethernet Controller 0x1503 -* +* Mediatek MT7922 802.11ax PCI Express Wireless Network Adapter */ static void quirk_no_flr (struct pci_dev *dev) {@@ -5534,6 +5534,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x149c, quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_AMD ,0x7901 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1502 , quirk_no_flr);DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_INTEL ,0x1503 , quirk_no_flr); +DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_MEDIATEK ,0x0616 , quirk_no_flr);/* FLR may cause the SolidRun SNET DPU (rev 0x1) to hang */ static void quirk_no_flr_snet (struct pci_dev *dev)Signature · 1 line
2.34.1