From: Felipe Balbi <balbi@kernel.org>
To: John Stultz <john.stultz@linaro.org>
Cc: Tejas Joglekar <tejas.joglekar@synopsys.com>,
Yang Fei <fei.yang@intel.com>,
Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>,
YongQin Liu <yongqin.liu@linaro.org>,
Andrzej Pietrasiewicz <andrzej.p@collabora.com>,
Thinh Nguyen <thinhn@synopsys.com>,
Linux USB List <linux-usb@vger.kernel.org>
Subject: Re: dwc3 inconsistent gadget connection state?
Date: Fri, 03 Jul 2020 12:54:45 +0300 [thread overview]
Message-ID: <87o8ow7wka.fsf@kernel.org> (raw)
In-Reply-To: <CALAqxLWAvvHGo1RYef1fJ_k65WqHAPCDhLfehO6_j_f8E2jB7Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2905 bytes --]
Hi,
John Stultz <john.stultz@linaro.org> writes:
> I've been tripping over an issue on my HiKey960 where with the usb-c
> gadget cable connected, the gadget code doesn't consistently seem to
> initialize properly. I had rarely seen this behavior previously, but
> more recently it has become more frequent and annoying.
>
> Usually, unplugging and replugging the USB-C cable would get things
> working again (but that's not helpful in test labs).
>
> I annotated a bunch of code trying to understand what was going on and
> I narrowed down the difference in the good and bad case to a dwc3
> reset interrupts happening after usb_gadget_probe_driver() completes.
> In the good case, we see the reset interrupts, and in the failed case
> we don't.
>
> [ 16.491953] JDB: usb_gadget_probe_driver
> [ 16.495938] JDB: udc_bind_to_driver
> [ 16.499555] JDB: dwc3_gadget_start irq: 65 revision: 1429417994
> [ 16.503803] JDB: __dwc3_gadget_ep_enable
> [ 16.507791] JDB: __dwc3_gadget_ep_enable
> [ 16.511715] JDB: dwc3_gadget_enable_irq
> [ 16.515582] JDB: usb_udc_connect_control
> [ 16.519510] JDB: usb_gadget_connect
> <in the bad case, this is all we see, the gadget device doesn't come up>
> [ 16.811010] JDB: dwc3_gadget_interrupt
> [ 16.814783] JDB: dwc3_gadget_reset_interrupt
> [ 16.819047] JDB: dwc3_reset_gadget
> [ 16.823935] JDB: dwc3_gadget_interrupt
> [ 16.827686] JDB: __dwc3_gadget_ep_enable
> [ 16.831611] JDB: __dwc3_gadget_ep_enable
> [ 16.994477] JDB: dwc3_gadget_interrupt
> [ 16.998246] JDB: dwc3_gadget_reset_interrupt
> [ 17.002519] JDB: dwc3_reset_gadget
> [ 17.005922] JDB: usb_gadget_udc_reset
> [ 17.062422] JDB: usb_gadget_set_state state: 5
> [ 17.067069] JDB: dwc3_gadget_interrupt
> [ 17.070823] JDB: __dwc3_gadget_ep_enable
> [ 17.074745] JDB: __dwc3_gadget_ep_enable
> [ 17.170898] JDB: usb_gadget_set_state state: 6
> [ 17.195605] JDB: usb_gadget_set_state state: 7
> [ 17.200179] JDB: __dwc3_gadget_ep_enable
> [ 17.204118] JDB: __dwc3_gadget_ep_enable
> [ 17.208057] JDB: usb_gadget_vbus_draw
> [ 17.211721] JDB: usb_gadget_set_state state: 7
> <in the good case everything is happy here>
>
>
> This sounds a bit like the issue in the comment here:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/dwc3/gadget.c?h=v5.8-rc3#n3143
>
> However, I've tried calling dwc3_gadget_reset_interrupt() and
> dwc3_reset_gadget() at the tail end of dwc3_gadget_start() but that
> doesn't seem to help.
>
> I was curious if you or anyone else had any thoughts on how to debug
> this further?
Try enabling dwc3 tracepoints and collecting working and failing
cases. If I were to guess, I would say there's a small race condition
between setting pullup and the transceiver sending the VBUS_VALID signal
to dwc3.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2020-07-03 9:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 21:44 dwc3 inconsistent gadget connection state? John Stultz
2020-07-03 2:55 ` Jun Li
2020-07-03 3:08 ` John Stultz
2020-07-03 7:46 ` Jun Li
2020-07-03 6:15 ` John Stultz
2020-07-03 7:57 ` Anurag Kumar Vulisha
2020-08-05 5:32 ` John Stultz
2020-07-03 9:54 ` Felipe Balbi [this message]
2020-07-04 5:51 ` John Stultz
2020-07-04 14:38 ` Felipe Balbi
2020-07-07 3:56 ` John Stultz
2020-07-07 10:43 ` Felipe Balbi
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=87o8ow7wka.fsf@kernel.org \
--to=balbi@kernel.org \
--cc=andrzej.p@collabora.com \
--cc=anurag.kumar.vulisha@xilinx.com \
--cc=fei.yang@intel.com \
--cc=john.stultz@linaro.org \
--cc=linux-usb@vger.kernel.org \
--cc=tejas.joglekar@synopsys.com \
--cc=thinhn@synopsys.com \
--cc=yongqin.liu@linaro.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;
as well as URLs for NNTP newsgroup(s).