Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ryan Brue" <ryanbrue.dev@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: mtu3: keep interrupts disabled in gadget completion callbacks
Date: Mon, 23 Nov 2026 02:30:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-228552@kernel.org> (raw)
In-Reply-To: <20261122-usb-mtu3-callbacks-irqs-off-v1-1-27733bb678c4@gmail.com>

> 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@kernel.org
> Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-usb-mtu3-callbacks-irqs-off-v1-1-27733bb678c4@gmail.com?part=1

      reply	other threads:[~2026-11-23  2:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  2:28 [PATCH] usb: mtu3: keep interrupts disabled in gadget completion callbacks Ryan Brue
2026-11-23  2:30 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-228552@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ryanbrue.dev@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox