public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Cc: linux-omap <linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-usb@vger.kernel.org"
	<linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: dwc3 gadget breaks on system suspend/resume
Date: Fri, 27 Jan 2017 17:47:22 +0200	[thread overview]
Message-ID: <87wpdg5wtx.fsf@linux.intel.com> (raw)
In-Reply-To: <8760l07dfh.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 12163 bytes --]


Hi,

(hmm, I didn't receive your reply in my intel inbox, only
gmail. Odd. Replying to myself here, but it should be on your reply,
rater).

Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> writes:
>> The previous commit c499ff71ff2a281366c6ec7a904c547d806cbcd1 is fine.
>
> okay. Then let's try to figure out what's going on. A diff of regdump
> before and after suspend/resume might start to give some clue about
> what's going on. DWC3 tracepoints should help too. Care to get those?
> BTW, is this dwc3 as host or peripheral?

You don't have any endpoints enabled:

-DALEPENA = 0x0000000f
+DALEPENA = 0x00000000

Your traces are peculiar:

    > irq/451-dwc3-2082  [000] d...   108.215104: dwc3_gadget: Disabling ep1in-bulk

okay, let's disable ep1in-bulk

    > irq/451-dwc3-2082  [000] d...   108.215106: dwc3_gadget_ep_cmd: ep1in-bulk: cmd 'End Transfer' [198920] params 00000000 00000000 00000000
    > irq/451-dwc3-2082  [000] d...   108.215109: dwc3_readl: addr fa89c200 value 00002500
    > irq/451-dwc3-2082  [000] d...   108.215114: dwc3_writel: addr fa89c838 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.215116: dwc3_writel: addr fa89c834 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.215118: dwc3_writel: addr fa89c830 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.215120: dwc3_writel: addr fa89c83c value 00030d08
    > irq/451-dwc3-2082  [000] d...   108.215123: dwc3_readl: addr fa89c83c value 00031908
    > irq/451-dwc3-2082  [000] d...   108.215125: dwc3_gadget: Command Complete --> 1
    > irq/451-dwc3-2082  [000] d...   108.215127: dwc3_gadget: (null): no resource available
    > irq/451-dwc3-2082  [000] d...   108.495119: dwc3_gadget_giveback: ep1in-bulk: req ed5cae80 length 0/4096 zsI ==> -108
    > irq/451-dwc3-2082  [000] d...   108.495123: dwc3_free_request: ep1in-bulk: req ed5cae80 length 0/4096 zsI ==> -108
    > irq/451-dwc3-2082  [000] d...   108.495127: dwc3_readl: addr fa89c720 value 00000000

read DALEPENA, already 0x00. How was ep1in-bulk even enabled???

    > irq/451-dwc3-2082  [000] d...   108.495130: dwc3_writel: addr fa89c720 value 00000000

clear bit for ep1in-bulk and write back the 0x00 you read. What gives??
Why is DALEPENA already zero here???? 

    > irq/451-dwc3-2082  [000] d...   108.495135: dwc3_gadget: Disabling ep1out-bulk
    > irq/451-dwc3-2082  [000] d...   108.495137: dwc3_gadget_ep_cmd: ep1out-bulk: cmd 'End Transfer' [133384] params 00000000 00000000 00000000
    > irq/451-dwc3-2082  [000] d...   108.495139: dwc3_readl: addr fa89c200 value 00002500
    > irq/451-dwc3-2082  [000] d...   108.495143: dwc3_writel: addr fa89c828 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495145: dwc3_writel: addr fa89c824 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495146: dwc3_writel: addr fa89c820 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495148: dwc3_writel: addr fa89c82c value 00020d08
    > irq/451-dwc3-2082  [000] d...   108.495151: dwc3_readl: addr fa89c82c value 00021908
    > irq/451-dwc3-2082  [000] d...   108.495153: dwc3_gadget: Command Complete --> 1
    > irq/451-dwc3-2082  [000] d...   108.495154: dwc3_gadget: (null): no resource available
    > irq/451-dwc3-2082  [000] d...   108.495258: dwc3_gadget_giveback: ep1out-bulk: req ed76d080 length 0/4096 zsI ==> -108
    > irq/451-dwc3-2082  [000] d...   108.495261: dwc3_free_request: ep1out-bulk: req ed76d080 length 0/4096 zsI ==> -108
    > irq/451-dwc3-2082  [000] d...   108.495264: dwc3_readl: addr fa89c720 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495266: dwc3_writel: addr fa89c720 value 00000000

same thing for ep1out-bulk. When you get a "Disabling epxxxx" message,
we not only clear DALEPENA (which shouldn't be zero, btw!), but we
also clear dep->flags unconditionally. Here's a blame of v4.7 for that
function:

72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  669) static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  670) {
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  671)        struct dwc3             *dwc = dep->dwc;
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  672)        u32                     reg;
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  673) 
7eaeac5c0e449 (Felipe Balbi              2015-07-20 14:46:15 -0500  674)        dwc3_trace(trace_dwc3_gadget, "Disabling %s", dep->name);
7eaeac5c0e449 (Felipe Balbi              2015-07-20 14:46:15 -0500  675) 
624407f96f134 (Sebastian Andrzej Siewior 2011-08-29 13:56:37 +0200  676)        dwc3_remove_requests(dwc, dep);
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  677) 
687ef9817df7e (Felipe Balbi              2014-04-16 10:30:33 -0500  678)        /* make sure HW endpoint isn't stalled */
687ef9817df7e (Felipe Balbi              2014-04-16 10:30:33 -0500  679)        if (dep->flags & DWC3_EP_STALL)
7a60855972f0d (Felipe Balbi              2014-09-24 14:19:52 -0500  680)                __dwc3_gadget_ep_set_halt(dep, 0, false);
687ef9817df7e (Felipe Balbi              2014-04-16 10:30:33 -0500  681) 
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  682)        reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  683)        reg &= ~DWC3_DALEPENA_EP(dep->number);
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  684)        dwc3_writel(dwc->regs, DWC3_DALEPENA, reg);
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  685) 
879631aa658be (Felipe Balbi              2011-09-30 10:58:47 +0300  686)        dep->stream_capable = false;
f9c56cdd3905c (Ido Shayevitz             2012-02-08 13:56:48 +0200  687)        dep->endpoint.desc = NULL;
c90bfaece97c1 (Felipe Balbi              2011-11-29 13:11:21 +0200  688)        dep->comp_desc = NULL;
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  689)        dep->type = 0;
879631aa658be (Felipe Balbi              2011-09-30 10:58:47 +0300  690)        dep->flags = 0;
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  691) 
aa7399744dd02 (Felipe Balbi              2015-07-20 14:48:13 -0500  692)        snprintf(dep->name, sizeof(dep->name), "ep%d%s",
aa7399744dd02 (Felipe Balbi              2015-07-20 14:48:13 -0500  693)                        dep->number >> 1,
aa7399744dd02 (Felipe Balbi              2015-07-20 14:48:13 -0500  694)                        (dep->number & 1) ? "in" : "out");
aa7399744dd02 (Felipe Balbi              2015-07-20 14:48:13 -0500  695) 
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  696)        return 0;
72246da40f371 (Felipe Balbi              2011-08-19 18:10:58 +0300  697) }


let's keep going, there's more...

    > irq/451-dwc3-2082  [000] d...   108.495280: dwc3_readl: addr fa89c704 value 80000000
    > irq/451-dwc3-2082  [000] d...   108.495283: dwc3_writel: addr fa89c704 value 80000000
    > irq/451-dwc3-2082  [000] d...   108.495287: dwc3_readl: addr fa89c700 value 004c098c
    > irq/451-dwc3-2082  [000] d...   108.495290: dwc3_writel: addr fa89c700 value 004c0804
    > irq/451-dwc3-2082  [000] d...   108.495292: dwc3_writel: addr fa89c40c value 00000004
    > irq/451-dwc3-2082  [000] d...   108.495295: dwc3_readl: addr fa89c408 value 80000100
    > irq/451-dwc3-2082  [000] d...   108.495297: dwc3_writel: addr fa89c408 value 00000100
    > irq/451-dwc3-2082  [000] d.H.   108.495342: dwc3_readl: addr fa89c40c value 00000010
    > irq/451-dwc3-2082  [000] d.H.   108.495347: dwc3_readl: addr fa89c408 value 00000100
    > irq/451-dwc3-2082  [000] d.H.   108.495349: dwc3_writel: addr fa89c408 value 80000100
    > irq/451-dwc3-2082  [000] d...   108.495374: dwc3_event: event 080311c6
    > irq/451-dwc3-2082  [000] d...   108.495378: dwc3_writel: addr fa89c40c value 00000004
    > irq/451-dwc3-2082  [000] d...   108.495381: dwc3_event: event 00000201
    > irq/451-dwc3-2082  [000] d...   108.495383: dwc3_readl: addr fa89c70c value 00006838
    > irq/451-dwc3-2082  [000] d...   108.495385: dwc3_readl: addr fa89c700 value 004c0804
    > irq/451-dwc3-2082  [000] d...   108.495388: dwc3_writel: addr fa89c700 value 004c0804
    > irq/451-dwc3-2082  [000] d...   108.495390: dwc3_readl: addr fa89c704 value 80000000
    > irq/451-dwc3-2082  [000] d...   108.495392: dwc3_writel: addr fa89c704 value 8c000000
    > irq/451-dwc3-2082  [000] d...   108.495394: dwc3_gadget: Enabling ep0out

... Enabling ep0out.

    > irq/451-dwc3-2082  [000] d...   108.495397: dwc3_gadget_ep_cmd: ep0out: cmd 'Set Endpoint Configuration' [1] params 80000200 00000500 00000000
    > irq/451-dwc3-2082  [000] d...   108.495399: dwc3_readl: addr fa89c200 value 00002500
    > irq/451-dwc3-2082  [000] d...   108.495401: dwc3_writel: addr fa89c808 value 80000200
    > irq/451-dwc3-2082  [000] d...   108.495403: dwc3_writel: addr fa89c804 value 00000500
    > irq/451-dwc3-2082  [000] d...   108.495405: dwc3_writel: addr fa89c800 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495406: dwc3_writel: addr fa89c80c value 00000401
    > irq/451-dwc3-2082  [000] d...   108.495409: dwc3_readl: addr fa89c80c value 00000001
    > irq/451-dwc3-2082  [000] d...   108.495411: dwc3_gadget: Command Complete --> 0

no writes to DALEPENA!

    > irq/451-dwc3-2082  [000] d...   108.495413: dwc3_gadget: Enabling ep0in
    > irq/451-dwc3-2082  [000] d...   108.495415: dwc3_gadget_ep_cmd: ep0in: cmd 'Set Endpoint Configuration' [1] params 80000200 02000500 00000000
    > irq/451-dwc3-2082  [000] d...   108.495416: dwc3_readl: addr fa89c200 value 00002500
    > irq/451-dwc3-2082  [000] d...   108.495419: dwc3_writel: addr fa89c818 value 80000200
    > irq/451-dwc3-2082  [000] d...   108.495420: dwc3_writel: addr fa89c814 value 02000500
    > irq/451-dwc3-2082  [000] d...   108.495423: dwc3_writel: addr fa89c810 value 00000000
    > irq/451-dwc3-2082  [000] d...   108.495425: dwc3_writel: addr fa89c81c value 00000401
    > irq/451-dwc3-2082  [000] d...   108.495428: dwc3_readl: addr fa89c81c value 00000001
    > irq/451-dwc3-2082  [000] d...   108.495429: dwc3_gadget: Command Complete --> 0

nor here! however we disabled ep0/1 on gadget_suspend:

0b0231aa246cb (Felipe Balbi              2014-10-07 10:19:23 -0500 2936) int dwc3_gadget_suspend(struct dwc3 *dwc)
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2937) {
9772b47a4c291 (Roger Quadros             2016-04-12 11:33:29 +0300 2938)        if (!dwc->gadget_driver)
9772b47a4c291 (Roger Quadros             2016-04-12 11:33:29 +0300 2939)                return 0;
9772b47a4c291 (Roger Quadros             2016-04-12 11:33:29 +0300 2940) 
7b2a0368bbc9b (Felipe Balbi              2013-12-19 13:43:19 -0600 2941)        if (dwc->pullups_connected) {
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2942)                dwc3_gadget_disable_irq(dwc);
7b2a0368bbc9b (Felipe Balbi              2013-12-19 13:43:19 -0600 2943)                dwc3_gadget_run_stop(dwc, true, true);
7b2a0368bbc9b (Felipe Balbi              2013-12-19 13:43:19 -0600 2944)        }
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2945) 
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2946)        __dwc3_gadget_ep_disable(dwc->eps[0]);
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2947)        __dwc3_gadget_ep_disable(dwc->eps[1]);
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2948) 
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2949)        dwc->dcfg = dwc3_readl(dwc->regs, DWC3_DCFG);
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2950) 
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2951)        return 0;
7415f17c9560c (Felipe Balbi              2012-04-30 14:56:33 +0300 2952) }

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  parent reply	other threads:[~2017-01-27 15:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 11:46 dwc3 gadget breaks on system suspend/resume Roger Quadros
     [not found] ` <54bdc1b7-69ed-d580-fd17-3e7499ac1c27-l0cyMroinI0@public.gmane.org>
2017-01-19 11:59   ` Felipe Balbi
     [not found]     ` <87a8anjm5z.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-19 12:16       ` Roger Quadros
     [not found]         ` <a0cc2705-b1f5-7b6e-d73c-ff9b525eead2-l0cyMroinI0@public.gmane.org>
2017-01-27 13:55           ` Roger Quadros
     [not found]             ` <e64bc4ee-1c71-d72c-cdc7-f5857f49a90e-l0cyMroinI0@public.gmane.org>
2017-01-27 14:17               ` Felipe Balbi
     [not found]                 ` <87inp07fkx.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-27 14:46                   ` Roger Quadros
     [not found]                     ` <57fbf2b6-3811-3202-0e69-7cf82662d50f-l0cyMroinI0@public.gmane.org>
2017-01-27 15:03                       ` Felipe Balbi
     [not found]                         ` <8760l07dfh.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-27 15:25                           ` Roger Quadros
2017-01-27 15:47                           ` Felipe Balbi [this message]
     [not found]                             ` <87wpdg5wtx.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-30 12:46                               ` Roger Quadros
     [not found]                                 ` <a91c7564-5bfa-c77f-8fa2-1c1b0bcfd815-l0cyMroinI0@public.gmane.org>
2017-01-30 12:59                                   ` Felipe Balbi
     [not found]                                     ` <87o9yo66w7.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-30 13:03                                       ` Roger Quadros
     [not found]                                         ` <19de4c77-0e95-f7b5-0f56-a705134fd4cc-l0cyMroinI0@public.gmane.org>
2017-01-30 13:16                                           ` Felipe Balbi
     [not found]                                             ` <87inow662n.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-30 13:47                                               ` Felipe Balbi
     [not found]                                                 ` <87d1f464mp.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-31 11:38                                                   ` Roger Quadros
     [not found]                                                     ` <90f70eb2-8b87-d33e-71cd-335c05c6f65a-l0cyMroinI0@public.gmane.org>
2017-01-31 12:03                                                       ` Felipe Balbi
     [not found]                                                         ` <87mve74esx.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-31 13:25                                                           ` Roger Quadros

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=87wpdg5wtx.fsf@linux.intel.com \
    --to=balbi-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rogerq-l0cyMroinI0@public.gmane.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