From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8DE12EF9CE; Tue, 22 Jul 2025 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753193248; cv=none; b=Qgh/2gHVl/1PyTm5B+AnZMf1037QXLzURtiVIYw65LprCJGKNogma+oYTuwQti+KEX1WtMo82m6j079w8VSzf7KGWlJeNtgesXJMjxYrcvjqEJb1WiLALfhG8aQJ1E3JnISs75kjhM8HcVSwB5tcYLDIgEwuO1Z0G6xQuNTfO8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753193248; c=relaxed/simple; bh=RoAb8Uui/kGRYJaTAnNFzdAtkt40zw3dBMXF2AWaWzw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nKZZ/tAjWhrpVRcw1PrZz/6fi3YplamtE3ivFVoeMOJvO8g0oldXYfKXrPzBB2JXXIoCHPr5g7OjMjnPt1CAAFZpmY/s7SsDYdw+Ilw2VHEzDq4OCGqkKpdpNDeKAXeYuuFB0odgZj+QvW5F2R8uSVZ7RNGc11g1VynOpxJkS9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xLSu2Ypr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xLSu2Ypr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47EF6C4CEF1; Tue, 22 Jul 2025 14:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753193248; bh=RoAb8Uui/kGRYJaTAnNFzdAtkt40zw3dBMXF2AWaWzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xLSu2YprvSHKR4lrxn6e6ZGEN3vW+l3TmqxkTKOZ4d/zCO7o7OULBoqjFKK8bGZ4Y je0fK/kmoyN+4Y+gt0o7wFjBQXwRSO/bUKOrO/pyfDfgHo9XFSL/1cDJEn1WEWIx85 NzNSDDjmY2WNGaDAXZ/axwh9fZS8618t8BwgqFHk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yehowshua Immanuel , Drew Hamilton Subject: [PATCH 6.15 007/187] usb: musb: fix gadget state on disconnect Date: Tue, 22 Jul 2025 15:42:57 +0200 Message-ID: <20250722134346.032139290@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250722134345.761035548@linuxfoundation.org> References: <20250722134345.761035548@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Drew Hamilton commit 67a59f82196c8c4f50c83329f0577acfb1349b50 upstream. When unplugging the USB cable or disconnecting a gadget in usb peripheral mode with echo "" > /sys/kernel/config/usb_gadget//UDC, /sys/class/udc/musb-hdrc.0/state does not change from USB_STATE_CONFIGURED. Testing on dwc2/3 shows they both update the state to USB_STATE_NOTATTACHED. Add calls to usb_gadget_set_state in musb_g_disconnect and musb_gadget_stop to fix both cases. Fixes: 49401f4169c0 ("usb: gadget: introduce gadget state tracking") Cc: stable@vger.kernel.org Co-authored-by: Yehowshua Immanuel Signed-off-by: Yehowshua Immanuel Signed-off-by: Drew Hamilton Link: https://lore.kernel.org/r/20250701154126.8543-1-drew.hamilton@zetier.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_gadget.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 6869c58367f2..caf4d4cd4b75 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1913,6 +1913,7 @@ static int musb_gadget_stop(struct usb_gadget *g) * gadget driver here and have everything work; * that currently misbehaves. */ + usb_gadget_set_state(g, USB_STATE_NOTATTACHED); /* Force check of devctl register for PM runtime */ pm_runtime_mark_last_busy(musb->controller); @@ -2019,6 +2020,7 @@ void musb_g_disconnect(struct musb *musb) case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_IDLE: musb_set_state(musb, OTG_STATE_B_IDLE); + usb_gadget_set_state(&musb->g, USB_STATE_NOTATTACHED); break; case OTG_STATE_B_SRP_INIT: break; -- 2.50.1