Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1562305 > unrolled thread

[PATCH] PCI: Avoid possible deadlock on pci_lock and p->pi_lock

Started byBjorn Helgaas <bhelgaas@google.com>
First post2017-01-19 00:50 +0100
Last post2017-01-19 00:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] PCI: Avoid possible deadlock on pci_lock and p->pi_lock Bjorn Helgaas <bhelgaas@google.com> - 2017-01-19 00:50 +0100

#1562305 — [PATCH] PCI: Avoid possible deadlock on pci_lock and p->pi_lock

FromBjorn Helgaas <bhelgaas@google.com>
Date2017-01-19 00:50 +0100
Subject[PATCH] PCI: Avoid possible deadlock on pci_lock and p->pi_lock
Message-ID<t189j-2dy-9@gated-at.bofh.it>
pci_lock is an IRQ-safe spinlock that protects all accesses to PCI
configuration space (see PCI_OP_READ() and PCI_OP_WRITE() in pci/access.c).

The pci_cfg_access_unlock() path acquires pci_lock, then p->pi_lock (inside
wake_up_all()).  According to lockdep, there is a possible path involving
snbep_uncore_pci_read_counter() that could acquire them in the reverse
order: acquiring p->pi_lock, then pci_lock, which could result in a
deadlock.  Lockdep details are in the bugzilla below.

Avoid the possible deadlock by dropping pci_lock before waking up any
config access waiters.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=192901
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/access.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index db239547fefd..68bd7201d8bc 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -684,8 +684,9 @@ void pci_cfg_access_unlock(struct pci_dev *dev)
 	WARN_ON(!dev->block_cfg_access);
 
 	dev->block_cfg_access = 0;
-	wake_up_all(&pci_cfg_wait);
 	raw_spin_unlock_irqrestore(&pci_lock, flags);
+
+	wake_up_all(&pci_cfg_wait);
 }
 EXPORT_SYMBOL_GPL(pci_cfg_access_unlock);
 

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web