From patchwork Tue Nov 6 13:21:00 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: 10670393 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 8855813A4 for ; Tue, 6 Nov 2018 13:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 766872A431 for ; Tue, 6 Nov 2018 13:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69FB62A43A; Tue, 6 Nov 2018 13:25:50 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 EA7D62A431 for ; Tue, 6 Nov 2018 13:25:49 +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:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hzWdlpVQWb9YQDVYiy3PiAB2+VUkd1gu7omrGWAzk60=; b=bsiiFQXVnvpsvG l2l7VV2D2F9PA5fjorGoJpsSnTtjUDdFmORZM/wroXnfDmagA5uPRdE9/53knErQfSzL98s5DZiX/ 1tQ5cY62Vs2quw4GmPrMCq9sbKtsHpatcdOyZ5uuJ/3jAft9d//fKK1NAcNyC+m7cbYHuH5hdfzi/ E9Ud9l9xrP0GievDA0rN9gJMnEUAPmexzTKvL4690Pf52BV8ia+4ZqL+c/2BlUtEvzgqUDds0rzji rbC40Z19hld/2XNRW+33pBIOR6mrwdbanGmCdvwqcYk5FIbIt7uLgz8RCJTdP5i2zI4/HGTLoRMQ3 sWzjeQelM1VEfkJY3Ogg==; 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 1gK1Ma-0008Pf-66; Tue, 06 Nov 2018 13:25:48 +0000 Received: from mail-he1eur01on061c.outbound.protection.outlook.com ([2a01:111:f400:fe1e::61c] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gK1IJ-0000r5-RP for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2018 13:21:25 +0000 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=sc5uKHbf3v0qCGYcXW6quzgbwBxS23iSrW0yDURxXNI=; b=N8d+9wkOjaawnZpwmINsGFhXVoJ/LlBkCXlwvV3PSZyhNFKdFMsROqK5FgKR17HVKmGMImGU3I9eVd41f47YPyHhMnn4usMBfmYuNlLb0+nBt1qpHOOhZkxQpsqLLmvPz5Dy+aEobjw0O/GPl12Wx3C1rgWHUimOkDc3vql/RZw= Received: from DB5PR04MB1221.eurprd04.prod.outlook.com (10.162.155.27) by DB5PR04MB1414.eurprd04.prod.outlook.com (10.162.221.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.27; Tue, 6 Nov 2018 13:21:00 +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.1273.035; Tue, 6 Nov 2018 13:21:00 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "l.subrahmanya@mobiveil.co.in" , "shawnguo@kernel.org" , Leo Li , "lorenzo.pieralisi@arm.com" Subject: [PATCH 18/23] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Topic: [PATCH 18/23] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Index: AQHUddOP9u/TlMIhSUSgJ6+th1klBQ== Date: Tue, 6 Nov 2018 13:21:00 +0000 Message-ID: <20181106131807.29951-19-Zhiqiang.Hou@nxp.com> References: <20181106131807.29951-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181106131807.29951-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: HK0PR03CA0008.apcprd03.prod.outlook.com (2603:1096:203:2e::20) To DB5PR04MB1221.eurprd04.prod.outlook.com (2a01:111:e400:51c2::27) 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; DB5PR04MB1414; 6:FT3m/CyJzk43NDHKn9yh9+hTv4DHr4VUSs+BKGs6T6AQIj1rf1zpuS4zih7RLzHPXu5i/DNd6PTPcfhKyRkOBdUQMh2b3GGu8pOPU1MBeYRvsxX6bfnYY6T2iteZGmqxAZ2dpuZD1bMiwmCzzSko8Ux3Tc5cr7vOHy+G5Va9lqL50JhAhNzaz052A01wBUEqWhGAtIlDO8q6dy6LzihnJaOSMPA8raWmdA1grYHvnyoj1GJZL4TKSl5sfAlHqSnTCbsur230Z3QpiCqHY1RA69DcyIs3BfbGmW7nw+c3P0832H5eJTgXhpGRIZRYpXG1IM9wai+1DMQNGC6MEQmk94fGlWLoq1gug1Kn7xikM5oWrkq3KAklkbV0mttrkPKX9/PParmZABzlFQT0A4ewuzmd3dLrEAG1OUNVsWqz//8kIT7xcftuu5ZVDz6+Ghf6VWeFYNZXl75U8Df/Rasshw==; 5:ggE/GtkItCqNTunVGnCKwBKrGsCUEz67C4dPk9/oIl7syI+pqBLJwC0gSvYQTMRPOPiBY1FL6wJUd8M/+j67qkIWHDM065ryncOrLZVsVmZr5chs6xoMflxpXzNeQZsPd5j5v4JW06uvNLC1RmFiFDlvRka1ZuHiors7+uOzX78=; 7:smQNiI1bshWtHAsvJ6rlVyCNDXIL4Ksu9Vt5ZUh/Adi7717OUGleGOo5/7XlZM/2aAnCBkdjwPeFoXSSDpWYCW8dIQO69Xo+Gy8gNZWaFVJWn7MHo9MKaF0Nn+HiQ9njo9NxLtBrs1joP7JKGO9qsw== x-ms-office365-filtering-correlation-id: fee4da17-a9a8-414a-10c9-08d643eab17f 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:DB5PR04MB1414; x-ms-traffictypediagnostic: DB5PR04MB1414: 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)(3002001)(10201501046)(93006095)(93001095)(3231382)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB5PR04MB1414; BCL:0; PCL:0; RULEID:; SRVR:DB5PR04MB1414; x-forefront-prvs: 0848C1A6AA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(396003)(376002)(346002)(136003)(189003)(199004)(97736004)(66066001)(8936002)(81156014)(81166006)(7416002)(8676002)(5660300001)(71200400001)(71190400001)(478600001)(6486002)(6116002)(2900100001)(1076002)(53936002)(6436002)(6512007)(305945005)(4326008)(25786009)(7736002)(105586002)(106356001)(68736007)(2906002)(3846002)(256004)(26005)(14444005)(486006)(2501003)(14454004)(99286004)(52116002)(76176011)(36756003)(110136005)(386003)(6506007)(102836004)(54906003)(86362001)(186003)(446003)(11346002)(316002)(2616005)(476003)(2201001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1414; H:DB5PR04MB1221.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: 5dGcm1parw0Sqc6syt8omU3BdxROGcIdO+s2QDq92VIXBvk1Mx3/ln2MGCiXkp4f18JKmTt8LS7B9EYAQyX96zAjgo+DCC75Rn58FFGu+akr07alNDrQqVFO+kJfX/fRxnbCtkBWtnUfc0bDGRBerka30CRycutZF0wW/tbB1+DClGYVBKeqAOo2w7ebQAn/e/sAb7cOzcOH2DU+cQhbCJeUdUCyyZMWl6yt4j1mu/ic+L9jdMbPreleRJV2vgohmYqcgfakd1mdthH9SWsA33JR3RmYj4q9DdonCgE1PCVtFji3zcyndvNVkznMa7eE4b0CLq22+GSaoqFtsA+SikshmULcFm4lUcDSz01S73w= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fee4da17-a9a8-414a-10c9-08d643eab17f X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2018 13:21:00.2659 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1414 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181106_052123_901316_47668289 X-CRM114-Status: GOOD ( 12.77 ) 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: "M.h. Lian" , "Z.q. Hou" , Xiaowei Bao , Mingkai Hu 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 From: Hou Zhiqiang Disabled all inbound and outbound windows before set up the windows in kernel, in case transactions match the window set by bootloader. Signed-off-by: Hou Zhiqiang --- .../controller/mobiveil/pcie-mobiveil-host.c | 7 +++++++ .../pci/controller/mobiveil/pcie-mobiveil.c | 18 ++++++++++++++++++ .../pci/controller/mobiveil/pcie-mobiveil.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c index 4419179f64bc..de24fedcb92d 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c @@ -217,6 +217,13 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) { u32 value, pab_ctrl, type; struct resource_entry *win; + int i; + + /* Disable all inbound/outbound windows */ + for (i = 0; i < pcie->apio_wins; i++) + mobiveil_pcie_disable_ob_win(pcie, i); + for (i = 0; i < pcie->ppio_wins; i++) + mobiveil_pcie_disable_ib_win(pcie, i); /* setup bus numbers */ value = csr_readl(pcie, PCI_PRIMARY_BUS); diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil.c b/drivers/pci/controller/mobiveil/pcie-mobiveil.c index 71389ebbf229..cd2a7b9a7a2f 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.c @@ -225,3 +225,21 @@ int mobiveil_bringup_link(struct mobiveil_pcie *pcie) return -ETIMEDOUT; } + +void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pci, int win_num) +{ + u32 val; + + val = csr_readl(pci, PAB_PEX_AMAP_CTRL(win_num)); + val &= ~(1 << AMAP_CTRL_EN_SHIFT); + csr_writel(pci, val, PAB_PEX_AMAP_CTRL(win_num)); +} + +void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pci, int win_num) +{ + u32 val; + + val = csr_readl(pci, PAB_AXI_AMAP_CTRL(win_num)); + val &= ~(1 << WIN_ENABLE_SHIFT); + csr_writel(pci, val, PAB_AXI_AMAP_CTRL(win_num)); +} diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil.h b/drivers/pci/controller/mobiveil/pcie-mobiveil.h index eb4cb61291a8..81685840b378 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.h +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.h @@ -171,6 +171,8 @@ void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr, u64 pci_addr, u32 type, u64 size); void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr, u64 pci_addr, u32 type, u64 size); +void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pci, int win_num); +void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pci, int win_num); u32 csr_read(struct mobiveil_pcie *pcie, u32 off, size_t size); void csr_write(struct mobiveil_pcie *pcie, u32 val, u32 off, size_t size);