From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796057707; b=oKqhA3u8138TOYfCvHevcxgP/i993lLET/lKvisVxDg+FUYd9tDitt9dlQVOyO2Uq4/F 9RekboGEKP8DpWJV97R82YmxKCa46j5m6OBPgcY/XVnoFIJijtv09FCXs8WhSLcp41JsL zCc+2ra8R+Lv88ikSXs2/1+OjLR+HcXGiuWZRj4dN4lCXDsfpaua3OgDvYhXrhrCI/uDT EMQKHll/uFj5hgEMHmvUa30a1k3CZKvdC3ki6oUf0YU48tkA7PvMyLIdE088F49zheVdH /02zKKclovggqI+QuNbxgCd0sP2TpJnivDobkP6n3qoUzeSyuF8L7+1g9caOAI9plbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796057707; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Mwf/5wQih0lw5VBJEKSHLX4/nENpED04b8/t4AzRqDw=; b=f1KAl0mps6AwYAR/lKyOzN3e2Ssqbbwbq2fXBejiKWMHfgxNp0xZVPfz+CBniti8AVve 4D/e5ljEX9aBko6c83nID0Px6frKFZWTRrjnG50FkqpBZWY/W3cgGiaojTKupMcVzcmH7 WsdjCNGLZEY6XT9RrCiffXOwqbsE0LiLhF1auftitckmXyY2tusrlKyhJMUzX05rAlWK3 Dj2FYYAVK+g/6XiqUpVZRCYJZU1IOfGVvu7Z6iwYAdua7beeVdRvmAQBGDjD0tTN4faCi +/6Gcd+825yYt4qWcQEYodcTufhbOITpzoIDhoi0aU4HhZ4zTgiBueMq7KZpyacW09g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kqtOYVe6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC7A606A32C for ; Mon, 30 Nov 2026 16:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kqtOYVe6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E01FC1F00933; Mon, 30 Nov 2026 16:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796057707; bh=Mwf/5wQih0lw5VBJEKSHLX4/nENpED04b8/t4AzRqDw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kqtOYVe6wiEH6C+S1TSCA8i6mWQF4ankLnucLEnVy9nRvyI+goEQ9EoIkZ6QDEHU8 oCXubnh2e5Er66N5MgrWlShRbQKZPssi9wVb5OchL4JFOg9M3x7dadQY9Gqrp/e3JP anEXNqxNWjJ58KHaOI41sZCHD7fkbeoqtFIXkYfVmSszzRjBlEmxXW+ji46DKqWaQW ObFRmAjAb7bq/F4cghZ1f6eod2Jzpx36eeOt1sAxq7dFPznbEYq7Z8py/i0XMtc1K2 zn+91o5N+qEdLLdsNHJXOe7oNDXh70mVFHen/ioDqTVDCcE7Gp9LspaoIvocm7FEsg mTfUUTWcNjBLA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RESEND] usb: mtu3: keep interrupts disabled in gadget completion callbacks Reply-To: sashiko-reviews@lists.linux.dev To: "Ryan Brue" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261130-usb-mtu3-callbacks-irqs-off-v1-1-b3180defb60c@gmail.com> References: <20261130-usb-mtu3-callbacks-irqs-off-v1-1-b3180defb60c@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 16:55:05 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > 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. >=20 > 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. >=20 > 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. >=20 > 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 completi= on > callbacks ran with interrupts enabled; with this change, none of about > 16,000 did, with no lockdep report and every copy intact. >=20 > Fixes: 625dd9076e35 ("usb: mtu3: don't run gadget completion callbacks wi= th interrupts disabled") > Cc: stable@kernel.org > Signed-off-by: Ryan Brue Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-usb-mtu3-c= allbacks-irqs-off-v1-1-b3180defb60c@gmail.com?part=3D1