All of lore.kernel.org
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded.com (Sergei Shtylyov)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v1 2/6] USB: disable IRQs deliberately when calling complete()
Date: Tue, 18 Jun 2013 19:13:46 +0400	[thread overview]
Message-ID: <51C0792A.9030409@cogentembedded.com> (raw)
In-Reply-To: <1371567833-9077-3-git-send-email-ming.lei@canonical.com>

Hello.

On 18-06-2013 19:03, Ming Lei wrote:

> We disable local IRQs here in case of running complete() by
> tasklet to avoid possible deadlock because drivers may call
> spin_lock() to hold lock which might be acquired in one hard
> interrupt handler.

> The local_irq_save()/local_irq_restore() around complete()
> will be removed if current USB drivers have been cleaned up
> and no one may trigger the above deadlock situation when
> running complete() in tasklet.

> Cc: Oliver Neukum <oliver@neukum.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
>   drivers/usb/core/hcd.c |   23 ++++++++++++++++++++++-
>   1 file changed, 22 insertions(+), 1 deletion(-)

> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index a272968..09a8263 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1673,7 +1673,28 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
>
>   	/* pass ownership to the completion handler */
>   	urb->status = status;
> -	urb->complete (urb);
> +
> +	/*
> +	 * We disable local IRQs here in case of running complete() by
> +	 * tasklet to avoid possible deadlock because drivers may call
> +	 * spin_lock() to hold lock which might be acquired in one hard
> +	 * interrupt handler.
> +	 *
> +	 * The local_irq_save()/local_irq_restore() around complete()
> +	 * will be removed if current USB drivers have been cleaned up
> +	 * and no one may trigger the above deadlock situation when
> +	 * running complete() in tasklet.
> +	 */
> +	if (hcd_giveback_urb_in_bh(hcd)) {
> +		unsigned long flags;
> +
> +		local_irq_save(flags);
> +		urb->complete (urb);

    I guess you didn't run the patch thru scripts/checkpatch.pl, did you?
It would complain about the space before (.

WBR, Sergei

  reply	other threads:[~2013-06-18 15:13 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 15:03 [RFC PATCH v1 0/6] USB: HCD/EHCI: giveback of URB in tasklet context Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 1/6] USB: HCD: support " Ming Lei
2013-06-18 16:05   ` Alan Stern
2013-06-19  2:59     ` Ming Lei
2013-06-19 11:50       ` Ming Lei
2013-06-19 15:37       ` Alan Stern
2013-06-20  1:50         ` Ming Lei
2013-06-20 14:59           ` Alan Stern
2013-06-20 15:13             ` Ming Lei
2013-06-20 16:52               ` Alan Stern
2013-06-21  1:12                 ` Ming Lei
2013-06-21  4:46                   ` Ming Lei
2013-06-21  5:13                     ` Ming Lei
2013-06-21  8:33                   ` Oliver Neukum
2013-06-21  9:13                     ` Ming Lei
2013-06-21  9:20                       ` Oliver Neukum
2013-06-21  9:43                         ` Ming Lei
2013-06-21 10:09                           ` Ming Lei
2013-06-21 14:48                           ` Alan Stern
2013-06-21 16:12                             ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 2/6] USB: disable IRQs deliberately when calling complete() Ming Lei
2013-06-18 15:13   ` Sergei Shtylyov [this message]
2013-06-18 16:36   ` Alan Stern
2013-06-19  3:02     ` Ming Lei
2013-06-19 15:30       ` Alan Stern
2013-06-18 15:03 ` [RFC PATCH v1 3/6] USB: URB documentation: claim complete() may be run with IRQs enabled Ming Lei
2013-06-18 16:42   ` Alan Stern
2013-06-19  3:06     ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 4/6] USB: EHCI: don't release ehci->lock if URB giveback in tasklet context Ming Lei
2013-06-18 16:43   ` Alan Stern
2013-06-19  3:13     ` Ming Lei
2013-06-19 15:47       ` Alan Stern
2013-06-20  1:53         ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 5/6] USB: EHCI: improve interrupt qh unlink Ming Lei
2013-06-18 16:51   ` Alan Stern
2013-06-19  3:36     ` Ming Lei
2013-06-19 15:44       ` Alan Stern
2013-06-20  6:05         ` Ming Lei
2013-06-21 20:16           ` Alan Stern
2013-06-24  4:55             ` Ming Lei
2013-06-18 15:03 ` [RFC PATCH v1 6/6] USB: EHCI: support running URB giveback in tasklet context Ming Lei
2013-06-18 16:55   ` Alan Stern
2013-06-19  3:39     ` Ming Lei

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=51C0792A.9030409@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-arm-kernel@lists.infradead.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 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.