From patchwork Thu Oct 25 09:22:35 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: 10655633 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 2551315A7 for ; Thu, 25 Oct 2018 09:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 134C82AF1F for ; Thu, 25 Oct 2018 09:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 079B62B02E; Thu, 25 Oct 2018 09:23:03 +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 ACAA42AF1F for ; Thu, 25 Oct 2018 09:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727135AbeJYRyc (ORCPT ); Thu, 25 Oct 2018 13:54:32 -0400 Received: from mail-eopbgr30078.outbound.protection.outlook.com ([40.107.3.78]:10483 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726785AbeJYRyb (ORCPT ); Thu, 25 Oct 2018 13:54:31 -0400 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=Ie25hpAqX9ySS3l7uae86c4vfPDa5RBfALtQqz40X5U=; b=Q3Yl+c0b1TUWU3+6Uk4F34X8weOgXTz+9RZ9J/q+qKO4B1PwWlDaD8T6LpkXTmMK04zIm7akgFPZSslT8msFRa5fMbFHyskk4PNg0+xbQfzz7302/OkX5TRSSgnJQMxemZRj3lLHI9t1LpGd+Vl6OtCtQhjYKk8iX+0/uk2G0Jc= Received: from DB5PR04MB1221.eurprd04.prod.outlook.com (10.162.155.27) by DB5PR04MB0952.eurprd04.prod.outlook.com (10.161.195.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 09:22:36 +0000 Received: from DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb]) by DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb%2]) with mapi id 15.20.1250.028; Thu, 25 Oct 2018 09:22:36 +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: [PATCH 1/4] PCI/dwc: fix potential memory leak Thread-Topic: [PATCH 1/4] PCI/dwc: fix potential memory leak Thread-Index: AQHUbEREQvuwyxv4sEeimaudU2OseQ== Date: Thu, 25 Oct 2018 09:22:35 +0000 Message-ID: <20181025092229.28413-2-Zhiqiang.Hou@nxp.com> References: <20181025092229.28413-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181025092229.28413-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: HK0P153CA0010.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::22) To DB5PR04MB1221.eurprd04.prod.outlook.com (2a01:111:e400:51c2::27) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB5PR04MB0952;6:ylp+qWsSOrYbYrK47SHgRb2l+SG0W1Spv3bpLWie7uu9klneCDBsYTVNexhTEh/2FcuSy/OugGnoMULTlljkkgVrTOxzL0Jyv8DIzvNfa7qQ3fXbvKFtR9G17qA6wC4O69pZUzyyB+zpUN+4lH7BC17zX+IqCelHwRjm9XJvqBhRq60+CY4k16bnON9tGIvukKAk8+V7OHZZVILogAlfjFqdCbN6noiZLFV2s2lLxjJ25TdYOSVuQtpvR+UGPIY2jYoBhHIWFsWbe3XF66W3LXuboVCNEU0Se7VpzYGaoAc0ix5WQv/A9HqduWiGUBeDkZjUxPg8Op2yHzhzksgta1WXpCOQ/tzFDygXKRq3a3L5xqXasfwmgsTbCdhZJ2w5T5T01P+8S3naWHoLas6ANkZrrqxgPVDrHG8udtHEw1hOz6lBb3jSxUZBw0q7Rcu/+wXJJlbKL+hNoTHXdySgFw==;5:2iSnQ4w8L3NmhBdrGpnN5+QTZhQxUxeB447TflDBDYqxiUxTnsC2SkkvssNc8vz3dl2hTXDZn1SobwYSqemf0V389M+CEioNVVXznZimRzrXBrqFhjkuhExcBv720iA88ECQnal66b+tHc9APq/IVj+3P43GKvlruT+8zzud9+0=;7:oQBHTzMRGmGnFjjLIrVydt8SV2gLCfGz2XMoU9L/WS5yBk00XeVfDkoK+y6n/KA8u75XsGbiMilsY8tBCnbFAsrm59zBbcznjBhEI8IooX+g1S9mfiDu79+XEs48RdUezkNzx+UfflhmOFDXvTP59DfjYjOrm7ro743+CnDyk4eSVBuNFav6I3+c10Ct+CY/H/jYve+PnpT3eNBrvxsexCsZ+YLVJYbwPdX7JKYevCqF4rpYAeL+GtbgttBXxOrD x-ms-office365-filtering-correlation-id: 1aaa4840-1fae-4fb8-ae0a-08d63a5b6664 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DB5PR04MB0952; x-ms-traffictypediagnostic: DB5PR04MB0952: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:DB5PR04MB0952;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB0952; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(39860400002)(346002)(136003)(376002)(199004)(189003)(6512007)(6436002)(97736004)(6486002)(39060400002)(99286004)(81166006)(4326008)(81156014)(53936002)(106356001)(25786009)(105586002)(2900100001)(102836004)(11346002)(7736002)(8936002)(446003)(2616005)(14444005)(256004)(305945005)(476003)(186003)(478600001)(86362001)(8676002)(26005)(68736007)(2201001)(6346003)(486006)(6116002)(3846002)(386003)(6506007)(76176011)(66066001)(2906002)(5660300001)(36756003)(1076002)(14454004)(316002)(54906003)(110136005)(71200400001)(71190400001)(52116002)(2501003)(5250100002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR04MB0952;H:DB5PR04MB1221.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-microsoft-antispam-message-info: UWd3NPj7GTJ8fJ2RPOuyg1W9AU7drqEhhNpvZGX1ajuFYYBOoxU+GqC23UgaqJgBO7jLjqA1ZAczEasOAEm9ldQFj6PY38wVuV+8w9gIKVZCWLbMkz6wh34X6CxnHvcKTTcl1iORZE/jQFwUY3eZqgLlV1NNfc1sOHrgbwQLLAu7TzmLdCHEVvWb5MFDjWye1swsvsgafqASMR+R+T8jVYfzsyQGxdNCeTwal6xDB3i2aoR4piCwASsmMy3uldjz/fXAd277GZrsUhA6wxZH82ACAOXeeic08S6AS4WwBtHbe+R8Ser5jot4STJOU3Vzend8/HosGeKJ/r5LFV26R9uvk+ie20JYOdgXm2/sp3U= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1aaa4840-1fae-4fb8-ae0a-08d63a5b6664 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 09:22:35.9282 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB0952 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 --- 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 Thu Oct 25 09:22:40 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: 10655627 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 1EFA315A7 for ; Thu, 25 Oct 2018 09:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CF382AF1F for ; Thu, 25 Oct 2018 09:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00FFA2B02E; Thu, 25 Oct 2018 09:22:49 +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 925822AF1F for ; Thu, 25 Oct 2018 09:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbeJYRyh (ORCPT ); Thu, 25 Oct 2018 13:54:37 -0400 Received: from mail-eopbgr30077.outbound.protection.outlook.com ([40.107.3.77]:6528 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726785AbeJYRyh (ORCPT ); Thu, 25 Oct 2018 13:54:37 -0400 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=lEzhvuS08m2N7aN8G/jU2BHrEOFPUwHANjFoyGLA6FY=; b=kdFkYe/fCJ+Fw77NmNiuHm8ebpllu+5O2BvhGSXj/DcsTzkmK+1TXmLl11uzr9nmeZs78mFoCaqbSZ6jbUqUJ998ur9YzFZL3wTOaY0nvk2WlZzjVMGRC358vHaBTV4LtrE7ylqQHInw8ke3zJVzhnM+Sjl8jSvtT38HmLgIckQ= Received: from DB5PR04MB1221.eurprd04.prod.outlook.com (10.162.155.27) by DB5PR04MB0952.eurprd04.prod.outlook.com (10.161.195.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 09:22:40 +0000 Received: from DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb]) by DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb%2]) with mapi id 15.20.1250.028; Thu, 25 Oct 2018 09:22:40 +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: [PATCH 2/4] PCI/dwc: Fix the 4GiB outbound window size truncated to zero issue Thread-Topic: [PATCH 2/4] PCI/dwc: Fix the 4GiB outbound window size truncated to zero issue Thread-Index: AQHUbERGs7x7LmcHLUS70YvdVhCN2A== Date: Thu, 25 Oct 2018 09:22:40 +0000 Message-ID: <20181025092229.28413-3-Zhiqiang.Hou@nxp.com> References: <20181025092229.28413-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181025092229.28413-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: HK0P153CA0010.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::22) To DB5PR04MB1221.eurprd04.prod.outlook.com (2a01:111:e400:51c2::27) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB5PR04MB0952;6:2PwRNPt/EuatCjmad/+t8bp9NS0xk1QMG/EncYBIWHNN2XnUTGufkIaZdYWPAIsE31tDLJghv5tsUBDwjglnNmlpsaeLWPV8dBe7/uInbB6cX9QAKVyLAdWvtNXdX+b4s3iC+DdjO5jY1mmfN9oRh2TOb4aTwdGi7qaV5krmJfe/EIMFS7AH6rV8WOPeHOhjEr8281Vn6B/5p0Z+ZXA2zL5d6zhflyw6/gmNtUKKQDTgQgzoq0Kohpx83SipaqhfF6p1Gv7YlrgKxtaHZq/UPxaHw3dZTzbCDuyGtwUBydnaTcPhSINjCoOH2svUgrSBgNxxOOwbmCKevNpOnBcZnBxDRF6C5ChfGsH2bqcHzf9s6sRk+EXdlsIAB5uTb+ZbQzQ5FSHhLLfzpICtca94uRHst/lEWKKvMpNDKN5u0UYesfv8nr0upF0W3p5cK1AOhTYNRD4xXTRFQypvSc8aaA==;5:ghADDvHPdHhFvGwfmFRJiUG4MZURREVPk1AKv+fdiJJ6BieZLZQDM4r9i+Ecm5gFouzUBx6FO2+YwfhkRW9AxRLCJdHHBIkjMWOxTgiCFbpkVdXor+ly5nJ32iw+OJpG8b1W2fiyJH90iA3hMhDptKCz2Q+9A/rQkVU533wf+Ic=;7:aM40D/upNNfldo30fF/bVUy7LIqSsFjEJQ7sUkAEwm6Gz+/qHPLaZ5Pbqr3NMjy/KX0eG4Kj5pVsW+ZKaopdwzleHsnUj6uTpXHiTjOGN3Mp/bOFm85yV0PXq5KGRiPWHtj7nyyKRXixjwPib35Fmivb3OEljkzlmQQB5TPYgIaDce5ZEE+V7Xddd+TqfUQeYcZMIa9kNcc+2UlUuV5JhkmkPen2rfESCRqOF7QJGCNvzV8UkJo58WBDBjpfv3vl x-ms-office365-filtering-correlation-id: 44b9222c-1626-41c1-aa6c-08d63a5b6940 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DB5PR04MB0952; x-ms-traffictypediagnostic: DB5PR04MB0952: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:DB5PR04MB0952;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB0952; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(39860400002)(346002)(136003)(376002)(199004)(189003)(6512007)(6436002)(97736004)(6486002)(39060400002)(99286004)(81166006)(4326008)(81156014)(53936002)(106356001)(25786009)(105586002)(2900100001)(102836004)(11346002)(7736002)(8936002)(446003)(2616005)(256004)(305945005)(476003)(186003)(478600001)(86362001)(8676002)(26005)(68736007)(2201001)(6346003)(486006)(575784001)(6116002)(3846002)(386003)(6506007)(76176011)(66066001)(2906002)(5660300001)(36756003)(1076002)(14454004)(316002)(54906003)(110136005)(71200400001)(71190400001)(52116002)(2501003)(5250100002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR04MB0952;H:DB5PR04MB1221.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-microsoft-antispam-message-info: icCp2+frD40EDW67CJZtDximquG6chqhNgkFytByUqxnEKiYVN9tYb9GzFWWmasFWPtCaxcH/zvN1EqoKsEPx05EUSvN19RSXckJlpMtxCEvNu7TsDFbIez/PnI+Ry9jKcoUTqaHkRq3Y70Z0nZXUlFA2/NZxSH5fzjq3crJa4gdHWaw9gh1GrFzgPaKQPZVrwNfkmn2VoxCcu2v85wKc7kIhJGmA+6ah7hYSarSvBGEVD4DDlcMedZImCgVGHbhl8c0oOgLphmfuKJcCDnvlpQ/Ga3ZQ2kHVYU6KnloOIkzmTf+4MFWTpruLFu1Sa5FfemDAybsQpw7KDOxZ1/s2nofdv+5XLzg6xYKaB+6p6k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44b9222c-1626-41c1-aa6c-08d63a5b6940 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 09:22:40.5065 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB0952 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 --- 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 Thu Oct 25 09:22:45 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: 10655629 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 C1692109C for ; Thu, 25 Oct 2018 09:22:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DFB2AF1F for ; Thu, 25 Oct 2018 09:22:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4D8F2B02E; Thu, 25 Oct 2018 09:22:51 +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 4EDB92AF1F for ; Thu, 25 Oct 2018 09:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727226AbeJYRym (ORCPT ); Thu, 25 Oct 2018 13:54:42 -0400 Received: from mail-eopbgr30072.outbound.protection.outlook.com ([40.107.3.72]:36992 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726785AbeJYRyl (ORCPT ); Thu, 25 Oct 2018 13:54:41 -0400 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=cwqeRYWI2ZrTiXz3DtAf7xwrHwMC/HTBR7Bjdhkay5k=; b=m47cjoRaQstkJ4g+S4iFUV5pwj2ltwAwND+z99niyrroiXLuIo4jMWRtXQNb32LPdJz/PkqUc6tCLSdkoFNWA6HfJ7E7DH1eP1U7wTaqT5PWBiXZUgmv/oLw6mxKWas2yFJKnck7SeastQt51/CEYM/rVY6eGJ+4BkPFsqJAYVw= Received: from DB5PR04MB1221.eurprd04.prod.outlook.com (10.162.155.27) by DB5PR04MB0952.eurprd04.prod.outlook.com (10.161.195.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 09:22:45 +0000 Received: from DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb]) by DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb%2]) with mapi id 15.20.1250.028; Thu, 25 Oct 2018 09:22:45 +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: [PATCH 3/4] PCI/layerscape: initialize the number of viewport Thread-Topic: [PATCH 3/4] PCI/layerscape: initialize the number of viewport Thread-Index: AQHUbERKdFptZfo9y06n6wAEdcBBgA== Date: Thu, 25 Oct 2018 09:22:45 +0000 Message-ID: <20181025092229.28413-4-Zhiqiang.Hou@nxp.com> References: <20181025092229.28413-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181025092229.28413-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: HK0P153CA0010.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::22) To DB5PR04MB1221.eurprd04.prod.outlook.com (2a01:111:e400:51c2::27) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB5PR04MB0952;6:oNhuikFHMw1NE+je8+n3f8KDxXPC680wSlO3HjlWFKQc2FunrZaRs86hTesf+b9VAJ7i2fQOLCUXr8KOYfYowlusPaE+CFqh2LXdOdxBZM5fHa+gxRIudOBolZg2+PQKPzoszOueoSpxM53ZT1ZQktNXT66/mmWThc82XGn678/Hwa/cTX656sx73PL6Fkc0Ot+Dh6KBCcSXQjp9Knv0GK0hhr/IlVSfNRFDm2H1mlGcN3rqRw1b6qav1o+zZUvU+Tr64sxhhWuCZ4FGzydFD+iKj224NwVEDX7HC/FBDJ6acrJ/427E6gUdubrVnV2oIKu9pxVqgTWtgRrChfrPC1R/QBBWtPciFi7wpFvmDlcfkL2owhAUn/2fv+zqmr4an9xp8x2CooYwv9PXeYqzy9zJC0VJ1BstnOO01RKbP7xWTyLboODVLr80QsMUMMSJifplzh3azUpg9Q5z5y9hvg==;5:iHsKebvizAqNKYhZFqEAYHGJNFpFnjVipPR9qQo9F1Y/KYWJE4X2ioFJoD28NV/1sgau+WW4gvvlKM9qNAuztRZp9qYZ5QAphGqUOE6XuASfLvojUVNNlpYb+Igtc5ua9lpyF+/aqx30DuwbyaW+hAlszf9J+btlpqQCN/j/eL0=;7:cgIQxSN93keykmEFNJ/Dp7rV7VvTh7D6lzbU3lwiEI6k7+ocJ7wfZVlm/Dh1NlFdFQU1RvbuZmGlFtQqZQn9GesdwHijhRsYX2CfvPxfjKllLUH8hRpOBQs3BolU0uW2Jp612LamFR+fU5g4aQp7TANChA/gRVCd865eNq+ANvdr6F5nuPlfIwoOPUna8t6T1qPMZVGpCYTXxwLc2oUQNITzAPaobhMib5/PYKdr+oD8mh44N3BJrMp0bUsrAwJh x-ms-office365-filtering-correlation-id: 6079341c-f9cb-44a1-2f4e-08d63a5b6c45 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DB5PR04MB0952; x-ms-traffictypediagnostic: DB5PR04MB0952: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:DB5PR04MB0952;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB0952; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(39860400002)(346002)(136003)(376002)(199004)(189003)(6512007)(6436002)(97736004)(6486002)(39060400002)(99286004)(81166006)(4326008)(81156014)(53936002)(106356001)(25786009)(105586002)(2900100001)(102836004)(11346002)(7736002)(8936002)(446003)(2616005)(256004)(305945005)(476003)(186003)(478600001)(86362001)(8676002)(26005)(68736007)(2201001)(6346003)(486006)(6116002)(3846002)(386003)(6506007)(76176011)(66066001)(2906002)(5660300001)(36756003)(1076002)(14454004)(316002)(54906003)(110136005)(71200400001)(71190400001)(52116002)(2501003)(5250100002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR04MB0952;H:DB5PR04MB1221.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-microsoft-antispam-message-info: 1uoEmt0U8ObnqBT6mlHrb9+MH8B0dtV7p1Aemw72wxdNT8qp6+WHoSuFEkCdN+dMcl2Ykq7F3nWhexAsHu0pxwA53PWxF1s6+Z55S5vq/iAG/Dfwnvfr8EH9kX3FHtldefQCvqpsw0eajGJUajbyisrw3GFUhkklx9S2601tCXPcIApA9uUfepLuq2VKRLoXlsvbwz3nih3tHDR4uQTLd+insEmfeedd0ubmXR0UXYgNt4tcB+Df90S8IjwmVNjs5zjyQ4l02p7HAI16wjdC4wbEhvxeVVEyS7nsp4rCfh4WqRnzUVF02Enw/8gpJ8eS3S0pOL3rWa39ZoNvRT9I6P3fvAhr8qXyIdZStiMtQWM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6079341c-f9cb-44a1-2f4e-08d63a5b6c45 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 09:22:45.7881 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB0952 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. Signed-off-by: Hou Zhiqiang --- 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 Thu Oct 25 09:22:50 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: 10655631 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 3DD60109C for ; Thu, 25 Oct 2018 09:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 284C42AF1F for ; Thu, 25 Oct 2018 09:23:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 196662B02E; Thu, 25 Oct 2018 09:23:02 +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 6B50A2AF1F for ; Thu, 25 Oct 2018 09:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726866AbeJYRyr (ORCPT ); Thu, 25 Oct 2018 13:54:47 -0400 Received: from mail-eopbgr30083.outbound.protection.outlook.com ([40.107.3.83]:23468 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726785AbeJYRyq (ORCPT ); Thu, 25 Oct 2018 13:54:46 -0400 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=2nkfQZl/cBzfEno5oHQWwPQaRwoPh/sKA6PawQmtZtM=; b=IDdYtu76bePFcgGDLdjgCidXQZ97+wp3bnRWRBNwb/Gr9aEvxrhoVseKYCAMLO2qRRNq1qABxep2LVv2igALUuVpzpCyqJ7ep1xLSiI82qzNzXmSSR7VzB/hG/wkBWbFAvvPbcfNbs5txgOXL9wEPknJ08SgIhfUr9wZTtw6J1A= Received: from DB5PR04MB1221.eurprd04.prod.outlook.com (10.162.155.27) by DB5PR04MB0952.eurprd04.prod.outlook.com (10.161.195.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1250.30; Thu, 25 Oct 2018 09:22:50 +0000 Received: from DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb]) by DB5PR04MB1221.eurprd04.prod.outlook.com ([fe80::6c36:f4cb:26c2:e8cb%2]) with mapi id 15.20.1250.028; Thu, 25 Oct 2018 09:22:50 +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: [PATCH 4/4] PCI/dwc: Add more than 4GiB range support Thread-Topic: [PATCH 4/4] PCI/dwc: Add more than 4GiB range support Thread-Index: AQHUbERMuOPdoBqF20StZYHO34SK+Q== Date: Thu, 25 Oct 2018 09:22:50 +0000 Message-ID: <20181025092229.28413-5-Zhiqiang.Hou@nxp.com> References: <20181025092229.28413-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181025092229.28413-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: HK0P153CA0010.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::22) To DB5PR04MB1221.eurprd04.prod.outlook.com (2a01:111:e400:51c2::27) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB5PR04MB0952;6:onz636fvb+t4WsseBBqScy1UExcduJVBLkY/DosHV9gb0ewx2zqMJWTfh22Z3yTpQ+jYRlHp8IuW17TUTwqSj1FMfY/rb+mY6oOjUVFGV+dxkkGo8EMa0aexHQI3v/ur+7s1HqRO6yxWjka2GtiR5GD3QZmTwVmIDENG6Ztc/gWlorpssL+OJUh9ByH7r8IE3UBdzT7NKusZAo52Ohp1/HWYMJKCr6OVh/sj2HdibCivbBPIeQHCrVoRyHupxz8+UvBbrGa3LNn1WajfYUczfKoPaAiCr95qzWJWfN1dU9qXKuFpYeUnS6bBdfZ9mDdM6vqxD7VWP5XzFI7XFNQP6IDLPdxTl+cfFhJJrlnN97Hu3B6VcJNXP24uRniJmztx7EALztoUwY8Y7JSpBHG/T3e2+rpL6GT3BOSEG3i/lbn5VHkw/GVWLo52LSJGPmUIEtks34Fki7ij+al7d1vOCA==;5:QjZzpPH8cdkyZNjfoYXOFSYUqmj7WWIwBoKTi/4Y8DWeSwXZwcgbOf7D26L5i5JH5/uMqQvAOOmwLVeC6l9Y9yQ6N5D4111nmvpg2PQOD/Efz8gy0cwR8DiUxB6KhOGwiENYWD97IKY1bRrNuQbZCirmioEck4jheaMr0yzKVz0=;7:qIjn1HAWzpb3pwuvcKXBOTxXwl+R1pORehgVBfHCBCzpVElT3gky68a+pxXRQV6FtczhwcqWPmJVcj9Cfx9K5sfdy6hxs5G6HUGPruizJznVb0XgT45wrm6Wn2kqAaszQ1hcWvHbeJj12a/FtNFYB7SV6/hA23HsOpeSADO+CIlfnqDACanEkStEdduZcSeaQF7hFYQV9U98xxZh/T/Uw7mEVKGMfu2zKMw3f36HW1xE1LB073HuheWqtA2w4u7e x-ms-office365-filtering-correlation-id: 53693be8-6026-4e3a-c950-08d63a5b6f1e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:DB5PR04MB0952; x-ms-traffictypediagnostic: DB5PR04MB0952: 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)(8121501046)(5005006)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:DB5PR04MB0952;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB0952; x-forefront-prvs: 083691450C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(39860400002)(346002)(136003)(376002)(199004)(189003)(6512007)(6436002)(97736004)(6486002)(39060400002)(99286004)(81166006)(4326008)(81156014)(53936002)(106356001)(25786009)(105586002)(2900100001)(102836004)(11346002)(7736002)(8936002)(446003)(2616005)(14444005)(256004)(305945005)(476003)(186003)(478600001)(86362001)(8676002)(26005)(68736007)(2201001)(6346003)(486006)(6116002)(3846002)(386003)(6506007)(76176011)(66066001)(2906002)(5660300001)(36756003)(1076002)(14454004)(316002)(54906003)(110136005)(71200400001)(71190400001)(52116002)(2501003)(5250100002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR04MB0952;H:DB5PR04MB1221.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-microsoft-antispam-message-info: byU5hhmjteYIuCHZ/QKbjUAaXGPUCGnAMcWk6TYviSM/JctsTMy1tD4ZCikJdwT8hvefYwB3Oiy7Hrv0PPZ6LnIBgJYHlOGaXGwo7NjLx7+WTcGfOTSsn7KcXHAchcwwAdmERXCqE58uhXOn4d0JPvNsSHRNO3uFLYJARwk2tM765xwVq4r0/w9foUrA4q/BkCKUvQPPNEZDNNcns7ZncZfboNff38Lz2MzoDQBcwas6DluII5+qG7vPbCplCd+FBQHkhJqDw88GzYpLMELNjJuS3BkjHZXfGE58CBp41sXTO6pDmcaz3zzYl+riux/ruxDzDcwF2GFDp0XJAPfi+yfcN2EcmcH0ljyBYXNY9b0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53693be8-6026-4e3a-c950-08d63a5b6f1e X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2018 09:22:50.5852 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB0952 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 As each viewport support upto 4GiB, to support greater than 4GiB range we need multiple viewport for MEM windows. And this patch explicitly assigned the last (if there are only 2 viewports) or last 2 viewports for CFG and IO windows and the rests for MEM windows. Signed-off-by: Hou Zhiqiang --- .../pci/controller/dwc/pcie-designware-host.c | 80 ++++++++++++++++--- drivers/pci/controller/dwc/pcie-designware.h | 3 + 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index ecacce016489..1b083873835e 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 window index: %d, IO window index: %d, Total MEM window number: %d\n", + pp->cfg_idx, pp->io_idx, pp->mem_wins); + bridge = pci_alloc_host_bridge(0); if (!bridge) return -ENOMEM; @@ -534,12 +563,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 +602,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 +681,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 +732,35 @@ 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); + remain_size = pp->mem_size; + base = pp->mem_base; + bus_addr = pp->mem_bus_addr; + + for (i = 0; remain_size > 0 && i < pp->mem_wins; i++) { + /* + * The maximum region size is 4 GB, and a region + * must not cross a 4 GB boundary. + */ + win_size = SZ_4G - (base & (SZ_4G - 1)); + win_size = min(win_size, remain_size); + dev_dbg(pci->dev, "iATU: MEM window %d: base = %llx, bus_addr = %llx, size = %llx\n", + i, base, bus_addr, win_size); + + dw_pcie_prog_outbound_atu(pci, i, + PCIE_ATU_TYPE_MEM, 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..20146b8729b3 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -148,12 +148,15 @@ 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; + u32 mem_wins; struct resource *cfg; struct resource *io; struct resource *mem;