From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:56010 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbdKFJMh (ORCPT ); Mon, 6 Nov 2017 04:12:37 -0500 Subject: Patch "PCI: Avoid possible deadlock on pci_lock and p->pi_lock" has been added to the 4.9-stable tree To: bhelgaas@google.com, alexander.levin@verizon.com, gregkh@linuxfoundation.org Cc: , From: Date: Mon, 06 Nov 2017 10:11:44 +0100 Message-ID: <1509959504165247@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled PCI: Avoid possible deadlock on pci_lock and p->pi_lock to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: pci-avoid-possible-deadlock-on-pci_lock-and-p-pi_lock.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Mon Nov 6 10:07:36 CET 2017 From: Bjorn Helgaas Date: Sat, 7 Oct 2017 22:37:34 +0000 Subject: PCI: Avoid possible deadlock on pci_lock and p->pi_lock From: Bjorn Helgaas [ Upstream commit cdcb33f9824429a926b971bf041a6cec238f91ff ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/access.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -672,8 +672,9 @@ void pci_cfg_access_unlock(struct pci_de 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); Patches currently in stable-queue which might be from bhelgaas@google.com are queue-4.9/pci-msi-return-failure-when-msix_setup_entries-fails.patch queue-4.9/pci-avoid-possible-deadlock-on-pci_lock-and-p-pi_lock.patch