From patchwork Fri Apr 12 15:44:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2436961 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 7A354DF2A1 for ; Fri, 12 Apr 2013 15:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756267Ab3DLPqy (ORCPT ); Fri, 12 Apr 2013 11:46:54 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:56168 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755201Ab3DLPqv (ORCPT ); Fri, 12 Apr 2013 11:46:51 -0400 Received: by mail-pa0-f44.google.com with SMTP id bi5so1532987pad.17 for ; Fri, 12 Apr 2013 08:46:51 -0700 (PDT) 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; bh=PBfIOBUI8xkHeZ6CHOq2M7WtsrVkQALy9dIeht2UsBk=; b=pgpZ7LbFOXds4h/chp18X/xXjhUyZSxuIcQ+FI/EcKuV+RIoeYNCKp6ilVwlrcipsm mu8p4GuQ+2qIFsPRt1dQ24V9XpPCSTppqm0WXAQidROtS/b16O89sSMCtyE06SlOkNNW /V9LVH+MMvQ8Eb0lXueAV48/n7L2oUz+6Xj4uhXtDjZ1e+41A8dAMysozl+yc1iPUYla bQiC9pkQ9LxUz9vJkhVpdWmgcZ5eaVuQF37ZN5UTyF1QMK0ELw9UMA0tFLdAhq2XGiMH DF5GSsyuPjG1Xyl6LlYHs98HCG4DqeYgB50C+0oUTd2vNdAajI8EIRjFLUpU1GkEmXff +z5w== X-Received: by 10.66.233.66 with SMTP id tu2mr1096448pac.12.1365781611040; Fri, 12 Apr 2013 08:46:51 -0700 (PDT) Received: from localhost.localdomain ([114.250.74.212]) by mx.google.com with ESMTPS id wz9sm9048741pbc.5.2013.04.12.08.46.41 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Apr 2013 08:46:50 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , "Rafael J . Wysocki" Cc: Jiang Liu , Yinghai Lu , Yijing Wang , Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Greg Kroah-Hartman , ACPI Devel Maling List , Toshi Kani , Myron Stowe , "Rafael J. Wysocki" , Tony Luck , Fenghua Yu , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-ia64@vger.kernel.org, x86@kernel.org Subject: [PATCH v9 06/16] PCI: introduce platform dependent hooks for creating/destroying PCI busses Date: Fri, 12 Apr 2013 23:44:20 +0800 Message-Id: <1365781470-32379-7-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1365781470-32379-1-git-send-email-jiang.liu@huawei.com> References: <1365781470-32379-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 On ACPI based platforms, the pci_slot driver creates PCI slot devices according to information from ACPI tables by registering an ACPI PCI subdriver. The ACPI PCI subdriver will only be called when creating/ destroying PCI root buses, and it won't be called when hot-plugging P2P bridges. It may cause stale PCI slot devices after hot-removing a P2P bridge if that bridge has associated PCI slots. And the acpiphp driver has the same issue too. This patch introduces two hook points into the PCI core, which will be invoked when creating/destroying PCI busses for PCI host and P2P bridges. They could be used to setup/destroy platform dependent staffs in a unified way, both at boot time and for PCI hotplug operations. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang Cc: Yinghai Lu Cc: "Rafael J. Wysocki" Cc: Toshi Kani Cc: Tony Luck Cc: Fenghua Yu Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Myron Stowe Cc: linux-pci@vger.kernel.org Cc: linux-ia64@vger.kernel.org Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/pci/probe.c | 12 ++++++++++++ drivers/pci/remove.c | 1 + include/linux/pci.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 45c93b3..43ece5d 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -673,6 +673,8 @@ add_dev: ret = device_register(&child->dev); WARN_ON(ret < 0); + pcibios_add_bus(child); + /* Create legacy_io and legacy_mem files for this bus */ pci_create_legacy_files(child); @@ -1660,6 +1662,14 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; } +void __weak pcibios_add_bus(struct pci_bus *bus) +{ +} + +void __weak pcibios_remove_bus(struct pci_bus *bus) +{ +} + struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata, struct list_head *resources) { @@ -1714,6 +1724,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, if (error) goto class_dev_reg_err; + pcibios_add_bus(b); + /* Create legacy_io and legacy_mem files for this bus */ pci_create_legacy_files(b); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index a831880..8fc54b7 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -51,6 +51,7 @@ void pci_remove_bus(struct pci_bus *bus) pci_bus_release_busn_res(bus); up_write(&pci_bus_sem); pci_remove_legacy_files(bus); + pcibios_remove_bus(bus); device_unregister(&bus->dev); } EXPORT_SYMBOL(pci_remove_bus); diff --git a/include/linux/pci.h b/include/linux/pci.h index 849a336..7eb6023 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -693,6 +693,8 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */ extern int no_pci_devices(void); void pcibios_resource_survey_bus(struct pci_bus *bus); +void pcibios_add_bus(struct pci_bus *bus); +void pcibios_remove_bus(struct pci_bus *bus); void pcibios_fixup_bus(struct pci_bus *); int __must_check pcibios_enable_device(struct pci_dev *, int mask); /* Architecture specific versions may override this (weak) */