From patchwork Tue Sep 25 14:29:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1504571 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 B030BDF283 for ; Tue, 25 Sep 2012 14:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755010Ab2IYOeW (ORCPT ); Tue, 25 Sep 2012 10:34:22 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:63709 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754774Ab2IYOeT (ORCPT ); Tue, 25 Sep 2012 10:34:19 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr4so203970pbb.19 for ; Tue, 25 Sep 2012 07:34:19 -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=pe+ck/CcDh5R8bghinn9z+cfNBrGxElByuFiqbP9aAg=; b=X+PaP62EgLosxdneQhkZ0HwPBmjfjd5GUwoiGWMHfmfeC1UyhS93UYQyNzXex2YyHh YznNFkT/lAMszodecSTB8X7ptKYCsqkivwUL1QBZTxbjvbMLoHfvkL7aza2gu7FQSYIn fYra+/nkP9FDj/i9t+5fH8sRzdBUQTdxUMwXlH5fCWBTNcHUT3ratGNgzNe8oIEN3z4Q vsDxs4dR327RyvAfAGrxuYMm/HZ4DPmcFM5wiEsJVFJHJ/GSCwlAJqH9MWFmA8GGfH/O mQAucXoQJWLqBFNYhIygttazWCuA6Iu6DY0k0z5dDY8S0yb43ON1rHDNsbINWcBYjOAX q8Fw== Received: by 10.68.242.9 with SMTP id wm9mr46320046pbc.62.1348583659192; Tue, 25 Sep 2012 07:34:19 -0700 (PDT) Received: from localhost.localdomain ([221.221.22.12]) by mx.google.com with ESMTPS id nu8sm415218pbc.45.2012.09.25.07.34.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 07:34:18 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas Cc: Jiang Liu , Yinghai Lu , Kenji Kaneshige , Yijing Wang , Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v3 7/7] PCI/acpiphp: serialize access to the bridge_list list Date: Tue, 25 Sep 2012 22:29:30 +0800 Message-Id: <1348583370-11006-7-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348583370-11006-1-git-send-email-jiang.liu@huawei.com> References: <1348583370-11006-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 From: Jiang Liu 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,