Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752070AbdFTOhv (ORCPT ); Tue, 20 Jun 2017 10:37:51 -0400 Received: from mail-cys01nam02on0063.outbound.protection.outlook.com ([104.47.37.63]:35266 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751095AbdFTOhr (ORCPT ); Tue, 20 Jun 2017 10:37:47 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Geetha sowjanya To: will.deacon@arm.com, robin.murphy@arm.com, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, iommu@lists.linux-foundation.org Cc: robert.moore@intel.com, lv.zheng@intel.com, rjw@rjwysocki.net, jcm@redhat.com, linux-kernel@vger.kernel.org, robert.richter@cavium.com, catalin.marinas@arm.com, sgoutham@cavium.com, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, geethasowjanya.akula@gmail.com, devel@acpica.org, linu.cherian@cavium.com, Charles.Garcia-Tobin@arm.com, robh@kernel.org, Geetha Sowjanya Subject: [PATCH v8 2/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #74 Date: Tue, 20 Jun 2017 19:47:38 +0530 Message-Id: <1497968259-16390-3-git-send-email-gakula@caviumnetworks.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1497968259-16390-1-git-send-email-gakula@caviumnetworks.com> References: <1497968259-16390-1-git-send-email-gakula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: PN1PR01CA0105.INDPRD01.PROD.OUTLOOK.COM (10.174.144.21) To SN1PR0701MB2031.namprd07.prod.outlook.com (10.163.132.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3de9b0e4-3866-49d4-c527-08d4b7e9e6b5 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:SN1PR0701MB2031; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0701MB2031;3:idA1pb4+xXr9D6HzVpCKd12TdugL1pZ1w3cqOmkbmTDbSg+RQyOaLuEDE2BR3hAtVZ0nMQzMfxIf6uvmnM43wLvxo+WTV0myZuNE612U58WZhOHKktsj9RzGm6Ty/VGiCIcy7nhfRuxWVtLPXe+62TrNu+ZupUahjUiE7OYDQ5If1Y3FFOpXZQUWGVG2cdb6FYm6B6t3MAAjr+S7SDIhul4a7FQ0Ok0ms7cNk1vHMTTPAyNnUc8KqGPvfAosWLn7S8LdQ24qs4I/oX2OfcLDFAKYIUM/x+RNtO4kcJyzcWykWqiTbw3k+pHv2zKyPCu5kUIBNnU9ZZh1uaNZ9SxLug==;25:Vzw52X+c5LfrK+nG1ZJDElfLLDw2see9cixbWnBya6qhQuhifNpuMra+HdkGfugJFoJG6MqAraTC91e0yj0UJEfkOBlpQ2bZc3KO69JYqI4I/llI0MefedxwJZHvfinNfljPSSYkIpTaNoeEFjGhGPKw8FNAG2UFk8ZI7/2iQ16P9yC0q1jZb9spknVkCinTfs5wejZUjngQtDusVKxQgQxs50Nq8J6Ip0AgKIL4QLPpWb4XdlNRhFpV15vZ9IPWz4BOym58PULdogv8BdgkxXRfJ5wuLagfUKcKYMUvWmKyvWmAt0bAOzqqzkMteb3eEQo0fsRcGj1LmpO0LTRxrwyI9Oho6i6DveHCOCtVREJ22hanvNeZrbOPLodlZIlDaU9oTZyQdO5QKfDS1HcEPkcf933P3Q9kfeIqBpeB3vQMfFJQlkC2oysjrTK1cejdq7YkklwbafJtpYfdKNiATrCHnQCSXJq4lbncNDBJVac= X-MS-TrafficTypeDiagnostic: SN1PR0701MB2031: X-Microsoft-Exchange-Diagnostics: 1;SN1PR0701MB2031;31:Ev+GpG83KdlejXjVYv0E1A+nfJ0TR0h1tSkn3QC9zZ16LokALKcZn+PlgaLKMER7KiRd7pVJICaN/sjQBFhbKuAdS5PPvEwCTqwmeBqtZdKr8glQcP/MLu4zSt+qRLu0GEbIexzYqPtdLkricG3P8kLQAt1TsGUROeOIwTlNWGlu+sLuczDZ6FOKN9dxU/jcVt1sECT1DRMxAbJ8PBeDODXnPGaVZmYTtZRY+kCuDdo=;20:5vV5wNfAyA5E85EWoSJNNpExAXbz9yfvz5f6w9DeDWQVuV3sNSDQ+Ti12II+WHdnyYtgNP5q2EPaeK/JCyy4ipSiCFujz+8cUtNGMV2F4oHhiTqz4xSDHf27tD9bl1eRtXnORanB+1QNRTTxgkKvTz2uCm+w0X0yS40QMWYI4P9W1tVf6EVCI8jcG6nI4z3r1gAfqXpclEmX7sL0/hWMIHVo9UmoTZR4AWsxjU5OcQlRBF41xhz57hbf5XQTcUvPRCGywSgHd/OaDvyXJ8NM2ZOO01BlJLBy1p/NrYDjIIRF37KlZlBzQUQTDLM/FuZm23rOko9Wr7XfS5MpjWKrEacg7bvRznUwMFrLUbiJd0doHeCMzy5i9laWqeVkdcWU+NJ5SPFqa+GB8jU1U5jSQPFPZhZBwfIVZZdm1xyPuPGvJyfJZyMiJVzli5UHzhtO/AICgCoGXE89jZlEKCsh3B4azuxW5wPPbvcWszG+yS+r7C2n85frInEqIhtbutW5xCK1qc3d5n5N3UaknRhZJm5+m1W/r94BHKb7FdxFdg2lRPWlvPMDosnSuLwDw1oFfIwBwh/hu2EkgrMfgEjB/fgY7JhNDj+jl2HO2KBQcfw= 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)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(3002001)(6041248)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN1PR0701MB2031;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN1PR0701MB2031; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR0701MB2031;4:u+2GCkTKKQBaIyJSAnaseJobbQIl8y6dVMQYQte7?= =?us-ascii?Q?XV9Ay4MoV2/MPY1g82WeyvUtpgcaeRoBDqjYjwDxS/MU7hX4FEc/+Mq9Ahjl?= =?us-ascii?Q?AXyLskVVAVTSCXZBQ3SRV4PsYlO7Y7UuFeNlDQjLllP6Ds+HviXlCkBuUDsb?= =?us-ascii?Q?Ri5dqC4pCfwamm2ykx50yN1RFLQ7ZvxahTmyvNS/Zu0vXx8tWmvbB5anp4ZM?= =?us-ascii?Q?pBxhV801eb9CtDxI/Y2IuNhkWDAg/ln/HYDsdvSosUlW1eCncC8hO1P9L1zy?= =?us-ascii?Q?2uUXsamjQ6DwBRJRZGBnKa1/px+rNCcsPqoBmyQHfbLiTN5ERNkLT6ldRMqF?= =?us-ascii?Q?tYAp+7WI2xcC5StcW+AoplrjriIcmSjLOWlwY+pFuvHVX2nfzh9W0Q/sCXGW?= =?us-ascii?Q?jxVRlif2nnNJ/4nDmCfnpYk6JcdcxyOZO7AEByWSPXwYXfZKUJovBmTP93fE?= =?us-ascii?Q?c5VVICflHxT9Q63SOFUUXMXXfmTqml2JG1vEBGtxeWVERslY8i0QFGheDcPa?= =?us-ascii?Q?dQH4wvbm1sUiFl1351h0K9jjEdlxQxdcqQeTHk4nR0HJhJU/C4Xo0E0Tu6f2?= =?us-ascii?Q?bVqurMAARgBo0DJAlUPa1YfB+kC4Y9miXoxnvmKtl+RxuIEVM8dbzMUdxEPs?= =?us-ascii?Q?k2SgFAy9EYSm/2tKNXZ+Yhuu//sCrv31fy+4JlA9t7q2UV3H6gpq1DNeg6Jt?= =?us-ascii?Q?qO7qEMDDgpsMy//ehfRmvRHlN5xXzbj3pbKCIji6WmL5mJ3HpU6FdjOk/bNK?= =?us-ascii?Q?Ecye4X4Tb1ry+GDFwGSENS00pZQqKsnh6jibHGaDbrachbpKVXWsM85HPOeq?= =?us-ascii?Q?Y76nuLFMVZLX4kXJboBqxtLud1jlen/Jw1v5UV3AscSc7zaFfLl46REpJSkt?= =?us-ascii?Q?1ehzBiCBPP9Eajy3uuzVwDV25Epow7zCpWYDL+X64LJBya5/rIXqoSyiLUdV?= =?us-ascii?Q?0Mqy/Xtcgxnb5B4uKF/XQvDMThcXVfrsneN5G8lLMukcf74JprEnCvSdaA41?= =?us-ascii?Q?XTJghGIfEJDGB/koXwJfSfJtmbs/uAG0qq1tQzOXrwrdBNX9kHIPQ1QjMFQb?= =?us-ascii?Q?Tc5JAvYZXO4bihcEIr4I6IcQNUFW9/jnKdUWo0w5vPGd1JVXh4MgcCvnkVdF?= =?us-ascii?Q?MTHLxverdiU=3D?= X-Forefront-PRVS: 03449D5DD1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39410400002)(39840400002)(39850400002)(39450400003)(39400400002)(4326008)(7416002)(3846002)(6116002)(50226002)(5009440100003)(5660300001)(305945005)(230783001)(38730400002)(110136004)(107886003)(53936002)(6512007)(6506006)(66066001)(47776003)(81166006)(8676002)(5003940100001)(478600001)(6486002)(2906002)(2950100002)(42882006)(48376002)(72206003)(189998001)(33646002)(50466002)(36756003)(50986999)(25786009)(76176999)(42186005)(110426004)(42262002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR0701MB2031;H:localhost.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR0701MB2031;23:qfep9KPGGzFjM98+we9pNH6b6M9zzJwSf14GgX0?= =?us-ascii?Q?nR/PKfpU2J0uM/Rvs01rZ67YDf6mT0u5UGcV14K9169qae4QttF983x8AOdB?= =?us-ascii?Q?xvl++rykib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nosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR0701MB2031;7:qX6NHvlXEYoF/7s8fe5vfa3Cjn3bLYCErB5tf05WXAL/xQEm1g8JuaddNq+02QpVYLwDJhC59Dp8jwLM0QSsTjysz7R2NH8i/ZBkMNdfAQcmnJA7vBXY4tpaQsNMCbqgsgrFtimAoSvyBvzt3trx8UCqAgMsD+wF2x9MqdrLKlLjyQROfqXGdzQOnbof4UVly/FJ4V+ttZS9MSSwPW3Zqq/fNU+kjxjN5GSVAgqF9JMx/+xe7sPyA68ifhrfbm3N8CCe3iMWmQMlLHzqLORf99BogSpT2Tpnij7gLRlyxabWGCtYt0bOnmoKkRayfPdRpjqs2hBDsUDInvvxO+9IUMX71mUY1YuqI/VPzNzDTYTSLGYx//HhkLNe5wRGt9q/FZXkeKpQaElmFNHoXGkiJ3UDVlHCWsZF8aL7b/pCwCAnXWcjwV+TaBOrcTtmFtL2bwDNxtesU799q/wVKxmrOX7zmZ/puc/hib7lTE4LDqx+PmbNY/kuUp4XLgaKr0R0IQBpPGlFPZZDrBgc5fifguGWz1gBXgg4xagYx+69J7RCLqw1B7pfGINk4LnIksIpR6qx1iwQlKb0GGq/rut+wf79A8c05tld3sw6fTM6SxuxySOmfe0y/dDJcV0jy8T/rbrZjXwjbsWzGJo2Msn0jU0eOqBudU2xgjQBOGId1wXodaKjaycdMbz2aLtEf6o2yvS7B2DZuQ1CtYdlJERA+Si+g8iyAc1kxLIBoFM6j0/N23xuIQSMtF1zSj8x43DHpp9w/IJaheJN4bCGNadM1jSYPutycaa3IhiggA2tioo= X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2017 14:37:32.8108 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0701MB2031 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7389 Lines: 199 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 | 68 ++++++++++++++----- 3 files changed, 57 insertions(+), 18 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..6ecc48c 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. + ** Example smmu@2b400000 { diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 380969a..5de258f 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -597,6 +597,7 @@ struct arm_smmu_device { u32 features; #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0) +#define ARM_SMMU_OPT_PAGE0_REGS_ONLY (1 << 1) u32 options; struct arm_smmu_cmdq cmdq; @@ -663,9 +664,20 @@ 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) && + (smmu->options & ARM_SMMU_OPT_PAGE0_REGS_ONLY)) + 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 +1973,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 +2375,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)); enables |= CR0_EVTQEN; ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, @@ -2379,9 +2393,9 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool bypass) 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); + arm_smmu_page1_fixup(ARM_SMMU_PRIQ_PROD, smmu)); writel_relaxed(smmu->priq.q.cons, - smmu->base + ARM_SMMU_PRIQ_CONS); + arm_smmu_page1_fixup(ARM_SMMU_PRIQ_CONS, smmu)); enables |= CR0_PRIQEN; ret = arm_smmu_write_reg_sync(smmu, enables, ARM_SMMU_CR0, @@ -2605,6 +2619,14 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) } #ifdef CONFIG_ACPI +static void acpi_smmu_get_options(u32 model, struct arm_smmu_device *smmu) +{ + if (model == ACPI_IORT_SMMU_V3_CAVIUM_CN99XX) + smmu->options |= ARM_SMMU_OPT_PAGE0_REGS_ONLY; + + dev_notice(smmu->dev, "option mask 0x%x\n", smmu->options); +} + static int arm_smmu_device_acpi_probe(struct platform_device *pdev, struct arm_smmu_device *smmu) { @@ -2617,6 +2639,8 @@ static int arm_smmu_device_acpi_probe(struct platform_device *pdev, /* Retrieve SMMUv3 specific data */ iort_smmu = (struct acpi_iort_smmu_v3 *)node->node_data; + acpi_smmu_get_options(iort_smmu->model, smmu); + if (iort_smmu->flags & ACPI_IORT_SMMU_V3_COHACC_OVERRIDE) smmu->features |= ARM_SMMU_FEAT_COHERENCY; @@ -2652,6 +2676,14 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, return ret; } +static unsigned long arm_smmu_resource_size(struct arm_smmu_device *smmu) +{ + if (smmu->options & ARM_SMMU_OPT_PAGE0_REGS_ONLY) + return SZ_64K; + else + return SZ_128K; +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -2668,9 +2700,20 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } smmu->dev = dev; + if (dev->of_node) { + ret = arm_smmu_device_dt_probe(pdev, smmu); + } else { + ret = arm_smmu_device_acpi_probe(pdev, smmu); + if (ret == -ENODEV) + return ret; + } + + /* Set bypass mode according to firmware probing result */ + bypass = !!ret; + /* Base address */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (resource_size(res) + 1 < SZ_128K) { + if (resource_size(res) + 1 < arm_smmu_resource_size(smmu)) { dev_err(dev, "MMIO region too small (%pr)\n", res); return -EINVAL; } @@ -2697,17 +2740,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (irq > 0) smmu->gerr_irq = irq; - if (dev->of_node) { - ret = arm_smmu_device_dt_probe(pdev, smmu); - } else { - ret = arm_smmu_device_acpi_probe(pdev, smmu); - if (ret == -ENODEV) - return ret; - } - - /* Set bypass mode according to firmware probing result */ - bypass = !!ret; - /* Probe the h/w */ ret = arm_smmu_device_hw_probe(smmu); if (ret) -- 1.7.1