From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.231.136 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796186676; b=OLOr92K9u6c2oZW5Qhvzi9GYl6CrYxFrRnGThXWtELA/iddESVYbTxUEqyC/MmB6s+8U I/9QAPgcdoZJdPyqr7t74bTmeGX9icuy74eUmFKk97AQPaacCTe+np/Gu0woG9xWno4BL 7uJMxKCaQLohA86yK6LLtTb2uHcHgQIGWULW6A7wJljFJnpYVTNYQ083WBlzu+0bG6yVs IkEOue+7AXnLUFIZPB7StF7nBsu/o7G/mV3+MRjz6DL1cImexELvInUpngcKz+wLL+2yT YKFoO8GZuKVuJbVJ2BLp2Lwe2av+ULeqm9tZleZL5ui8CgGZkagtnbCJjx/jvNwZYSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796186676; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=n94dWlJRm2Re3ANC4gik8ZEsyDnCn+0FKHuVyiZcaOI=; b=BQmbA9x0AGCQ9Ie/rlFZ4zdnJOQp3c+0J+KvaJWPwOfqK9XDD1tig0lFgd1MY6W251hz 2/6TuhCbUZ+1eRGh1eImQq8PFcZ3wYtSwnTK5hqLli5joZeI5sf+HdbHDpLz+DCImjG2Y CbMYWxRkuYWdFMYRHrmxVdTwsxCbcOPvp2oT8QEhRU8nK5HLho4dHc5HNn7ouCb9YeM98 NieXfWGsMusSB8RfdQLp9rI5kb+BhGubyttultRLDQZrx+M7nvhF8l9OIqLJJt16b73yV gVpNfmodGIkJuwYDslZhOZwUGOtC53Sb2MNR6n77JmAob9FVYhaF7xwcypfKYmfh77Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G9o2pBA7; arc=none smtp.remote-ip=74.125.231.136 Received: from mail-oo2-f8.google.com (mail-oo2-f8.google.com [74.125.231.136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE9DB606A323 for ; Wed, 2 Dec 2026 04:44:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE9DB606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G9o2pBA7 Received: by mail-oo2-f8.google.com with SMTP id 006d021491bc7-71733a926edso1346115eaf.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=vger.kernel.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=G9o2pBA7/X0rLW4OlVlL8BWToUlM2l08qzdjKlVpEsnkmLE6Tvvezvrqzz0pQTCQbl FdRaG5ACIhgK3fmRCluCD5/MnDXrctDoyPJs1zmrrzz4J61XJpY8ACxdkSDd+YaVBMN5 JCZ4dZsIfQXMuFtGY1U93daWHPr7pvIUCXqWMQxuJSKg7pF2S6vZFOMofIL1LcgudGgA qCiWgqqhddp6d4yJ+RU+xrz8Pk0vX0KrX7flFVhUx0ht5ut8oXEzPe2E1EuNe7Gcrd3W Khwq4rPYU/3MyFGDSfUH+SemUkbX0Y0LayGsNmZtSPwEDiSgSgTPWRhfLKEw2riLAL8+ dw9w== 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=n94dWlJRm2Re3ANC4gik8ZEsyDnCn+0FKHuVyiZcaOI=; b=vPPd076ZgHTkTcSoBcd4qVWyBp9bbbHiDFGd7UQt+UZNyXTxpafnhMJ8llDFCIP+yx K2yUDaYeakpUZWf0AmA/twjEwNM9y4/zcdCYsTY0u7oGaJm07ZR/9k9U2K4TVpp991KE Or/UkKghNM8pLxk7EtEph8MPINX8A6xSQ7OBaIDVzl1QyAIjXS8PCooKaE+MiceZETSw 7bQt3R/+vNM4jyEYWP+MoUZ/Wk/dka/UFOW0zW/O//qRAMCZ+hon692MTbyQF+cqxHru 6prHKY4iZvW074DwsZ+fb0O6hpVEwXrDwSnbiT0j+SfhdHtU2S3AIA5ieHkoI6tugCzR 0HIQ== X-Forwarded-Encrypted: i=1; AL+hErFZXeszsPqpIgSLembtCuT8kNuZcqiEGH9Z+NY8J+r8rocYIVW7lgq6iMat9GVxhk1wTt7ujEqDqDPVnk4=@vger.kernel.org X-Gm-Message-State: APuU4Z9A2jnQDxxhQT01vRlHgAj9eq9W2Y/pIV3BxTY1kauV759LjAYF 5Qzx3zIKbT8TagJJYufGhowTSpD4iputzYn41dXy8tncVbvOr4zH2LKC X-Gm-Gg: AZFdTZcn25MlWgDa5onGfxL7FCYiGgI4qJ4e454pQwsE40FzEPmls+Bl6+/83qgTtq9 P7idwSLW6AH6NRyCiDV/ZSrm+PWKsU2ccWiKPJsUwslymhbrjfF6FuWZ/ffFUmKdGmPdXgaJgnn E3Sj/0ru9v08TnU1lYPD192LDlVq5ss2Fi5peOTYn0O13bsc/bnWF9gKKQsZGBuf6JCKTkAyfjr ZcWIdApu+6W4QOVesn/78ZcD3MCeUvxkF6/ONil5Yiw6458rvCfcCVTKvwJAzkwmPTIRE5yqcQh /nLpn5IFZJfVGC9rzTxSfHPGpsO7V3bYnXSrxcKoK4tH/26+MkIAyuqFXyr9grIfM56K3VbCFU7 CTMCJwheeeCS1CA+8oIpCR1Fmx3pzzhFBx8tVSGoO86qiKmeeB7D454VQKBfP9NoTmWMoDrBPIn DhuWrOYrFu56Y3dprEaeZ8oZbSzJj/fjSLmVEwKXlZiz4XLiW92MKPZlpEjKWo1o6nbVcul12kj 7pNwFwdb0UgWFfQSUhjRZ0rD0ZAwaeUiQDYIOjUAJMvicXfjNJYk4daliurimem3j2+d9n03A2z npuZHXPg8nnMLlGrncKbVyIaH01GAMxsuDP3rIYI6zJE 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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