From patchwork Tue Nov 20 09:27:33 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: 10690661 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 7814413BB for ; Tue, 20 Nov 2018 16:05:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 651532847A for ; Tue, 20 Nov 2018 16:05:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5974028535; Tue, 20 Nov 2018 16:05: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=-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 DA8CA2847A for ; Tue, 20 Nov 2018 16:05:48 +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=Z3QUsbQK7KlNTF7xdSs3Xj6CZjMnYmN0ksoc5oMgZnY=; b=TJApGxR/K3pQY7 2Io2dLOwwrdLHeCzzKyRaw73RVekk9CxXCF6+jEgDFlil3pD8xMOTZKUATXPIYu7999iX82quVR1G g1FAchkequEoalGPVvjhXMfd2H/2sNKcpCgZnFR9Nlk/PJmsnaOxKHA6J+Dg/Cg9Te/Yua2zXo+2A yYs2qaFJs3ACcSPmXCJNZM2ylFSqGab8D5dd+pA63lYygBlGw3G5o+qIMAZqDStn1D2XNwRGss4+E hgHsbhnZXtomvWHJByAYLnr+PazerGQqQ7scIL+hGZ5jRx8qvfDWA/ywoNrxIZUC1CvhYHi02NBHd RYIetu8nmDM0J8QpJFFA==; 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 1gP8Wu-0003Wd-VL; Tue, 20 Nov 2018 16:05:36 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP8Gt-0003nl-QI for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Nov 2018 15:49:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=MIME-Version:Content-Transfer-Encoding: Content-Type:In-Reply-To:References:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YDw3kEaa0DQsETyfo+oSPAgHHhgLI1NCNUESfmlPsyc=; b=sS/VoTD/jO/OWtrUOrNw9lF/2E NjAtuN0sgwtbd1DroaWeEbD/bl7PoHtcQNbsYBQ/JKNqtlqM/8yLo78WdfEb6YpkNs5DrjU5cq/+F +TxpNZRNCLIzfDhz3JxZQn0jsd3VyZKpJMuDIKWT46s9/gFww1usu8RMzKuiQtzEs6u2/nWGI6ue7 ipLEQOzwwUbvpqaAaxdipwkCxTVoe4TmY5SAlNuF9VX4zpYBb8ub1vfYjMamE99U4pMgiuuw4OdQi +g2T/5mVOLmXaYruE1+HTH0cOsbnBnog03JyzxlO6vKS7sm8QmpuGCTFddIurg3xCltzeDZfhieXk CUZICZpA==; Received: from mail-he1eur04on0625.outbound.protection.outlook.com ([2a01:111:f400:fe0d::625] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP2KU-0005tD-SI for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 09:28:23 +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=YDw3kEaa0DQsETyfo+oSPAgHHhgLI1NCNUESfmlPsyc=; b=NzqOilEhG4Hn9EPrNKF79c1QqWQPunTPOz94b6gwq7wnqmppwCWmxNWsWGYBDCiOfkqf/KUhmQrglL8da/AHkNIVuMLd9vdgG3/HijHf+dfCTnH2aRAdrLRKu+10o+0uzy9umtUkY1izOMFf6b7QLNDhn9vVVCdH80+YmMVaVg8= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.2.80) by AM6PR04MB4775.eurprd04.prod.outlook.com (20.177.32.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.21; Tue, 20 Nov 2018 09:27:33 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::29b5:b3ed:3854:cf1c]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::29b5:b3ed:3854:cf1c%4]) with mapi id 15.20.1339.026; Tue, 20 Nov 2018 09:27:33 +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" , "catalin.marinas@arm.com" , "will.deacon@arm.com" Subject: [PATCHv2 19/25] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Topic: [PATCHv2 19/25] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Index: AQHUgLNEY3zDU/qMo0Oy4NY1Qyg81w== Date: Tue, 20 Nov 2018 09:27:33 +0000 Message-ID: <20181120092615.11680-20-Zhiqiang.Hou@nxp.com> References: <20181120092615.11680-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20181120092615.11680-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: HK2PR03CA0050.apcprd03.prod.outlook.com (2603:1096:202:17::20) 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; AM6PR04MB4775; 6:Q4KzPdFe3J+y1T/1qtn4Z/74yD5vZAjz9tx4QrCG7JFVXwo2YDowfNVt9xFrTGJ/jhXal5FKgm3kg0qarHJ3Ufd8wZuT7H8KXNRkMaP0pZgjXhIPVAeJHfUNj0hOWi0iPjAb3xs7Oi5b61/LcgbdJeVABbSVaOiYEYSLHhvQVKGhxcpzq2IK5CqOh7aVo9jSfseItDHkwOpa+0OL3wwNzPEzuKzp8+tC13O0jtebUlgjuyl4g+ftZxoWXUa+K93aRx6J0tQjZQ9D+gTrFfNIOZu94RJUMyuWJWTki7X8k8q+G+BvWbrU/mt6tBr3PfYX7HRUoFS4jNJb/tcOF5BrjyI2J/l8nkaZm9/CN6T4EdJ8ulc9fZl7p2wo1KRpjCbdeaoT7usdc5/Ig+I82M0wG2aFZwIeh0JAs7G2Z3M9nlYm+MKv/bVV8j+xUj3Q9UDaBdbjjbsIJlkmmPqCPqMYWw==; 5:UpPggIRmA5xf4owFMdK51G8XEBVGMmlxBneAb9Sh5d7JWGUo9cJs5x/r08VF8ufbvvpPjDynvLV2Kf0n0+ItirETc2Bpkau3La/1rs6DnJrvMCtUoxjLqgWsJRziDnZ1kPuoBf8YggIxnmCb1/vqcXuVlneRG/gfSNDxVr0m3HA=; 7:4oClPQx7FfkWhivydoCSd1z8m9+Cr36RylQ/z0pFzi3DaYDT9AQHNjde4Ds2+swKBplrR+nwbteKL43BSRRGHQWsEawzCsCXj2HSFuoHxjCQny7Q4uo4XqmQbwtIG/LvkPcivANmd8+i0XFgCs+/yw== x-ms-office365-filtering-correlation-id: beb93c8a-4d22-47b9-3044-08d64eca66a9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM6PR04MB4775; x-ms-traffictypediagnostic: AM6PR04MB4775: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231442)(944501410)(52105112)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:AM6PR04MB4775; BCL:0; PCL:0; RULEID:; SRVR:AM6PR04MB4775; x-forefront-prvs: 08626BE3A5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(136003)(376002)(396003)(346002)(189003)(199004)(66066001)(1076002)(2900100001)(68736007)(8676002)(6486002)(5660300001)(8936002)(6116002)(3846002)(2501003)(97736004)(81166006)(26005)(186003)(81156014)(105586002)(7416002)(102836004)(2906002)(386003)(6506007)(7736002)(305945005)(106356001)(6512007)(76176011)(36756003)(4326008)(99286004)(52116002)(14444005)(25786009)(575784001)(110136005)(54906003)(2616005)(86362001)(53936002)(446003)(11346002)(256004)(2201001)(6436002)(486006)(71190400001)(71200400001)(478600001)(316002)(476003)(14454004)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR04MB4775; 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: LhdnLkClXRsFFqPKipGSxXJwgpHMWOodwiY70PrYvrnUrw+/DHx/48uM87z46ww18Wq0IpJiT0f+WFBe3C4PT3O9v5x4DsZWQQktq6Wry1paXZG0Ay9IOo81Iz0NatsCHFZASKbrZOg3OQTPRmCNmVfCZEp8mpw17TUBjy/BgGjmLMT6CwbT/dIVRvCZRRveBN9GItHF5JGO7WQytcRQTK9QhC9poVa/Mdu1R1TvZocy7OV9FMbTTav+UcVQPtSLXAKJV0xdmPvjuraV7ulFm5XSPgUqG8VGYNzJenKZpctpKpF7DwMplpXcnEGwYKAzcpmWwRb3+qkaHkrZO7z3YvspHgDsDDp23SQZIFMbJgo= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: beb93c8a-4d22-47b9-3044-08d64eca66a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Nov 2018 09:27:33.4728 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4775 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_042823_002786_C72FBA5B X-CRM114-Status: GOOD ( 13.89 ) 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 reviewed-by: Minghuan Lian --- V2: - no change .../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 d1765d572f44..d028cdf31d0e 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c @@ -221,6 +221,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 370658d6546d..49d471b75925 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.c @@ -226,3 +226,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);