]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: mt7921u: escalate broken USB transport to device reset
authorSean Wang <sean.wang@mediatek.com>
Wed, 1 Apr 2026 19:06:32 +0000 (14:06 -0500)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:15:22 +0000 (10:15 +0000)
Check the USB control path before running the normal WFSYS reset flow.

If USB access is no longer reliable, stop the WFSYS-only reset path,
mark the device as bus_hung, and queue a USB device reset instead.

Reuse the existing bus_hung state to represent transport-level failure,
keeping the semantics consistent with the SDIO path.

Also initialize bus_hung explicitly during probe for consistency.

Reported-by: Bryam Vargas <bryamestebanvargas@gmail.com>
Closes: https://lore.kernel.org/r/CANAPQziOh3sB7B8G+U3AZsFfeFN1uAg4munhwA_feZi56D7W+Q@mail.gmail.com
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/20260401190632.147042-2-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/mac.c
drivers/net/wireless/mediatek/mt76/mt7921/usb.c
drivers/net/wireless/mediatek/mt76/mt792x.h
drivers/net/wireless/mediatek/mt76/mt792x_usb.c

index 03b4960db73f0bbf73304e420304ea0b4b3f6e64..d27dbee8df1b5199fcd194ec231720f495dc4922 100644 (file)
@@ -675,7 +675,9 @@ void mt7921_mac_reset_work(struct work_struct *work)
                if (!ret)
                        break;
        }
-       if (mt76_is_sdio(&dev->mt76) && atomic_read(&dev->mt76.bus_hung))
+
+       if ((mt76_is_sdio(&dev->mt76) || mt76_is_usb(&dev->mt76)) &&
+           atomic_read(&dev->mt76.bus_hung))
                return;
 
        if (i == 10)
index 01fa1b03e2105fdb4fb95784faae8397887cb090..2fdecf239125ddbf03185bc45e14c5a4c6f5f8bd 100644 (file)
@@ -90,6 +90,10 @@ static int mt7921u_mac_reset(struct mt792x_dev *dev)
 {
        int err;
 
+       mt792xu_reset_on_bus_error(dev);
+       if (atomic_read(&dev->mt76.bus_hung))
+               return 0;
+
        mt76_txq_schedule_all(&dev->mphy);
        mt76_worker_disable(&dev->mt76.tx_worker);
 
@@ -198,6 +202,7 @@ static int mt7921u_probe(struct usb_interface *usb_intf,
        dev = container_of(mdev, struct mt792x_dev, mt76);
        dev->fw_features = features;
        dev->hif_ops = &hif_ops;
+       atomic_set(&dev->mt76.bus_hung, false);
        mt792xu_reset_work_init(dev);
 
        usb_reset_device(udev);
index 95e7fb64599d9c7718e1549a465a56c61dcaf6a6..70073b43af5431fdeaf6888c15a3f29ed98198b9 100644 (file)
@@ -521,6 +521,7 @@ int mt792xu_init_reset(struct mt792x_dev *dev);
 void mt792xu_reset_work_init(struct mt792x_dev *dev);
 void mt792xu_reset_work_cleanup(struct mt792x_dev *dev);
 int mt792xu_check_bus(struct mt792x_dev *dev);
+int mt792xu_reset_on_bus_error(struct mt792x_dev *dev);
 u32 mt792xu_rr(struct mt76_dev *dev, u32 addr);
 void mt792xu_wr(struct mt76_dev *dev, u32 addr, u32 val);
 u32 mt792xu_rmw(struct mt76_dev *dev, u32 addr, u32 mask, u32 val);
index 58d442b395362bf30a27d3ba4f71244c360042a2..910132e94956aa9d3e9cfcd1cf91c33fd839f931 100644 (file)
@@ -60,6 +60,32 @@ int mt792xu_check_bus(struct mt792x_dev *dev)
 }
 EXPORT_SYMBOL_GPL(mt792xu_check_bus);
 
+int mt792xu_reset_on_bus_error(struct mt792x_dev *dev)
+{
+       int err = 0;
+
+       if (!atomic_read(&dev->mt76.bus_hung))
+               err = mt792xu_check_bus(dev);
+
+       if (err) {
+               atomic_set(&dev->mt76.bus_hung, true);
+
+               if (!atomic_xchg(&dev->usb_reset_pending, 1)) {
+                       dev_warn(dev->mt76.dev,
+                                "USB transport access failed (%d), queueing device reset\n",
+                                err);
+
+                       schedule_work(&dev->usb_reset_work);
+               }
+
+               return err;
+       }
+
+       atomic_set(&dev->mt76.bus_hung, false);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mt792xu_reset_on_bus_error);
+
 u32 mt792xu_rr(struct mt76_dev *dev, u32 addr)
 {
        u32 ret;