linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Felipe Balbi <felipe.balbi@linux.intel.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Roger Quadros <rogerq@ti.com>
Cc: Sam Protsenko <semen.protsenko@linaro.org>,
	Vincent Pelletier <plr.vincent@gmail.com>,
	linux-usb@vger.kernel.org, Praneeth Bajjuri <praneeth@ti.com>
Subject: usb: gadget: ffs: Fix BUG when userland exits with submitted AIO transfers
Date: Tue, 23 Oct 2018 16:22:24 +0200	[thread overview]
Message-ID: <e91f428b-6cec-6650-bf73-64a7a89b60de@metafoo.de> (raw)

On 06/29/2018 08:32 AM, Felipe Balbi wrote:
> 
> Hi,
> 
> Alan Stern <stern@rowland.harvard.edu> writes:
>> On Thu, 21 Jun 2018, Roger Quadros wrote:
>>
>>>>> Can we avoid the spin_lock() and the work-queue and call usb_ep_dequeue() directly from here?
>>>>>> What is the purpose of the spin_lock()?
>>>>
>>>> I agree that the lock doesn't seem to be necessary. But I believe the whole
>>>> thing is already running in non-sleeping context, even before the spinlock
>>>> is taken. So this wouldn't help much.
>>>>
>>>> Even the io_cancel() syscall takes a spinlock before invoking the cancel
>>>> function. So this issue is not exclusive to program termination.
>>>>
>>>> Are there any documented guidelines on which context usb_ep_dequeue() should
>>>> be able to be called in? The sleep in the dwc3 driver seems to be a recent
>>>> addition.
>>>
>>> drivers/usb/udc/gadget/core.c has the only documentation, but context is not mentioned there.
>>> Felipe, what do you suggest?
>>
>> As far as I remember, usb_ep_dequeue() is supposed to be more or less 
>> analogous to usb_ep_queue(); drivers should be allowed to call either 
>> routine in an atomic context.
> 
> Hmm, that's what I remember, but we don't have that documented and dwc3
> has a sleep in its dequeue, which I need to remove for other reasons
> anyway.
> 
> Can we get a patch updating documentation to make it clear that both
> queue and dequeue should be callable from any context?
> 

Felipe, for the DWC3 do you see an issue with moving the giveback and the
cleanup of the TRBs simply into END_TRANSFER interrupt? That seems to work
for me for fixing the issue, but I don't have a full understanding of all
the dependencies of the DWC3 gadget driver and don't know if it could
introduce other issues.

             reply	other threads:[~2018-10-23 14:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 14:22 Lars-Peter Clausen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-01-17 16:29 usb: gadget: ffs: Fix BUG when userland exits with submitted AIO transfers Evan Green
2019-01-16 23:56 Evan Green
2018-10-23 12:20 Lars-Peter Clausen
2018-09-27  2:31 He, Bo
2018-09-25 12:46 Vincent Pelletier
2018-08-02 14:23 Vincent Pelletier
2018-08-02  0:45 He, Bo
2018-08-01 15:03 Vincent Pelletier
2018-06-29  6:32 Felipe Balbi
2018-06-21 15:30 Alan Stern
2018-06-21 11:10 Roger Quadros
2018-06-21 10:52 Lars-Peter Clausen
2018-06-21  8:29 Roger Quadros
2018-06-19 13:20 Sam Protsenko
2018-06-14 13:23 Sam Protsenko
2018-06-13 11:05 Vincent Pelletier

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=e91f428b-6cec-6650-bf73-64a7a89b60de@metafoo.de \
    --to=lars@metafoo.de \
    --cc=felipe.balbi@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=plr.vincent@gmail.com \
    --cc=praneeth@ti.com \
    --cc=rogerq@ti.com \
    --cc=semen.protsenko@linaro.org \
    --cc=stern@rowland.harvard.edu \
    /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).