Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967460AbdD0MGJ (ORCPT ); Thu, 27 Apr 2017 08:06:09 -0400 Received: from mail-dm3nam03on0080.outbound.protection.outlook.com ([104.47.41.80]:13668 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S937577AbdD0MFl (ORCPT ); Thu, 27 Apr 2017 08:05:41 -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: 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, linu.cherian@cavium.com, Geetha Subject: [PATCH 2/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #74 Date: Thu, 27 Apr 2017 17:16:23 +0530 Message-Id: <1493293584-20287-3-git-send-email-gakula@caviumnetworks.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1493293584-20287-1-git-send-email-gakula@caviumnetworks.com> References: <1493293584-20287-1-git-send-email-gakula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: PN1PR01CA0077.INDPRD01.PROD.OUTLOOK.COM (10.174.144.145) To BN3PR07MB2500.namprd07.prod.outlook.com (10.167.4.137) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca17c9f0-1a68-4e5a-9988-08d48d65b56a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR07MB2500; X-Microsoft-Exchange-Diagnostics: 1;BN3PR07M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L3u3Z6oRv1xDHZWicaaFztj51bLanTYZdH1lw;20:8d1DACeiXzpOwsYGnoQH+rO9399bMMsRKvvhVYgE4FDEmfaUUCkMwhQ1SYBfabGMcL8Y2Zvk2MB9pkss9nuhdd35Ozx1GWld682GMFFoAJejBM8ZBKeL99+4sAXxqmJyfqloantjZiWNHmrusaTN4wMgVaiGwN/Or+uge1rqfB3aZdqE+q6vBp7pk/IE31Ta+IuKPgBuMuKoBPTFz8rl6msIxTW/bm4KkhNXcRdsjAOTl/PQrGNlq7cv0NcoUsSMsGKzvmkD1YuKnAI6tebAB53TyILjjpfirttqMhIwyEotsBLbDoYdH3aL6HAhZD/fLjfnN9Nl75MSrfcM6lBt1Wd+nNjKjZjONtauh5R3Px9qTrutq74i03Lw4lhIxBocXac66sOKdTceO8Qems/aO75IDrqxJ7fwIBXwkd0LHJQI1PZsY/l/n3f27PQS0DATlePsfeehbGaZspN0cH6kczeMUdMIxLnYYOSWZ68Fbaa/VmjJ/eE9aHFU1qsEd3tU2eKM7ceHnsx2FVILOGFKLe5QOk6fHQAMicEUF7/FkC54LBmWon2EVyKkp5GrtMJOwArpWEw1jwzgDf6yYa2GV7FZMeDxsTu4MKri0CHuKbk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148);SRVR:BN3PR07MB2500;BCL:0;PCL:0;RULEID:;SRVR:BN3PR07MB2500; X-Microsoft-Exchange-Diagnostics: 1;BN3PR07MB2500;4:CH/bq6E9FjfzIotD3T9AJnPA8wUUMDPwHLUtX6dYklL3MgT6ywy92/wkAGfpkNcKWykTq6xqm5oi1tMb/4mYLnIY8QJPOFFcGiLYmMsmGeQWnsnK8N+7qtVOdIOgcIUQlwKkESpDX0ZptGQGrJPZ5qnTiVWmoDw3YUCCv3rVbdjkZUoSAd4ESMKHhMIOCSZZO5gGOmpuDGUZYO5MJ+cA9SIhJEo4QgSVX4o99XjPlR37Rz8fkj23eAdcJK1xeUVdr+H32P/5hpXA3xGGasQ7/sN7USixdFKq69lNRhoLK2EUnRR4HyLmw/yqBWFliCqPFVbR+cq+CeYGmoaX3M2oICtADOcD5q/2XHeNm5WmNIYcpnmwWakNSjycQdiu7s3CyHkbHKYm+7cgM356hsgJmRosYDqGt+L3UG/Vl/HA0tHnRVMfqZ373fa+S4rrLNZkj7QvFMrPpQa0kKTq5CHj5B1cVw+Vtti2ztEt73d4VwY6DyuyRxcaCJOssQtnyBPqajjzpdTYVHctx7rXhLm5cbjIKoSHkniierBOh5nC1BaGq+HjeQB06XzL8Zkv0e+l6Dd44c2+0YkJGbGhT7j9YobY3eav1YENpxKrgRdr7ETqoPFpmt7xl+RzLo3GwL+HY0VJnkTimaOGQrtRBIqFbEvneh3qxhVDdXOIqQP8Ahx9nn61SrCj3l1yeW/R8XMa X-Forefront-PRVS: 029097202E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39840400002)(39410400002)(39400400002)(39850400002)(39450400003)(6486002)(5003940100001)(33646002)(5009440100003)(76176999)(50986999)(36756003)(230783001)(189998001)(53936002)(6666003)(2906002)(42882006)(2950100002)(3846002)(42186005)(6116002)(6506006)(6512007)(50466002)(48376002)(8676002)(81166006)(5660300001)(110136004)(25786009)(107886003)(38730400002)(7416002)(4326008)(50226002)(66066001)(305945005)(47776003)(110426004)(42262002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR07MB2500;H:localhost.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR07MB2500;23:wOV0RgOoDYFQ0h58DWOzwszhyeJ+Td4F/vY5wws/4?= =?us-ascii?Q?TiQ3HcvPrAjJ9glPw5BrzNAZH8v3X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xrr6/oDDMlwu7SmPyz6AQXqJs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR07MB2500;7:PPOSG6xOqAMGcZUOx5vPd71Q6B6ja0zmURKXCJdrrqo90px/9FfMYpKU0nxRuOJUdVE8X/lEz6hdG5xpPxBcQEMGkw6ZIbMvCdIl2DI4SttqhX2jarpsq2+j6U8zNMSMY1+J7vdFSBFu168Jn7Kue/emmo2YgK4Es1jivYGyOunD7NqlJvo4QIO66p1hpax5xlo6LWhNLHFWhcMr2Ow3yMn8twJpq5KvFIp2jAGvYjxs+Maj7m5RJ/+ddo2fauPkeNXCN9ab9H9jeXGWxRfARCjR+akzvsATMUXDtBxpuW/SkUbvNNywpSHUqmaeVmMdj7b1UCKE1tiBdeqZVuTEpQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2017 12:05:30.1415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2500 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5182 Lines: 151 From: Linu Cherian Cavium 99xx SMMU implementation doesn't support page 1 register space. Based on silicon id, ARM_SMMU_PAGE0_REGS_ONLY macro is set as an errata workaround. This macro when set, replaces all page 1 offsets used for EVTQ_PROD/CONS, PRIQ_PROD/CONS register access with page 0 offsets. Signed-off-by: Linu Cherian Signed-off-by: Geetha --- Documentation/arm64/silicon-errata.txt | 1 + drivers/acpi/arm64/iort.c | 14 +++++++++++++- drivers/iommu/arm-smmu-v3.c | 32 +++++++++++++++++++++++++++----- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt index 2f66683..629e2ce 100644 --- a/Documentation/arm64/silicon-errata.txt +++ b/Documentation/arm64/silicon-errata.txt @@ -61,6 +61,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/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 4a5bb96..a074ce9 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -25,6 +25,7 @@ #include #include #include +#include #define IORT_TYPE_MASK(type) (1 << (type)) #define IORT_MSI_TYPE (1 << ACPI_IORT_NODE_ITS_GROUP) @@ -669,12 +670,23 @@ static void __init arm_smmu_v3_init_resources(struct resource *res, { struct acpi_iort_smmu_v3 *smmu; int num_res = 0; + u32 cpu_model; + unsigned long size = SZ_128K; /* Retrieve SMMUv3 specific data */ smmu = (struct acpi_iort_smmu_v3 *)node->node_data; + /* + * Override the size, for Cavium CN99xx implementations + * which doesn't support the page 1 SMMU register space. + */ + cpu_model = read_cpuid_id() & MIDR_CPU_MODEL_MASK; + if (cpu_model == MIDR_THUNDERX_99XX || + cpu_model == MIDR_BRCM_VULCAN) + size = SZ_64K; + res[num_res].start = smmu->base_address; - res[num_res].end = smmu->base_address + SZ_128K - 1; + res[num_res].end = smmu->base_address + size - 1; res[num_res].flags = IORESOURCE_MEM; num_res++; diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 1dcd154..ee23ccd 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -38,6 +38,7 @@ #include #include +#include #include "io-pgtable.h" @@ -176,15 +177,15 @@ #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_PROD (page1_offset_adjust(0x100a8)) +#define ARM_SMMU_EVTQ_CONS (page1_offset_adjust(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_PROD (page1_offset_adjust(0x100c8)) +#define ARM_SMMU_PRIQ_CONS (page1_offset_adjust(0x100cc)) #define ARM_SMMU_PRIQ_IRQ_CFG0 0xd0 #define ARM_SMMU_PRIQ_IRQ_CFG1 0xd8 #define ARM_SMMU_PRIQ_IRQ_CFG2 0xdc @@ -412,6 +413,10 @@ #define MSI_IOVA_BASE 0x8000000 #define MSI_IOVA_LENGTH 0x100000 +#define ARM_SMMU_PAGE0_REGS_ONLY \ + (((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_THUNDERX_99XX) \ + || ((read_cpuid_id() & MIDR_CPU_MODEL_MASK) == MIDR_BRCM_VULCAN)) + static bool disable_bypass; module_param_named(disable_bypass, disable_bypass, bool, S_IRUGO); MODULE_PARM_DESC(disable_bypass, @@ -660,6 +665,15 @@ struct arm_smmu_option_prop { { 0, NULL}, }; +static inline unsigned long page1_offset_adjust( + unsigned long off) +{ + if (!ARM_SMMU_PAGE0_REGS_ONLY) + return off; + else + return (off - SZ_64K); +} + static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) { return container_of(dom, struct arm_smmu_domain, domain); @@ -2631,6 +2645,14 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, return ret; } +static unsigned long arm_smmu_resource_size(void) +{ + if (ARM_SMMU_PAGE0_REGS_ONLY) + return SZ_64K; + else + return SZ_128K; +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -2649,7 +2671,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) /* 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()) { dev_err(dev, "MMIO region too small (%pr)\n", res); return -EINVAL; } -- 1.9.1