From patchwork Fri Oct 12 12:34:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tangchen X-Patchwork-Id: 1586681 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 58551DFF71 for ; Fri, 12 Oct 2012 12:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422682Ab2JLMfd (ORCPT ); Fri, 12 Oct 2012 08:35:33 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:44434 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S932316Ab2JLMfc (ORCPT ); Fri, 12 Oct 2012 08:35:32 -0400 X-IronPort-AV: E=Sophos;i="4.80,577,1344182400"; d="scan'208";a="5990352" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 12 Oct 2012 20:34:02 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q9CCZS2c024282; Fri, 12 Oct 2012 20:35:28 +0800 Received: from tangchen.fnst.cn.fujitsu.com ([10.167.225.117]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012101220351605-453685 ; Fri, 12 Oct 2012 20:35:16 +0800 From: Tang Chen To: bhelgaas@google.com, lenb@kernel.org, yinghai@kernel.org, jiang.liu@huawei.com, izumi.taku@jp.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tang Chen Subject: [PATCH 2/3 v2] Do not use acpi_device to find pci root bridge in _init code. Date: Fri, 12 Oct 2012 20:34:20 +0800 Message-Id: <1350045261-7344-3-git-send-email-tangchen@cn.fujitsu.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1350045261-7344-1-git-send-email-tangchen@cn.fujitsu.com> References: <1350045261-7344-1-git-send-email-tangchen@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/12 20:35:16, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/10/12 20:35:16, Serialize complete at 2012/10/12 20:35:16 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When the kernel is being initialized, and some hardwares are not added to system, there won't be acpi_device structs for these devices. But acpi_is_root_bridge() depends on acpi_device struct. As a result, all the not-added root bridge will not be judged as a root bridge in find_root_bridges(). And further more, no handle_hotplug_event_root() notifier will be installed for them. This patch introduces a new api to find all root bridges in system by getting HID directly from ACPI namespace, not depending on acpi_device struct. Signed-off-by: Tang Chen Signed-off-by: Liu Jiang --- drivers/acpi/pci_root.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 6151d83..582eb11 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -129,20 +129,23 @@ EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle); * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge * @handle - the ACPI CA node in question. * - * Note: we could make this API take a struct acpi_device * instead, but - * for now, it's more convenient to operate on an acpi_handle. + * Note: If a device is not added to the system yet, there won't be an + * acpi_device struct for it. So do not get HID and CID from acpi_device, + * get them from ACPI namespace directly. */ int acpi_is_root_bridge(acpi_handle handle) { - int ret; - struct acpi_device *device; + struct acpi_device_info *info; + acpi_status status; - ret = acpi_bus_get_device(handle, &device); - if (ret) + status = acpi_get_object_info(handle, &info); + if (ACPI_FAILURE(status)) { + printk(KERN_ERR PREFIX "%s: Error reading" + "device info\n", __func__); return 0; + } - ret = acpi_match_device_ids(device, root_device_ids); - if (ret) + if (acpi_match_object_info_ids(info, root_device_ids)) return 0; else return 1;