[PATCH] usb: mtu3: keep interrupts disabled in gadget completion callbacks

From: Ryan Brue

Date: Sun Nov 22 2026 - 21:28:21 EST


Commit 625dd9076e35 ("usb: mtu3: don't run gadget completion callbacks
with interrupts disabled") made the threaded mtu3_irq() take mtu->lock
with spin_lock_bh(). mtu3_req_complete() drops the lock with a plain
spin_unlock() around usb_gadget_giveback_request(), so the gadget
function's completion callback now runs with interrupts enabled.

That breaks the gadget API, struct usb_request's @complete "will always
be called with interrupts disabled". u_serial's console relies on it:
gs_console_complete_out() takes cons->lock with spin_lock(), and
gs_console_write() takes the same lock with spin_lock_irqsave() from
printk, which can then interrupt the callback on the same CPU while it
holds the lock.

Keep spin_lock_irqsave() in mtu3_irq() and disable bottom halves around
it instead, as dwc3 does in commit 84918a89d6ef ("usb: dwc3: gadget: Let
the interrupt handler disable bottom halves."). netif_rx() then finds
softirqs disabled and leaves them alone, the completion callbacks run
with interrupts disabled again, and the softirq netif_rx() raises runs
at local_bh_enable(), once the lock is dropped and interrupts are on.

Tested on an MT8173 tablet with PROVE_LOCKING, copying a 21 MB file over
USB ethernet three times per arm: with spin_lock_bh(), all 8,333 completion
callbacks ran with interrupts enabled; with this change, none of about
16,000 did, with no lockdep report and every copy intact.

Fixes: 625dd9076e35 ("usb: mtu3: don't run gadget completion callbacks with interrupts disabled")
Cc: stable@xxxxxxxxxx
Signed-off-by: Ryan Brue <ryanbrue.dev@xxxxxxxxx>
---
Greg, commit 625dd9076e35 in usb-linus is v1 of my mtu3 callbacks fix,
the one I asked you on 2026-11-03 not to apply. With spin_lock_bh() the
gadget completion callbacks run with interrupts enabled, which the
gadget API rules out. v2 [1] got no reply, so here is v2's change as a
fix on top of 625dd9076e35; the resulting mtu3_irq() is the same as v2's.

My bad for the original error in v1.

[1] https://lore.kernel.org/all/20261104-usb-mtu3-gadget-completion-callback-fix-v2-1-2769533a39cb@xxxxxxxxx/
---
drivers/usb/mtu3/mtu3_core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
index fc274646fcde..f6677f58dd1f 100644
--- a/drivers/usb/mtu3/mtu3_core.c
+++ b/drivers/usb/mtu3/mtu3_core.c
@@ -790,9 +790,11 @@ static irqreturn_t mtu3_u2_common_isr(struct mtu3 *mtu)
static irqreturn_t mtu3_irq(int irq, void *data)
{
struct mtu3 *mtu = (struct mtu3 *)data;
+ unsigned long flags;
u32 level1;

- spin_lock_bh(&mtu->lock);
+ local_bh_disable();
+ spin_lock_irqsave(&mtu->lock, flags);

/* U3D_LV1ISR is RU */
level1 = mtu3_readl(mtu->mac_base, U3D_LV1ISR);
@@ -813,7 +815,8 @@ static irqreturn_t mtu3_irq(int irq, void *data)
if (level1 & QMU_INTR)
mtu3_qmu_isr(mtu);

- spin_unlock_bh(&mtu->lock);
+ spin_unlock_irqrestore(&mtu->lock, flags);
+ local_bh_enable();

return IRQ_HANDLED;
}

---
base-commit: b0baaf6cbb16bc773d0c76916aac17c44a6cd557
change-id: 20261122-usb-mtu3-callbacks-irqs-off-71bfbb2ed4fc

Best regards,
--
Ryan Brue <ryanbrue.dev@xxxxxxxxx>