linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux USB <linux-usb@vger.kernel.org>,
	Tuba Yavuz <tuba@ece.ufl.edu>
Subject: [1/2] usb: gadget: udc: core: update usb_ep_queue() documentation
Date: Tue, 27 Mar 2018 09:59:08 +0300	[thread overview]
Message-ID: <87y3iem2bn.fsf@linux.intel.com> (raw)

Hi,

Alan Stern <stern@rowland.harvard.edu> writes:
> On Mon, 26 Mar 2018, Felipe Balbi wrote:
>
>> Mention that ->complete() should never be called from within
>> usb_ep_queue().
>> 
>> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>> ---
>>  drivers/usb/gadget/udc/core.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
>> index 50988b21a21b..842814bc0e4f 100644
>> --- a/drivers/usb/gadget/udc/core.c
>> +++ b/drivers/usb/gadget/udc/core.c
>> @@ -238,6 +238,9 @@ EXPORT_SYMBOL_GPL(usb_ep_free_request);
>>   * arranges to poll once per interval, and the gadget driver usually will
>>   * have queued some data to transfer at that time.
>>   *
>> + * Note that @req's ->complete() callback must never be called from
>> + * within usb_ep_queue() as that can create deadlock situations.
>> + *
>
> I think this is highly questionable.  Certainly it was not David 
> Brownell's original intention; his dummy-hcd driver will sometimes 
> give back a request from within usb_ep_queue() -- and I believe he 
> wrote it that way in order to emulate a feature of his net2280 driver.
>
> In this particular case, the problem is that a driver acquires a 
> spinlock in its complete() routine, but then it holds that same 
> spinlock while submitting a request.  This is a bug; it should be fixed 
> in the driver.  The spinlock should be dropped while the request is 
> submitted.  I'm sure there are examples whether other drivers do this.

usb_ep_queue() can be called from atomic, there's no explicit
requirement that locks should be released. Either one case or the other
should be made explicit.

             reply	other threads:[~2018-03-27  6:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27  6:59 Felipe Balbi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-03-28 23:19 [1/2] usb: gadget: udc: core: update usb_ep_queue() documentation Yavuz, Tuba
2018-03-28  7:43 Felipe Balbi
2018-03-27 14:13 Alan Stern
2018-03-26 17:44 Yavuz, Tuba
2018-03-26 17:32 Alan Stern
2018-03-26 10:14 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=87y3iem2bn.fsf@linux.intel.com \
    --to=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=tuba@ece.ufl.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).