mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration
@ 2024-12-23  4:25 Roy Luo
  2024-12-23  6:51 ` André Draszik
  0 siblings, 1 reply; 2+ messages in thread
From: Roy Luo @ 2024-12-23  4:25 UTC (permalink / raw)
  To: royluo, Thinh.Nguyen, gregkh, linux-usb, linux-kernel
  Cc: badhri, andre.draszik, peter.griffin

The UDC state in sysfs (/sys/class/udc/<udc>/state) should accurately
reflect the current state of the USB Device Controller.

Currently, the UDC state is not handled consistently during gadget
disconnection. While the disconnect interrupt path correctly sets the
state to "not-attached", manual deconfiguration leaves the state in
"configured", misrepresenting the actual situation.

This commit ensures consistent UDC state handling by setting the state to
"not-attached" after manual deconfiguration. This accurately reflects the
UDC's state and provides a consistent behavior regardless of the
disconnection method.

Signed-off-by: Roy Luo <royluo@google.com>
---
 drivers/usb/dwc3/gadget.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 83dc7304d701..fb4f6487c4ce 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2740,6 +2740,8 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
 	__dwc3_gadget_stop(dwc);
 	spin_unlock_irqrestore(&dwc->lock, flags);
 
+	usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED);
+
 	return ret;
 }
 

base-commit: 4bbf9020becbfd8fc2c3da790855b7042fad455b
-- 
2.47.1.613.gc27f4b7a9f-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration
  2024-12-23  4:25 [PATCH v1] usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration Roy Luo
@ 2024-12-23  6:51 ` André Draszik
  0 siblings, 0 replies; 2+ messages in thread
From: André Draszik @ 2024-12-23  6:51 UTC (permalink / raw)
  To: Roy Luo, Thinh.Nguyen, gregkh, linux-usb, linux-kernel
  Cc: badhri, peter.griffin

On Mon, 2024-12-23 at 04:25 +0000, Roy Luo wrote:
> The UDC state in sysfs (/sys/class/udc/<udc>/state) should accurately
> reflect the current state of the USB Device Controller.
> 
> Currently, the UDC state is not handled consistently during gadget
> disconnection. While the disconnect interrupt path correctly sets the
> state to "not-attached", manual deconfiguration leaves the state in
> "configured", misrepresenting the actual situation.
> 
> This commit ensures consistent UDC state handling by setting the state to
> "not-attached" after manual deconfiguration. This accurately reflects the
> UDC's state and provides a consistent behavior regardless of the
> disconnection method.
> 
> Signed-off-by: Roy Luo <royluo@google.com>
> ---

Reviewed-by: André Draszik <andre.draszik@linaro.org>
Tested-by: André Draszik <andre.draszik@linaro.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-23  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-23  4:25 [PATCH v1] usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration Roy Luo
2024-12-23  6:51 ` André Draszik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®