From patchwork Mon Sep 18 20:39:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Pledge X-Patchwork-Id: 9957665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F04C9601E9 for ; Mon, 18 Sep 2017 20:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1EA128A90 for ; Mon, 18 Sep 2017 20:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D64D128C2C; Mon, 18 Sep 2017 20:45: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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 6E18E28C55 for ; Mon, 18 Sep 2017 20:45:01 +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:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tGfnWg4JiUIF08mhMNNBcmuYD2DPSBmye3GNpS2S2uY=; b=k+gLlY6VvHmxTu 3y6FP257LDA/SUFxps+VKXIEQnwBilbFKKDgxErpVufnCI9H2fLl45kPTQ5QxONfdiu+GQYfY4TdO uu9TNGyKccEAPKxwnVsFnhvt16nROSYHMNiLlKqVIshZuBjorvXWlykKPCJx+9TIz/H9Tpv1J6H7l gza2CtQRDqekE6+z7w80TOi16mRb2K/Pa0o1H2VPpJ5lhwTKxiDfnvTgDvwu+1bVFB885uMqhhjbe MCe9WNroJ2uPwRrx80Pw15OeZFF4sAfspDYioUs7vUHCUgvfveRsrmtiqhSgrdkXpYp+V1VuCGa1Q C3PSA+lNQphhyDir+j7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1du2tc-0005fh-8f; Mon, 18 Sep 2017 20:44:00 +0000 Received: from mail-co1nam03on0061.outbound.protection.outlook.com ([104.47.40.61] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1du2q5-0001SO-71 for linux-arm-kernel@lists.infradead.org; Mon, 18 Sep 2017 20:40:36 +0000 Received: from BN3PR03CA0090.namprd03.prod.outlook.com (10.167.1.178) by BN6PR03MB2689.namprd03.prod.outlook.com (10.173.144.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Mon, 18 Sep 2017 20:39:59 +0000 Received: from BN1AFFO11FD016.protection.gbl (2a01:111:f400:7c10::199) by BN3PR03CA0090.outlook.office365.com (2a01:111:e400:7a4d::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10 via Frontend Transport; Mon, 18 Sep 2017 20:39:58 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD016.mail.protection.outlook.com (10.58.52.76) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.35.14 via Frontend Transport; Mon, 18 Sep 2017 20:39:58 +0000 Received: from otc-sw1.am.freescale.net (otc-sw1.am.freescale.net [10.29.200.182]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8IKdn2t025841; Mon, 18 Sep 2017 13:39:57 -0700 From: Roy Pledge To: , , , , Subject: [v5 08/12] soc/fsl/qbman: Rework portal mapping calls for ARM/PPC Date: Mon, 18 Sep 2017 16:39:43 -0400 Message-ID: <1505767187-4596-9-git-send-email-roy.pledge@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505767187-4596-1-git-send-email-roy.pledge@nxp.com> References: <1505767187-4596-1-git-send-email-roy.pledge@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131502407988919859; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7966004)(376002)(346002)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(77096006)(50226002)(189998001)(68736007)(4326008)(54906002)(43066003)(36756003)(356003)(53936002)(81156014)(105606002)(305945005)(5003940100001)(8936002)(498600001)(81166006)(8676002)(47776003)(6666003)(33646002)(104016004)(2201001)(2906002)(85426001)(7416002)(106466001)(316002)(5660300001)(76176999)(97736004)(575784001)(50986999)(86362001)(16586007)(48376002)(2950100002)(50466002)(3450700001)(8656003)(110136005)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2689; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD016; 1:lve3upOr+uywWwYJ6Gvb4IDmnLicySQaZ89QvtlcajVywuuwRNVg3H5O4TrvAc3nOe7FVyVjnyWzHY0k/5OeLUgRtyxzy4G9UiS9tiXedeXl+NO9v1wdjK6It2JLhReF MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 434287bf-1303-4cd8-5cd2-08d4fed56dbe X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR03MB2689; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 3:nK33bNTz4Zl252sfVIEI3ZLZmgXUC9Avbk4B4wZhR7KbpGvlZ4A+8DGS0Xgt8H0KQnYQoL5/bPyh3NsD/uQ0F29Y3ImYouc8GwsgQq1ceXfZupDDPtxS5Mhh8fTWRoEiwjulXIl1kK/S4JVnIYsxIndgwqg1gON8yd58K/5v4ogVDHr/zYq1/87ph/F2FFiLTsFPIJeJRiad1wzNwwtmZ18sVlNAj0Rym2ExBdKEmrW5xIKR+eEYkhnfGT974bfKM/XqKANlIqPZTlYf3U0M0DSd00F5qO76vVCM0jobmq20BMkTYBq8pQ8IKU/wLgj/aiIcntbROzfoK+sJu9O+7s03wQ89+E/pPZLYfv/adbI=; 25:irZMMk3j4xDerd46HLw1LdBKdAqc+5u2Wfc2rW8h/c4QmwBjYIHMR19BRooPo5jgsomUnBugMRTrZwpaDbUgIZwu0mXuvQUVYb4OJm7zfyNlSPVaMhvHmvv/sd3ZWV592Zn3Ctcrc1NzTPFAEB4PuHUjjoH8LYAej4q+qq4uCHuLFv08hdwjiWn8uZyN5BBbUiRwJIN91LTbSJ4xScLteOb5bsjTW+xY89jY7H/OtJXxbfBw+JRTjyEJIZsVGmMUSmA65XqPR0iivtZwI1ukvoGGRg3U94XPDIeMMUaJ3CfW6Dq0THXdiVTkShr7oFT6CYbZHtaE4F9wJc95QY/NUg== X-MS-TrafficTypeDiagnostic: BN6PR03MB2689: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 31:KAjN5Rs5vzmEimHys7Ozq7T/DkmeHINLf5VAknPz9BxKFVt67B7deHsu94Lr2eOj/i2mStoZYoBeZ+G+ROOvxgQV9vRTwakAMsGjnsTq16hIzH3d6sd6z4jgxs6jFS5SvlUxVZar6Holqrmu3KzSUEXnCghezx6smV/vJotVEN+be5SGFgG+MWq2JY/VnudYyCYMOMUcb9P/hBhIrFicJIbHvYEBZ4f2eHne2kwRAb0=; 4:oXAEPvNs09D1hcey0GjPlOBvXpaXlR60kU3bu+nUnLBPW7YQCCo4FkvxGWqXinC6hMKGNm0p31gzNgL+QrO7xphy3V0E1XQ7FmAK/e+v1c5kxKgLJ7gCZm57w5l6pg9tzOWkQGcXXJc2/MC3O4WyAGQrDuIKdl+P8hjNlYDZ/7+WbLLWZ4rFEMMhWLjrPcPnrhHP8/BW2Gwf6qXeRbKml+8GBYTr8qqN4st/XZfIwn2puEoiGNLEmJeDbf1nCPB6xb03iYBwxiY/lXbP90xG3WB0pp2SBwelzzTgJssWkP0MPwadfoFrYfGw7scXxvzhyza627fsgIRF+o8S/b5ZIg== X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123556025)(20161123559100)(20161123563025)(20161123561025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR03MB2689; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR03MB2689; X-Forefront-PRVS: 04347F8039 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2689; 23:N+Ecf+js21XjcTZloKATiYAur0PXzseoEAKBBMuwc?= =?us-ascii?Q?aSV8tycKpNChXvP6eF7uJcYzs6tS1KKl0dCnDPQ+5VUebMwn2/Zn0O5tqYnw?= =?us-ascii?Q?imYCk3LyPsxPdeCH+IqPZ+Oaj/tqlCKE+x9iTmBKQ5PhjVvzlGxNYgEbvueb?= =?us-ascii?Q?BBIk9zIUSzE3m9sY2+wWR1zVjavngYaoxOLB0XsUghIv4VSvXElVBIpbA1lm?= =?us-ascii?Q?i8hW/RKV2n/koGLPcVcj565yyWsPL7kc2rsNp3xkhNxdfr2owoM2w3gBcckc?= =?us-ascii?Q?2ge2tT1Qkghk7Ar05jBIFP5XX0IA3fbCjBfIbI97Yq+VGCFJY4kbnOSOJDhB?= =?us-ascii?Q?pHp/JBX84T+hel3e4OtG0HNM+sVkXkte0KqbSs+Bqlw/YC9G+PbeJbGDHV9I?= =?us-ascii?Q?XiR+UymD3yMAKrh8hYlCTjsHURd+CZAQmQvlvaoQmahwTu3kggVyLNGAfwUh?= =?us-ascii?Q?qkuGlS8DCwyM+Y2dZjoNs1O3msbL2HPhEkdOeDxdVyy9ghQNMjtjXDqpcZQm?= =?us-ascii?Q?yni0hzJu123b5MWbi83DmJti5NDKM9I/J+MziuQ0/RGA2u1d7LiVDgDguOE0?= =?us-ascii?Q?q079IzYfrCrsFiRT7Daijw3djFt+JU1jkIQtjuq4fbvA1I1JJpBZYcFE7UYo?= =?us-ascii?Q?u2Se0BFWLvsBL4riJgI+oJX/IIZEfO0Wj8dms35hgovP0FBu4xdAUmuPvAln?= =?us-ascii?Q?ui8lj/UP2qeIW6gBXWBngutxSmq1LAaHMyHSQyg60lfj8ZAU2A5jih6CDsOK?= =?us-ascii?Q?FE6s1PZTdnTW6JsEoSRGV5uwJm1jScyioKcwpi3DvBnQxQHdjgYmwFu8tOCb?= =?us-ascii?Q?bK6p00gWmJHdoTrp1yRXocxQYCBiloa1i7uZ1gTN6RFo0O2JHYH0tgdbQPLJ?= =?us-ascii?Q?WBgeS3iDcZHPCI6VNKZjrwbT1URQd3IHarBd0P2LJ8dVJ5Sujv6zhacLFqL7?= =?us-ascii?Q?27oTeFBOCQdNg5BXMKE3HDqAvqzNeugw47iQ1xuPfP/ELjwXcQINpscptvvE?= =?us-ascii?Q?zw0DMe/qLFyCBNI8R0b/gpXj8m+otf6yV6IV29UIcIIxLYUq+KewCJ8swr0Q?= =?us-ascii?Q?XU36/tBg4miSK+myk+Nem1ORVMYPvEKh2agQSTWFqT/a5CVgiYgHR42p8Qmf?= =?us-ascii?Q?PGe9fX6b+/NoosGg0tAN0h7DkPeXrC2O3CyNyReCL86mVmZEvNG+h63QO0ff?= =?us-ascii?Q?+jd9wrg7VffAAHUeqEBoNI2xtMEMuj2csw3Rxt7iF1xlCsrbD7UNJH8pGaG3?= =?us-ascii?Q?fcrl9M1guWAOF/iCRdhYZoExeFQMi5bp4kf7lpk5q7TZ94M53JIDvg2hFnO/?= =?us-ascii?B?dz09?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 6:XMkLGqU+NzqBYpI5K2xWzuT3q6rFoQjFglGT5psMxKs/dGcoC8WMHb8RifHVtVyqV7QMMNislPDR60X0Qg2hsUSf414PFdRAoSwJ2bSoUW4wIC9vvm5LB165mmIVnQLHNLonacY23ITXNX2vaKHk/NqNWBCecF5HiVlGMbx0Dx8E3Jo27LBmySlKcFsn3Q+uVAQ4mlTw6wOXfgOs0suxaStA011GGg9RLJZuO2YmUU37ipFKTUkyWlDHmqqCyPVnPVm5wnnaysGW8C98vIEGqz9GuJjv8u6prM8QcPd7Tglk3jmu6j8BhrGTig/hhTpIlRE28FY92lHheb+jh8UjFw==; 5:nuQ72BT2XdNvv/OQmCQto0AeFPFO7m+WUta30FURJfCzR4JQMYGjy1no6BOAPpewinPE7ps1G+Hfh1U13nOdxSYHjwkKeOBXjDJvr+87yiKKlnd6iu7ZW6KAzfxrm57m0gPLxeScljasJTB4eer3QQ==; 24:AT/fwW3a8CNFKjJ9y+GGNMYwskbr2AYVA1DJziv4yc/WioC63d3JyCsTpJG6GB6dkaRqKE7OLW0aQZTejP4VUx1tEB13kA0P0b/qcpfcPF8=; 7:BoK6fPC/DDFCtBKOuyxYiUs7rA6CJAbVE5vuLlgbawAtusT8a7eAcDoZHiGQL77sMZAsZE/sfKkMZObQ5sUXGWFx8/ABf6IOYhXyoaRby4IwOHIdkxAw8S+fWvqpdEtqJBurT8pcAD1ChhP44g0xCPLkPIEBjWeg7fvSyI43sE9h8q3StJ+qwCUB43+OEpoDIFwH/oo5W8ClwCMblUPBeeHdFgBC8qLbSpnBCb+gfzg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2017 20:39:58.6891 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2689 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170918_134021_815486_9B76CE0E X-CRM114-Status: GOOD ( 19.39 ) 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: , Reply-To: roy.pledge@nxp.com Cc: mark.rutland@arm.com, arnd@arndb.de, madalin.bucur@nxp.com, catalin.marinas@arm.com, Roy Pledge , linux@armlinux.org.uk, oss@buserror.net 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 Rework portal mapping for PPC and ARM. The PPC devices require a cacheable coherent mapping while ARM will work with a non-cachable/write combine mapping. This also eliminates the need for manual cache flushes on ARM. This also fixes the code so sparse checking is clean. Signed-off-by: Roy Pledge Reviewed-by: Catalin Marinas --- drivers/soc/fsl/qbman/bman.c | 18 ++++++++++-------- drivers/soc/fsl/qbman/bman_portal.c | 23 ++++++++++------------- drivers/soc/fsl/qbman/bman_priv.h | 8 +++----- drivers/soc/fsl/qbman/dpaa_sys.h | 15 +++++++++++---- drivers/soc/fsl/qbman/qman.c | 31 +++++++++++++------------------ drivers/soc/fsl/qbman/qman_portal.c | 23 ++++++++++------------- drivers/soc/fsl/qbman/qman_priv.h | 8 +++----- 7 files changed, 60 insertions(+), 66 deletions(-) diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c index ff8998f..5dbb5cc 100644 --- a/drivers/soc/fsl/qbman/bman.c +++ b/drivers/soc/fsl/qbman/bman.c @@ -154,7 +154,8 @@ struct bm_mc { }; struct bm_addr { - void __iomem *ce; /* cache-enabled */ + void *ce; /* cache-enabled */ + __be32 *ce_be; /* Same as above but for direct access */ void __iomem *ci; /* cache-inhibited */ }; @@ -167,12 +168,12 @@ struct bm_portal { /* Cache-inhibited register access. */ static inline u32 bm_in(struct bm_portal *p, u32 offset) { - return be32_to_cpu(__raw_readl(p->addr.ci + offset)); + return ioread32be(p->addr.ci + offset); } static inline void bm_out(struct bm_portal *p, u32 offset, u32 val) { - __raw_writel(cpu_to_be32(val), p->addr.ci + offset); + iowrite32be(val, p->addr.ci + offset); } /* Cache Enabled Portal Access */ @@ -188,7 +189,7 @@ static inline void bm_cl_touch_ro(struct bm_portal *p, u32 offset) static inline u32 bm_ce_in(struct bm_portal *p, u32 offset) { - return be32_to_cpu(__raw_readl(p->addr.ce + offset)); + return be32_to_cpu(*(p->addr.ce_be + (offset/4))); } struct bman_portal { @@ -408,7 +409,7 @@ static int bm_mc_init(struct bm_portal *portal) mc->cr = portal->addr.ce + BM_CL_CR; mc->rr = portal->addr.ce + BM_CL_RR0; - mc->rridx = (__raw_readb(&mc->cr->_ncw_verb) & BM_MCC_VERB_VBIT) ? + mc->rridx = (mc->cr->_ncw_verb & BM_MCC_VERB_VBIT) ? 0 : 1; mc->vbit = mc->rridx ? BM_MCC_VERB_VBIT : 0; #ifdef CONFIG_FSL_DPAA_CHECKING @@ -466,7 +467,7 @@ static inline union bm_mc_result *bm_mc_result(struct bm_portal *portal) * its command is submitted and completed. This includes the valid-bit, * in case you were wondering... */ - if (!__raw_readb(&rr->verb)) { + if (!rr->verb) { dpaa_invalidate_touch_ro(rr); return NULL; } @@ -512,8 +513,9 @@ static int bman_create_portal(struct bman_portal *portal, * config, everything that follows depends on it and "config" is more * for (de)reference... */ - p->addr.ce = c->addr_virt[DPAA_PORTAL_CE]; - p->addr.ci = c->addr_virt[DPAA_PORTAL_CI]; + p->addr.ce = c->addr_virt_ce; + p->addr.ce_be = c->addr_virt_ce; + p->addr.ci = c->addr_virt_ci; if (bm_rcr_init(p, bm_rcr_pvb, bm_rcr_cce)) { dev_err(c->dev, "RCR initialisation failed\n"); goto fail_rcr; diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c index 39b39c8..2f71f7d 100644 --- a/drivers/soc/fsl/qbman/bman_portal.c +++ b/drivers/soc/fsl/qbman/bman_portal.c @@ -91,7 +91,6 @@ static int bman_portal_probe(struct platform_device *pdev) struct device_node *node = dev->of_node; struct bm_portal_config *pcfg; struct resource *addr_phys[2]; - void __iomem *va; int irq, cpu; pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); @@ -123,23 +122,21 @@ static int bman_portal_probe(struct platform_device *pdev) } pcfg->irq = irq; - va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0); - if (!va) { - dev_err(dev, "ioremap::CE failed\n"); + pcfg->addr_virt_ce = memremap(addr_phys[0]->start, + resource_size(addr_phys[0]), + QBMAN_MEMREMAP_ATTR); + if (!pcfg->addr_virt_ce) { + dev_err(dev, "memremap::CE failed\n"); goto err_ioremap1; } - pcfg->addr_virt[DPAA_PORTAL_CE] = va; - - va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]), - _PAGE_GUARDED | _PAGE_NO_CACHE); - if (!va) { + pcfg->addr_virt_ci = ioremap(addr_phys[1]->start, + resource_size(addr_phys[1])); + if (!pcfg->addr_virt_ci) { dev_err(dev, "ioremap::CI failed\n"); goto err_ioremap2; } - pcfg->addr_virt[DPAA_PORTAL_CI] = va; - spin_lock(&bman_lock); cpu = cpumask_next_zero(-1, &portal_cpus); if (cpu >= nr_cpu_ids) { @@ -164,9 +161,9 @@ static int bman_portal_probe(struct platform_device *pdev) return 0; err_portal_init: - iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]); + iounmap(pcfg->addr_virt_ci); err_ioremap2: - iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]); + memunmap(pcfg->addr_virt_ce); err_ioremap1: return -ENXIO; } diff --git a/drivers/soc/fsl/qbman/bman_priv.h b/drivers/soc/fsl/qbman/bman_priv.h index f6896a2..751ce90 100644 --- a/drivers/soc/fsl/qbman/bman_priv.h +++ b/drivers/soc/fsl/qbman/bman_priv.h @@ -46,11 +46,9 @@ extern u16 bman_ip_rev; /* 0 if uninitialised, otherwise BMAN_REVx */ extern struct gen_pool *bm_bpalloc; struct bm_portal_config { - /* - * Corenet portal addresses; - * [0]==cache-enabled, [1]==cache-inhibited. - */ - void __iomem *addr_virt[2]; + /* Portal addresses */ + void *addr_virt_ce; + void __iomem *addr_virt_ci; /* Allow these to be joined in lists */ struct list_head list; struct device *dev; diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h index 61cfdb3..5a2c0af 100644 --- a/drivers/soc/fsl/qbman/dpaa_sys.h +++ b/drivers/soc/fsl/qbman/dpaa_sys.h @@ -51,12 +51,12 @@ static inline void dpaa_flush(void *p) { + /* + * Only PPC needs to flush the cache currently - on ARM the mapping + * is non cacheable + */ #ifdef CONFIG_PPC flush_dcache_range((unsigned long)p, (unsigned long)p+64); -#elif defined(CONFIG_ARM) - __cpuc_flush_dcache_area(p, 64); -#elif defined(CONFIG_ARM64) - __flush_dcache_area(p, 64); #endif } @@ -102,4 +102,11 @@ static inline u8 dpaa_cyc_diff(u8 ringsize, u8 first, u8 last) int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr, size_t *size); +/* memremap() attributes for different platforms */ +#ifdef CONFIG_PPC +#define QBMAN_MEMREMAP_ATTR MEMREMAP_WB +#else +#define QBMAN_MEMREMAP_ATTR MEMREMAP_WC +#endif + #endif /* __DPAA_SYS_H */ diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index 25419e1..8934c27 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -300,7 +300,8 @@ struct qm_mc { }; struct qm_addr { - void __iomem *ce; /* cache-enabled */ + void *ce; /* cache-enabled */ + __be32 *ce_be; /* same value as above but for direct access */ void __iomem *ci; /* cache-inhibited */ }; @@ -321,12 +322,12 @@ struct qm_portal { /* Cache-inhibited register access. */ static inline u32 qm_in(struct qm_portal *p, u32 offset) { - return be32_to_cpu(__raw_readl(p->addr.ci + offset)); + return ioread32be(p->addr.ci + offset); } static inline void qm_out(struct qm_portal *p, u32 offset, u32 val) { - __raw_writel(cpu_to_be32(val), p->addr.ci + offset); + iowrite32be(val, p->addr.ci + offset); } /* Cache Enabled Portal Access */ @@ -342,7 +343,7 @@ static inline void qm_cl_touch_ro(struct qm_portal *p, u32 offset) static inline u32 qm_ce_in(struct qm_portal *p, u32 offset) { - return be32_to_cpu(__raw_readl(p->addr.ce + offset)); + return be32_to_cpu(*(p->addr.ce_be + (offset/4))); } /* --- EQCR API --- */ @@ -646,11 +647,7 @@ static inline void qm_dqrr_pvb_update(struct qm_portal *portal) */ dpaa_invalidate_touch_ro(res); #endif - /* - * when accessing 'verb', use __raw_readb() to ensure that compiler - * inlining doesn't try to optimise out "excess reads". - */ - if ((__raw_readb(&res->verb) & QM_DQRR_VERB_VBIT) == dqrr->vbit) { + if ((res->verb & QM_DQRR_VERB_VBIT) == dqrr->vbit) { dqrr->pi = (dqrr->pi + 1) & (QM_DQRR_SIZE - 1); if (!dqrr->pi) dqrr->vbit ^= QM_DQRR_VERB_VBIT; @@ -777,11 +774,8 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal) union qm_mr_entry *res = qm_cl(mr->ring, mr->pi); DPAA_ASSERT(mr->pmode == qm_mr_pvb); - /* - * when accessing 'verb', use __raw_readb() to ensure that compiler - * inlining doesn't try to optimise out "excess reads". - */ - if ((__raw_readb(&res->verb) & QM_MR_VERB_VBIT) == mr->vbit) { + + if ((res->verb & QM_MR_VERB_VBIT) == mr->vbit) { mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1); if (!mr->pi) mr->vbit ^= QM_MR_VERB_VBIT; @@ -822,7 +816,7 @@ static inline int qm_mc_init(struct qm_portal *portal) mc->cr = portal->addr.ce + QM_CL_CR; mc->rr = portal->addr.ce + QM_CL_RR0; - mc->rridx = (__raw_readb(&mc->cr->_ncw_verb) & QM_MCC_VERB_VBIT) + mc->rridx = (mc->cr->_ncw_verb & QM_MCC_VERB_VBIT) ? 0 : 1; mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0; #ifdef CONFIG_FSL_DPAA_CHECKING @@ -880,7 +874,7 @@ static inline union qm_mc_result *qm_mc_result(struct qm_portal *portal) * its command is submitted and completed. This includes the valid-bit, * in case you were wondering... */ - if (!__raw_readb(&rr->verb)) { + if (!rr->verb) { dpaa_invalidate_touch_ro(rr); return NULL; } @@ -1123,8 +1117,9 @@ static int qman_create_portal(struct qman_portal *portal, * config, everything that follows depends on it and "config" is more * for (de)reference */ - p->addr.ce = c->addr_virt[DPAA_PORTAL_CE]; - p->addr.ci = c->addr_virt[DPAA_PORTAL_CI]; + p->addr.ce = c->addr_virt_ce; + p->addr.ce_be = c->addr_virt_ce; + p->addr.ci = c->addr_virt_ci; /* * If CI-stashing is used, the current defaults use a threshold of 3, * and stash with high-than-DQRR priority. diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c index cbacdf4..a120002 100644 --- a/drivers/soc/fsl/qbman/qman_portal.c +++ b/drivers/soc/fsl/qbman/qman_portal.c @@ -224,7 +224,6 @@ static int qman_portal_probe(struct platform_device *pdev) struct device_node *node = dev->of_node; struct qm_portal_config *pcfg; struct resource *addr_phys[2]; - void __iomem *va; int irq, cpu, err; u32 val; @@ -262,23 +261,21 @@ static int qman_portal_probe(struct platform_device *pdev) } pcfg->irq = irq; - va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0); - if (!va) { - dev_err(dev, "ioremap::CE failed\n"); + pcfg->addr_virt_ce = memremap(addr_phys[0]->start, + resource_size(addr_phys[0]), + QBMAN_MEMREMAP_ATTR); + if (!pcfg->addr_virt_ce) { + dev_err(dev, "memremap::CE failed\n"); goto err_ioremap1; } - pcfg->addr_virt[DPAA_PORTAL_CE] = va; - - va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]), - _PAGE_GUARDED | _PAGE_NO_CACHE); - if (!va) { + pcfg->addr_virt_ci = ioremap(addr_phys[1]->start, + resource_size(addr_phys[1])); + if (!pcfg->addr_virt_ci) { dev_err(dev, "ioremap::CI failed\n"); goto err_ioremap2; } - pcfg->addr_virt[DPAA_PORTAL_CI] = va; - pcfg->pools = qm_get_pools_sdqcr(); spin_lock(&qman_lock); @@ -310,9 +307,9 @@ static int qman_portal_probe(struct platform_device *pdev) return 0; err_portal_init: - iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]); + iounmap(pcfg->addr_virt_ci); err_ioremap2: - iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]); + memunmap(pcfg->addr_virt_ce); err_ioremap1: return -ENXIO; } diff --git a/drivers/soc/fsl/qbman/qman_priv.h b/drivers/soc/fsl/qbman/qman_priv.h index b1e2cbf..9407d2e 100644 --- a/drivers/soc/fsl/qbman/qman_priv.h +++ b/drivers/soc/fsl/qbman/qman_priv.h @@ -153,11 +153,9 @@ static inline void qman_cgrs_xor(struct qman_cgrs *dest, void qman_init_cgr_all(void); struct qm_portal_config { - /* - * Corenet portal addresses; - * [0]==cache-enabled, [1]==cache-inhibited. - */ - void __iomem *addr_virt[2]; + /* Portal addresses */ + void *addr_virt_ce; + void __iomem *addr_virt_ci; struct device *dev; struct iommu_domain *iommu_domain; /* Allow these to be joined in lists */