From patchwork Mon Mar 18 09:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EAF513B5 for ; Mon, 18 Mar 2019 09:58:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 297D729314 for ; Mon, 18 Mar 2019 09:58:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B2FC29317; Mon, 18 Mar 2019 09:58:30 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A82FF29314 for ; Mon, 18 Mar 2019 09:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fJY+m2U2p0YSwT/06mh8WYZYPvsOwSQOj0ozbbtzglE=; b=AXMMxSdFpzOYxo vbcCdlhtPP/CXRkVkSgEpT+zh0BPirv1FdmWeDKZx/LEuq8ib1dO9Kctx04cKKcRPjFq5qCwDwjQt OHtL8HxrQbGXNpYTR/5rm6YKKc7OZk6wfeVZ6umE1kSHkekS1j13qs348OOJZS48YpGNRGzsY6vZW wCpVPPPTaQmOyYfcBhTxrL2GxaMRxE4l3dopG/+I6YMejtj+NDRYR+ga5RN0oJy/hQ6CwA90KDX1g ZBifUw48lGJNBhUIGkncOeM/ZRwno1hqUz8JKcEkAy+2Y/+Lt/07ok5Bl6EqR+niLEM4OV3qx/BgL jXmXMzgGpRdQ4T9IaRMw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p2D-00030f-HP; Mon, 18 Mar 2019 09:58:21 +0000 Received: from mail-eopbgr760051.outbound.protection.outlook.com ([40.107.76.51] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p2A-000304-5e for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:58:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1EQqX9ME+mxb3YmCx3NnvilWTazcKxTSTu4S7WoOB6M=; b=BaprT3uQSYr6N/Dp5mMovqB38SgX2ojNOo5POFHqVnDsfvOaSuNGlKY8wqPsImOP6Dsp2h/aM1PbkZ/HJhv3/En8Ms2iHZmpCfgtBl/KIDO+nhyDFe0zpv0NJbrHjFikzvgYzs3wzkkPAiuAeS9yta4Q+nBcVaRmQwrf4yhRLws= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3512.namprd03.prod.outlook.com (52.135.213.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.14; Mon, 18 Mar 2019 09:58:15 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::1a8:1bc4:174b:472b%2]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 09:58:15 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 5/5] PCI: dwc: Save root bus for driver remove Thread-Topic: [PATCH v3 5/5] PCI: dwc: Save root bus for driver remove Thread-Index: AQHU3XEaIjuV04Qzc028Roxs68+AUw== Date: Mon, 18 Mar 2019 09:58:15 +0000 Message-ID: <20190318175051.5430be17@xhacker.debian> References: <20190318174415.74fd25a5@xhacker.debian> In-Reply-To: <20190318174415.74fd25a5@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [199.33.119.15] x-clientproxiedby: TYCPR01CA0089.jpnprd01.prod.outlook.com (2603:1096:405:3::29) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f8c1895e-bbf6-447a-50df-08d6ab883d38 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3512; x-ms-traffictypediagnostic: BYAPR03MB3512: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(366004)(396003)(376002)(39850400004)(199004)(189003)(6506007)(386003)(102836004)(6346003)(26005)(76176011)(54906003)(52116002)(99286004)(86362001)(316002)(53936002)(6436002)(9686003)(6512007)(110136005)(5660300002)(66066001)(256004)(1076003)(71200400001)(71190400001)(81156014)(6486002)(105586002)(106356001)(8676002)(81166006)(3846002)(6116002)(446003)(97736004)(11346002)(2906002)(4326008)(186003)(25786009)(7736002)(305945005)(72206003)(478600001)(68736007)(8936002)(14454004)(486006)(476003)(50226002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3512; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:0; MX:1; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: iURua1eFaXMYR1Q8DEr+I6K9AnTjkDIYzQIM6+yBNswGnhOTG7xKnb3Kh+9ZKQ4iKw8UMV6kiaP6Eqez7iKZL9zHeVWjSp63RvTYA0qGGpi23KZJen799/eZbJAYIWXd6+rDZcG6AKNuL/Gl+P1WNPi1U5KTF0vZIAyH8jKsrQXT+CtTEyXqtMjOEGszVDGMiwX8L3pS1KciWmyprSHhSG5egs8FdV5eFBP5yWEjwwAaKAaXaHnItpSxDxARvwnDWSDDVeQj2JpjfIyOj4MvPpn42CTjDBs41OaFztBObrcW36/ygj9eOKgzS8CByMp4pclDTFPJ/TcFdB0/mFPF+B7D/SZQ0FUX3B5wk1h7cAn/HdtcNA705CQkY5y18wn2Xrl4EgufzEFV7fcfx5kM5gwWXsUpq+WLDKN3bfrUXSE= Content-ID: <08929240328F81479A90EC463E20D17E@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8c1895e-bbf6-447a-50df-08d6ab883d38 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:58:15.1897 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB3512 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_025818_212807_354A906B X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently dwc host doesn't support the remove, but nothing prevent us from supporting it. Save the root bus for clean up work in driver remove code path. After this patch, the dwc host users could implement its remove as: static int foo_pcie_remove(struct platform_device *pdev) { ... pci_stop_root_bus(pp->root_bus); pci_remove_root_bus(pp->root_bus); dw_pcie_free_msi(pp); ... } Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++------ drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 68a9dac23b1b..7e9dad7ba056 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -341,7 +341,7 @@ int dw_pcie_host_init(struct pcie_port *pp) struct device_node *np = dev->of_node; struct platform_device *pdev = to_platform_device(dev); struct resource_entry *win, *tmp; - struct pci_bus *bus, *child; + struct pci_bus *child; struct pci_host_bridge *bridge; struct resource *cfg_res; int ret; @@ -496,18 +496,18 @@ int dw_pcie_host_init(struct pcie_port *pp) if (ret) goto err_free_msi; - bus = bridge->bus; + pp->root_bus = bridge->bus; if (pp->ops->scan_bus) pp->ops->scan_bus(pp); - pci_bus_size_bridges(bus); - pci_bus_assign_resources(bus); + pci_bus_size_bridges(pp->root_bus); + pci_bus_assign_resources(pp->root_bus); - list_for_each_entry(child, &bus->children, node) + list_for_each_entry(child, &pp->root_bus->children, node) pcie_bus_configure_settings(child); - pci_bus_add_devices(bus); + pci_bus_add_devices(pp->root_bus); return 0; err_free_msi: diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 6fb0a1879932..adff0c713665 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -182,6 +182,7 @@ struct pcie_port { struct page *msi_page; u32 num_vectors; u32 irq_mask[MAX_MSI_CTRLS]; + struct pci_bus *root_bus; raw_spinlock_t lock; DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); };