From patchwork Tue Aug 7 16:10:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 175705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id AFF8F2C00AE for ; Wed, 8 Aug 2012 02:22:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755757Ab2HGQVY (ORCPT ); Tue, 7 Aug 2012 12:21:24 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:58061 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755753Ab2HGQVX (ORCPT ); Tue, 7 Aug 2012 12:21:23 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so3858495ghr.19 for ; Tue, 07 Aug 2012 09:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=kcr9QDa7nzAPPV1ZAPiT+flCj/ZRANRIgvWmcrAqSA4=; b=ZxWdZovk7fqob6xUNJc/mlbSogQwamELVn8hJCGg1y+U5KIE6iMMr55dE5kCN6MBqQ v6h2rny6xCbaflwIxi7kEIB9++phy8jEgliHBEUoo3+sHSWxW9o3vtWfpFbWhMNmSdEH QIheQWotzGOSbKBWTev3uIRxeO7f4s7pg6LE+cDxogpC350XLcgt/lHcXff8aw5gyLtM KprSTX6muEMNpb/9dfNOKPLyj7WDfvFuiLoia7ApaVI1SPkGtmzTJp8gJ7GRb6+NDAD1 CUnKSKRD4L5a8UbVzEBRlJJN3wof/W8h60DbVVlMzoTkLMKpelBvKrEZgF89IsCLjs0b 8EJw== Received: by 10.66.78.196 with SMTP id d4mr27135670pax.76.1344356482409; Tue, 07 Aug 2012 09:21:22 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pt2sm11429362pbb.58.2012.08.07.09.21.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 09:21:21 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , Yinghai Lu , Greg KH , Kenji Kaneshige Cc: Jiang Liu , Taku Izumi , "Rafael J . Wysocki" , Yijing Wang , Xinwei Hu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH v1 19/22] PCI/x86: enable PCI bus lock mechanism for x86 platforms Date: Wed, 8 Aug 2012 00:10:59 +0800 Message-Id: <1344355862-2726-20-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1344355862-2726-1-git-send-email-jiang.liu@huawei.com> References: <1344355862-2726-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch turns on PCI bus lock mechanism for x86 platforms. It also enhances x86 specific PCI implementation to support PCI bus lock. Signed-off-by: Jiang Liu --- arch/x86/pci/acpi.c | 6 +++++- arch/x86/pci/common.c | 12 ++++++++++++ drivers/pci/Kconfig | 3 +-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 2bb885a..c68dbdf 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -414,7 +414,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) * Maybe the desired pci bus has been already scanned. In such case * it is unnecessary to scan the pci bus with the given domain,busnum. */ - bus = pci_find_bus(domain, busnum); + bus = __pci_get_and_lock_bus(domain, busnum, + PCI_BUS_STATE_STOPPING - 1); if (bus) { /* * If the desired bus exits, the content of bus->sysdata will @@ -449,6 +450,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) pci_free_resource_list(&resources); __release_pci_root_info(info); } + pci_bus_get(bus); } /* After the PCI-E bus has been walked and all devices discovered, @@ -475,6 +477,8 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) #endif } + pci_unlock_and_put_bus(bus); + return bus; } diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 0ad990a..8b7ae63 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -667,6 +667,18 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno) return pci_scan_bus_on_node(busno, &pci_root_ops, -1); } +static DEFINE_MUTEX(pci_root_bus_mutex); + +void arch_pci_lock_host_bridge_hotplug(void) +{ + mutex_lock(&pci_root_bus_mutex); +} + +void arch_pci_unlock_host_bridge_hotplug(void) +{ + mutex_unlock(&pci_root_bus_mutex); +} + /* * NUMA info for PCI busses * diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index a6df8b1..1bbe924 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -122,5 +122,4 @@ config PCI_LABEL select NLS config PCI_BUS_LOCK - bool - default n + def_bool y if X86