Received: by 10.192.165.148 with SMTP id m20csp3414615imm; Sun, 29 Apr 2018 22:53:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq/JUhZYmiiUaMhWUU/Xq9HZXUjWSUdEQUHwcpEUzzla0FOygOzQ2xm4JnRg4tno1r0SX8R X-Received: by 10.98.152.203 with SMTP id d72mr10794963pfk.98.1525067582043; Sun, 29 Apr 2018 22:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525067582; cv=none; d=google.com; s=arc-20160816; b=k8ECXAy8QmeBgFv1z25UYqoyuJVpjvGgUaPjU4T0PYi2hm+eTwlPiQwZRSAazPlLMa qn5ibPmWyGqS2zTK4ZOzqz8OciyEnMI1DSb0/aA0bDiRO0+W0AKxVSY/3E5VOzHw8cqS LRUdHPuJG74aSdbtGZIKzGORyQ+szhgkKyYbdZiME/9++OGRp+LrIMPpseMpaAuIaStF 2IEMICLw2nczAKdtcfzwkTz5RZaVVGANhwV7FHDmp4t5/2PKh2kzxsoeXK4FlqCzx03v M82TBUJ87KH53YnGV8t7R8HU2DGUpIV1KZS9HTkWk1RvRIO7EaKU90Iz+EwbklKLSoD7 8N8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Nkh3RyRiplFeXY51oXiwGOOuOd+SKObkBmXGu/nVBdc=; b=m25lxQwo6QMsdTo/3vm81eV3+Qryy7evMa8XQgQrT7CuFrltwLQhk/mx6gniZuQ+kK Ql3yjAFlg/RnWHjITqxWeAyxNOiV6qAneknkkf+Mk4BWzv2DmR8unadLaJsxS1OjMhXq pLb56bpU2DigVa+pf1Xd2l/GNk/d/3+U7dspP5P7kmWLsfMKvgU0EH78V8Rssuh/xj97 Hhx0fmYiTveAAZqz+BHqnw2/kY/BSkthBO90Z9gfVSwxg1F0+poakd307px62cvoD/xK XPpKn7rrfWHDxRLFscO4n/34YVOBtDqVLzhDBZomv8QH8sCsWLtzqR5y0SMsqUv4wAnY qDVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v40-v6si6920692plg.84.2018.04.29.22.52.48; Sun, 29 Apr 2018 22:53:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752361AbeD3Fut (ORCPT + 99 others); Mon, 30 Apr 2018 01:50:49 -0400 Received: from thoth.sbs.de ([192.35.17.2]:41356 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbeD3FtP (ORCPT ); Mon, 30 Apr 2018 01:49:15 -0400 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w3U5mneq012500 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Apr 2018 07:48:49 +0200 Received: from md1f2u6c.ww002.siemens.net ([167.87.54.87]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w3U5mj71003250; Mon, 30 Apr 2018 07:48:48 +0200 From: Jan Kiszka To: Bjorn Helgaas , Linux Kernel Mailing List , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Lorenzo Pieralisi Subject: [PATCH v2 09/10] PCI: Add support for unbinding the generic PCI host controller Date: Mon, 30 Apr 2018 07:48:43 +0200 Message-Id: X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka Particularly useful when working in virtual environments where the controller may come and go, but possibly not only there. CC: Will Deacon CC: Lorenzo Pieralisi Signed-off-by: Jan Kiszka --- drivers/pci/host/pci-host-common.c | 13 +++++++++++++ drivers/pci/host/pci-host-generic.c | 1 + include/linux/pci-ecam.h | 1 + 3 files changed, 15 insertions(+) diff --git a/drivers/pci/host/pci-host-common.c b/drivers/pci/host/pci-host-common.c index 5d028f53fdcd..d8f10451f273 100644 --- a/drivers/pci/host/pci-host-common.c +++ b/drivers/pci/host/pci-host-common.c @@ -101,5 +101,18 @@ int pci_host_common_probe(struct platform_device *pdev, return ret; } + platform_set_drvdata(pdev, bridge->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 45319ee3b484..dea3ec7592a2 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -95,5 +95,6 @@ static struct platform_driver gen_pci_driver = { .suppress_bind_attrs = true, }, .probe = gen_pci_probe, + .remove = pci_host_common_remove, }; builtin_platform_driver(gen_pci_driver); diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h index baadad1aabbc..29efa09d686b 100644 --- a/include/linux/pci-ecam.h +++ b/include/linux/pci-ecam.h @@ -62,5 +62,6 @@ extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */ /* 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 -- 2.13.6