From patchwork Fri Feb 18 17:32:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12751677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D81DC4332F for ; Fri, 18 Feb 2022 17:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238626AbiBRRdH (ORCPT ); Fri, 18 Feb 2022 12:33:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236830AbiBRRdG (ORCPT ); Fri, 18 Feb 2022 12:33:06 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFAFC2B4D9A; Fri, 18 Feb 2022 09:32:49 -0800 (PST) Date: Fri, 18 Feb 2022 18:32:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1645205567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=g2CWKBvUgnW8+rhv+YuxoDA1gTBduF4DcHc2yTMdEzA=; b=0Q0L8bxs+BmGckvx/nkNo81zL4oRAgOtitETMEuGBvmyUbb/N9wBwRdnZS/sIsH8Rm5ddM fZ6xQ2gbq6pPc202A9jbw6/tIZ1ZZsnyoIGJeUudZ3X8YZLN4R0IrmG4oYaStVgkwNoVXA TV29qJdP6Jcp4NOe3d91G7sQCdqUZ/AbbOPLR+IglVXAFf5igATeCG58d7Wes+Hb1Hx73P UT78YS9aPGwD2bVGlbkMaLKaW/hkDugyeixWQiE8Oh6dJ1mZgjbkmD6NkNE2hJL+/KVA2r lGJOM1JE25ZgDoQtgmhFc9A5XDF7NDIqz7YgJhKe6sDm6BRDCbamOCnUlmrMQA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1645205567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=g2CWKBvUgnW8+rhv+YuxoDA1gTBduF4DcHc2yTMdEzA=; b=zOTVEQFe+owllU86mgiL+jBSRUVoYjZY/iNPrDE0Y1+oHyWl4kCbVc3/kb0vhd+fHCj42Q Mry87Li7RjxKFLDA== From: Sebastian Andrzej Siewior To: Greg Kroah-Hartman Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Alexei Starovoitov , Daniel Borkmann , Eric Dumazet , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Thomas Gleixner , Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rg?= =?utf-8?q?ensen?= , Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgense?= =?utf-8?q?n?= , Felipe Balbi , linux-usb@vger.kernel.org, Marek Szyprowski Subject: [PATCH] usb: dwc3: gadget: Let the interrupt handler disable bottom halves. Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The interrupt service routine registered for the gadget is a primary handler which mask the interrupt source and a threaded handler which handles the source of the interrupt. Since the threaded handler is voluntary threaded, the IRQ-core does not disable bottom halves before invoke the handler like it does for the forced-threaded handler. Due to changes in networking it became visible that a network gadget's completions handler may schedule a softirq which remains unprocessed. The gadget's completion handler is usually invoked either in hard-IRQ or soft-IRQ context. In this context it is enough to just raise the softirq because the softirq itself will be handled once that context is left. In the case of the voluntary threaded handler, there is nothing that will process pending softirqs. Which means it remain queued until another random interrupt (on this CPU) fires and handles it on its exit path or another thread locks and unlocks a lock with the bh suffix. Worst case is that the CPU goes idle and the NOHZ complains about unhandled softirqs. Disable bottom halves before acquiring the lock (and disabling interrupts) and enable them after dropping the lock. This ensures that any pending softirqs will handled right away. Reported-by: Marek Szyprowski Link: https://lkml.kernel.org/r/c2a64979-73d1-2c22-e048-c275c9f81558@samsung.com Fixes: e5f68b4a3e7b0 ("Revert "usb: dwc3: gadget: remove unnecessary _irqsave()"") Signed-off-by: Sebastian Andrzej Siewior Tested-by: Marek Szyprowski --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 183b90923f51b..a0c883f19a417 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -4160,9 +4160,11 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt) unsigned long flags; irqreturn_t ret = IRQ_NONE; + local_bh_disable(); spin_lock_irqsave(&dwc->lock, flags); ret = dwc3_process_event_buf(evt); spin_unlock_irqrestore(&dwc->lock, flags); + local_bh_enable(); return ret; }