From patchwork Wed Feb 13 00:16:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 2132751 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 D32873FDF1 for ; Wed, 13 Feb 2013 00:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759281Ab3BMAJ5 (ORCPT ); Tue, 12 Feb 2013 19:09:57 -0500 Received: from hydra.sisk.pl ([212.160.235.94]:37662 "EHLO hydra.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759276Ab3BMAJz (ORCPT ); Tue, 12 Feb 2013 19:09:55 -0500 Received: from vostro.rjw.lan (aavq132.neoplus.adsl.tpnet.pl [83.6.50.132]) by hydra.sisk.pl (Postfix) with ESMTPSA id CBC8EE3EC1; Wed, 13 Feb 2013 01:09:44 +0100 (CET) From: "Rafael J. Wysocki" To: ACPI Devel Maling List Cc: Bjorn Helgaas , LKML , Jiang Liu , Yinghai Lu , Toshi Kani , Yasuaki Ishimatsu , Myron Stowe , linux-pci@vger.kernel.org Subject: [PATCH] ACPI / PCI: Initialize PCI root drivers after PCI bus enumeration Date: Wed, 13 Feb 2013 01:16:20 +0100 Message-ID: <1882094.fnYp8pBVVX@vostro.rjw.lan> User-Agent: KMail/4.9.5 (Linux/3.8.0-rc7; KDE/4.9.5; x86_64; ; ) MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Rafael J. Wysocki After commit 1aeae82 (ACPI / PCI: avoid building pci_slot as module) the pci_slot driver's .add() callback routine, acpi_pci_slot_add(), is executed from within acpi_pci_root_add() before the PCI devices on the bus are enumerated and that triggers the WARN_ON() in kobject_get(): WARNING: at /scratch/rafael/work/test/include/linux/kref.h:42 kobject_get+0x33/0x40() Hardware name: PORTEGE R500 Modules linked in: Pid: 1, comm: swapper/0 Not tainted 3.8.0-rc7+ #160 Call Trace: [] warn_slowpath_common+0x7a/0xb0 [] warn_slowpath_null+0x15/0x20 [] kobject_get+0x33/0x40 [] get_device+0x12/0x30 [] register_slot+0x243/0x295 [] ? trace_hardirqs_on+0xd/0x10 [] acpi_ns_walk_namespace+0x10f/0x24a [] ? walk_p2p_bridge+0x13b/0x13b [] ? walk_p2p_bridge+0x13b/0x13b [] acpi_walk_namespace+0xe9/0x132 [] ? walk_p2p_bridge+0x13b/0x13b [] walk_p2p_bridge+0xf8/0x13b [] ? acpi_os_signal_semaphore+0x76/0x87 [] ? walk_p2p_bridge+0x13b/0x13b [] acpi_ns_walk_namespace+0x10f/0x24a [] ? do_sta_before_sun+0x2b/0x2b [] ? do_sta_before_sun+0x2b/0x2b [] acpi_walk_namespace+0xe9/0x132 [] ? acpi_pci_root_add+0x3e7/0x49a [] acpi_pci_slot_add+0xb2/0x103 [] ? walk_p2p_bridge+0x13b/0x13b [] acpi_pci_root_add+0x3ff/0x49a which means that pci_bus->dev used in register_slot() has not been registered yet at that point. To fix this use the observation that before commit 1aeae82 acpi_pci_slot_add() was always run after pci_bus_add_devices() and that happened to the acpiphp's .add() callback routine too. Thus it is safe to reorder acpi_pci_root_add() to make the PCI root drivers' .add() callbacks be run after pci_bus_add_devices(), so do that. This approach was previously proposed by Myron Stowe. References: https://patchwork.kernel.org/patch/1848781/ Signed-off-by: Rafael J. Wysocki --- The commit mentioned in the changelog above is in linux-pm.git/linux-next. Thanks, Rafael --- drivers/acpi/pci_root.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) -- 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 Index: test/drivers/acpi/pci_root.c =================================================================== --- test.orig/drivers/acpi/pci_root.c +++ test/drivers/acpi/pci_root.c @@ -600,17 +600,20 @@ static int acpi_pci_root_add(struct acpi if (system_state != SYSTEM_BOOTING) pci_assign_unassigned_bus_resources(root->bus); + /* need to after hot-added ioapic is registered */ + if (system_state != SYSTEM_BOOTING) + pci_enable_bridges(root->bus); + + pci_bus_add_devices(root->bus); + mutex_lock(&acpi_pci_root_lock); + list_for_each_entry(driver, &acpi_pci_drivers, node) if (driver->add) driver->add(root); - mutex_unlock(&acpi_pci_root_lock); - /* need to after hot-added ioapic is registered */ - if (system_state != SYSTEM_BOOTING) - pci_enable_bridges(root->bus); + mutex_unlock(&acpi_pci_root_lock); - pci_bus_add_devices(root->bus); return 1; out_del_root: