Skip to content
Snippets Groups Projects
Commit 05f1084f authored by Myron Stowe's avatar Myron Stowe
Browse files

PCI: Avoid FLR for Mediatek MT7922 WiFi

JIRA: https://issues.redhat.com/browse/RHEL-83611
Upstream Status: 81f64e925c29fe6e99f04b131fac1935ac931e81

commit 81f64e925c29fe6e99f04b131fac1935ac931e81
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Wed Feb 12 13:35:16 2025 -0600

    PCI: Avoid FLR for Mediatek MT7922 WiFi

    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 d591f680 ("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 d591f680, 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 d591f680, 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.

    Link: https://lore.kernel.org/r/20250212193516.88741-1-helgaas@kernel.org
    Fixes: d591f680 ("PCI: Wait for device readiness with Configuration RRS")
    Link: https://github.com/QubesOS/qubes-issues/issues/9689#issuecomment-2582927149
    Link: https://lore.kernel.org/r/Z4pHll_6GX7OUBzQ@mail-itl


Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Cc: stable@vger.kernel.org

Signed-off-by: default avatarMyron Stowe <mstowe@redhat.com>
parent 8cca0235
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment