All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Yijing Wang <wangyijing@huawei.com>
Cc: linux-pci@vger.kernel.org, rajatja@google.com,
	linux@roeck-us.net, rjw@rjwysocki.net
Subject: Re: [PATCH v2 0/2] Fix a deadlock for aer and pciehp driver
Date: Thu, 30 Jul 2015 16:20:26 -0500	[thread overview]
Message-ID: <20150730212026.GK9640@google.com> (raw)
In-Reply-To: <1437124592-2070-1-git-send-email-wangyijing@huawei.com>

On Fri, Jul 17, 2015 at 05:16:30PM +0800, Yijing Wang wrote:
> Yijing Wang (2):
>   PCI: Use a local mutex instead of pci_bus_sem to avoid deadlock
>   PCI: Lock pci_slot_mutex when traverse bus->slots

Applied to pci/hotplug for v4.3 with changelogs as follows, thanks!

commit b37795cdcc42286f78711311943af38a615ea17c
Author: Yijing Wang <wangyijing@huawei.com>
Date:   Fri Jul 17 17:16:31 2015 +0800

    PCI: Protect pci_bus->slots with pci_slot_mutex, not pci_bus_sem
    
    Rajat Jain reported a deadlock when PCIe hot-add and AER recovery happen at
    the same time:
    
    thread 1:
    
      pciehp_enable_slot
        pciehp_configure_device
          pci_bus_add_devices
            pci_bus_add_device
              device_attach
                device_lock(dev)                       # acquire device lock
                ...
                pciehp_probe
                  init_slot
                    pci_hp_register
                      pci_create_slot
                        down_write(pci_bus_sem)        # deadlock here
    
    thread 2:
    
      aer_isr_one_error
        aer_process_err_device
          do_recovery
            broadcast_error_message(..., report_error_detected)
              pci_walk_bus(..., cb=report_error_detected, ...)
                down_read(&pci_bus_sem)                # acquire pci_bus_sem
                report_error_detected(dev)             # cb()
                  device_lock(dev)                     # deadlock here
    
    Previously, the bus->devices and bus->slots list were protected by
    pci_bus_sem.  In pci_create_slot(), we held it for writing so we could
    add to the bus->slots list.
    
    Add a new local pci_slot_mutex to protect bus->slots.  Hold pci_bus_sem for
    reading while searching the bus->devices list.
    
    [bhelgaas: changelog]
    Link: http://lkml.kernel.org/r/CAA93t1qpPqbih+UB0McA_d_+2rVaNkXsinAUxYzK9+JXSS+L-g@mail.gmail.com
    Reported-by: Rajat Jain <rajatja@google.com>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Yijing Wang <wangyijing@huawei.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

commit 4ea786b8f6734a706bc4c2f84c2a2bbc77845487
Author: Yijing Wang <wangyijing@huawei.com>
Date:   Fri Jul 17 17:16:32 2015 +0800

    PCI: Hold pci_slot_mutex while searching bus->slots list
    
    Previously, pci_setup_device() and similar functions searched the
    pci_bus->slots list without any locking.  It was possible for another
    thread to update the list while we searched it.
    
    Add pci_dev_assign_slot() to search the list while holding pci_slot_mutex.
    
    [bhelgaas: changelog]
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Yijing Wang <wangyijing@huawei.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

  parent reply	other threads:[~2015-07-30 21:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  9:16 [PATCH v2 0/2] Fix a deadlock for aer and pciehp driver Yijing Wang
2015-07-17  9:16 ` [PATCH v2 1/2] PCI: Use a local mutex instead of pci_bus_sem to avoid deadlock Yijing Wang
2015-07-24  3:07   ` Guenter Roeck
2015-07-24  4:08     ` wangyijing
2015-07-17  9:16 ` [PATCH v2 2/2] PCI: Lock pci_slot_mutex when traverse bus->slots Yijing Wang
2015-07-18  3:50 ` [PATCH v2 0/2] Fix a deadlock for aer and pciehp driver Guenter Roeck
2015-07-30 21:20 ` Bjorn Helgaas [this message]
2015-07-31  1:37   ` Guenter Roeck
2015-07-31 15:31     ` Bjorn Helgaas
2015-08-10 19:29 ` Bjorn Helgaas
2015-08-11  1:07   ` wangyijing

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=20150730212026.GK9640@google.com \
    --to=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rajatja@google.com \
    --cc=rjw@rjwysocki.net \
    --cc=wangyijing@huawei.com \
    /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.