From patchwork Tue Jun 21 18:07:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 9191235 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3A6860756 for ; Tue, 21 Jun 2016 18:40:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A652F20499 for ; Tue, 21 Jun 2016 18:40:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 999A428306; Tue, 21 Jun 2016 18:40:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2900020499 for ; Tue, 21 Jun 2016 18:40:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbcFUSkZ (ORCPT ); Tue, 21 Jun 2016 14:40:25 -0400 Received: from goliath.siemens.de ([192.35.17.28]:42977 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753131AbcFUSkX (ORCPT ); Tue, 21 Jun 2016 14:40:23 -0400 X-Greylist: delayed 1888 seconds by postgrey-1.27 at vger.kernel.org; Tue, 21 Jun 2016 14:40:23 EDT Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id u5LI7qCo008061 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jun 2016 20:07:52 +0200 Received: from md1f2u6c.ww002.siemens.net ([139.25.68.37]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id u5LI7pK4007304; Tue, 21 Jun 2016 20:07:52 +0200 To: Will Deacon Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List From: Jan Kiszka Subject: [PATCH] pci: Add support for unbinding the generic PCI host controller Message-ID: <57698276.6050606@siemens.com> Date: Tue, 21 Jun 2016 20:07:50 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Particularly useful when working in virtual environments where the controller may come and go, but possibly not only there. Signed-off-by: Jan Kiszka --- drivers/pci/ecam.h | 1 + drivers/pci/host/pci-host-common.c | 13 +++++++++++++ drivers/pci/host/pci-host-generic.c | 1 + 3 files changed, 15 insertions(+) diff --git a/drivers/pci/ecam.h b/drivers/pci/ecam.h index 9878beb..5a5f607 100644 --- a/drivers/pci/ecam.h +++ b/drivers/pci/ecam.h @@ -63,5 +63,6 @@ extern struct pci_ecam_ops pci_generic_ecam_ops; /* for DT-based PCI controllers that support ECAM */ int pci_host_common_probe(struct platform_device *pdev, struct pci_ecam_ops *ops); +int pci_host_common_remove(struct platform_device *pdev); #endif #endif diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c index 8cba7ab..c0ff4b1 100644 --- a/drivers/pci/host/pci-host-common.c +++ b/drivers/pci/host/pci-host-common.c @@ -164,6 +164,19 @@ int pci_host_common_probe(struct platform_device *pdev, } pci_bus_add_devices(bus); + platform_set_drvdata(pdev, bus); + return 0; +} + +int pci_host_common_remove(struct platform_device *pdev) +{ + struct pci_bus *bus = platform_get_drvdata(pdev); + + pci_lock_rescan_remove(); + pci_stop_root_bus(bus); + pci_remove_root_bus(bus); + pci_unlock_rescan_remove(); + return 0; } diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 6eaceab..0a2e75b 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -65,6 +65,7 @@ static struct platform_driver gen_pci_driver = { .of_match_table = gen_pci_of_match, }, .probe = gen_pci_probe, + .remove = pci_host_common_remove, }; module_platform_driver(gen_pci_driver);