Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752533AbaAORib (ORCPT ); Wed, 15 Jan 2014 12:38:31 -0500 Received: from mail-ig0-f179.google.com ([209.85.213.179]:64694 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbaAORi1 (ORCPT ); Wed, 15 Jan 2014 12:38:27 -0500 Date: Wed, 15 Jan 2014 10:38:23 -0700 From: Bjorn Helgaas To: "Rafael J. Wysocki" Cc: Yinghai Lu , "Rafael J. Wysocki" , Gu Zheng , Guo Chao , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Mika Westerberg , Myron Stowe , Benjamin Herrenschmidt , linux-scsi@vger.kernel.org, Matthew Garrett , Konrad Rzeszutek Wilk Subject: Re: [Update][PATCH 8/9] powerpc / eeh_driver: Use global PCI rescan-remove locking Message-ID: <20140115173823.GA24030@google.com> References: <1385429290-25397-1-git-send-email-yinghai@kernel.org> <20440867.YaQfKrcfsQ@vostro.rjw.lan> <4447911.Q1f9tEzrXs@vostro.rjw.lan> <1476201.kR505WbUas@vostro.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1476201.kR505WbUas@vostro.rjw.lan> 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 On Wed, Jan 15, 2014 at 02:36:36PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > Subject: powerpc / eeh_driver: Use global PCI rescan-remove locking > > Race conditions are theoretically possible between the PCI device > addition and removal in the PPC64 PCI error recovery driver and > the generic PCI bus rescan and device removal that can be triggered > via sysfs. > > To avoid those race conditions make PPC64 PCI error recovery driver > use global PCI rescan-remove locking around PCI device addition and > removal. > > Signed-off-by: Rafael J. Wysocki > --- > > The previous version had wrong function names in the last hunk, sorry about > that. I replaced the previous version and re-pushed the pci/locking branch, thanks! > > Rafael > > --- > arch/powerpc/kernel/eeh_driver.c | 19 ++++++++++++++++--- > 1 file changed, 16 insertions(+), 3 deletions(-) > > Index: linux-pm/arch/powerpc/kernel/eeh_driver.c > =================================================================== > --- linux-pm.orig/arch/powerpc/kernel/eeh_driver.c > +++ linux-pm/arch/powerpc/kernel/eeh_driver.c > @@ -369,7 +369,9 @@ static void *eeh_rmv_device(void *data, > edev->mode |= EEH_DEV_DISCONNECTED; > (*removed)++; > > + pci_lock_rescan_remove(); > pci_stop_and_remove_bus_device(dev); > + pci_unlock_rescan_remove(); > > return NULL; > } > @@ -416,10 +418,13 @@ static int eeh_reset_device(struct eeh_p > * into pcibios_add_pci_devices(). > */ > eeh_pe_state_mark(pe, EEH_PE_KEEP); > - if (bus) > + if (bus) { > + pci_lock_rescan_remove(); > pcibios_remove_pci_devices(bus); > - else if (frozen_bus) > + pci_unlock_rescan_remove(); > + } else if (frozen_bus) { > eeh_pe_dev_traverse(pe, eeh_rmv_device, &removed); > + } > > /* Reset the pci controller. (Asserts RST#; resets config space). > * Reconfigure bridges and devices. Don't try to bring the system > @@ -429,6 +434,8 @@ static int eeh_reset_device(struct eeh_p > if (rc) > return rc; > > + pci_lock_rescan_remove(); > + > /* Restore PE */ > eeh_ops->configure_bridge(pe); > eeh_pe_restore_bars(pe); > @@ -462,6 +469,7 @@ static int eeh_reset_device(struct eeh_p > pe->tstamp = tstamp; > pe->freeze_count = cnt; > > + pci_unlock_rescan_remove(); > return 0; > } > > @@ -618,8 +626,11 @@ perm_error: > eeh_pe_dev_traverse(pe, eeh_report_failure, NULL); > > /* Shut down the device drivers for good. */ > - if (frozen_bus) > + if (frozen_bus) { > + pci_lock_rescan_remove(); > pcibios_remove_pci_devices(frozen_bus); > + pci_unlock_rescan_remove(); > + } > } > > static void eeh_handle_special_event(void) > @@ -692,6 +703,7 @@ static void eeh_handle_special_event(voi > if (rc == 2 || rc == 1) > eeh_handle_normal_event(pe); > else { > + pci_lock_rescan_remove(); > list_for_each_entry_safe(hose, tmp, > &hose_list, list_node) { > phb_pe = eeh_phb_pe_get(hose); > @@ -703,6 +715,7 @@ static void eeh_handle_special_event(voi > eeh_pe_dev_traverse(pe, eeh_report_failure, NULL); > pcibios_remove_pci_devices(bus); > } > + pci_unlock_rescan_remove(); > } > } > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-pci" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- 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/