Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754497AbbETTr4 (ORCPT ); Wed, 20 May 2015 15:47:56 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:33560 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754126AbbETTrx (ORCPT ); Wed, 20 May 2015 15:47:53 -0400 Date: Wed, 20 May 2015 14:47:49 -0500 From: Bjorn Helgaas To: Yinghai Lu , Jeff Kirsher Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org Subject: e1000e pci_disable_link_state_locked() issues Message-ID: <20150520194749.GA10210@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2224 Lines: 48 I think we have some issues with the e1000e usage of pci_disable_link_state_locked(), which Yinghai added with 9f728f53dd70 ("PCI/e1000e: Add and use pci_disable_link_state_locked()"). That fixed an AER deadlock in the following path, where pci_bus_sem is held by pci_walk_bus(), and we deadlocked when we tried to re-acquire it in pci_disable_link_state(): do_recovery broadcast_error_message(..., report_slot_reset) pci_walk_bus down_read(&pci_bus_sem) cb(...) # report_slot_reset report_slot_reset dev->driver->err_handler->slot_reset # e1000_io_slot_reset e1000_io_slot_reset e1000e_disable_aspm pci_disable_link_state down_read(&pci_bus_sem) 9f728f53dd70 fixed that by changing e1000e_disable_aspm() to use pci_disable_link_state_locked() instead, which assumes pci_bus_sem is already held. That's fine for the e1000_io_slot_reset() path, where pci_bus_sem really *is* held. But e1000e_disable_aspm() is also called from e1000_probe() and __e1000_resume(), and in those paths, we *don't* hold pci_bus_sem. In effect, the caller of pci_disable_link_state_locked() is promising that pci_bus_sem is held, and __pci_disable_link_state() relies on that promise for its locking. But e1000e isn't upholding its end of the bargain. I'm not 100% sure __pci_disable_link_state() actually *needs* that locking: it is only called from a driver, and it should be impossible for a device or any upstream bridge to go away while a driver is bound to it. If somebody wanted to analyze this further and propose a patch to remove the locking (if it seems safe), that would be great. But in any case, __pci_disable_link_state() should be able to rely on its callers following the rules, so I'd like to see an e1000e change to use pci_disable_link_state() from the paths where pci_bus_sem is not held. Bjorn -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/