linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ming.lei@canonical.com (Ming Lei)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 0/4] USB: HCD/EHCI: giveback of URB in tasklet context
Date: Wed, 12 Jun 2013 19:33:03 +0800	[thread overview]
Message-ID: <CACVXFVPSTLm9E55YLTJ51f-d0a6tkUnncPn2cfU2BtjNx8+f=g@mail.gmail.com> (raw)
In-Reply-To: <3473222.45jKxS1jDK@linux-5eaq.site>

On Wed, Jun 12, 2013 at 6:19 PM, Oliver Neukum <oliver@neukum.org> wrote:
> On Wednesday 12 June 2013 18:11:34 Ming Lei wrote:
>> On Wed, Jun 12, 2013 at 5:11 PM, Oliver Neukum <oliver@neukum.org> wrote:
>> > On Tuesday 11 June 2013 15:10:03 Alan Stern wrote:
>> >> In order to prevent this from happening, you would have to change the
>> >> spin_lock() call in the completion handler to spin_lock_irqsave().
>> >> Furthermore, you will have to audit every USB driver to make sure that
>> >> all the completion handlers get fixed.
>> >
>> > Yes. However, it can be done mechanically. And we know only
>> > the handlers for complete need to be fixed.
>>
>> I am wondering if the change is needed since timer function is still
>> run in softirq context instead of hard irq.
>>
>> Looks Alan concerned that one USB interface driver may have another
>> hard interrupt handler involved. Is there such kind of USB driver/device
>> in tree?
>
> No. Suppose a USB network driver.
> The complete() handler is written on the assumption that interrupts are off.
> So it takes a spinlock from the network subsystem. It does so with spin_lock()

Looks I misses the case, but IMO, it might not be very common, generally
subsystem provides API for drivers to do something(handle rx/report tx) inside
complete(), and seldom exports subsystem-wide lock directly to drivers.
API has no context info, and should have called spin_lock_irqrestore().

>
> Other network drivers also take the lock. And they may take it from an IRQ handler.
> If such an IRQ interrupts the tasklet complete() is running in, the CPU will deadlock.

Looks no usbnet drivers hold subsystem(network) locks in its complete().
Both the locks held are per device/per skb list. In usbnet_bh(), there
is one, eg.
netif_rx(), which is a API and disables local IRQ.

>
> The danger is not interrupt handlers in the same driver but IRQ handlers of _other_
> drivers (PCI, ...) a lock is shared with.

Right, so generally drivers which spin_lock(subsystem lock) in complete()
might be affected.

>
> You need to go through all USB drivers and change every spin_lock() that goes
> for a lock that is exported to a spin_lock_irqsave()

Yes, that is the safest way.

Thanks,
--
Ming Lei

      reply	other threads:[~2013-06-12 11:33 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-09 15:18 [RFC PATCH 0/4] USB: HCD/EHCI: giveback of URB in tasklet context Ming Lei
2013-06-09 15:18 ` [RFC PATCH 1/4] USB: HCD: support " Ming Lei
2013-06-09 15:58   ` Alan Stern
2013-06-10  8:12     ` Ming Lei
2013-06-10  8:43   ` Oliver Neukum
2013-06-10  9:23     ` Ming Lei
2013-06-10  9:31       ` Oliver Neukum
2013-06-10  9:51         ` Ming Lei
2013-06-09 15:18 ` [RFC PATCH 2/4] USB: EHCI: don't release ehci->lock if URB giveback " Ming Lei
2013-06-09 16:06   ` Alan Stern
2013-06-10  9:10     ` Ming Lei
2013-06-09 15:18 ` [RFC PATCH 3/4] USB: EHCI: improve interrupt qh unlink Ming Lei
2013-06-09 15:18 ` [RFC PATCH 4/4] USB: EHCI: support running URB giveback in tasklet context Ming Lei
2013-06-09 15:48 ` [RFC PATCH 0/4] USB: HCD/EHCI: giveback of URB " Alan Stern
2013-06-10  6:05   ` Ming Lei
2013-06-10 14:03     ` Alan Stern
2013-06-10 14:12       ` Oliver Neukum
2013-06-10 15:33         ` Alan Stern
2013-06-10 15:37       ` Ming Lei
2013-06-10 17:36         ` Alan Stern
2013-06-10 18:52           ` Steven Rostedt
2013-06-10 20:47             ` Alan Stern
2013-06-10 20:54               ` Steven Rostedt
2013-06-11  8:40                 ` Ming Lei
2013-06-10 20:51           ` Alan Stern
2013-06-11  6:19             ` Ming Lei
2013-06-11  5:40           ` Ming Lei
2013-06-11  7:18             ` Oliver Neukum
2013-06-11  8:14               ` Ming Lei
2013-06-11  8:49                 ` Oliver Neukum
2013-06-11  9:27                   ` Ming Lei
2013-06-11 10:51                     ` Oliver Neukum
2013-06-11 11:19                       ` Ming Lei
2013-06-11 19:10             ` Alan Stern
2013-06-12  2:43               ` Ming Lei
2013-06-12  6:41                 ` Ming Lei
2013-06-12  7:45                 ` Thomas Gleixner
2013-06-13  2:25                   ` Ming Lei
2013-06-13 14:54                     ` Alan Stern
2013-06-13 18:47                       ` Greg Kroah-Hartman
2013-06-13 19:41                         ` Alan Stern
2013-06-13 20:08                           ` Steven Rostedt
2013-06-13 21:09                             ` Alan Stern
2013-06-13 22:24                               ` Steven Rostedt
2013-06-13 23:08                                 ` Alan Stern
2013-06-14  1:27                               ` Ming Lei
2013-06-14  0:35                           ` Greg Kroah-Hartman
2013-06-14  1:53                             ` Ming Lei
2013-06-14  6:05                               ` Greg Kroah-Hartman
2013-06-14 10:05                                 ` Ming Lei
2013-06-14  1:37                           ` Ming Lei
2013-06-14  3:24                           ` Ming Lei
2013-06-14 14:56                             ` Alan Stern
2013-06-14 15:15                               ` Ming Lei
2013-06-14 20:23                                 ` Alan Stern
2013-06-14 21:09                                   ` Thomas Gleixner
2013-06-15  1:49                                   ` Ming Lei
2013-06-14  2:03                       ` Ming Lei
2013-06-12 14:35                 ` Alan Stern
2013-06-12 15:10                   ` Oliver Neukum
2013-06-13  3:41                   ` Ming Lei
2013-06-13 15:05                     ` Alan Stern
2013-06-12  9:11               ` Oliver Neukum
2013-06-12 10:11                 ` Ming Lei
2013-06-12 10:19                   ` Oliver Neukum
2013-06-12 11:33                     ` Ming Lei [this message]

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='CACVXFVPSTLm9E55YLTJ51f-d0a6tkUnncPn2cfU2BtjNx8+f=g@mail.gmail.com' \
    --to=ming.lei@canonical.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 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).