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 DF14D1F4CA9; Tue, 26 Aug 2025 13:40:02 +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=1756215603; cv=none; b=g6iiW+Hat5KnxYv2aCsH/ttuSl43UZWNXJPM+uCsM/F1pnyRAye+e8tcEXQcc/QLazKCP8huScfTp+cbNuQVu3aEyX66RkGoHIJkLoNQdHh/MUYDjDxT3Msdu911aUXEK3pOL1vQD+kx2ar5GE8/+tHHD2yhXRULVA4pbpkOgXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756215603; c=relaxed/simple; bh=GUnfJXnZoxxQr2e3fXLUIJXB+UNqHnezqH2urso/nwo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gPw65Lay4VgEhmeNpk6mAQw2grAC0OnYsY6dwFPwoRq6JyrH9tHzGafWPTweEKhbp97GJZJ3one+sw5ZsYF+HHLbfWpoWRvHdMCvgHdw8mXxBTbhHWc121zUg586GZn6OYpVIIB1I3Iq7CyrO0KVD/uN7zKlDn/PBsTVpqmBd9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PfBswuD2; 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="PfBswuD2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 447E2C4CEF1; Tue, 26 Aug 2025 13:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756215602; bh=GUnfJXnZoxxQr2e3fXLUIJXB+UNqHnezqH2urso/nwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PfBswuD2tgBEtyM9bA0IjzjcR4eVfK5pPq5JBR42WKPvGN/mHtXVd5EKiEFCsYzzm DR4ykTTKM8Jv4VA2iZBoUNVWY59Fls7G8M5Fd30HD+SHvV0rhhqhVF5plhlafw8Vuj 9Co/JUBFiuCUb67Tml/nnKJLyTRqphqY/HUbDEzw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yehowshua Immanuel , Drew Hamilton , Sasha Levin Subject: [PATCH 5.15 065/644] usb: musb: fix gadget state on disconnect Date: Tue, 26 Aug 2025 13:02:36 +0200 Message-ID: <20250826110948.110387786@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110946.507083938@linuxfoundation.org> References: <20250826110946.507083938@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.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: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_gadget.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1909,6 +1909,7 @@ static int musb_gadget_stop(struct usb_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 */ schedule_delayed_work(&musb->irq_work, 0); @@ -2017,6 +2018,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;