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>
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)
{
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);
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);
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);
}
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;