From patchwork Wed Nov 7 10:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10672065 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-2.web.codeaurora.org (Postfix) with ESMTP id 7EDA314E2 for ; Wed, 7 Nov 2018 10:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F2C72B9D3 for ; Wed, 7 Nov 2018 10:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6284F2B9D8; Wed, 7 Nov 2018 10:09:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 E6C9B2B9D3 for ; Wed, 7 Nov 2018 10:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730555AbeKGTis (ORCPT ); Wed, 7 Nov 2018 14:38:48 -0500 Received: from mail-eopbgr80050.outbound.protection.outlook.com ([40.107.8.50]:33632 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726363AbeKGTir (ORCPT ); Wed, 7 Nov 2018 14:38:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PO6aXvTx9PEDBl3j8yMQvs7T2dGXFUiPS3YOtAwTqgA=; b=N/wU5tyWq8/awsbQpH8YfJRurncpkHBxmnv35aIMRy9RJ51vucWPGeKb8ch8XKVh0iFy6sbddb5Y6SzjV3bGAb3LLI5khC7GdRxp1YswGuOtNmV+/hVnsvxLZKVRCjcehRDxBvZljDCxW+Z04bwSHjW6oa6TY4rXcJeNwzDtNi4= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.2.80) by AM6PR04MB5224.eurprd04.prod.outlook.com (20.177.35.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Wed, 7 Nov 2018 10:09:04 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00%3]) with mapi id 15.20.1273.035; Wed, 7 Nov 2018 10:09:04 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "jingoohan1@gmail.com" , "gustavo.pimentel@synopsys.com" CC: Roy Zang , Mingkai Hu , "M.h. Lian" , "Z.q. Hou" Subject: [PATCHv2 1/4] PCI: dwc: fix potential memory leak Thread-Topic: [PATCHv2 1/4] PCI: dwc: fix potential memory leak Thread-Index: AQHUdoHpGzf55QFgZUifBzAS9plOMQ== Date: Wed, 7 Nov 2018 10:09:04 +0000 Message-ID: <20181107100854.28389-2-Zhiqiang.Hou@nxp.com> References: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0023.apcprd04.prod.outlook.com (2603:1096:203:36::35) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:aa::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM6PR04MB5224;6:gGlRdu6jMGubMw8rT9eCGmGsmi6Ql6lSg+TwElppVRZOpeEa6cy0AEPefbptf2NQ/HU41Y4L89P5u0lHqEWlBRdbn6zq3V1b23TXdDUol6uCy1kHNv6NrRHl7hvGVWChKvntsNAH4I4Ejw+B2+k5wxL4kbjjriPQ/g5sI0lJFykp7axVpw04ITUp+oJ770ib1QgtdoOqC9VI9HFeweAuabaMsQ6IoAaoyP7eU5c5QG7Z7Z4J11lK0eCEk9LXgCIV3gYrjYcIkL78mT8xMgSR4orlmiQP6+qxP7mDPifhVfsGNyEr/pu24HtCTLlckHETQ8c2b2G1F1C5zYjg6BKGQjdo0bFHmzwh/G1rFBbcgivScmP7vRXfunAY0rppVPoCAYGQuxz4CsQEE1oj1X8R6OAfHqFRLNTrhCdT3Il+LNMPnmU7lixu/ThG+VBt0Im4Ey4sHA+ytWF7AD+CcLLfAQ==;5:yaKlNwhahdUl5SsbJyUiW/jCKj8GYZBGa59nzO/IDYr6+dtGVYlmOblkE0cJVrkAHFW9xgpOKZZ6WBUdr1rKhqhdQrZVj5M7Q7beVRJbW3jvlGiY8HXdv0UdjW9L1D0sL6K0jFSsr7AjWXicsfL5zsoyqE6/rEs6w7IRVaGDASs=;7:BxDioFn7z5LTYoXUyTHAGpu8MQuxEFQwuRpzsNTkkMYIHKtp85YB8ZWAuoopT/z41UR07ybt16gdb7xBIqyhzM5X0E2JjIgb6J8kqdDqAL1ZgAL7J7OVoYramZQpIPr1On76+RMRrGAOTb7F1Ub0DA== x-ms-office365-filtering-correlation-id: d56a41e8-6eaf-4cff-802b-08d644990ba6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR04MB5224; x-ms-traffictypediagnostic: AM6PR04MB5224: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:AM6PR04MB5224;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB5224; x-forefront-prvs: 08497C3D99 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(396003)(39860400002)(376002)(346002)(189003)(199004)(71200400001)(71190400001)(39060400002)(5660300001)(305945005)(2501003)(25786009)(386003)(6506007)(6116002)(3846002)(102836004)(1076002)(8936002)(68736007)(81166006)(97736004)(81156014)(256004)(14444005)(2906002)(99286004)(186003)(66066001)(76176011)(52116002)(26005)(86362001)(54906003)(2201001)(6436002)(316002)(2900100001)(8676002)(446003)(53936002)(2616005)(486006)(11346002)(105586002)(478600001)(36756003)(106356001)(476003)(14454004)(7736002)(6512007)(110136005)(4326008)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB5224;H:AM6PR04MB5781.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ihuIUNGHQiavdTlLu96K7jUzB9K8C1E1VvWUFhHDCBVN9z5fTElZue2jGaK2RUv87f7uLAZTC+lr4ByMvnZ/OEZWAOkQUS7OkTip/ZeGsSDAjxa6MulE3azO1r2pU3hpg3SSRNRPEKYzbm6JC5MEnTvwA9sT8lbY562t83U8F4iI9wMFts5pmYBEEZxqyeHWxeqaGuoXaqii7RX5kgdbI83xflWV33fOybVqTgS1Yko2gq+npFIpmPdcxEn5kD0dKYDimI9Gl0MBZkAI6bNt0YHgNPUl4NQvFPqUSAnufLdQCn7mZi5EqGtkIemqZHO6J0+82/Xz9PLN0gTWj1byfQlKwUA76NQbjOPWrNxrsUw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d56a41e8-6eaf-4cff-802b-08d644990ba6 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2018 10:09:04.6157 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5224 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 From: Hou Zhiqiang Free the allocated pci_host_bridge struct when failed to get host bridge resources, and free the resource windows before free the bridge. Signed-off-by: Hou Zhiqiang Acked-by: Gustavo Pimentel --- V2: - Reworded the subject. drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 29a05759a294..ecacce016489 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -353,7 +353,7 @@ int dw_pcie_host_init(struct pcie_port *pp) ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, &bridge->windows, &pp->io_base); if (ret) - return ret; + goto error; ret = devm_request_pci_bus_resources(dev, &bridge->windows); if (ret) @@ -502,6 +502,7 @@ int dw_pcie_host_init(struct pcie_port *pp) return 0; error: + pci_free_resource_list(&bridge->windows); pci_free_host_bridge(bridge); return ret; } From patchwork Wed Nov 7 10:09:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10672073 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-2.web.codeaurora.org (Postfix) with ESMTP id 694791751 for ; Wed, 7 Nov 2018 10:10:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5647C2B9D3 for ; Wed, 7 Nov 2018 10:10:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4886B2B9DA; Wed, 7 Nov 2018 10:10:09 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 C9A182B9D3 for ; Wed, 7 Nov 2018 10:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730744AbeKGTjg (ORCPT ); Wed, 7 Nov 2018 14:39:36 -0500 Received: from mail-eopbgr80075.outbound.protection.outlook.com ([40.107.8.75]:13776 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726363AbeKGTjf (ORCPT ); Wed, 7 Nov 2018 14:39:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jh9q8ArwnTVY+6n9Iz6EqdBrKSSzih8Z1nryTiD9d/Y=; b=gStQ8yh3GK5CjT48lBGr4RFc0xSVp81tWocVAMKD4W6rX602rEYRS4/IRiddXFGdGJY5BgkVC5q9q8IE8NuQi8/CpoN3cR5ceiU+KX/90VcGpuiF0wCZrF6b/v6fJXMiuKDQcQivOoLca1m7ByuTLXBBXJUSlf1uxL3AJYEMDPI= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.2.80) by AM6PR04MB5224.eurprd04.prod.outlook.com (20.177.35.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Wed, 7 Nov 2018 10:09:10 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00%3]) with mapi id 15.20.1273.035; Wed, 7 Nov 2018 10:09:10 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "jingoohan1@gmail.com" , "gustavo.pimentel@synopsys.com" CC: Roy Zang , Mingkai Hu , "M.h. Lian" , "Z.q. Hou" Subject: [PATCHv2 2/4] PCI: dwc: fix 4GiB outbound window size truncated to zero issue Thread-Topic: [PATCHv2 2/4] PCI: dwc: fix 4GiB outbound window size truncated to zero issue Thread-Index: AQHUdoHtyqLmhpxOWkOjGGaxpD7Vzw== Date: Wed, 7 Nov 2018 10:09:10 +0000 Message-ID: <20181107100854.28389-3-Zhiqiang.Hou@nxp.com> References: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0023.apcprd04.prod.outlook.com (2603:1096:203:36::35) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:aa::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM6PR04MB5224;6:wP7AxXsraYyWPG3kPhOzZUOd28FNckdSDzW6PclzZmTNpVTGPViNvNeMRe7FYRIwWfx6CHOPifEO4STcgCpHAk7sZPBXzmxtivJIt5cW/+szKMtSet/vgV8q7UwIdPcjY1PfYYOsmZz+wDMOd+obuSCjJRyC6T+2u/lspEB5KmvcYEO1KEtHoObkx9cP+4G3LKLE/CzoXOilkOmsoy0emtnSOxJE4Lb/Y8ePVQALxyZ6oZrHdySKb3XpV8C8AcyA9Rn5KmKBN/+wALx4CqE8yCG0y1oDV8BSiFGOJ+4twQIyFwyVvB+51+SV01n2MlZ4oRWBTzBHt+p5bzxJ834Le0hHZXISygYWqj9rJ/BjHZuD+QwURWPzovnIWhk52dZP62fCTdSfzXiOg3v4HfQ/dmUNDl6pw/5Fp2nUKo95O6FHEmHxpg/FMZs4cbmGYEOIOTRCISA1s4uybaz8FBVK9A==;5:9RjN7nmN4wI19Uji1H3/81+KGZrCjXuk29N4ImOz0UQm0FJSEtSGd7vVMMvJ6NP6RB5E/FdKnXbBMIBoPAsBrFz3b3O8IaQc1qFMvIqNRzO3Th7CScaDZak2mPbaLDIJaicL5KVyMsv3tI/eTZdphqHDXFT8U3ZjTI4x1TwQuLI=;7:NuK9QRzlXKhdXb7TmuPpuqzDwuGeJoSK+47CnmNHzn2AoQGoi71uOeLrphB21cwIP2W7nS9uGEvAm8RaaOioK3wLkDxo5X5wrDIePhQx1w/GFaYcsXray2QLaImUWBkuFjKvDuMPcwa6Z4bIicnydg== x-ms-office365-filtering-correlation-id: c356716a-96c8-4b01-7f20-08d644990f87 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR04MB5224; x-ms-traffictypediagnostic: AM6PR04MB5224: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:AM6PR04MB5224;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB5224; x-forefront-prvs: 08497C3D99 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(396003)(39860400002)(376002)(346002)(189003)(199004)(71200400001)(71190400001)(39060400002)(5660300001)(305945005)(2501003)(25786009)(386003)(6506007)(6116002)(3846002)(102836004)(1076002)(8936002)(68736007)(81166006)(97736004)(81156014)(256004)(2906002)(99286004)(575784001)(186003)(66066001)(76176011)(52116002)(26005)(86362001)(54906003)(2201001)(6436002)(316002)(2900100001)(8676002)(446003)(53936002)(2616005)(486006)(11346002)(105586002)(478600001)(36756003)(106356001)(476003)(14454004)(7736002)(6512007)(110136005)(4326008)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB5224;H:AM6PR04MB5781.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: wpN/7T+YsiCgFVuMlRbJsbC5esst9Vt1+i3jcyha9eiYcfS0GjYoejNBIsSOpt/4OKIu8GPAXF6EhQiqiFnZ+tIZUaDOlA1hUp5N1AXOazFtQIG1NVyIgcwX6/9bJJn/2qDs5tcM8AQ+C+pL/2dVumzmshXFR3e1qzaTEtkW6PEDMqMKfipbVLmjT5E2/F4pMNP6deuYikO1DCQyYHCzzNk5u0sz2g/KSgHa0lUBDLhPuHSEvXngeeqIylZtr4pwOVO7vvQDxilbs+ElFZmAc1Vc/lPnZ5QZ/sh2Y2LXp94tNOkbmK7ehUXDjdg+neIZtFFXTXdQfHws6wxUmzZwsitGjdOE3WKNTk0p8oyMyQA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c356716a-96c8-4b01-7f20-08d644990f87 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2018 10:09:10.3639 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5224 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 From: Hou Zhiqiang The current type of mem_size is 'u32', so when resource_size() return 4G it will be truncated to zero. This patch fix it by changing its type to 'u64'. Signed-off-by: Hou Zhiqiang Acked-by: Gustavo Pimentel --- V2: - Reworded the subject. drivers/pci/controller/dwc/pcie-designware.c | 4 ++-- drivers/pci/controller/dwc/pcie-designware.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 2153956a0b20..7ac5989c23ef 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -106,7 +106,7 @@ static void dw_pcie_writel_ob_unroll(struct dw_pcie *pci, u32 index, u32 reg, static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index, int type, u64 cpu_addr, - u64 pci_addr, u32 size) + u64 pci_addr, u64 size) { u32 retries, val; @@ -141,7 +141,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index, } void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, - u64 cpu_addr, u64 pci_addr, u32 size) + u64 cpu_addr, u64 pci_addr, u64 size) { u32 retries, val; diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 9f1a5e399b70..a438c3879aa9 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -153,7 +153,7 @@ struct pcie_port { u32 io_size; u64 mem_base; phys_addr_t mem_bus_addr; - u32 mem_size; + u64 mem_size; struct resource *cfg; struct resource *io; struct resource *mem; @@ -238,7 +238,7 @@ int dw_pcie_link_up(struct dw_pcie *pci); int dw_pcie_wait_for_link(struct dw_pcie *pci); void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, u64 cpu_addr, u64 pci_addr, - u32 size); + u64 size); int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int bar, u64 cpu_addr, enum dw_pcie_as_type as_type); void dw_pcie_disable_atu(struct dw_pcie *pci, int index, From patchwork Wed Nov 7 10:09:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10672069 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-2.web.codeaurora.org (Postfix) with ESMTP id E5C621751 for ; Wed, 7 Nov 2018 10:09:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D48D32B9D3 for ; Wed, 7 Nov 2018 10:09:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C86CF2B9DC; Wed, 7 Nov 2018 10:09:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 6DEC82B9D6 for ; Wed, 7 Nov 2018 10:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbeKGTjf (ORCPT ); Wed, 7 Nov 2018 14:39:35 -0500 Received: from mail-eopbgr80071.outbound.protection.outlook.com ([40.107.8.71]:4671 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726225AbeKGTje (ORCPT ); Wed, 7 Nov 2018 14:39:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kT5Ao4oUD2UohVRBAQrFLHPZqrPUd8f5tBMkVUCFNFE=; b=FMTguQ72cbEpzEHP5MGwi6S6rzCMTc5y5Jy9erOGUT2gdhfhcg/OXyxAXcLSZ/BUW/CB09tUoubi7Inmh/isKOlguJNKrpwn2M8ya5phfUZQmFpSdyRBrUXmiMuX3Ns64F88jQr9tGuryR1af13p1U4X1NvqOUQbkXuVFkBxzXc= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.2.80) by AM6PR04MB5224.eurprd04.prod.outlook.com (20.177.35.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Wed, 7 Nov 2018 10:09:17 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00%3]) with mapi id 15.20.1273.035; Wed, 7 Nov 2018 10:09:17 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "jingoohan1@gmail.com" , "gustavo.pimentel@synopsys.com" CC: Roy Zang , Mingkai Hu , "M.h. Lian" , "Z.q. Hou" Subject: [PATCHv2 3/4] PCI: layerscape: initialize the number of viewport Thread-Topic: [PATCHv2 3/4] PCI: layerscape: initialize the number of viewport Thread-Index: AQHUdoHwwQtALiNKOkSV/HKwxAJl5g== Date: Wed, 7 Nov 2018 10:09:16 +0000 Message-ID: <20181107100854.28389-4-Zhiqiang.Hou@nxp.com> References: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0023.apcprd04.prod.outlook.com (2603:1096:203:36::35) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:aa::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM6PR04MB5224;6:RAmOVCrS7XVngyuK5jFsWObpM0zIuCygAd4LnZmptyiy2fpqKNF3FJ1/OUpF13O+p/aRQEE4ohaQWtksU71AGym/7yG47wfm7tZ1gs+D+5IXLsYucqlBSVlTMY0VJ+6dfGZaNe4lX75wgUwG1x8Bl/WLQ7nJ8gJ3DUXnfouX1BgYRFc4vunZg+4MPSfsxarOBcR0bL67xG8BK3VICqQh6JrqJGla122W0ZFSUBnU2J8DUEwx/O6rao5YiQdNEe5xH61S5AN16ImyU4vm1/MqX2zwREBW99tlwQF/vtLeECqw5qUhmcFfvkge5bcr9/5sgHpbLVQe/ke9JguuU4ee9j0FHZVPdxgpprA130YYS5SsOmh/PSviuBXG9/QLTX1T7qP0+QX8pumweuxo3RJ0bkcPD1PVOv67fOeMzcgOc5SOGXUNm37xJXYL0ZqGq20CPwJw5nky+R6tQY9CBpTGfg==;5:CW7diaGnEP/dypWM8Nz3S4jHamHeJb6Bwe1C/ch5uSh/tZjCtSSPLHJwFMRcACUJSJcluzqyf+SfFPOgtv/XXPuhLl/nM0kE4HPpOG5cU7Iat//timzyCYrlmIJaX1ooD/o3z7Maeb1Bxb+eAUzCXrEWb407WGNS86Lor3p/DEs=;7:ehODYLQu1T9+gweXNeHxt2WAJfds/KowRSZ5zdammpJscPZo8EQSlKi+vM+NdIybHuNLY8Bmd95HHedWQFgNq1vIJopmlZfQlNxbmc+gF6kpy5F9sra8hyc5rVm4TqMBQ6GKst+P6QlSMxJocovmQA== x-ms-office365-filtering-correlation-id: 87494380-dec4-46d5-2dd4-08d644991203 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR04MB5224; x-ms-traffictypediagnostic: AM6PR04MB5224: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:AM6PR04MB5224;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB5224; x-forefront-prvs: 08497C3D99 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(396003)(39860400002)(376002)(346002)(189003)(199004)(71200400001)(71190400001)(39060400002)(5660300001)(305945005)(2501003)(25786009)(386003)(6506007)(6116002)(3846002)(102836004)(1076002)(8936002)(68736007)(81166006)(97736004)(81156014)(256004)(2906002)(99286004)(186003)(66066001)(76176011)(52116002)(26005)(86362001)(54906003)(2201001)(6436002)(316002)(2900100001)(8676002)(446003)(53936002)(2616005)(486006)(11346002)(105586002)(478600001)(36756003)(106356001)(476003)(14454004)(7736002)(6512007)(110136005)(4326008)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB5224;H:AM6PR04MB5781.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: zYY51Pj1soZPnxg/iZnwcJb024Gp51uOtBtYA4mZvE5dzZD+bshji6nGVI+KkeX7hD5ub1K0rvVwZLN5P/Tb+jBlqVC4GWJpzqbSC37qtcNVHKXRQSpq9/9Uxu0sn0j8lR1dlHaoHKXJeYMWOBlpt+qgU773VOmJh1HaVKS2d5AyHPSlknFYiU22T5KN4yJ2/1kGogosdmP1/T2/n1b41X7c0R4I7DE/udrPHcZywhVeS5e0xHDyN9UYu1M6gNAbkdYBKvFndAfYUJfipD5aZBJgF17t/r2S3RgSHu/9cDPoMDM2RNzIf7y0Dp7d58k48qRUEIVnqxJI+gQKLgkkT4BgItrJbSrECd0gSyadfVA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87494380-dec4-46d5-2dd4-08d644991203 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2018 10:09:16.9326 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5224 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 From: Hou Zhiqiang FSL implements 6 viewports on Layerscape series SoCs PCIe controllers. Signed-off-by: Hou Zhiqiang --- V2: - Reworded the subject and commit description. drivers/pci/controller/dwc/pci-layerscape.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index 3724d3ef7008..69f3f1a5a782 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -280,6 +280,9 @@ static int __init ls_add_pcie_port(struct ls_pcie *pcie) pp->ops = pcie->drvdata->ops; + /* FSL implements 6 windows */ + pci->num_viewport = 6; + ret = dw_pcie_host_init(pp); if (ret) { dev_err(dev, "failed to initialize host\n"); From patchwork Wed Nov 7 10:09:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10672071 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-2.web.codeaurora.org (Postfix) with ESMTP id A00F515A6 for ; Wed, 7 Nov 2018 10:10:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88BAB2B9E0 for ; Wed, 7 Nov 2018 10:10:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CED82B9EB; Wed, 7 Nov 2018 10:10:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 B34AC2B9DA for ; Wed, 7 Nov 2018 10:10:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730805AbeKGTji (ORCPT ); Wed, 7 Nov 2018 14:39:38 -0500 Received: from mail-eopbgr80071.outbound.protection.outlook.com ([40.107.8.71]:4671 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726411AbeKGTjh (ORCPT ); Wed, 7 Nov 2018 14:39:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2U9bTI06bt+YUlAqIRHbFrMn8xSfemDHPNYsvSM4Il0=; b=oLcckoRab2RsyFciBHHO8ZMMbbvvx9l6ZULRQIGRzO4AeHZ29N3yrAzzrRbS+CEPSkXLcaX6kaXuhCuxlwFn/epDt5KMTcgYkgxr1nYXQPSRf9pnPiRNjjK2KZXflc4vybRMDtNR8z6OdhWmSyaiQ8+Yz+QC9nYbast1qh62J8Y= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.2.80) by AM6PR04MB5224.eurprd04.prod.outlook.com (20.177.35.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Wed, 7 Nov 2018 10:09:21 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::7d93:8053:57fd:1a00%3]) with mapi id 15.20.1273.035; Wed, 7 Nov 2018 10:09:21 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "jingoohan1@gmail.com" , "gustavo.pimentel@synopsys.com" CC: Roy Zang , Mingkai Hu , "M.h. Lian" , "Z.q. Hou" Subject: [PATCHv2 4/4] PCI: dwc: add prefetchable memory range support Thread-Topic: [PATCHv2 4/4] PCI: dwc: add prefetchable memory range support Thread-Index: AQHUdoHzO92qDxmIZkykN3HwHZxeDg== Date: Wed, 7 Nov 2018 10:09:21 +0000 Message-ID: <20181107100854.28389-5-Zhiqiang.Hou@nxp.com> References: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR04CA0023.apcprd04.prod.outlook.com (2603:1096:203:36::35) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:aa::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM6PR04MB5224;6:apE9Sd9R3v87v81SY+ZBMv4f/xYIAssvGz8KUCBV80URINUosd8GyrkhpLFtd0FGUYslgJYxV29h3bBgpiJUZoWW7Km3ABX7RAXwYGwdAi2JtwEVIVwS2wehKAglDEnmY9AZuBLDM2wPPIur4dMirA+japOZtd4rDE9WYNss6PwlRXtSDnUXw92l0q4yvX2xwGvDZqMC2cSnpk+zg2yKoePLzfjvPiIX5b/kdeXh9w4x7c7P92rVGhxElT4atGJQiHJiw/SdG1huLmRDeVsSAG1p8OJZximvYeis6angZnKLX/GxU38Yjrig3nlQv/v+xtsHj0bK+HpGNikMTVHHqQp8lg4U21eYip0hhYdE0zuSWY+Sm/DZjHa6p8lZH17L+bT7pPDzzSIYcVU3RGrJ9MCJZz1lwoZ35wCK3W1G36+Whf2DuCnHy4M4n4IevK87rQk4eM4TG17yUnSb7nBwfA==;5:PCqbum8TRHPub+l1TI52AbWOB0V7wLyPNtnoolO1l4ychpVr9D5Nl55zial83Q7+C48NTuhGqK3v1Zn7EhQwdZcWIQZ2D4n4yXJs1NqoZd1MSrMhgjlTzpRxMJ2hJFYHjj8PDBzDHpwBFtesRU8V2qdloi7Io/LKu1uwqQFJ31w=;7:dwOdsYHqgZFr9NHqomjbutqZ9A2GVtfjIKC4pS1CzlHOKMniveUBLaA9W7r9dKayMARpBf9X2F6HTzdkLlDAxRI75IBuJCwqgojEuHZKfW1jrIlG5al7J0bafWXHegvdNJlv3QuqXYo5gqnOJWjRkA== x-ms-office365-filtering-correlation-id: 32705812-5318-4915-c0ee-08d644991607 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM6PR04MB5224; x-ms-traffictypediagnostic: AM6PR04MB5224: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:AM6PR04MB5224;BCL:0;PCL:0;RULEID:;SRVR:AM6PR04MB5224; x-forefront-prvs: 08497C3D99 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(366004)(396003)(39860400002)(376002)(346002)(189003)(199004)(71200400001)(71190400001)(39060400002)(5660300001)(305945005)(2501003)(25786009)(386003)(6506007)(6116002)(3846002)(102836004)(1076002)(8936002)(68736007)(81166006)(97736004)(81156014)(256004)(14444005)(2906002)(99286004)(186003)(66066001)(76176011)(52116002)(26005)(86362001)(54906003)(2201001)(6436002)(316002)(2900100001)(8676002)(446003)(53936002)(2616005)(486006)(11346002)(105586002)(478600001)(36756003)(106356001)(476003)(14454004)(7736002)(6512007)(110136005)(4326008)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB5224;H:AM6PR04MB5781.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 2YjS3ID+xvPQCwTPsdRWANl2sHSZtfwvl7FcqSWSM6Ui3vvyypkoFlLErDySbM5axd3RvkRM0/eDKkw53rijE3Pk7j4d85i4uB0rH9j7nH0wHRuZgjQVGn/dcH17Y/4DroRltrwPPAKc4pToT1JfQRer9YYgIr7JVxosDzbxAixDitQjJT0EHjR43gyHBkvSfZbLtlKMGl7q5Sap00BcaBrgBU57p/Zc4ugHhz8rC4Jv05xLixOAGmUXF1zszHM8n1/yFpPemCcUr3ZPNzSH27GITV9pph8i7YKtOwYLcz1f6611xzmKIHiefbHaVjmrOb6/3xtM/93NVTl0RY8YPsY+/kuMZQ5eMkZeH5+LISU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32705812-5318-4915-c0ee-08d644991607 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2018 10:09:21.3178 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5224 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 From: Hou Zhiqiang The current code only support non-prefetchable memory range, as the non-prefetchable memory range must not be greater than 4GiB, one viewport can cover it, which supports upto 4GiB. To support prefetchable memory range, which is upto 64-bit memory space and can be greater than 4GiB, so we need multiple viewports. And added separate vars to store prefetchable memory range info to prevent overriding the non-prefetchable memory range info. And this patch explicitly assigned the last (if there are only 2 viewports) or last 2 viewports for CFG and I/O windows and the rests for MEM windows. Signed-off-by: Hou Zhiqiang Acked-by: Gustavo Pimentel --- V2: - Reworded the subject and commit description. - Fix the prefetchable memory range overriding non-perfetchable memory range issue by adding vars to store prefetchable memory range info. .../pci/controller/dwc/pcie-designware-host.c | 107 ++++++++++++++---- drivers/pci/controller/dwc/pcie-designware.h | 7 ++ 2 files changed, 95 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index ecacce016489..328aa40a6609 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -346,6 +346,35 @@ int dw_pcie_host_init(struct pcie_port *pp) dev_err(dev, "Missing *config* reg space\n"); } + /* + * If vendor's platform driver has set the num_viewport and it is + * not less than 2, skip getting the num_viewport from DT here. + */ + if (pci->num_viewport < 2) { + ret = of_property_read_u32(np, "num-viewport", + &pci->num_viewport); + if (ret || pci->num_viewport < 2) + pci->num_viewport = 2; + } + + /* + * if there are only 2 viewports, assign the last viewport for + * both CFG and IO window, otherwise assign the last 2 viewport + * for CFG and IO window specific. And the rest viewports are + * assigned to MEM windows. + */ + if (pci->num_viewport == 2) { + pp->cfg_idx = pp->io_idx = PCIE_ATU_REGION_INDEX1; + pp->mem_wins = 1; + } else { + pp->cfg_idx = pci->num_viewport - 1; + pp->io_idx = pci->num_viewport - 2; + pp->mem_wins = pci->num_viewport - 2; + } + + dev_dbg(dev, "CFG win id: %d, I/O win id: %d, Total MEM win: %d\n", + pp->cfg_idx, pp->io_idx, pp->mem_wins); + bridge = pci_alloc_host_bridge(0); if (!bridge) return -ENOMEM; @@ -377,10 +406,20 @@ int dw_pcie_host_init(struct pcie_port *pp) } break; case IORESOURCE_MEM: - pp->mem = win->res; - pp->mem->name = "MEM"; - pp->mem_size = resource_size(pp->mem); - pp->mem_bus_addr = pp->mem->start - win->offset; + if (win->res->flags & IORESOURCE_PREFETCH) { + pp->mem_perf = win->res; + pp->mem_perf->name = "MEM perf"; + pp->mem_perf_size = resource_size(pp->mem_perf); + pp->mem_perf_bus_addr = pp->mem_perf->start - + win->offset; + pp->mem_perf_base = pp->mem_perf->start; + } else { + pp->mem = win->res; + pp->mem->name = "MEM"; + pp->mem_size = resource_size(pp->mem); + pp->mem_bus_addr = pp->mem->start - win->offset; + pp->mem_base = pp->mem->start; + } break; case 0: pp->cfg = win->res; @@ -406,8 +445,6 @@ int dw_pcie_host_init(struct pcie_port *pp) } } - pp->mem_base = pp->mem->start; - if (!pp->va_cfg0_base) { pp->va_cfg0_base = devm_pci_remap_cfgspace(dev, pp->cfg0_base, pp->cfg0_size); @@ -534,12 +571,12 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, va_cfg_base = pp->va_cfg1_base; } - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX1, + dw_pcie_prog_outbound_atu(pci, pp->cfg_idx, type, cpu_addr, busdev, cfg_size); ret = dw_pcie_read(va_cfg_base + where, size, val); - if (pci->num_viewport <= 2) - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX1, + if (pp->cfg_idx == pp->io_idx) + dw_pcie_prog_outbound_atu(pci, pp->io_idx, PCIE_ATU_TYPE_IO, pp->io_base, pp->io_bus_addr, pp->io_size); @@ -573,12 +610,12 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus, va_cfg_base = pp->va_cfg1_base; } - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX1, + dw_pcie_prog_outbound_atu(pci, pp->cfg_idx, type, cpu_addr, busdev, cfg_size); ret = dw_pcie_write(va_cfg_base + where, size, val); - if (pci->num_viewport <= 2) - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX1, + if (pp->cfg_idx == pp->io_idx) + dw_pcie_prog_outbound_atu(pci, pp->io_idx, PCIE_ATU_TYPE_IO, pp->io_base, pp->io_bus_addr, pp->io_size); @@ -652,6 +689,9 @@ static u8 dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci) void dw_pcie_setup_rc(struct pcie_port *pp) { u32 val, ctrl, num_ctrls; + u64 remain_size, base, win_size; + phys_addr_t bus_addr; + int i; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); dw_pcie_setup(pci); @@ -700,13 +740,42 @@ void dw_pcie_setup_rc(struct pcie_port *pp) dev_dbg(pci->dev, "iATU unroll: %s\n", pci->iatu_unroll_enabled ? "enabled" : "disabled"); - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX0, - PCIE_ATU_TYPE_MEM, pp->mem_base, - pp->mem_bus_addr, pp->mem_size); - if (pci->num_viewport > 2) - dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX2, - PCIE_ATU_TYPE_IO, pp->io_base, - pp->io_bus_addr, pp->io_size); + /* + * The maximum region size is 4 GB, and a region + * must not cross a 4 GB boundary. + */ + win_size = SZ_4G - (pp->mem_base & (SZ_4G - 1)); + win_size = min(win_size, pp->mem_size); + dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_MEM, + pp->mem_base, pp->mem_bus_addr, + win_size); + dev_dbg(pci->dev, + "iATU: non-pref MEM: win = %d: base = %llx, bus_addr = %pa, size = %llx\n", + 0, pp->mem_base, &pp->mem_bus_addr, win_size); + + /* Prefetchable range can be 64bit space */ + remain_size = pp->mem_perf_size; + base = pp->mem_perf_base; + bus_addr = pp->mem_perf_bus_addr; + for (i = 1; remain_size > 0 && i < pp->mem_wins; i++) { + win_size = SZ_4G - (base & (SZ_4G - 1)); + win_size = min(win_size, remain_size); + dw_pcie_prog_outbound_atu(pci, i, PCIE_ATU_TYPE_MEM, + base, bus_addr, win_size); + dev_dbg(pci->dev, "iATU: pref MEM: win = %d: base = %llx, bus_addr = %pa, size = %llx\n", + i, base, &bus_addr, win_size); + + base += win_size; + bus_addr += win_size; + remain_size -= win_size; + } + + if (remain_size > 0) + dev_info(pci->dev, "iATU: MEM window isn't enough\n"); + + dw_pcie_prog_outbound_atu(pci, pp->io_idx, PCIE_ATU_TYPE_IO, + pp->io_base, pp->io_bus_addr, + pp->io_size); } dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index a438c3879aa9..0197f67f82b7 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -148,15 +148,22 @@ struct pcie_port { u64 cfg1_base; void __iomem *va_cfg1_base; u32 cfg1_size; + u32 cfg_idx; resource_size_t io_base; phys_addr_t io_bus_addr; u32 io_size; + u32 io_idx; u64 mem_base; phys_addr_t mem_bus_addr; u64 mem_size; + u64 mem_perf_base; + phys_addr_t mem_perf_bus_addr; + u64 mem_perf_size; + u32 mem_wins; struct resource *cfg; struct resource *io; struct resource *mem; + struct resource *mem_perf; struct resource *busn; int irq; const struct dw_pcie_host_ops *ops;