From: Felipe Balbi <balbi@kernel.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Greg KH <gregkh@linuxfoundation.org>,
Mark Brown <broonie@kernel.org>, USB <linux-usb@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq
Date: Thu, 13 Oct 2016 10:51:59 +0300 [thread overview]
Message-ID: <87inswvg80.fsf@linux.intel.com> (raw)
In-Reply-To: <CAMz4ku+5h26qA4UDXi=WDcany6z_FAK=ie7w93nyDY9-wkz0hg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2191 bytes --]
Hi,
Baolin Wang <baolin.wang@linaro.org> writes:
> Hi,
>
> On 13 October 2016 at 15:02, Felipe Balbi <balbi@kernel.org> wrote:
>>
>> Hi,
>>
>> Baolin Wang <baolin.wang@linaro.org> writes:
>>> @@ -1742,6 +1791,17 @@ static int dwc3_gadget_stop(struct usb_gadget *g)
>>> dwc->gadget_driver = NULL;
>>> spin_unlock_irqrestore(&dwc->lock, flags);
>>>
>>> + /*
>>> + * Since the xHCI will share the same interrupt with gadget, thus when
>>> + * free the gadget irq, it will not shutdown this gadget irq line. Then
>>> + * the gadget driver can not handle the end transfer command complete
>>> + * event after free the gadget irq, which will hang the system to crash.
>>> + *
>>> + * So we should wait for the end transfer command complete event before
>>> + * free it to avoid this situation.
>>> + */
>>> + dwc3_wait_command_complete(dwc);
>>
>> this doesn't make sense. We have already masked all interrupts before
>> getting here. We have also, already, disabled all endpoints.
>
> No, you just mask the interrupts described in DEVTEN register, and you
> did not disable the endpoint command complete event.
True that
>> I'm thinking this is a bug in configfs interface of Gadget API, not
>> dwc3. The only reason for this to happen would be if we get to
>> ->udc_stop() with endpoints still enabled.
>>
>> Can you check if that's the case? i.e. can you check if any endpoints
>> are still enabled when we get here?
>
> No, it is not any endpoints are still enabled. Like I said in commit
> message, we will start end transfer command when disable the endpoint,
> if the end transfer command complete event comes after we have freed
> the gadget irq, it will trigger the interrupt line all the time to
> crash the system.
I see what the problem is. Databook tells us we *must* set CMDIOC when
issuing EndTransfer command and we should always wait for Command
Complete IRQ. However, we took a shortcut and just delayed for 100us
after issuing End Transfer.
It seems as if *that* should be fixed. We should start actually waiting
for Command Complete IRQ.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]
next prev parent reply other threads:[~2016-10-13 7:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-12 11:37 [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang
2016-10-13 7:02 ` Felipe Balbi
2016-10-13 7:34 ` Baolin Wang
2016-10-13 7:51 ` Felipe Balbi [this message]
2016-10-13 8:00 ` Baolin Wang
2016-10-13 9:55 ` Felipe Balbi
2016-10-13 10:56 ` Felipe Balbi
2016-10-13 11:16 ` Baolin Wang
2016-10-13 11:23 ` Felipe Balbi
2016-10-13 12:41 ` Baolin Wang
2016-10-13 13:34 ` Felipe Balbi
2016-10-14 7:03 ` Baolin Wang
2016-10-14 7:46 ` Felipe Balbi
2016-10-14 9:10 ` Baolin Wang
2016-10-14 9:50 ` Felipe Balbi
2016-10-14 14:36 ` Alan Stern
2016-10-17 8:10 ` 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=87inswvg80.fsf@linux.intel.com \
--to=balbi@kernel.org \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--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