lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 4 Jun 2024 23:06:30 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Mike Looijmans <mike.looijmans@...ic.nl>
CC: Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: dwc3: gadget: Inform system of suspended state

Hi,

On Tue, Jun 04, 2024, Mike Looijmans wrote:
> On 04-06-2024 03:03, Thinh Nguyen wrote:
> > Hi,
> > 
> > On Mon, Jun 03, 2024, Mike Looijmans wrote:
> > > When disconnecting the USB cable on an LS1028 device, nothing happens
> > > in userspace, which keeps thinking everything is still up and running.
> > > Turns out that the DWC3 controller only sends DWC3_DEVICE_EVENT_SUSPEND
> > > in that case, and not a DWC3_DEVICE_EVENT_DISCONNECT as one would
> > > expect. As a result, sysfs attribute "state" remains "configured"
> > > until something resets it.
> > > 
> > > Forward the "suspended" state to sysfs, so that the "state" at least
> > > changes into "suspended" when one removes the cable, and hence also
> > > matches the gadget's state when really suspended.
> > On disconnection, did you see disconnect interrupt? If so, it should
> > transition to USB_STATE_NOATTACHED. This change doesn't seem to directly
> > address your issue. Can you provide the driver tracepoints?
> 
> The device doesn't issue a disconnect event, I didn't have tracing enabled
> in the kernel but added some dev_info() calls to determine what was going
> on. Added this to dwc3_process_event_entry():
> 
> dev_info(dwc->dev, "event: 0x%x type=0x%x", event->raw, event->type.type);
> 
> When disconnecting the cable from the host, I see this:
> 
> [   50.841411] dwc3 3110000.usb: event: 0x6084 type=0x42
> [   50.841457] dwc3 3110000.usb: event: 0x4086 type=0x43
> [   50.841494] dwc3 3110000.usb: event: 0x6084 type=0x42
> [   50.841534] dwc3 3110000.usb: event: 0x4086 type=0x43
> [   50.841571] dwc3 3110000.usb: event: 0x4086 type=0x43
> [   52.650990] dwc3 3110000.usb: event: 0x30601 type=0x0
> 
> The "0x4086" and "0x6084" messages are endpoint events that occur all the
> time while connected. The last event is the "suspend" one. After that, total
> silence.
> 
> If you need traces, please point me to a description on how to obtain them.
> 
> 

Let me know if you run into issues following this instructions to
capture the tracepoints:
https://docs.kernel.org/driver-api/usb/dwc3.html#required-information

From the patch you provided, you only apply the change for the usb
suspend. But did your device go through system suspend? If that's the
case, then the dwc3 driver will cause a soft-disconnect. Currently that
will not prompt a state change. We need the tracepoint to know more
detail.

Until we have the tracepoints, you can experiment with this test patch.
If my suspiction is correct, then this may resolve your issue:

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 89fc690fdf34..29dbb889a0e2 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2682,6 +2682,8 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
         */
        ret = dwc3_gadget_run_stop(dwc, false);
 
+       usb_gadget_set_state(dwc->gadget, USB_STATE_NOTATTACHED);
+
        /*
         * Stop the gadget after controller is halted, so that if needed, the
         * events to update EP0 state can still occur while the run/stop


--

Thanks,
Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ