From patchwork Mon Mar 18 09:53:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857139 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 2290213B5 for ; Mon, 18 Mar 2019 09:54:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB26728459 for ; Mon, 18 Mar 2019 09:54:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9F5428528; Mon, 18 Mar 2019 09:54:06 +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 86D9528459 for ; Mon, 18 Mar 2019 09:54:06 +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=rjPSTHAKDeiH7cn0otI1QiDu0H/oOq0L1Low6AL/GuU=; b=N3GPBUIbMEaWP+ RHPfWCMUSk0O8A19cdzTkX3MSusnleCNiZbmifDdn0uclO9bAQWdWprwT2TGQdAprNUwxEghyMSEZ Dy6ExdBdzJB6+hyS9njEnF6oKYaBljP9esMyG96fai3+WcCcK7HCtnGoEdx1cnro4b4ql8993q+Cr DkYyS7tTAR8NrhxUfNbooPQEHb6myt++azeK8wcEOnr4zAFniH24QmukQjnsn4Kaqq0w3QSh5OWWw LmCmbz2JVlV6+ZWqicHJ2ajutzoo1ppfrEOlK14OvUv93gzos94c/OTFGKbFD9FCd4bzE7iHbkRJd fURe327Zig6Fim2zzzLA==; 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 1h5oy4-0000Fc-F1; Mon, 18 Mar 2019 09:54:04 +0000 Received: from mail-by2nam01on0611.outbound.protection.outlook.com ([2a01:111:f400:fe42::611] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5oy1-0000Eo-5W for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:54:02 +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=VlDmh5ePIbNZPBL+IgT3EwX/R9HbEjvFeuVZYROQgJE=; b=jdWfvxfxwWGgWZVZYG1dQTRImFg2AgmMMNwF6CukXbLm79s+tc+OleVDSyIrFiMwCFaWvCTwu67QM1jZF10hnuF4u6ymRFErzHWCWuofKEPKZ7x1K5OdoyIMccdTTzw8vdKwTf5BQjo5uYyKaXsWK0nBYFuU0koSnKEKSoInyK4= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3928.namprd03.prod.outlook.com (20.177.124.157) 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:53:58 +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:53:58 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid Thread-Topic: [PATCH v3 1/5] PCI: dwc: Fix dw_pcie_free_msi() if msi_irq is invalid Thread-Index: AQHU3XCBU3uwzE9WGUSd1tZpXYixvQ== Date: Mon, 18 Mar 2019 09:53:58 +0000 Message-ID: <20190318174633.0c274139@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: TY2PR01CA0033.jpnprd01.prod.outlook.com (2603:1096:404:ce::21) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; 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: 229742a1-4efe-48ea-3b04-08d6ab87a404 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3928; x-ms-traffictypediagnostic: BYAPR03MB3928: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(346002)(136003)(366004)(189003)(199004)(476003)(11346002)(97736004)(6436002)(3846002)(6116002)(6486002)(71200400001)(71190400001)(256004)(486006)(446003)(26005)(8676002)(5660300002)(68736007)(7736002)(86362001)(102836004)(4326008)(316002)(110136005)(2906002)(99286004)(54906003)(105586002)(25786009)(6506007)(386003)(52116002)(76176011)(81166006)(81156014)(186003)(106356001)(14454004)(53936002)(6512007)(9686003)(50226002)(72206003)(66066001)(8936002)(478600001)(4744005)(1076003)(305945005)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3928; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ccpHDM39++MylEVwt8a6f0aKg00R4KN4/syV5OD+UUPHsDqk41z4J29BWvCqKTHoIiUh8LH5L+Q8uC+d+WB5EEz/Ok4/FFpPWSi/h5H+rh1hGwpQ3le9Mgf/IXW/qOxrAyXe/zQgb+ogEJbaH6xBiTOtkpvaI1GxphgxLqxlCSKSdy4Vi8teH+y48ysEZF9ZsAl56s8MPg3tgVxpMJx1KW6X5d5ZE7Mcs8uE1NYfis0Q0GaXcP94l+gxc2iGEzgpa4qqdOZgzCz5SCnZzcf2Ernr2KI83f/tWrXwHircz3kvV6zeSjZDBiBcCXcgNs0EreVw6UbIW+Gurhn8ZMvI7gr+QRDq4Fl8FK8EA6cPoOGFpS1APfOS6BtPGEuDKToEbWhRG+dMWTa10vL0XlpPJBTRJ7lFwhSCS3y5TsLfQEw= Content-ID: <53329CAEE770B34EBA1A7B7036C3A00F@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 229742a1-4efe-48ea-3b04-08d6ab87a404 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:53:58.2851 (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: BYAPR03MB3928 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_025401_208744_900ADB15 X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. 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 We should check msi_irq before calling irq_set_chained_handler() and irq_set_handler_data(). Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- drivers/pci/controller/dwc/pcie-designware-host.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 25087d3c9a82..1040939f45b4 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -298,8 +298,10 @@ int dw_pcie_allocate_domains(struct pcie_port *pp) void dw_pcie_free_msi(struct pcie_port *pp) { - irq_set_chained_handler(pp->msi_irq, NULL); - irq_set_handler_data(pp->msi_irq, NULL); + if (pp->msi_irq) { + irq_set_chained_handler(pp->msi_irq, NULL); + irq_set_handler_data(pp->msi_irq, NULL); + } irq_domain_remove(pp->msi_domain); irq_domain_remove(pp->irq_domain); From patchwork Mon Mar 18 09:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857143 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 6941A13B5 for ; Mon, 18 Mar 2019 09:54:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4742F28FDE for ; Mon, 18 Mar 2019 09:54:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39A29291AE; Mon, 18 Mar 2019 09:54:46 +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 D249E28FDE for ; Mon, 18 Mar 2019 09:54:45 +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=yeT/FDy6pF50yp1YZDSgyadbFZzyzyDi6ggs8elhQK4=; b=IMc0zOBNNuQ8je cj8+RfZRizVQxlGAv94GX5j5NR79sUcTm80X/ZKTGjdCX4zmjjkwugQSGCI73rN4/N7fhAujQZzpH DTsEndd430qKHY/+j9jvkJJsCxYMeyjzOL5SXrPst9RsbQeiy/pivX4VM3p3LSk15HM16fbeiSmNQ 76lucQtrGxa2ie8AJCmdZbjewIeKYQ5VavieKRDdGGmSSbnvAPKTGB1gsS01xSjxs5krnxhB75bWq Bd1BybtXB/6aqWGlnVregc7rJkwZPCTkwwphdEqh6NIOAbralLxuS3De13loSXqS3tC+QL2DEsK0q PhPJizJir9N2CJvcWtjQ==; 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 1h5oyi-0000dz-1e; Mon, 18 Mar 2019 09:54:44 +0000 Received: from mail-eopbgr810040.outbound.protection.outlook.com ([40.107.81.40] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5oye-0000cZ-HN for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:54:41 +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=Isj1DBcl8+ro68MJQCtUVGEyy5WmT9Mr4dwWnY7EqcI=; b=Pu4GGN3PifjZZlUL6WTwci/fpCwnMfwTmaw3olgBpIoMdpHouG3kB055XCDAyJjYypwO5CekvxjxxvKJySEsp7mlD271cF27OC6OE31vgCHvdwtJMm203FjrNjw9fPk+AMkAubxOumVvLcje6IFO/ws0O1UpRqVdL2ZkaNms3lg= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3928.namprd03.prod.outlook.com (20.177.124.157) 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:54:35 +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:54:35 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 2/5] PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi() Thread-Topic: [PATCH v3 2/5] PCI: dwc: Free the page for MSI IRQ in dw_pcie_free_msi() Thread-Index: AQHU3XCXLFkjRFjYXE6Zgkga34dsXA== Date: Mon, 18 Mar 2019 09:54:35 +0000 Message-ID: <20190318174711.4b7e556a@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: TY2PR06CA0036.apcprd06.prod.outlook.com (2603:1096:404:2e::24) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; 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: eac676f7-6dba-449d-6b63-08d6ab87ba01 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3928; x-ms-traffictypediagnostic: BYAPR03MB3928: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(346002)(136003)(366004)(189003)(199004)(476003)(11346002)(97736004)(6436002)(3846002)(6116002)(6486002)(71200400001)(71190400001)(256004)(486006)(446003)(26005)(8676002)(5660300002)(68736007)(7736002)(86362001)(102836004)(4326008)(316002)(110136005)(2906002)(99286004)(54906003)(105586002)(25786009)(6506007)(386003)(52116002)(76176011)(81166006)(81156014)(186003)(106356001)(14454004)(53936002)(6512007)(9686003)(50226002)(72206003)(66066001)(8936002)(478600001)(1076003)(305945005)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3928; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ig23TILqcWMGEjo2l+xtqMLrwtl3hjqUhZfZfalMcGzf2DRjcAWkAacQHZ8V+xc3x0lUoXPYnZbk8AA5J5IIisl1CbXQfZNRKX9m3ore3lxvv7VmrQCwdcMAbrDXyt42rsRL+zRnMeLNiWzJosubJDbV0jvXdjZJ7adlGoi8LZkbloBkvoI/h/Mc7S8qU0KQSonSS7li3dmlNRXHd5TrHVQpCsRYr947WZ1xlZYsavwnsNISn6jRUB9DxefsYLuOM3Qn40qlFrRR2Ub+/u/Corpfqi+QvIeMuQiDkjuWmuNe/6ALsHhqOT8wZUNd6lkKk65rJ1OszJofWrT+qQY45yK4oZWy7nCSbvl3uP94/WseNaSJ1m+Sxhdncx+JuzbppTYeLX6SI2lspUJrHn+aWku6KTbzNOUX7u/wM6ovDDU= Content-ID: <81A4B6EE3748A14588AFA809EC746986@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: eac676f7-6dba-449d-6b63-08d6ab87ba01 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:54:35.0714 (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: BYAPR03MB3928 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_025440_575502_46A523A9 X-CRM114-Status: GOOD ( 10.91 ) 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 To avoid memory leak, we need to free the page for MSI in dw_pcie_free_msi(). 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, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 1040939f45b4..a71b874ae3c0 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -305,20 +305,24 @@ void dw_pcie_free_msi(struct pcie_port *pp) irq_domain_remove(pp->msi_domain); irq_domain_remove(pp->irq_domain); + + if (pp->msi_page) + __free_page(pp->msi_page); } void dw_pcie_msi_init(struct pcie_port *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct device *dev = pci->dev; - struct page *page; u64 msi_target; - page = alloc_page(GFP_KERNEL); - pp->msi_data = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); + pp->msi_page = alloc_page(GFP_KERNEL); + pp->msi_data = dma_map_page(dev, pp->msi_page, 0, PAGE_SIZE, + DMA_FROM_DEVICE); if (dma_mapping_error(dev, pp->msi_data)) { dev_err(dev, "Failed to map MSI data\n"); - __free_page(page); + __free_page(pp->msi_page); + pp->msi_page = NULL; return; } msi_target = (u64)pp->msi_data; diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 377f4c0b52da..6fb0a1879932 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -179,6 +179,7 @@ struct pcie_port { struct irq_domain *irq_domain; struct irq_domain *msi_domain; dma_addr_t msi_data; + struct page *msi_page; u32 num_vectors; u32 irq_mask[MAX_MSI_CTRLS]; raw_spinlock_t lock; From patchwork Mon Mar 18 09:56:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857149 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 0540613B5 for ; Mon, 18 Mar 2019 09:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D664E29312 for ; Mon, 18 Mar 2019 09:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C87AF29316; Mon, 18 Mar 2019 09:56:33 +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 67C1129312 for ; Mon, 18 Mar 2019 09:56:33 +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=k6DIinejVy5uuhR2FRW3fhFq6mGohJ/lREei85t+iaM=; b=WGo9DZ/v6b4CrC OyId8xcXqFN3Oi+2ncGD0Y5MBHevoLFVo3cLo4uek5fEBgx48jUhrgec3JM1ebsVdKEUxibvwYdvH q+MR6HH99ZtHuYpugpnSQ5deq2dDbLs9XxMW6sDGnAa56T2d3K0ijxhrCQO2ULU/DsGHVrRifl4Hl +oO9/ERK1aTryWXrC7Eo3bc7WSvNgbHEvn4gjaYTaHv1kWdTRdr3Td29TYnaLYUGoqBQcOWrevZdE DEn3p9V2ZtdkxseLm3OYjHNPCJ9bT8DxPBONaHcrmczfQP8f/da2BqYYEIGHT8eNje2tnHSMsyeV+ 639jPG4iJSvDdEHVUZKg==; 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 1h5p0M-0002LM-D3; Mon, 18 Mar 2019 09:56:26 +0000 Received: from mail-by2nam01on0618.outbound.protection.outlook.com ([2a01:111:f400:fe42::618] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p0I-0002Kw-Iq for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:56:24 +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=UhvE0+1qXeAFOcQksGpZl2UoMr49mpT1gKdIfBx/6N4=; b=MUTIQzTX6IigVX9EyPk489TGr6ts9OoXdxSEYhx+4ckEmc9OLtIWDkQUQF0rNNE//gyF91mTCcH7Df/HhHEcq35+kvALNy6rw/PB3GM2uTrB5StOhgAzEUUYf7Ito+2LQRVkXXwcw4P9ljUMiidTi3bGHt3zkOqSyg6Y3P4tA6Y= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB3928.namprd03.prod.outlook.com (20.177.124.157) 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:56:05 +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:56:05 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init() Thread-Topic: [PATCH v3 3/5] PCI: dwc: Free MSI in the error code path of dw_pcie_host_init() Thread-Index: AQHU3XDNPtxLI80dvkeT0+gZl/Yu8A== Date: Mon, 18 Mar 2019 09:56:05 +0000 Message-ID: <20190318174841.522fb6fd@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: TYAPR01CA0211.jpnprd01.prod.outlook.com (2603:1096:404:29::31) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; 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: 9f371ff8-3ea1-4e7a-fdc3-08d6ab87efd7 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:BYAPR03MB3928; x-ms-traffictypediagnostic: BYAPR03MB3928: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(346002)(136003)(366004)(189003)(199004)(476003)(11346002)(97736004)(6436002)(3846002)(6116002)(6486002)(71200400001)(71190400001)(256004)(486006)(446003)(26005)(8676002)(5660300002)(68736007)(7736002)(86362001)(102836004)(4326008)(316002)(110136005)(2906002)(99286004)(54906003)(105586002)(25786009)(6506007)(386003)(52116002)(76176011)(81166006)(81156014)(186003)(106356001)(14454004)(53936002)(6512007)(9686003)(50226002)(72206003)(66066001)(8936002)(478600001)(1076003)(305945005)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR03MB3928; H:BYAPR03MB4773.namprd03.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: SKykdF2ZdTcVp+fZ2kSFJgpjY+kIfFD8QWg6vu5hduKcwZ6Pf2MYAClJaTDMpbR25NPm8gvkYMA/HdEzhLVDkQz20QCih5H9kJAiYub2IPfJgfjYO4UGIQHbmaGu/BqIUoZDt/P7V7FYOYsAwmIn4iuAW/01vPb6kXbhJv6HgCVIj4aG3UWU5BTqpaSSnoqyR/7q4Nt1mQVk4MHEAvfHk67DZLoxcyPiRXztTwf4XeWsuFd/KaWvnOtx0zgl0xeZxHGkJUdgL/KZK+4SO/fPLvatb9Q/nj/HBPyK2Uwi3G5kkMYiDSMGbHJxJvOXoQAEzOLpCmIpoicdCe5YjlNUosVkCvujOwx5j15mqNkXQ2N+xML8/olw7ZtiCoq560HTl1lk5tf7OLM9jszyJOSv6i9sYFm1YHUHD6w7QD4Q8Q0= Content-ID: <29FD94CCD3AE3D40893E8C601FCF84CA@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f371ff8-3ea1-4e7a-fdc3-08d6ab87efd7 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:56:05.4850 (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: BYAPR03MB3928 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190318_025622_625595_C150B748 X-CRM114-Status: GOOD ( 11.42 ) 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 If we ever did some msi related initializations, we need to call dw_pcie_free_msi() in the error code path. Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- drivers/pci/controller/dwc/pcie-designware-host.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index a71b874ae3c0..585080699675 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -483,7 +483,7 @@ int dw_pcie_host_init(struct pcie_port *pp) if (pp->ops->host_init) { ret = pp->ops->host_init(pp); if (ret) - goto error; + goto err_free_msi; } pp->root_bus_nr = pp->busn->start; @@ -497,7 +497,7 @@ int dw_pcie_host_init(struct pcie_port *pp) ret = pci_scan_root_bus_bridge(bridge); if (ret) - goto error; + goto err_free_msi; bus = bridge->bus; @@ -513,6 +513,10 @@ int dw_pcie_host_init(struct pcie_port *pp) pci_bus_add_devices(bus); return 0; +err_free_msi: + if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled() && + !pp->ops->msi_host_init) + dw_pcie_free_msi(pp); error: pci_free_host_bridge(bridge); return ret; From patchwork Mon Mar 18 09:57:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10857157 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 8E92D1575 for ; Mon, 18 Mar 2019 09:57:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DA8929316 for ; Mon, 18 Mar 2019 09:57:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 614A92931A; Mon, 18 Mar 2019 09:57:44 +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 DF95B29316 for ; Mon, 18 Mar 2019 09:57:43 +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=FJCgbHaqZdndz8ErL70569xGzXWTv6MPeuK4XdDmvpY=; b=a/keuwhGcbjM76 0MMoZqkb8b70e75MgYOtbXE6QgZfhcaluYZY9WDyXfjASEHRw0teyAIC853GnGHu3iQ8sWW7Sv9hA RC/5I5FdmNbn+gKrXZifn518HBSIz+/1v8/BmmiAdLrarvP4G4EB77qawaLwvRH6RpRgl2TAKzj4I REsoGEw9zwUBDx+Kkof3yt5NOgSJ/ZRLlGduk3aJ81DC456ExHvLygfk0VfvifNT+CNuHU6Z+ipEY oTMj+UIuMnHTEI7M4r25miVEjA2oDisjUr719Iy4ZjrL1qw3NukLPuhaX1wa/8j4LizfYoWrZhbSC KtN6fADNsEcFeiXLr8sQ==; 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 1h5p1V-0002ga-48; Mon, 18 Mar 2019 09:57:37 +0000 Received: from mail-cys01nam02on0628.outbound.protection.outlook.com ([2a01:111:f400:fe45::628] helo=NAM02-CY1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5p1R-0002dT-Pa for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2019 09:57:34 +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=MfZNa/BIRYhv/l35s63hd8lYRfM5oD9vfKkc+5UeD4k=; b=JiIs3T9Kj+ApW1ZflERY+FI5N7VOHYfDGsMzP3M7J0fZhnpGAd7Nxw4BLWFB21G8PKeJN3kaQxZdo+ZAjBJTIeWFkHyLnjQIKhuay9Z6Y2Cr2n1fFN1vfMozHAi72uXHVDW3LIvDVLAcy/QJuN8A1st2TpyRjFDRI4L75cuOaIw= 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:57:29 +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:57:29 +0000 From: Jisheng Zhang To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH v3 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code Thread-Topic: [PATCH v3 4/5] PCI: dwc: Use devm_pci_alloc_host_bridge() to simplify the code Thread-Index: AQHU3XD/ghaIsUq3jEigJqiYRMMPzA== Date: Mon, 18 Mar 2019 09:57:28 +0000 Message-ID: <20190318175005.7bfaec27@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: TYAPR04CA0001.apcprd04.prod.outlook.com (2603:1096:404:15::13) 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: e7655bff-c393-486c-096a-08d6ab882197 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)(14444005)(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: u7Ca3+VTu+mxCuRkfcl5eT7HwmQ8ocjzxelESWSufor4akKaKswSQ8IXHd00zUqtm/HYX98BzRUo15HfqBB0GXvU1lryXghJnDLxNTy4USbdQ04FJPT9W1SkwIEpiN/xQ7jWzUjGVvh7dY4c25DXLhGGyAbYFaoCyuwW/4C+dsocC8wP+x5nDqQdTbHGPSAlnrPgmx/dujCy3Hkx1WiAKOdx8LcNvhNAvrbbmXChBR+ZQiUsf1HPMCaqcrwjI0sy8yZqByCfkYYEwCfBVMiJOmuR8H/uOKHBvy+E/+88rRFL4Ss0XePSUbZhwr6I0Y/MS3/oAMMxCzKrdCOLZdV5Jjhe4Z49fZIqQuR4X0H23t0KXHFo1OXPsxORafUwy81E0anMKAYg5L7vFnOQhYoDDBGBBkULVx41heVhXuo0sEU= Content-ID: <029917FE50189E4AA5B5516964D21C93@namprd03.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7655bff-c393-486c-096a-08d6ab882197 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 09:57:28.8583 (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_025733_842974_FAF02383 X-CRM114-Status: GOOD ( 12.07 ) 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 Use devm_pci_alloc_host_bridge() to simplify the error code path. Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- .../pci/controller/dwc/pcie-designware-host.c | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 585080699675..68a9dac23b1b 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -358,7 +358,7 @@ int dw_pcie_host_init(struct pcie_port *pp) dev_err(dev, "Missing *config* reg space\n"); } - bridge = pci_alloc_host_bridge(0); + bridge = devm_pci_alloc_host_bridge(dev, 0); if (!bridge) return -ENOMEM; @@ -369,7 +369,7 @@ int dw_pcie_host_init(struct pcie_port *pp) ret = devm_request_pci_bus_resources(dev, &bridge->windows); if (ret) - goto error; + return ret; /* Get the I/O and memory ranges from DT */ resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { @@ -413,8 +413,7 @@ int dw_pcie_host_init(struct pcie_port *pp) resource_size(pp->cfg)); if (!pci->dbi_base) { dev_err(dev, "Error with ioremap\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -425,8 +424,7 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base, pp->cfg0_size); if (!pp->va_cfg0_base) { dev_err(dev, "Error with ioremap in function\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -436,8 +434,7 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg1_size); if (!pp->va_cfg1_base) { dev_err(dev, "Error with ioremap\n"); - ret = -ENOMEM; - goto error; + return -ENOMEM; } } @@ -460,14 +457,14 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->num_vectors == 0) { dev_err(dev, "Invalid number of vectors\n"); - goto error; + return -EINVAL; } } if (!pp->ops->msi_host_init) { ret = dw_pcie_allocate_domains(pp); if (ret) - goto error; + return ret; if (pp->msi_irq) irq_set_chained_handler_and_data(pp->msi_irq, @@ -476,7 +473,7 @@ int dw_pcie_host_init(struct pcie_port *pp) } else { ret = pp->ops->msi_host_init(pp); if (ret < 0) - goto error; + return ret; } } @@ -517,8 +514,6 @@ int dw_pcie_host_init(struct pcie_port *pp) if (IS_ENABLED(CONFIG_PCI_MSI) && pci_msi_enabled() && !pp->ops->msi_host_init) dw_pcie_free_msi(pp); -error: - pci_free_host_bridge(bridge); return ret; } 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); };