[PATCH 2/2] wifi: mm81x: clear a stalled bulk endpoint before the next transfer

From: YuanZhe Liu

Date: Sat Nov 21 2026 - 11:49:59 EST


A bulk endpoint stays halted after it has answered a transfer with a
stall, and only a CLEAR_FEATURE(ENDPOINT_HALT) request resumes it. The
driver never sends one: the completion callbacks only record -EPIPE in
musb->errors, so every later register or memory access on that endpoint
stalls immediately and the device remains unusable until it is
re-enumerated.

Clear the halt of the endpoint that reported -EPIPE before returning the
error, so that a following restart can reach the device again. The command
endpoint is the memory write endpoint, hence the same recovery is applied
when the command urb itself stalls.

usb_clear_halt() sends a control request and may sleep, so it is called
from the process-context paths that wait for the transfer and never from a
completion callback.

Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>
---
drivers/net/wireless/morsemicro/mm81x/usb.c | 23 +++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/drivers/net/wireless/morsemicro/mm81x/usb.c b/drivers/net/wireless/morsemicro/mm81x/usb.c
index 98ca9575b990..72cbe468969c 100644
--- a/drivers/net/wireless/morsemicro/mm81x/usb.c
+++ b/drivers/net/wireless/morsemicro/mm81x/usb.c
@@ -106,6 +106,19 @@ static bool mm81x_usb_urb_status_is_disconnect(const struct urb *urb)
(urb->status == -ETIME) || (urb->status == -EPIPE));
}

+static void mm81x_usb_clear_halt(struct mm81x *mors, struct mm81x_usb *musb,
+ struct mm81x_usb_endpoint *ep, bool dir_in)
+{
+ int ret;
+
+ ret = usb_clear_halt(musb->udev,
+ dir_in ? usb_rcvbulkpipe(musb->udev, ep->addr) :
+ usb_sndbulkpipe(musb->udev, ep->addr));
+ if (ret)
+ dev_err(mors->dev, "failed to clear halt of endpoint %u: %d\n",
+ ep->addr, ret);
+}
+
static void mm81x_usb_int_handler(struct urb *urb)
{
int ret;
@@ -266,6 +279,10 @@ static int mm81x_usb_cmd(struct mm81x_usb *musb,
}

musb->ongoing_cmd = false;
+
+ if (musb->errors == -EPIPE)
+ mm81x_usb_clear_halt(mors, musb, ep, false);
+
return musb->errors ? musb->errors : writesize;

error:
@@ -374,6 +391,9 @@ static int mm81x_usb_mem_read(struct mm81x_usb *musb, u32 address, u8 *data,

if (musb->errors) {
ret = musb->errors;
+ if (ret == -EPIPE)
+ mm81x_usb_clear_halt(mors, musb,
+ &musb->endpoints[MM81X_EP_MEM_RD], true);
dev_err(mors->dev, "mem read error %d", ret);
goto error;
}
@@ -444,6 +464,9 @@ static int mm81x_usb_mem_write(struct mm81x_usb *musb, u32 address, u8 *data,

if (musb->errors) {
ret = musb->errors;
+ if (ret == -EPIPE)
+ mm81x_usb_clear_halt(mors, musb,
+ &musb->endpoints[MM81X_EP_MEM_WR], false);
dev_err(mors->dev, "error %d", ret);
goto error;
}
--
2.34.1