Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Ian May <ian.may@canonical.com>
To: linux-pci@vger.kernel.org
Subject: [PATCH 2/2] PCIe hotplug interrupt and AER pci_slot_mutex deadlock
Date: Mon, 15 Jun 2020 09:32:50 -0500	[thread overview]
Message-ID: <20200615143250.438252-3-ian.may@canonical.com> (raw)
In-Reply-To: <20200615143250.438252-1-ian.may@canonical.com>

In the AER recovery code path, pci_bus_error_reset acquires the pci_slot_mutex,
unlock and relock in call to pci_slot_reset around controller reset to lock in
same order as the hotplug code path.

        Hotplug                                AER
----------------------------       ---------------------------
down_read(&ctrl->reset_lock)	   mutex_lock(&pci_slot_mutex)
mutex_lock(&pci_slot_mutex)	   down_write(&ctrl->reset_lock)

Signed-off-by: Ian May <ian.may@canonical.com>
---
 drivers/pci/pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e32c5a1a706e..4eeca8b18664 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5229,6 +5229,7 @@ static int pci_slot_reset(struct pci_slot *slot, int probe)
 
 	if (!probe)
 	{
+		mutex_unlock(&pci_slot_mutex);
 		slot->hotplug->ops->reset_lock(slot->hotplug);
 		pci_slot_lock(slot);
 	}
@@ -5241,6 +5242,7 @@ static int pci_slot_reset(struct pci_slot *slot, int probe)
 	{
 		pci_slot_unlock(slot);
 		slot->hotplug->ops->reset_unlock(slot->hotplug);
+		mutex_lock(&pci_slot_mutex);
 	}
 
 	return rc;
-- 
2.25.1


      parent reply	other threads:[~2020-06-15 14:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 14:32 [PATCH 0/2] Hotplug interrupt and AER recovery deadlocks Ian May
2020-06-15 14:32 ` [PATCH 1/2] PCIe hotplug interrupt and AER deadlock with reset_lock and device_lock Ian May
2020-06-15 18:56   ` Lukas Wunner
2020-06-16 17:13     ` Ian May
2020-07-17  5:20       ` Lukas Wunner
     [not found]         ` <CAE1ug=a8PJpKh0Jx2ZZxo5kwQvvK883xs+mzyMWbW8T1oqyKDg@mail.gmail.com>
2020-08-01 16:14           ` Lukas Wunner
2020-07-14 23:58     ` Bjorn Helgaas
2020-06-15 14:32 ` Ian May [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=20200615143250.438252-3-ian.may@canonical.com \
    --to=ian.may@canonical.com \
    --cc=linux-pci@vger.kernel.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