]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: cdns3: Fix deadlock when using NCM gadget
authorRalph Siemsen <ralph.siemsen@linaro.org>
Tue, 18 Mar 2025 15:09:32 +0000 (11:09 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:39:27 +0000 (07:39 +0200)
commit a1059896f2bfdcebcdc7153c3be2307ea319501f upstream.

The cdns3 driver has the same NCM deadlock as fixed in cdnsp by commit
58f2fcb3a845 ("usb: cdnsp: Fix deadlock issue during using NCM gadget").

Under PREEMPT_RT the deadlock can be readily triggered by heavy network
traffic, for example using "iperf --bidir" over NCM ethernet link.

The deadlock occurs because the threaded interrupt handler gets
preempted by a softirq, but both are protected by the same spinlock.
Prevent deadlock by disabling softirq during threaded irq handler.

Cc: stable <stable@kernel.org>
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Acked-by: Peter Chen <peter.chen@kernel.org>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20250318-rfs-cdns3-deadlock-v2-1-bfd9cfcee732@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/cdns3/gadget.c

index 61283e7e602a27364b68aee7db06e4e1cbd96678..88c3c3a1e189e16e10ea5bd5d7f77a8f010cf3be 100644 (file)
@@ -1920,6 +1920,7 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
                          "%s is already disabled\n", priv_ep->name))
                return 0;
 
+       local_bh_disable();
        spin_lock_irqsave(&priv_dev->lock, flags);
 
        trace_cdns3_gadget_ep_disable(priv_ep);
@@ -1976,6 +1977,7 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
        priv_ep->flags &= ~EP_ENABLED;
 
        spin_unlock_irqrestore(&priv_dev->lock, flags);
+       local_bh_enable();
 
        return ret;
 }