From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8BC5606A322 for ; Wed, 2 Dec 2026 04:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=UIXpYQvh; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=dUBsQ+KU DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=n94dWlJRm2Re3ANC4gik8ZEsyDnCn+0FKHuVyiZcaOI=; b=UIXpYQvhWk2ZX8 xJHtfXVYLnzV0uQFBJ6YvbMdAaIkzrvhz2nFELLo0jdj8pbsgi7Xvxpp5ZR5OuciH1kNWzpzx0QD4 cfe0HMHt9TszeWzaKjbTYidOXpclxzEVpTkCPL+yo052DRDSI7qdlgqwyxkRfV1O1fnm8vakfG+uj XvwEhmrSOp5nc0qfb2iS+fFOhlc8wYVbpBU/bS/t0bhSb1H2+tot1BZ4d0qfYWsTOflV9XHtQFLaF aLDDBm7zihu6oz1COv6U+m+MgzhqKjSIoHS+b8X5Mxikd4JREfZt7+DQJP+8TRMQz5XPZVjd7HlVq VxgTOd3oEdyEwTbSCLNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYcCu-0000000ACcw-2GUw; Wed, 02 Dec 2026 04:44:40 +0000 Received: from mail-oo2-x08.google.com ([2607:f8b0:4864:31::8]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYcCq-0000000ACaz-0U7s for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 04:44:37 +0000 Received: by mail-oo2-x08.google.com with SMTP id 006d021491bc7-71733a926edso1346117eaf.1 for ; Tue, 01 Dec 2026 20:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796186675; x=1796791475; darn=lists.infradead.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=n94dWlJRm2Re3ANC4gik8ZEsyDnCn+0FKHuVyiZcaOI=; b=dUBsQ+KUxgJM/C5pmbNb8gqyzJNNHkR0KHO9RYNz/+rl7LnUDKmVUts2/Hi7YyRU2L 4S8mz8EcSimAGfxiDBmPJgrUqmFf0jZWVxo8vBOrZB3DsiZRT9wUsgsX4crb8EVW9o3c A7u7XqRNR2DfY441wBkmuOicFWKxvpjkU46osPf4t6JiSklxugZnJQa5LRPGXvww0yuG Jbn/qzFMGi5kPOETZ90rH0yA7C8cHF2s72BvWybyEidRruNlFq/5KEgkrcJWt351jJeI 3lCLyT2rJHT1MZaxFGgeTo0uajAoAO7giq29WbHyvbtimO1H38aJYRDDquNpJm7cs//r ErJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796186675; x=1796791475; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=n94dWlJ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ayTRZfJudMY zkiKwRG3nim6DGb444n/RpeXmLgNHxnFBcSG0JFNRONWZ5+qU7QxLTang6/UvGU2HFUB8+Shicd TNytkaAtfKJsdktR254o9ZXIqggUakyX9wP747x1ytjbts7ilDiRD9uYamqSVGnz1+r/jwm3mqT nGLmfHwG1zAGqLqy8cm4rpfTE9Ccwdf7uJR3YJUtf40M X-Received: by 2002:a05:6820:16a0:b0:71b:40c:9d5c with SMTP id 006d021491bc7-71b3942fb61mr32600122eaf.29.1796186674670; Tue, 01 Dec 2026 20:44:34 -0800 (PST) Received: from ?IPV6:2600:8804:5716:d800::d500? ([2600:8804:5716:d800::d500]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71b38015c51sm27085982eaf.3.2026.12.01.20.44.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 20:44:33 -0800 (PST) Message-ID: <8c827a28-e424-4a32-8c16-e8389c5c69ce@gmail.com> Date: Tue, 1 Dec 2026 22:44:31 -0600 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND] usb: mtu3: keep interrupts disabled in gadget completion callbacks To: Alan Stern Cc: Chunfeng Yun , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stable@kernel.org References: <20261130-usb-mtu3-callbacks-irqs-off-v1-1-b3180defb60c@gmail.com> <449e050f-4dab-4403-b507-f20514863b26@rowland.harvard.edu> Content-Language: en-US From: Ryan Brue In-Reply-To: <449e050f-4dab-4403-b507-f20514863b26@rowland.harvard.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_204436_200927_D0A95EF2 X-CRM114-Status: GOOD ( 21.16 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-4.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Alan, thanks for the look. On 11/30/26 12:18 PM, Alan Stern wrote: > This seems like a strange approach. > > Yes, interrupts certainly should be disabled when the request's > completion routine is called. But why explicitly disable bottom halves? > And besides, doesn't spin_lock_irqsave() disable bottom halves already? Not in the sense that matters here. spin_lock_irqsave() turns interrupts off, but it leaves softirq_count() at zero, and mtu3_irq() is a threaded handler (no primary handler) since 13118959cb1a. So the completion runs in task context with interrupts off and neither hardirq_count() nor softirq_count() set. netif_rx() checks exactly those two counts, and when both are zero it does its own local_bh_disable()/local_bh_enable(). local_bh_enable() with interrupts disabled is the WARN that 625dd9076e35 intended to fix:   WARNING: kernel/softirq.c:430 at __local_bh_enable_ip+0x17c/0x188     netif_rx     rx_complete [u_ether]     usb_gadget_giveback_request     mtu3_req_complete     ...     mtu3_irq     irq_thread_fn Disabling bottom halves explicitly, outside the irqsave, means netif_rx() sees softirq_count() set and leaves BH alone. The NET_RX softirq it raises then runs at our local_bh_enable(), after interrupts are back on. > Also, why should a networking gadget depend on some particular BH > setting when the completion routine runs? Different UDC drivers will > behave in different ways, and the gadget driver has to work with all of > them. The only real guarantee is the one stated in the API, namely, > that interrupts will be disabled. If the gadget wants more, it has to > take the additional actions itself. The UDC driver isn't responsible. > > Alan Stern I agree that the API only promises interrupts disabled, but I don't think u_ether can take those actions itself. Called with interrupts off from task context, it can't call netif_rx(), and it can't wrap the call in its own local_bh_disable()/local_bh_enable() either, because that hits the same assertion. It would have to defer the receive path to a work item or similar. The callbacks used to run in hardirq context, where all of this is fine. They stopped doing so when mtu3 moved to a threaded handler. For force-threaded handlers the IRQ core already brackets the handler with local_bh_disable()/local_bh_enable() (irq_forced_thread_fn()) for this reason. mtu3 threads its handler voluntarily, so it doesn't get that. dwc3 had the same problem and fixed it the same way in the controller, in 84918a89d6ef ("usb: dwc3: gadget: Let the interrupt handler disable bottom halves."), which this follows. Also, the BH part is already in mainline: 625dd9076e35 (in v7.4-rc5) switched mtu3_irq() to spin_lock_bh(). That made the callbacks run with interrupts enabled, which breaks the guarantee you quote: u_serial's console callback takes a lock that printk takes with spin_lock_irqsave() on the same CPU. This patch only restores interrupts-off and keeps the BH disabling. If you'd rather see the gadget side changed instead, I can look at that, but mtu3 would still need this fix, since 625dd9076e35 breaks the interrupts-disabled guarantee on its own (my bad :|). Best regards, Ryan Brue