From patchwork Tue Sep 18 06:25:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 1470861 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 DDFB0DF24C for ; Tue, 18 Sep 2012 06:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756698Ab2IRGZq (ORCPT ); Tue, 18 Sep 2012 02:25:46 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:57950 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755437Ab2IRGZp (ORCPT ); Tue, 18 Sep 2012 02:25:45 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id BDB843EE0AE; Tue, 18 Sep 2012 15:25:44 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id A0D3A45DE50; Tue, 18 Sep 2012 15:25:44 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 3ADA245DE4F; Tue, 18 Sep 2012 15:25:44 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 26B731DB802F; Tue, 18 Sep 2012 15:25:44 +0900 (JST) Received: from m005.s.css.fujitsu.com (m005.s.css.fujitsu.com [10.23.4.35]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id CF6841DB803F; Tue, 18 Sep 2012 15:25:43 +0900 (JST) Received: from m005.css.fujitsu.com (m005 [127.0.0.1]) by m005.s.css.fujitsu.com (Postfix) with ESMTP id 9DE2C2E07B5; Tue, 18 Sep 2012 15:25:43 +0900 (JST) Received: from DEUCALION (unknown [10.124.101.32]) by m005.s.css.fujitsu.com (Postfix) with SMTP id 528592E07BB; Tue, 18 Sep 2012 15:25:43 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Date: Tue, 18 Sep 2012 15:25:53 +0900 From: Taku Izumi To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: linux-acpi@vger.kernel.org, kaneshige.kenji@jp.fujitsu.com, yinghai@kernel.org, jiang.liu@huawei.com Subject: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function Message-Id: <20120918152553.8c8390d8.izumi.taku@jp.fujitsu.com> In-Reply-To: <20120918151215.59ea763b.izumi.taku@jp.fujitsu.com> References: <20120918151215.59ea763b.izumi.taku@jp.fujitsu.com> X-Mailer: Sylpheed 3.1.1 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently there's no PCI-related clean-up code in acpi_pci_root_remove() function. This patch introduces function for hostbridge removal, and brings back pci_stop_bus_devices() function. Signed-off-by: Taku Izumi --- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+) -- 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: Bjorn-next-0903/drivers/pci/remove.c =================================================================== --- Bjorn-next-0903.orig/drivers/pci/remove.c +++ Bjorn-next-0903/drivers/pci/remove.c @@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(stru pci_destroy_dev(dev); } EXPORT_SYMBOL(pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices(struct pci_bus *bus) +{ + struct pci_dev *dev, *tmp; + + list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) { + if (dev->subordinate) + pci_stop_bus_devices(dev->subordinate); + pci_stop_dev(dev); + } + +} +EXPORT_SYMBOL(pci_stop_bus_devices); + +void pci_remove_host_bridge(struct pci_host_bridge *bridge) +{ + struct pci_bus *root = bridge->bus; + struct pci_dev *dev, *tmp; + + list_for_each_entry_safe_reverse(dev, tmp, &root->devices, bus_list) + pci_stop_and_remove_bus_device(dev); + + pci_remove_bus(root); + + device_unregister(&bridge->dev); +} +EXPORT_SYMBOL(pci_remove_host_bridge); Index: Bjorn-next-0903/drivers/acpi/pci_root.c =================================================================== --- Bjorn-next-0903.orig/drivers/acpi/pci_root.c +++ Bjorn-next-0903/drivers/acpi/pci_root.c @@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a { struct acpi_pci_root *root = acpi_driver_data(device); struct acpi_pci_driver *driver; + struct pci_host_bridge *bridge = to_pci_host_bridge(root->bus->bridge); mutex_lock(&acpi_pci_root_lock); + pci_stop_bus_devices(root->bus); list_for_each_entry(driver, &acpi_pci_drivers, node) if (driver->remove) driver->remove(root); @@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct a device_set_run_wake(root->bus->bridge, false); pci_acpi_remove_bus_pm_notifier(device); + acpi_pci_irq_del_prt(root->bus); + acpi_pci_unbind_root(device); + + pci_remove_host_bridge(bridge); + list_del(&root->node); mutex_unlock(&acpi_pci_root_lock); kfree(root); Index: Bjorn-next-0903/include/linux/pci.h =================================================================== --- Bjorn-next-0903.orig/include/linux/pci.h +++ Bjorn-next-0903/include/linux/pci.h @@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(struc extern void pci_dev_put(struct pci_dev *dev); extern void pci_remove_bus(struct pci_bus *b); extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); +extern void pci_stop_bus_devices(struct pci_bus *bus); +extern void pci_remove_host_bridge(struct pci_host_bridge *bridge); void pci_setup_cardbus(struct pci_bus *bus); extern void pci_sort_breadthfirst(void); #define dev_is_pci(d) ((d)->bus == &pci_bus_type) Index: Bjorn-next-0903/drivers/acpi/pci_bind.c =================================================================== --- Bjorn-next-0903.orig/drivers/acpi/pci_bind.c +++ Bjorn-next-0903/drivers/acpi/pci_bind.c @@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devic return 0; } + +void acpi_pci_unbind_root(struct acpi_device *device) +{ + device->ops.bind = NULL; + device->ops.unbind = NULL; +} + Index: Bjorn-next-0903/include/acpi/acpi_drivers.h =================================================================== --- Bjorn-next-0903.orig/include/acpi/acpi_drivers.h +++ Bjorn-next-0903/include/acpi/acpi_drivers.h @@ -101,6 +101,7 @@ struct pci_bus; struct pci_dev *acpi_get_pci_dev(acpi_handle); int acpi_pci_bind_root(struct acpi_device *device); +void acpi_pci_unbind_root(struct acpi_device *device); /* Arch-defined function to add a bus to the system */