All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Felipe Balbi <felipe.balbi@linux.intel.com>
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: Mon, 26 Mar 2018 13:32:35 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1803261319530.21764-100000@netrider.rowland.org> (raw)

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.

Alan Stern
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-03-26 17:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26 17:32 Alan Stern [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-27  6:59 Felipe Balbi
2018-03-26 17:44 Yavuz, Tuba
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=Pine.LNX.4.44L0.1803261319530.21764-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.