mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v3] usb: dwc3: core: Fix RAM interface getting stuck during enumeration
Date: Thu, 15 Oct 2026 08:48:03 +0530	[thread overview]
Message-ID: <526b4857-4a4e-4ebc-a367-bdcf9a9c9a53@oss.qualcomm.com> (raw)
In-Reply-To: <atAuSs9VTveGwzpy@vbox>



On 10/15/2026 7:42 AM, Thinh Nguyen wrote:
> On Wed, Oct 14, 2026, Krishna Kurapati wrote:
>>
>>
>> On 10/14/2026 7:14 AM, Thinh Nguyen wrote:
>>> On Tue, Oct 13, 2026, Krishna Kurapati wrote:
>>>>
>>>>
>>>> On 9/29/2026 10:49 AM, Krishna Kurapati wrote:
>>>>> During plug-in/plug-out test cases, it is sometimes seen that no events
>>>>> are generated by the controller and all CSR register reads give "0" and
>>>>> CSR_Timeout bit gets set indicating that CSR reads/writes are timing out
>>>>> or timed out.
>>>>>
>>>>> The issue comes up on different instnaces of enumeration on different
>>>>> platforms. On SM8550, the debug log is as follows:
>>>>>
>>>>> Prepared a TRB on ep0out and did start transfer to get set
>>>>> address request from host:
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421006: dwc3_gadget_ep_cmd: ep0out:
>>>>> cmd 'Start Transfer' [406] params 00000000 efffa000 00000000 -->
>>>>> status: Successful
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421196: dwc3_event: event (0000c040):
>>>>> ep0out: Transfer Complete (sIL) [Setup Phase]
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421197: dwc3_ctrl_req: Set
>>>>> Address(Addr = 01)
>>>>>
>>>>> An XFER NRDY is received on ep0in for zero length status phase and
>>>>> a Start Transfer was done on ep0in with 0-length packet in 2 Stage
>>>>> status phase:
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421249: dwc3_event: event (000020c2):
>>>>> ep0in: Transfer Not Ready [00000000] (Not Active) [Status Phase]
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421266: dwc3_prepare_trb: ep0in: trb
>>>>> ffffffc00fcfd000 (E0:D0) buf 00000000efffa000 size 0 ctrl 00000c33
>>>>> sofn 00000000 (HLcs:SC:status2)
>>>>>
>>>>> <...>-7191    [000] D..1.    66.421387: dwc3_gadget_ep_cmd: ep0in: cmd
>>>>> 'Start Transfer' [406] params 00000000 efffa000 00000000 -->status:
>>>>> Successful
>>>>>
>>>>> A bus reset was then received directly after 500 msec. Software never
>>>>> got the cmd complete for the start transfer done in status phase. Here
>>>>> the RAM interface is stuck. So host issues a bus reset as link is
>>>>> idle for 500 msec:
>>>>>
>>>>> <...>-7191    [000] D..1.    66.935603: dwc3_event: event (00000101):
>>>>> Reset [U0]
>>>>>
>>>>> Then software sees that it is in status phase and we issue an ENDXFER
>>>>> on ep0in and it gets timedout waiting for the CMDACT to go '0':
>>>>>
>>>>> <...>-7191    [000] D..1.    66.958249: dwc3_gadget_ep_cmd: ep0in: cmd
>>>>> 'End Transfer' [10508] params 00000000 00000000 00000000 --> status:
>>>>> Timed Out
>>>>>
>>>>> Upon debug with Synopsys, the root cause is as follows:
>>>>>
>>>>> During any transfer, if the data is not successfully transmitted,
>>>>> then a Done (with failure) handshake is returned, so that the BMU
>>>>> can re-attempt the same data again by rewinding its data pointers.
>>>>>
>>>>> But, if the USB IN is a 0-length payload (which is what is happening
>>>>> in this case - 2 stage status phase of set_address), then there is no
>>>>> need to rewind the pointers and the Done (with failure) handshake is
>>>>> not returned for failure case. This keeps the Request-Done interface
>>>>> busy till the next Done handshake. The MAC sends the 0-length payload
>>>>> again when the host requests. If the transmission is successful this
>>>>> time, the Done (with success) handshake is provided back. Otherwise,
>>>>> it repeats the same steps again.
>>>>>
>>>>> If the cable is disconnected or if the Host aborts the transfer on 3
>>>>> consecutive failed attempts, the Request-Done handshake is not
>>>>> complete. This keeps the interface busy.
>>>>>
>>>>> The subsequent RAM access cannot proceed until the above pending
>>>>> transfer is complete. This results in failure of any access to RAM
>>>>> address locations. Many of the EndPoint commands need to access the
>>>>> RAM and they would fail to complete successfully.
>>>>>
>>>>> Furthermore when cable removal happens, this would not generate a
>>>>> disconnect event and the "connected" flag remains true always blockin
>>>>> suspend.
>>>>>
>>>>> Synopsys confirmed that the issue is present on all USB3 devices and
>>>>> as a workaround, suggested to re-initialize device mode.
>>>>>
>>>>> Signed-off-by: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
>>>>
>>>>
>>>> Thinh, Can you help provide your review on this patch.
>>>>
>>>
>>> Hi Krishna,
>>>
>>> If the CSR_Timeout bit is set, why not check GSTS.CSRTimeout directly
>>> instead of indirectly checking DEPCMD type mismatch?
>>>
>>
>> As per discussion on [1], implemented this checking of DEPCMD registers. Let
>> me know if reading GSTS is a better option here. Will send v4 accordingly.
> 
> At the time, my understanding was that all register reads return 0 in
> this state as noted in that conversation. However, based on your commit
> message and the databook, GSTS is still accessible and CSRTimeout is
> set. Also, on CSR timeout, the read data is residue from a previous read
> and isn't guaranteed to be 0. So the DEPCMD read back isn't reliable.
> 
> Can you check GSTS.CSRTimeout after the CMDACT polling instead?
> Something like this:
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index ee837235630a..ff4957a7311e 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -283,6 +283,8 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned int cmd,
>   	return ret;
>   }
>   
> +static void dwc3_schedule_err_recovery(struct dwc3 *dwc);
> +
>   /**
>    * dwc3_send_gadget_ep_cmd - issue an endpoint command
>    * @dep: the endpoint to which the command is going to be issued
> @@ -432,6 +434,14 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
>   		cmd_status = -ETIMEDOUT;
>   	}
>   
> +	reg = dwc3_readl(dwc, DWC3_GSTS);
> +	if (reg & DWC3_GSTS_CSR_TIMEOUT) {
> +		dwc3_writel(dwc, DWC3_GSTS, DWC3_GSTS_CSR_TIMEOUT);
> +		ret = -ETIMEDOUT;
> +		cmd_status = -ETIMEDOUT;
> +		dwc3_schedule_err_recovery(dwc);
> +	}
> +
>   skip_status:
>   	trace_dwc3_gadget_ep_cmd(dep, cmd, params, cmd_status);
>   

I don't have the apparatus to reproduce this issue at my end currently 
and extremely difficult to reproduce at customer end. Will send this 
diff along with your suggested-by tag if that is fine.

> 
>>
>>> Also, shouldn't we return an error code instead of success if need to
>>> schedule recovery?
>>>
>> I think that is done while queueing recovery work:
>> dwc->err_state = DWC3_ERR_RECOVERY;
>>
> 
> That only blocks new requests. The current call still returns 0, so the
> caller still sees the command as success.
> 

ACK.

Regards,
Krishna,

      reply	other threads:[~2026-10-15  3:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260929051941epcas5p27a5c69151937b9105660941776cda819@epcas5p2.samsung.com>
2026-09-29  5:19 ` Krishna Kurapati
2026-09-29  6:45   ` Selvarasu Ganesan
2026-09-29  8:35     ` Krishna Kurapati
2026-09-29 11:02       ` Selvarasu Ganesan
2026-09-29 17:50         ` Krishna Kurapati
2026-10-13  8:40   ` Krishna Kurapati
2026-10-14  1:44     ` Thinh Nguyen
2026-10-14 10:58       ` Krishna Kurapati
2026-10-15  2:12         ` Thinh Nguyen
2026-10-15  3:18           ` Krishna Kurapati [this message]

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=526b4857-4a4e-4ebc-a367-bdcf9a9c9a53@oss.qualcomm.com \
    --to=krishna.kurapati@oss.qualcomm.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®