From patchwork Tue Jan 8 16:52:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1946891 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 74DC340B27 for ; Tue, 8 Jan 2013 16:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756809Ab3AHQwy (ORCPT ); Tue, 8 Jan 2013 11:52:54 -0500 Received: from mail-pb0-f43.google.com ([209.85.160.43]:64025 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756787Ab3AHQwv (ORCPT ); Tue, 8 Jan 2013 11:52:51 -0500 Received: by mail-pb0-f43.google.com with SMTP id um15so349918pbc.30 for ; Tue, 08 Jan 2013 08:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references; bh=ZRssKYMOztNeSv31Dokjbq1NFZ2wLM7q/ZA6mgMiSs0=; b=zVyEY+/FV3FMPpAWW7eb2buTsXeZn+V0ZdSYjIz3wV9PY2YJ/5IzfDcqHZId80Tizb gh3HFgCiIqjWrcLddQCtTWgeK8UiJTYGZWG9XhzS9r+qPCKGCqPYD0f++KECwQDe5PfX a3QQRCFzB75NVrekPU6asGtOQC8a+BRjGMe9jojo5KN3FYFZI13T2O1S0Rqo05Iq1TlJ 9X0AjFukgSvFEm+oSUTzROxanAKK6qSC4bvKN4MM6G4jOa+7POAfqD20x4lptiVX60Ma bWOUc6HQz27Yv8vRdpHbl3E5bH0qjbTAErLvzduXFuskkKO4V79ZrOMfjEQFz78WinGG iWSg== X-Received: by 10.68.234.167 with SMTP id uf7mr200258212pbc.20.1357663971417; Tue, 08 Jan 2013 08:52:51 -0800 (PST) Received: from localhost.localdomain ([120.196.98.117]) by mx.google.com with ESMTPS id f5sm41038922pav.22.2013.01.08.08.52.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 08:52:50 -0800 (PST) From: Jiang Liu To: Bjorn Helgaas Cc: Jiang Liu , "Rafael J . Wysocki" , Yijing Wang , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v3 5/6] PCI/acpiphp: serialize access to the bridge_list list Date: Wed, 9 Jan 2013 00:52:24 +0800 Message-Id: <1357663945-16054-6-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357663945-16054-1-git-send-email-jiang.liu@huawei.com> References: <1357663945-16054-1-git-send-email-jiang.liu@huawei.com> In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Serialize access to the bridge_list in the acpiphp driver. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang --- drivers/pci/hotplug/acpiphp_glue.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 16fe692..884cbf4 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -53,6 +53,7 @@ #include "../pci.h" #include "acpiphp.h" +static DEFINE_MUTEX(bridge_mutex); static LIST_HEAD(bridge_list); #define MY_NAME "acpiphp_glue" @@ -519,8 +520,10 @@ static int add_bridge(struct acpi_pci_root *root) } /* search P2P bridges under this host bridge */ + mutex_lock(&bridge_mutex); status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, find_p2p_bridge, NULL, NULL, NULL); + mutex_unlock(&bridge_mutex); if (ACPI_FAILURE(status)) warn("find_p2p_bridge failed (error code = 0x%x)\n", status); @@ -618,6 +621,8 @@ static void remove_bridge(struct acpi_pci_root *root) struct acpiphp_bridge *bridge; acpi_handle handle = root->device->handle; + mutex_lock(&bridge_mutex); + /* cleanup p2p bridges under this host bridge in a depth-first manner */ acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, @@ -636,6 +641,8 @@ static void remove_bridge(struct acpi_pci_root *root) else acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY, handle_hotplug_event_bridge); + + mutex_unlock(&bridge_mutex); } static int power_on_slot(struct acpiphp_slot *slot) @@ -1438,11 +1445,13 @@ static void acpiphp_hp_notify_add(struct pci_dev *dev) if (!dev->subordinate || !handle) return; + mutex_lock(&bridge_mutex); /* check if this bridge has ejectable slots */ if (detect_ejectable_slots(handle) > 0) { dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); add_p2p_bridge(handle); } + mutex_unlock(&bridge_mutex); } static void acpiphp_hp_notify_del(struct pci_dev *dev) @@ -1453,11 +1462,13 @@ static void acpiphp_hp_notify_del(struct pci_dev *dev) if (!bus) return; + mutex_lock(&bridge_mutex); list_for_each_entry_safe(bridge, tmp, &bridge_list, list) if (bridge->pci_bus == bus) { cleanup_bridge(bridge); break; } + mutex_unlock(&bridge_mutex); } static int acpi_pci_hp_notify_fn(struct notifier_block *nb,