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=1796308281; b=PCc+Gf/iGzEd1G4V8HuLgKL8CN2YpqKszXR2yy5xULeLFTbQ69w/mV26GL+rWiL298l3 aARH3TeHb9yogEG9WdH95GKMdjAfXQbD2jpM1jOXGHAFJx1Gun6FQqqr7hsOWdmAoqLMb 4HwsV1OatZ0a+VXU9pnTZtHXvPLIqF/4Tx2aD5lpqXUkLt1FO4Mc6A6EW1NYYT4MnbnCW ai6wdP1EujwWzSP7CeQFJYeKGZbUGCcInyoOt/2c0vz0sTAwp7l8+D0QIj7LQahOn2zwg /Wc95/T2SOfwft3R2U9zEaENuU2W+hYDx7u4FwHm9gfnZ4NMWoyxPDPyF3TjhBfsjCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308281; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=DAHNEgLHGh+iLDCOY34/sBl3YKReDLNeam4rEG/Nn3Q=; b=iqIXNS47dK3SKR7BGPkIVzmCK/n5VeMRSk4TTJzBbKodH8bi21kxw8M2cfZ1w7WnDSm9 xR6+fDsLxxJKDf4fbu5GOaW10Rxrjf3Z0DrNr8kIlk3j5miLpPQluyj7dW2eyIoEls/GV p5sJnogTjooqrxzciAam+/oN9cuSgQ/6f/KMfpA9PxmwYMD37BukwPqUyqAHhjMW2Y+32 /rwck7rRgSY3AJP+dNXKUdGtMdqbq9UI/Sg5rE/pXA9LaXHW1tEqMQjZmPqb4od9okyib PVQWrLJILqNo0DIwYfAzSribxk+SOA4inUYO1YE30tGtu7ZjfkJomQxfy+dcnXlCFBg== 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=FD89nr2D; 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 37AFB606A32D; Thu, 3 Dec 2026 14:31:20 +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=FD89nr2D Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3F4A1F00925; Thu, 3 Dec 2026 14:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796308280; bh=DAHNEgLHGh+iLDCOY34/sBl3YKReDLNeam4rEG/Nn3Q=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=FD89nr2D6tT9ycgH1doTKoTLgLcP7JmHvhYjMWbTpc8hwhGOk8Jfgzaz99enqsLTF 0r41Dztjr5HCeZSM34M7jUi2FKUE2ZnOs2o+Ha0PozXCDkKWEKtyzXL/PjZZ3kHcRd B8BEhaKzKf9PvJ6TfQolZCLZ5HQ68pt4IjQInBXxR8jmJxBztZa0BovgOftw4cFIko yCsc/OqKkrSlbwXEaDa49q62npXfG8VgnI7o+0V/tZamX/duf1Ygtbv/eZgq30FcBV MdlRlk8bBMoP8UZhmkeYtqNZU8t5mIl58rwMcRkxcKCn1hyi+JZz6s1F3SiWitwmxE 5nDODu3C3n0wA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] usb: gadget: midi2: serialize the IN endpoint transmit path Reply-To: sashiko-reviews@lists.linux.dev To: "Jaegyun Lee" Cc: linux-usb@vger.kernel.org, linux-sound@vger.kernel.org In-Reply-To: <20261203135832.3396094-1-dreams200260@gmail.com> References: <20261203135832.3396094-1-dreams200260@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:31:20 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] usb: gadget: midi2: unbounded IRQ-off tx_lock hold in f_midi2_tx_run() -- commit 4c531e02ef82b71c676e76246bc9dc99b92503af Author: Jaegyun Lee usb: gadget: midi2: serialize the IN endpoint transmit path This commit adds a per-endpoint spinlock (tx_lock) and work item (tx_work) to serialize IN endpoint transmission with request allocation and teardown, and defers transmission from IN completion handlers to system_highpri_wq. > diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/f= unction/f_midi2.c > index 75036d4d60b35..8f34204a620c7 100644 > --- a/drivers/usb/gadget/function/f_midi2.c > +++ b/drivers/usb/gadget/function/f_midi2.c [ ... ] > @@ -1052,6 +1054,26 @@ static void process_midi1_transmit(struct f_midi2 = *midi2) > } > } > =20 > +static void f_midi2_tx_run(struct f_midi2_usb_ep *usb_ep) > +{ > + unsigned long flags; > + > + if (!usb_ep->usb_ep) > + return; > + > + spin_lock_irqsave(&usb_ep->tx_lock, flags); > + if (usb_ep->ep) > + process_ump_transmit(usb_ep->ep); > + else > + process_midi1_transmit(usb_ep->card); > + spin_unlock_irqrestore(&usb_ep->tx_lock, flags); > +} [Severity: High] Can holding usb_ep->tx_lock with IRQs disabled across the entire transmit loop in f_midi2_tx_run() cause an indefinite IRQ-off stall? In altset 0, process_midi1_transmit() runs an unbounded loop draining four bytes per snd_ump_transmit() call and continues without queueing a request when a UMP packet does not convert to MIDI 1.0 (such as a Utility message). A concurrent writer in snd_rawmidi_kernel_write1() can refill the buffer faster than the loop drains it, keeping local IRQs off indefinitely and triggering an RCU stall or hard lockup while f_midi2_stop_eps() busy-spins on tx_lock. Even with valid streaming traffic, f_midi2_ep_in_complete() and f_midi2_midi1_ep_in_complete() call put_empty_request() without taking tx_lock, so cross-CPU completions can keep both transmit loops spinning with IRQs disabled for the duration of sustained streaming. Separately, f_midi2_stop_eps() holds ep_in->tx_lock across f_midi2_drop_reqs(ep_out) for the unrelated OUT endpoint, and f_midi2_start_eps() holds it across f_midi2_alloc_ep_reqs() while allocating up to 32 requests. Bounding the work done per tx_lock hold and re-queueing tx_work when more data remains would avoid holding IRQs off indefinitely. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203135832.3396= 094-1-dreams200260@gmail.com?part=3D1