From patchwork Fri Apr 12 08:37:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10897477 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 23CD717E6 for ; Fri, 12 Apr 2019 08:37:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0810528E1D for ; Fri, 12 Apr 2019 08:37:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F062428E5D; Fri, 12 Apr 2019 08:37:10 +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 88AD928E30 for ; Fri, 12 Apr 2019 08:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbfDLIhE (ORCPT ); Fri, 12 Apr 2019 04:37:04 -0400 Received: from mail-eopbgr80073.outbound.protection.outlook.com ([40.107.8.73]:38403 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727279AbfDLIhE (ORCPT ); Fri, 12 Apr 2019 04:37:04 -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=yYJ9WCpyA8Tb2vN+8zCIgMdl2noAhzwvzErWOpfZhcg=; b=RPbsEw4cIGZ0s+j5Deo1xVWwJq24Oiu/HQE+tkjoyck/X5ixZ+iAFh6rp5mJU5vblPZnCD2bDwm2ETcWU5ZlfOQVkIkpj+5VLc0kerLc75mDGeSxGKiZhNKbbB1kvs3k+cyg+PZJ9MwYenvSaIgpeinH0Q2HNdPiAACSxvf35ZQ= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.3.19) by AM6PR04MB5846.eurprd04.prod.outlook.com (20.179.3.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1792.18; Fri, 12 Apr 2019 08:37:00 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::f9db:ed86:614e:460]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::f9db:ed86:614e:460%4]) with mapi id 15.20.1792.009; Fri, 12 Apr 2019 08:37: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" , "catalin.marinas@arm.com" , "will.deacon@arm.com" CC: Mingkai Hu , "M.h. Lian" , Xiaowei Bao , "Z.q. Hou" Subject: [PATCHv5 18/20] PCI: mobiveil: Disable IB and OB windows set by bootloader Thread-Topic: [PATCHv5 18/20] PCI: mobiveil: Disable IB and OB windows set by bootloader Thread-Index: AQHU8Qrl2X2dZdmZtkqqPC5pUtT6KA== Date: Fri, 12 Apr 2019 08:37:00 +0000 Message-ID: <20190412083635.33626-19-Zhiqiang.Hou@nxp.com> References: <20190412083635.33626-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20190412083635.33626-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: HK2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:202:2e::23) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:ad::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1de61a70-4c30-48c3-756d-08d6bf220794 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:AM6PR04MB5846; x-ms-traffictypediagnostic: AM6PR04MB5846: x-microsoft-antispam-prvs: x-forefront-prvs: 0005B05917 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(366004)(376002)(396003)(346002)(136003)(189003)(199004)(486006)(478600001)(2616005)(476003)(316002)(446003)(11346002)(305945005)(7736002)(81166006)(25786009)(81156014)(256004)(14454004)(8676002)(7416002)(4326008)(186003)(50226002)(26005)(8936002)(68736007)(2906002)(53936002)(102836004)(6512007)(66066001)(86362001)(99286004)(106356001)(6116002)(3846002)(6436002)(97736004)(1076003)(6506007)(386003)(52116002)(2201001)(105586002)(6486002)(36756003)(71200400001)(110136005)(54906003)(5660300002)(2501003)(71190400001)(76176011)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR04MB5846;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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: UTLqI3Xaa4/Sazab2LnbMbOtUZ02NZ4Kx6jHySdPKvITaAxCjFRz5dhEFVzuv29rCw8UKuW2lt8jK2u21Qim9IMW3zvsEp9U23Uvnwc+q7vm8tEt4x1ZaZDpRgbKHTJ4+lCLyikAHHE98CYrxwdtG7BL9nTCN+3tlv5G70WH4nnLwQA4zET6kFNBNPke776GFyQNnMyP+LwAsSxWLrDfkZF4blxOyJYAfKbz/seVZmRW80+d3l7kEOCJNSFwwDtRENoFNtQAulsgbHVPN2vA8Hf+dt3sP3iMff8G+/t3fRet0k4pQM6bKYdxfSSpFKuR0cxITHb/D6FzK0LOLWGUpyaN7BFtEazbcUhqrpzzrrEeSeIGVmn8TE4982gDnsQrh+kjxzZ5gA7tCbeqVs0E1B/lbyG8PG4ER3Ndgf9ygTc= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1de61a70-4c30-48c3-756d-08d6bf220794 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Apr 2019 08:37:00.0169 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5846 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 Disable 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 Reviewed-by: Subrahmanya Lingappa --- V5: - No functionality change. drivers/pci/controller/pcie-mobiveil.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index 8dc87c7a600e..411e9779da12 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c @@ -565,6 +565,24 @@ static int mobiveil_bringup_link(struct mobiveil_pcie *pcie) return -ETIMEDOUT; } +static void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pcie, int idx) +{ + u32 val; + + val = csr_readl(pcie, PAB_PEX_AMAP_CTRL(idx)); + val &= ~(1 << AMAP_CTRL_EN_SHIFT); + csr_writel(pcie, val, PAB_PEX_AMAP_CTRL(idx)); +} + +static void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pcie, int idx) +{ + u32 val; + + val = csr_readl(pcie, PAB_AXI_AMAP_CTRL(idx)); + val &= ~(1 << WIN_ENABLE_SHIFT); + csr_writel(pcie, val, PAB_AXI_AMAP_CTRL(idx)); +} + static void mobiveil_pcie_enable_msi(struct mobiveil_pcie *pcie) { phys_addr_t msg_addr = pcie->pcie_reg_base; @@ -585,6 +603,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);