Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbdFLIMV (ORCPT ); Mon, 12 Jun 2017 04:12:21 -0400 Received: from mail-by2nam01on0074.outbound.protection.outlook.com ([104.47.34.74]:4224 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751930AbdFLIMQ (ORCPT ); Mon, 12 Jun 2017 04:12:16 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; Date: Mon, 12 Jun 2017 08:12:00 +0000 From: Jayachandran C To: Robin Murphy Cc: Geetha sowjanya , will.deacon@arm.com, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, iommu@lists.linux-foundation.org, robh@kernel.org, Charles.Garcia-Tobin@arm.com, Geetha Sowjanya , geethasowjanya.akula@gmail.com, jcm@redhat.com, linu.cherian@cavium.com, rjw@rjwysocki.net, robert.moore@intel.com, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, robert.richter@cavium.com, lv.zheng@intel.com, catalin.marinas@arm.com, sgoutham@cavium.com, linux-arm-kernel@lists.infradead.org, devel@acpica.org Subject: Re: Fwd: [PATCH v7 2/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #74 Message-ID: <20170612081158.GA2435@localhost> References: <1496145821-3411-1-git-send-email-gakula@caviumnetworks.com> <1496145821-3411-3-git-send-email-gakula@caviumnetworks.com> <9263562d-03a3-d02e-6b7e-01613a4bd296@arm.com> <20170609113832.GB106079@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: MWHPR01CA0003.prod.exchangelabs.com (10.168.201.141) To BLUPR0701MB1060.namprd07.prod.outlook.com (10.160.35.147) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLUPR0701MB1060: X-MS-Office365-Filtering-Correlation-Id: 1370ce89-067e-4148-6946-08d4b16abadb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BLUPR0701MB1060; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1060;3:jMzEIPWG2qZt+y/MsHXDIJOC/EziQwXtHkYj2CHrjGYgx2REvdOoJK3PhIabwD8kGUjf0L0+R9sAv0420Nwm3zgfSOdSeSqIjNb9dvEdXsu63CvHqv8VvqnDSBIWtBCkOhgH6dZ5CN0zB1oiC5DYTim3ev2JgjiVo3wpe2UzkKNCL5QMv72EnCo3TstGEdT48QmHvCf5qVNgO6HyueqcvVgCBYXo0/zmTrLmYuxVAOQiRkFbqAcF6bd/KhVnqM4SfjuDedJbfTsie3pcHFKmk2svpn5CRAhIc6iZoH7YSDycnib2NhjZZluzLd/zGQbOYAbnoZd6bEevm4bxr0Q8yg==;25:wmuLgqQM3vwPfXlVyNcIpTj5thF0VClV9iX3CrMBxRLmvsYNCc2w0AZ9nso2Ea3Y/L7K11I+vBAICkcVLKuiGzQCYdrAzpoePNRoqaSAfPEzYPD2J9VOyVf5qMxFBaLh+LtcJvBK36/JSQjrnuGe07X1er+3uJ9RWlq2jhv271vw2t+HW7iPsWz2AA814WbsiyYHp2JH9C1HnQbx04rjh2DL5XYuy/wcGtk+8hrdGEWyLsMqGQbHfEuBLQXhB9+md5sT8STrC2hpHktUMg7e4tGjgSZAmBb6ZN5y8hFWLUco+oY/KTaap9MITnK9/FJ4Uvvr/mRB/DPKdwABeDgybpiHu3I/iqQdfyCxkmtEZHaPVKyv42eOmjoV+z5UxWzETbaQObekcSNunvr6WYyAJSeqJFEhRnC+WeiESfkubVPCSqZ98lnKOV11s9J5Veihug5x/H/nJjK6xAA5PFPJ5+4a7U2wE5RchtyYvZpzrBA= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1060;31:Y40Z4r1aB7XjJqCyWwbcVztD36taiyAts2+gldXIdGURe5REAL6VqpFpEy/5DBssgsbib7LezcW+n6PiXq+wDD7JYHkIXllx5Kd574P+F5jodVMi0+j+PJJ+eSCF4DH1pWmJ7BkPxem8ds4cb4chvEMBFRbaLAKX7okxCsfklhJ51GUixM7efyrdL9K0WdP47A7n6e1s/P2dLCegfHlcsJ4XmXVqcywAtOyXss4GkJM=;20:XV0KPuFwVfkglpoEG8xTmrlTOOdxytJmScDCF7XuV8PK9zgz8RDMT0OZsXNFPo/tiIUeTDga56BRHmiDK/1+nYxcVCPLf4/y7usDUzp9EltN/ktBQ3J5DsCJpEed37XGa/VOVV2Va81VpdxTARU6diRFFM+VdKlGcP8ENOVhT+kCMEX1eNHFs2Z+gJw72niWtRBErvy3cWPZXL37feo583RcFdK+tpavTWqh39OXiUVuPj6QpMX2drnPbctWJu50bbsPyXLki7kf8ZTUz1i79P8TPaauoGdXMNEOvfFHPbKPptydOjqJuKWxQ0SeNaw09d6h4G6HDMvZF4f9Yerg8vM+0H6gg8+mNPBDhJ6pncCiMGmhiuZBB5O2dVw2LKXbhX9u30MOCsgvEHKGC9dccsESKJc3fMx0d2EIGCTIdMQvjQ+K42FTj5k0FE8lUbld6Q6uvAbxPzWP9IDuAluUtcNXJ7z/d0znmvrncOTa5G3YeKaCrSf2tUIIZmlrEyVeCeWQ6/yFbLvuThxCwrJxUMOgP828ijw9mw+DKWh5ETg/YN7O6xH8woDtJO696l2CkFQWOIvPhjJ35AKE9UIICh6EeFOplxcmg3NQyfYsaos= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3002001)(100000703101)(100105400095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BLUPR0701MB1060;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BLUPR0701MB1060; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1060;4:dA0d0PCU/ruUAmuKlwP8yn2fk+kDgV4KWzelcSqJ?= =?us-ascii?Q?zrAipiR+4UaEG5w9NmWRmjQeLCFzOOG/wuA+iBpk0QS39WXctp9cSo33E1Mu?= =?us-ascii?Q?loQKLY31QMGewDTyMXScZ83a0ShSB04SAjOvKgi0Zd17bev08E3NQ/4B1uNG?= =?us-ascii?Q?npL+Df1xHwWrDKA1IYrTlT3nD/c17v15rIaNYOAFkGWVcjk65/A3QsVspkiS?= =?us-ascii?Q?Oltl3hQPJzsCoSzg3TvfFDtZ0yZB9pflDcAzSoyFIFQxmfGcZu1/ffqxAX7c?= =?us-ascii?Q?GtTebA2NA4XsazOKu0vGdKuj6pWTU3Ho60kb7TOY7OGVudPxEJdLsjknxQ+F?= =?us-ascii?Q?7PmMFMV0ezeXztKKlxCxXdXXgZSreZuvpecv+YQUcXsuNdrpnsSaXzQhF+yq?= =?us-ascii?Q?tUwElWDjC+LhQn3wTMXcyQeI/aVkYPkKQVVxJQ+hhBdsqKk36YzHcbQjCV6y?= =?us-ascii?Q?5Yglz0Dm0qKz5z030WzZZHwpd9JfrtrdUWdOytLNtM1Lx2xNNaoM+Olyc52q?= =?us-ascii?Q?nlGjy4GGPduy+hN9T9H/K3BHkTj1JzTC+8QXK2cvBT53Nb+sLj2Or5/cmnp/?= =?us-ascii?Q?JZM/yVYrL5QV33kYDS0AmOCLNwUcpwC1GNpXkcDtFAIHy2v6EoBFDW2UMLsR?= =?us-ascii?Q?9xNPaI+uCpl04s7Ww9Q23R3zB53MWGt/YdcvnDU9tE/UUHls9KAmcM2vrFGx?= =?us-ascii?Q?Rt9AtEbvJiCL43lqouzMpY53t1X+VaQhes4Mqdt5heUz9NwBRf7obhON4Nds?= =?us-ascii?Q?XW2UTTh+aYNt94/tF6RvFWsI8Gyiw1uZPrUQeSmY2lJydPfPMIQBVsJgvhfI?= =?us-ascii?Q?bFm/YasZH1IfFWQir8B48HY0L7HqzuONf37qLYUsOoOMSfHamkznvuqWU7j4?= =?us-ascii?Q?SOMLc3gqEXFXcJq9MmwVb+QHsL6G8e/vaYRYUFiHzkaXhcazuUdvZ6E4qdVA?= =?us-ascii?Q?jivlIgTjEFySxXMnOp5DYzpPcAxNYHYwkj1mgIbbfYtN2082ktIa82DrUQUp?= =?us-ascii?Q?/tKktKX/OdOLrZskLAAB9UcsQti6ze+8cnFKOyxM7S7ndaFQ2s6Z5xDEhQc6?= =?us-ascii?Q?xXMSKFcVH4IyIXnrxbXVWWH8gEXVoqG4899bAkqW5zFjDN1LNCRlF60Cp2Tu?= =?us-ascii?Q?k5VrAUoq7sc=3D?= X-Forefront-PRVS: 03361FCC43 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39840400002)(39850400002)(39450400003)(39400400002)(39410400002)(24454002)(6246003)(2950100002)(9686003)(6496005)(110136004)(54906002)(7416002)(5660300001)(47776003)(55016002)(305945005)(7736002)(72206003)(38730400002)(575784001)(53936002)(6666003)(25786009)(53546009)(1076002)(478600001)(4326008)(23726003)(33656002)(2906002)(230783001)(93886004)(33716001)(76506005)(3846002)(229853002)(81166006)(8676002)(42882006)(6916009)(42186005)(50986999)(54356999)(76176999)(189998001)(66066001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1060;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1060;23:hO/oQhnh/zVSydomMHR8tQDcNqQVwni7BPKqSJK?= =?us-ascii?Q?RdP4GR/2mnGiDVHjEdviNGvdOKT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RkhajLQeSl2vbWXY0xo9pq5UckYZ9B3hcnIlxd1cmNamXfjZjLLX1Ut12k8HKdeFJmyOlBYD10rPkCs99ywfZbJs1rddmK+D2iCZ8v5XLElh46IIoyS9KFkT2Eqs4c4pPHnbK2MY1ZYTLuYE4NDApMGvsXARKpT6StTBnO9ajXA8RVOVjPScKFJ/UBRk8Zue7/beVb5RqZ5/515aRB8+0+InAA3I5mmDDDevw+1lDSA+bVFqDqxqv/6WQZkIj0y2Y+cySzh3IAFGhrUIZZSSUsRRPf4cHOB5k9A5qBOSOW68hIA/mqJDuw16VZgUD821Bdf9BuEf8t7/h44o4X04SZopxYm3rmo46iCmCyWbjIjEXupODVYz7bvh4LXFwVsyjeIkUPxJaQxWvYBn2zxSmMfkLsqK8HXO8qyI1acnc77DwHWjPzF12KmP0f7i6xRW+gsK+ne1;24:z4d4Gup7oHWzdAw7n7qA94JRSbFDlg7a1EliXuevLHdPcLVeZEqlWWkWwkWfTZcUHzVWWOr6Ec1Ngt5CuJykBJOlwpJsmKMLP5d4NvVGKoU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1060;7:sq1GksZJjRBBI0NZHz7YSOrkB3m1vitfPhZzpJGbVGJPUD/ZUQMxV4lg1/dtE9rSFVs4E9rT8nyJcKkUl2fscSViS8KgrsjP4B5PDUxAMz9uMKgklXLhAB2BIG9rchj17muxvrYXUWOkUxRzmBuMuhD+4GmwCAqWt3RJbjs+SJWUbjRfhWB1wRXBCjURrJv7RMB0TrQ9vUTvUJw0dtqbQ0CwQI+O65YJZoh3YcOLDmiVQ/8cnBTk17pdqAQN29HW5AcIpHaoYtV2q0Jo/OIiTmQg0jK/b2M0YfQtqhBinY7mAcwNV64N5brLXOEDUKyd1wSRLpSyjlc/ORyUPNyesg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2017 08:12:10.2054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1060 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14502 Lines: 326 On Fri, Jun 09, 2017 at 04:43:07PM +0100, Robin Murphy wrote: > On 09/06/17 12:38, Jayachandran C wrote: > > On Fri, Jun 09, 2017 Robin Murphy wrote: > >> > >> On 30/05/17 13:03, Geetha sowjanya wrote: > >>> From: Linu Cherian > >>> > >>> Cavium ThunderX2 SMMU implementation doesn't support page 1 register space > >>> and PAGE0_REGS_ONLY option is enabled as an errata workaround. > >>> This option when turned on, replaces all page 1 offsets used for > >>> EVTQ_PROD/CONS, PRIQ_PROD/CONS register access with page 0 offsets. > >>> > >>> SMMU resource size checks are now based on SMMU option PAGE0_REGS_ONLY, > >>> since resource size can be either 64k/128k. > >>> For this, arm_smmu_device_dt_probe/acpi_probe has been moved before > >>> platform_get_resource call, so that SMMU options are set beforehand. > >>> > >>> Signed-off-by: Linu Cherian > >>> Signed-off-by: Geetha Sowjanya > >>> --- > >>> Documentation/arm64/silicon-errata.txt | 1 + > >>> .../devicetree/bindings/iommu/arm,smmu-v3.txt | 6 ++ > >>> drivers/iommu/arm-smmu-v3.c | 64 +++++++++++++++----- > >>> 3 files changed, 56 insertions(+), 15 deletions(-) > >>> > >>> diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt > >>> index 10f2ddd..4693a32 100644 > >>> --- a/Documentation/arm64/silicon-errata.txt > >>> +++ b/Documentation/arm64/silicon-errata.txt > >>> @@ -62,6 +62,7 @@ stable kernels. > >>> | Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 | > >>> | Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | > >>> | Cavium | ThunderX SMMUv2 | #27704 | N/A | > >>> +| Cavium | ThunderX2 SMMUv3| #74 | N/A | > >>> | | | | | > >>> | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | > >>> | | | | | > >>> diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt > >>> index be57550..607e270 100644 > >>> --- a/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt > >>> +++ b/Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt > >>> @@ -49,6 +49,12 @@ the PCIe specification. > >>> - hisilicon,broken-prefetch-cmd > >>> : Avoid sending CMD_PREFETCH_* commands to the SMMU. > >>> > >>> +- cavium,cn9900-broken-page1-regspace > >>> + : Replaces all page 1 offsets used for EVTQ_PROD/CONS, > >>> + PRIQ_PROD/CONS register access with page 0 offsets. > >>> + Set for Caviun ThunderX2 silicon that doesn't support > >>> + SMMU page1 register space. > >> > >> The indentation's a bit funky here - the rest of this file is actually > >> indented with spaces, but either way it's clear your editor isn't set to > >> 8-space tabs ;) > >> > >>> + > >>> ** Example > >>> > >>> smmu@2b400000 { > >>> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > >>> index 380969a..4e80205 100644 > >>> --- a/drivers/iommu/arm-smmu-v3.c > >>> +++ b/drivers/iommu/arm-smmu-v3.c > >>> @@ -412,6 +412,9 @@ > >>> #define MSI_IOVA_BASE 0x8000000 > >>> #define MSI_IOVA_LENGTH 0x100000 > >>> > >>> +#define ARM_SMMU_PAGE0_REGS_ONLY(smmu) \ > >>> + ((smmu)->options & ARM_SMMU_OPT_PAGE0_REGS_ONLY) > >> > >> At the two places we use this macro, frankly I think it would be clearer > >> to just reference smmu->options directly, as we currently do for > >> SKIP_PREFETCH. The abstraction also adds more lines than it saves... > >> > >>> + > >>> static bool disable_bypass; > >>> module_param_named(disable_bypass, disable_bypass, bool, S_IRUGO); > >>> MODULE_PARM_DESC(disable_bypass, > >>> @@ -597,6 +600,7 @@ struct arm_smmu_device { > >>> u32 features; > >>> > >>> #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0) > >>> +#define ARM_SMMU_OPT_PAGE0_REGS_ONLY (1 << 1) > >> > >> Whitespace again, although this time it's spaces where there should be a > >> tab. > >> > >>> u32 options; > >>> > >>> struct arm_smmu_cmdq cmdq; > >>> @@ -663,9 +667,19 @@ struct arm_smmu_option_prop { > >>> > >>> static struct arm_smmu_option_prop arm_smmu_options[] = { > >>> { ARM_SMMU_OPT_SKIP_PREFETCH, "hisilicon,broken-prefetch-cmd" }, > >>> + { ARM_SMMU_OPT_PAGE0_REGS_ONLY, "cavium,cn9900-broken-page1-regspace"}, > >>> { 0, NULL}, > >>> }; > >>> > >>> +static inline void __iomem *arm_smmu_page1_fixup(unsigned long offset, > >>> + struct arm_smmu_device *smmu) > >>> +{ > >>> + if (offset > SZ_64K && ARM_SMMU_PAGE0_REGS_ONLY(smmu)) > >>> + offset -= SZ_64K; > >>> + > >>> + return smmu->base + offset; > >>> +} > >>> + > >>> static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) > >>> { > >>> return container_of(dom, struct arm_smmu_domain, domain); > >>> @@ -1961,8 +1975,8 @@ static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu, > >>> return -ENOMEM; > >>> } > >>> > >>> - q->prod_reg = smmu->base + prod_off; > >>> - q->cons_reg = smmu->base + cons_off; > >>> + q->prod_reg = arm_smmu_page1_fixup(prod_off, smmu); > >>> + q->cons_reg = arm_smmu_page1_fixup(cons_off, smmu); > >>> q->ent_dwords = dwords; > >>> > >>> q->q_base = Q_BASE_RWA; > >>> @@ -2363,8 +2377,10 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) > >>> > >>> /* Event queue */ > >>> writeq_relaxed(smmu->evtq.q.q_base, smmu->base + ARM_SMMU_EVTQ_BASE); > >>> - writel_relaxed(smmu->evtq.q.prod, smmu->base + ARM_SMMU_EVTQ_PROD); > >>> - writel_relaxed(smmu->evtq.q.cons, smmu->base + ARM_SMMU_EVTQ_CONS); > >>> + writel_relaxed(smmu->evtq.q.prod, > >>> + arm_smmu_page1_fixup(ARM_SMMU_EVTQ_PROD, smmu)); > >>> + writel_relaxed(smmu->evtq.q.cons, > >>> + arm_smmu_page1_fixup(ARM_SMMU_EVTQ_CONS, smmu)); > > > > This sequence and the arm_smmu_page1_fixup() call is repeated in quite a few > > places. I think this errata code is messy because the original driver does not > > make the alias page usage explicit. > > It *is* explicit - the architecture says the event queue and PRI queue > pointers exist only on page 1, and that is the offset we define for > them. The architecture also says "The equivalent Page 0 offsets of > registers that are defined on Page 1 are Reserved and ARM recommends > that they are not accessed. Access to these offsets is CONSTRAINED > UNPREDICTABLE..." Ok. The patch makes the page used for producer/consumer queue registers explicit fo cmdq (page 0) and the eventq/priq(page1). There is no suggestion here to use page 0 address for eventq/priq. > This workaround is a bodge dependent on a specific implementation always > having a specific CONSTRAINED UNPREDICTABLE behaviour, and I see no > point in trying to dress it up as anything else. Yes, it could be > considered a little bit messy, but messy is what you get when you step > outside the spec. The fixup is invoked a grand total of 6 times, over 3 > locations, and there's no way of factoring it out further that doesn't > just add significantly more code and complexity than it would save. With the changes below, the fixup are simpler and will be needed only in 2 places - and it gets the hardware init repeated 3 times in the driver into a single place. That bikeshed will look real nice :) JC. > > > A patch like the one below (no functional changes) would clean up the original > > driver and make the errata change much simpler - any comments? > > > > -- >8 -- > > > > Date: Tue, 30 May 2017 15:43:29 +0000 > > Subject: [PATCH] iommu: arm-smmu-v3: make alias page usage explicit > > > > --- > > drivers/iommu/arm-smmu-v3.c | 76 +++++++++++++++++++++++++++------------------ > > 1 file changed, 46 insertions(+), 30 deletions(-) > > > > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > > index 380969a..11fdb4f 100644 > > --- a/drivers/iommu/arm-smmu-v3.c > > +++ b/drivers/iommu/arm-smmu-v3.c > > @@ -171,20 +171,19 @@ > > #define STRTAB_BASE_CFG_FMT_LINEAR (0 << STRTAB_BASE_CFG_FMT_SHIFT) > > #define STRTAB_BASE_CFG_FMT_2LVL (1 << STRTAB_BASE_CFG_FMT_SHIFT) > > > > +#define ARM_SMMU_Q_PROD(qbase) ((qbase) + 0x8) > > +#define ARM_SMMU_Q_PROD_PAGE1(qbase) ((qbase) + 0x10008) > > +#define ARM_SMMU_Q_CONS(qbase) ((qbase) + 0xc) > > +#define ARM_SMMU_Q_CONS_PAGE1(qbase) ((qbase) + 0x1000c) > > + > > #define ARM_SMMU_CMDQ_BASE 0x90 > > -#define ARM_SMMU_CMDQ_PROD 0x98 > > -#define ARM_SMMU_CMDQ_CONS 0x9c > > > > #define ARM_SMMU_EVTQ_BASE 0xa0 > > -#define ARM_SMMU_EVTQ_PROD 0x100a8 > > -#define ARM_SMMU_EVTQ_CONS 0x100ac > > #define ARM_SMMU_EVTQ_IRQ_CFG0 0xb0 > > #define ARM_SMMU_EVTQ_IRQ_CFG1 0xb8 > > #define ARM_SMMU_EVTQ_IRQ_CFG2 0xbc > > > > #define ARM_SMMU_PRIQ_BASE 0xc0 > > -#define ARM_SMMU_PRIQ_PROD 0x100c8 > > -#define ARM_SMMU_PRIQ_CONS 0x100cc > > #define ARM_SMMU_PRIQ_IRQ_CFG0 0xd0 > > #define ARM_SMMU_PRIQ_IRQ_CFG1 0xd8 > > #define ARM_SMMU_PRIQ_IRQ_CFG2 0xdc > > @@ -1946,11 +1945,30 @@ static struct iommu_ops arm_smmu_ops = { > > }; > > > > /* Probing and initialisation functions */ > > +static int arm_smmu_reset_one_queue(struct arm_smmu_device *smmu, > > + struct arm_smmu_queue *q, > > + unsigned long qoffset, > > + int page_to_use) > > +{ > > + unsigned long prod, cons; > > + > > + writeq_relaxed(q->q_base, smmu->base + qoffset); > > + if (page_to_use == 1) { > > + prod = ARM_SMMU_Q_PROD_PAGE1(qoffset); > > + cons = ARM_SMMU_Q_CONS_PAGE1(qoffset); > > + } else { > > + prod = ARM_SMMU_Q_PROD(qoffset); > > + cons = ARM_SMMU_Q_CONS(qoffset); > > + } > > + writeq_relaxed(q->prod, smmu->base + prod); > > + writeq_relaxed(q->cons, smmu->base + cons); > > +} > > + > > static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu, > > struct arm_smmu_queue *q, > > - unsigned long prod_off, > > - unsigned long cons_off, > > - size_t dwords) > > + unsigned long qoffset, > > + size_t dwords, > > + int page_to_use) > > { > > size_t qsz = ((1 << q->max_n_shift) * dwords) << 3; > > > > @@ -1961,8 +1979,13 @@ static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu, > > return -ENOMEM; > > } > > > > - q->prod_reg = smmu->base + prod_off; > > - q->cons_reg = smmu->base + cons_off; > > + if (page_to_use == 1) { > > + q->prod_reg = smmu->base + ARM_SMMU_Q_PROD_PAGE1(qoffset); > > + q->cons_reg = smmu->base + ARM_SMMU_Q_CONS_PAGE1(qoffset); > > + } else { > > + q->prod_reg = smmu->base + ARM_SMMU_Q_PROD(qoffset); > > + q->cons_reg = smmu->base + ARM_SMMU_Q_CONS(qoffset); > > + } > > q->ent_dwords = dwords; > > > > q->q_base = Q_BASE_RWA; > > @@ -1980,14 +2003,14 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu) > > > > /* cmdq */ > > spin_lock_init(&smmu->cmdq.lock); > > - ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, ARM_SMMU_CMDQ_PROD, > > - ARM_SMMU_CMDQ_CONS, CMDQ_ENT_DWORDS); > > + ret = arm_smmu_init_one_queue(smmu, &smmu->cmdq.q, ARM_SMMU_CMDQ_BASE, > > + CMDQ_ENT_DWORDS, 0); > > if (ret) > > return ret; > > > > /* evtq */ > > - ret = arm_smmu_init_one_queue(smmu, &smmu->evtq.q, ARM_SMMU_EVTQ_PROD, > > - ARM_SMMU_EVTQ_CONS, EVTQ_ENT_DWORDS); > > + ret = arm_smmu_init_one_queue(smmu, &smmu->evtq.q, ARM_SMMU_EVTQ_BASE, > > + EVTQ_ENT_DWORDS, USE_PAGE1); > > if (ret) > > return ret; > > > > @@ -1995,8 +2018,8 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu) > > if (!(smmu->features & ARM_SMMU_FEAT_PRI)) > > return 0; > > > > - return arm_smmu_init_one_queue(smmu, &smmu->priq.q, ARM_SMMU_PRIQ_PROD, > > - ARM_SMMU_PRIQ_CONS, PRIQ_ENT_DWORDS); > > + return arm_smmu_init_one_queue(smmu, &smmu->priq.q, ARM_SMMU_PRIQ_BASE, > > + PRIQ_ENT_DWORDS, 1); > > } > > > > static int arm_smmu_init_l1_strtab(struct arm_smmu_device *smmu) > > @@ -2332,9 +2355,8 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) > > smmu->base + ARM_SMMU_STRTAB_BASE_CFG); > > > > /* Command queue */ > > - writeq_relaxed(smmu->cmdq.q.q_base, smmu->base + ARM_SMMU_CMDQ_BASE); > > - writel_relaxed(smmu->cmdq.q.prod, smmu->base + ARM_SMMU_CMDQ_PROD); > > - writel_relaxed(smmu->cmdq.q.cons, smmu->base + ARM_SMMU_CMDQ_CONS); > > + arm_smmu_reset_one_queue(smmu, &smmu->evtq.q, > > + ARM_SMMU_CMDQ_BASE, 0); > > > > enables = CR0_CMDQEN; > > ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, > > @@ -2362,9 +2384,8 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) > > arm_smmu_cmdq_issue_cmd(smmu, &cmd); > > > > /* Event queue */ > > - writeq_relaxed(smmu->evtq.q.q_base, smmu->base + ARM_SMMU_EVTQ_BASE); > > - writel_relaxed(smmu->evtq.q.prod, smmu->base + ARM_SMMU_EVTQ_PROD); > > - writel_relaxed(smmu->evtq.q.cons, smmu->base + ARM_SMMU_EVTQ_CONS); > > + arm_smmu_reset_one_queue(smmu, &smmu->evtq.q, > > + ARM_SMMU_EVTQ_BASE, 1); > > > > enables |= CR0_EVTQEN; > > ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, > > @@ -2376,13 +2397,8 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) > > > > /* PRI queue */ > > if (smmu->features & ARM_SMMU_FEAT_PRI) { > > - writeq_relaxed(smmu->priq.q.q_base, > > - smmu->base + ARM_SMMU_PRIQ_BASE); > > - writel_relaxed(smmu->priq.q.prod, > > - smmu->base + ARM_SMMU_PRIQ_PROD); > > - writel_relaxed(smmu->priq.q.cons, > > - smmu->base + ARM_SMMU_PRIQ_CONS); > > - > > + arm_smmu_reset_one_queue(smmu, &smmu->priq.q, > > + ARM_SMMU_PRIQ_BASE, 1); > > enables |= CR0_PRIQEN; > > ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, > > ARM_SMMU_CR0ACK); > > >