public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Looijmans <mike.looijmans@topic.nl>
To: Krishna Kurapati PSSNV <quic_kriskura@quicinc.com>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: gadget: Inform system of suspended state
Date: Tue, 4 Jun 2024 10:25:55 +0200	[thread overview]
Message-ID: <9473c090-a21b-4d11-a98d-6083547d9648@topic.nl> (raw)
In-Reply-To: <91b3af13-e723-4a49-b7f6-06f927c286c9@quicinc.com>

On 04-06-2024 08:45, Krishna Kurapati PSSNV wrote:
>
>
> On 6/4/2024 10:56 AM, 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.
>>
>>
>
> Hi Mike,
>
>  I may be wrong, but can you help understand the mechanism as to how 
> disconnect interrupt is generated in your targets. For example, on QC 
> SoC's, this happens when HS_PHY_CTRL reg VBUS_VALID bit is cleared and 
> cable is disconnected. This is because the vbus line is not routed to 
> controller. But from my calls with Synopsys previously, I remember 
> that the vbus line is routed to the controller as well for other OEMs. 
> In your SoC, what is the indication to controller that vbus is absent ?
>
The board I'm testing this on is an LS1028ARDB. Looking at the 
schematic, VBUS is routed to the chip. There's also an LED attached to 
it, which turns off when I unplug the cable.

In the devicetree, I can't see any hint of NXP-specific "glue" in the 
DWC3 entries, so it uses the controller "as is":

                         compatible = "fsl,ls1028a-dwc3", "snps,dwc3";
                         reg = <0x0 0x3100000 0x0 0x10000>;
                         snps,dis_rxdet_inp3_quirk;
                         snps,quirk-frame-length-adjustment = <0x20>;
                         snps,incr-burst-type-adjustment = <1>, <4>, 
<8>, <16>;

The "fsl,ls1028a-dwc3" keyword doesn't actually occur anywhere in the 
kernel, so it uses plain "snps,dwc3".


> Also, after this happens, do you see the next plug in working ?

Next plugin works, because of a "reset" event at that point that makes 
everything happy again.

The state remains in "configured" while the cable is out. Plugging the 
cable back in makes it revert to "default" first, then it goes back into 
"configured".

-- 
Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijmans@topic.nl
W: www.topic.nl




  reply	other threads:[~2024-06-04  8:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.c5f44c79-75b2-43c1-a791-806fe8b693cd@emailsignatures365.codetwo.com>
2024-06-03 13:13 ` [PATCH] usb: dwc3: gadget: Inform system of suspended state Mike Looijmans
2024-06-04  1:03   ` Thinh Nguyen
2024-06-04  5:26     ` Mike Looijmans
2024-06-04  6:45       ` Krishna Kurapati PSSNV
2024-06-04  8:25         ` Mike Looijmans [this message]
2024-06-04  8:52           ` Krishna Kurapati PSSNV
2024-06-04 23:06       ` Thinh Nguyen
2024-06-05 14:32         ` Mike Looijmans
2024-06-06  0:28           ` Thinh Nguyen
2024-06-06  5:52             ` Mike Looijmans
2024-06-06 15:11             ` Mike Looijmans
2024-06-06 20:21               ` Thinh Nguyen
2024-06-07  6:10                 ` Mike Looijmans
2024-06-07 22:57                   ` Thinh Nguyen
2024-06-11  4:59                     ` Mike Looijmans
2024-06-11  8:02                     ` Mike Looijmans
2024-06-13  0:32                       ` Thinh Nguyen
2024-06-13  8:51                         ` Mike Looijmans
2024-06-17 23:46                           ` Thinh Nguyen
2024-06-18  0:26                             ` Thinh Nguyen
2024-06-05 14:41         ` Mike Looijmans
2024-06-06  0:29           ` Thinh Nguyen
2026-03-05  9:45             ` Ravineet Singh
2026-03-06  2:06               ` Thinh Nguyen
2026-03-06 12:07                 ` Ravineet Singh
2026-03-06 23:05                   ` Thinh Nguyen
2026-03-09  9:52                     ` Ravineet Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9473c090-a21b-4d11-a98d-6083547d9648@topic.nl \
    --to=mike.looijmans@topic.nl \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=quic_kriskura@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox