From patchwork Sat Sep 15 03:05:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1461321 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E3DADDF264 for ; Sat, 15 Sep 2012 03:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755873Ab2IODNz (ORCPT ); Fri, 14 Sep 2012 23:13:55 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:33180 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756721Ab2IODNr (ORCPT ); Fri, 14 Sep 2012 23:13:47 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so6509443pbb.19 for ; Fri, 14 Sep 2012 20:13:47 -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=khAxx5SJvA3CJGbp/TRzYEnQHqD4zfhm3aohOti2fe8=; b=wG2TYWWyZANFUNZdzNRJhP8YXH4CibULcLX7liWrOR+RXgAmM5aH09f7/j7iNZPNl/ fVD+mS5qAu1FZaDhiAXRFyDnRG0CLV4XG1RA+Wq0k9cUWxrmF5RZrZUpkvDWVMGUCFY7 viQx6kTtn89bA3DcXEJ1KAXF+h++fakFG05exu1w+mbrnHRhMYXfDLBMJdwxaur0qJIF CqcVHWpyD7oMKkXaw8DGpq32qa8E/woWfB+a+mpi/9cSGY1ube6nRra7le7ChmkVQJqb m8+3ESOXts8HY8u8YOB5XUOjphueDOlhq/j3xsXkSbAvejzy1Woy70TwdZYQTCg+8Phz cKew== Received: by 10.66.78.73 with SMTP id z9mr7145177paw.9.1347678827316; Fri, 14 Sep 2012 20:13:47 -0700 (PDT) Received: from localhost.localdomain ([221.221.18.122]) by mx.google.com with ESMTPS id jz10sm2092777pbc.8.2012.09.14.20.13.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Sep 2012 20:13:46 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas Cc: Tony Luck , Jiang Liu , Yinghai Lu , Kenji Kaneshige , Yijing Wang , Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v2 8/9] PCI/acpiphp: serialize access to the bridge_list list Date: Sat, 15 Sep 2012 11:05:11 +0800 Message-Id: <1347678312-11124-9-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347678312-11124-1-git-send-email-jiang.liu@huawei.com> References: <1347678312-11124-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 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 1fb0eb7..348afd7 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" @@ -497,8 +498,10 @@ static int add_bridge(acpi_handle handle) } /* 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); @@ -595,6 +598,8 @@ static void remove_bridge(acpi_handle handle) { struct acpiphp_bridge *bridge; + mutex_lock(&bridge_mutex); + /* cleanup p2p bridges under this host bridge in a depth-first manner */ acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, @@ -613,6 +618,8 @@ static void remove_bridge(acpi_handle handle) 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) @@ -1415,11 +1422,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) @@ -1430,11 +1439,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,