From patchwork Thu Feb 18 18:23:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8353401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E7B20C0553 for ; Thu, 18 Feb 2016 18:26:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 068F020357 for ; Thu, 18 Feb 2016 18:26:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11110202E9 for ; Thu, 18 Feb 2016 18:26:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWTFX-0003CW-VM; Thu, 18 Feb 2016 18:24:23 +0000 Received: from mail-bl2on0080.outbound.protection.outlook.com ([65.55.169.80] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWTFS-00032k-KJ for linux-arm-kernel@lists.infradead.org; Thu, 18 Feb 2016 18:24:20 +0000 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none; arm.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from tiru-pc.caveonetworks.com (64.2.3.194) by BY1PR0701MB1781.namprd07.prod.outlook.com (10.162.141.19) with Microsoft SMTP Server (TLS) id 15.1.409.15; Thu, 18 Feb 2016 18:23:54 +0000 From: To: , Subject: [PATCH] iommu/arm-smmu-v2: Add support for 16 bit VMID Date: Thu, 18 Feb 2016 10:23:37 -0800 Message-ID: <1455819817-8432-1-git-send-email-tchalamarla@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: SN1PR10CA0057.namprd10.prod.outlook.com (25.164.10.153) To BY1PR0701MB1781.namprd07.prod.outlook.com (25.162.141.19) X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1781; 2:ibSkvw6Jc6jWLpDfq0aJWfQba4wG8G82JrqOQ54+6uLkjkMdPS6BqVOBM/P5dNDyA8iEPb9KklRrmUzNqNquVFpoQF9n4JS3gPTfvXfLCjn24XTHMnqbixZV09agmmpQlV7LJwA2232NXOZCIMyZ5Q==; 3:L7pqCieDg5dZQSEk4OTm+q7PRiksXOMuye4N2HGHAkIJx0s7459YjrpMCSe7JnMjlwt1fIjfL7xhwxniU3hlqsqftDygOEr9gk5RWLc+Bl1XBOnSWY8DH3X78NAl3dnw; 25:EFomHrM7mEqDXb9lhB/p+4c2Iq/Xsg9stPC9VX8IMI2xaBj+Fj0ZtGcg+mRtW0Hy7XxK+HxQpkc0Kw+BYO7OH5dWYArXR4Zqr0skXU1lBBc29AgXlZoj4KSgi0Fv7MP9PyD79EwuunD+HbPmOwf3WDiRKNK0NykMLoo/gbWA7XRxbYJYgecFw5XDu64Z7VtV6j7diUTNLAFEmVHbB7V11Sy8pQnoBH24cXyovAM+SBpj43OF4QYDu5jKoWtjyZJTmC5QdDgoxi9MynwG/kZ+2rPMjx837OWGYZI5JWDCjqK6D9BXqEDHN3/yauOl23FC X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1781; X-MS-Office365-Filtering-Correlation-Id: 05b5ff4d-d0a3-42a9-3d16-08d33890a948 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1781; 20:s8q2D9QfdgCiGSIAbzBXw5N22X3VCK5fyWx2aI8ANPEY4qtvP9HrvjnSsagnzdM4V2bam/IiBAo2eFpRil8Xd25i5D3NtodJ8S0gQFTP4U2yQYQGy5xpArdjlJNpAP05ihoifAFLUVe5aB5Fb5BQeKaap+T43HtxLC1ZB8TbQlpn1idViwVkkqUXy4sA9hxeqnR0dwKLBRgJ0dqrSo+Ve234XTMiPHQV0A7hakQdPJP2HeeDxWAcXg88W0jNiFVjwE2m7QFDioUbtsltSL1/VWb7d9FLlXQtu/cDdpvtPSIDH66cFg6HqKpElPmzacjZVuoc9ojrlIx7S1Dvs+ugqUb7NDbSUnvvOoletoLb744ka20QSnEKn/ZL9PhGnTEcrU+ad1gR6Y1sETegaTryrd4dXt8TBg5YTcb6VwjsJJNsgdtR1A/r4TmpPxtO7eR4dKwnAPBfEcho3j4cWkBN05nOI/7PZTniy2rp4xrokonVcyoD12rPx2b4XDHbfvtrCXHlwSJ+9vmtfZVlbLqflremOuNjxtgfBFVtDCKEmuZfKYzrg3VUJtUCFtSMiAeKlHB/6nkiYyTbjRNEyq1N28yfLG6Bi69bujnn/fvXraY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:BY1PR0701MB1781; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1781; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1781; 4:A+Ha/IXTmj8SamxKl90lmRRBDxwU5hZgPl5GKsjibaZERNVjInTm9vFF7H8wV2cyyOWxp8Q/J055iJIaxwXG5BtaGTUrgm664mCD3f5CZXhDU7USl7BNQY6Z3vzUqB4cGwUUUfqvFsB4EQbkpm+1GvaJntf2Qw5rG3vwBPKjUoMMZ5EoDpo9kz6hU8I182a87FibzlffVSiqHJSlSc3gJTjmhaKlmnSc1t5T20EAmFFcyPMKG5mvsl3m2m6i3J9EaSHCx/1XYMXSxsusfDXSASkn2hOVayNuRGkfRWQDebvMD7ViQmNvMKYGM0vsBDfNoEBWeX5phJi8vXbdW6KO6Vn36sPhrSUHabBof1qmP/Y7odPCie1WxY7CuWLIXbxI X-Forefront-PRVS: 085634EFF4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(586003)(3846002)(66066001)(1096002)(122386002)(92566002)(2906002)(2876002)(40100003)(48376002)(50986999)(6116002)(33646002)(4326007)(5003940100001)(4001430100002)(77096005)(47776003)(36756003)(5008740100001)(50466002)(53416004)(189998001)(19580405001)(5001770100001)(42186005)(5004730100002)(86152002)(19580395003)(230783001)(5001960100002)(107886002)(50226001)(229853001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1781; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1781; 23:zzjQVWmLdme7hIkGxwryk6RmoLTUZtllGYmailh?= =?us-ascii?Q?9XOXd3ZMLiTtw7htrkaSidPjIWkEfCstqcVySN5Q8JXH5pC0L8cFEHXaBZ+U?= =?us-ascii?Q?3+dsQsHxfsIUd2x0Eqh4qfMGDXz/knnAaw6sbToMS6ixiMRXYfga2I80cME2?= =?us-ascii?Q?Ry7h4i83ftdB5yIklSTknyIBpMNwlSuO0K5Wg8QZARSTVzLG9xXptz88O08/?= =?us-ascii?Q?qRKStf5cX1QUp4JlaDLc86cBtUERR5W7GBPfnD19LS1JgG4ZmzQ5OjrKM0hb?= =?us-ascii?Q?x5QqPIB+zXvZlw5kzu/J+CAYZNMAFQmUSsMOytuVlllE1RrQGWcqcLfp3zY1?= =?us-ascii?Q?lT8myOyj2tP5wxW0XXnZQxY1Hze9I1Bh0n4N2fGlZQi2yWvarWyqh5CvfrXA?= =?us-ascii?Q?9kv5cXO9p2nmSg9zxFr9NX/3Rqw4QDTV6Jfcy4nbsCyncFMrQ0oA9cRpjCG2?= =?us-ascii?Q?5GlssxYkyU/sGaKXJdGeP9fcGq6Q4hlw8PKFC8mGRDwmrm8GztTOl/N3cyfQ?= =?us-ascii?Q?uTn+WBD2MvFs1wPv8hm4Sk2So65plnrkuUkpIRa5WYzCmGAsPdrSnIBO6JiZ?= =?us-ascii?Q?LObigs6COMDyD4rWMBAnfbsanPpjSDc2UcTOx2iGCTp8OjSBwM7My9yjnK5E?= =?us-ascii?Q?R700inRmnq0TmwMORg/v4OJzq18AsdF1bKxwmQKwK4bq/cworeNcwn2MtrS8?= =?us-ascii?Q?IERGsaFxw1agTWP84ISkMds7UU4sGpdLXCPQigcsFtpNQ93n96LCWdHBTuEk?= =?us-ascii?Q?qQmkY/RhmFQ+i+olQ/QnSpYFFgAdkt+kfQJjimVM8uPmc27viIKFnx8B8vQ+?= =?us-ascii?Q?BNio4HqyNAYckScDasYrLJCGSNZ9PKEqYW/ZVOZqnLUh1uUyZP111NXkgQtL?= =?us-ascii?Q?vmy1hGVXEg+qtPEj4WbllV38lFIciLRzNeff8P+QbJGyeJR73ZVPuhvD4Zoa?= =?us-ascii?Q?uX876Q5pt3V73o0FVdGMuj7qAHdnzG3w4CB88QIdpIw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1781; 5:kpHHPl2SBW2RcWripCAgC8GmvxpNqgSxL5hhP1OuIrfbE+h+GmyB0otgkv/zIjFEF1hnaJdoDzGFoRBN5nGRs0QbJB0D0slZ5UKwf+io6azanpRsrWF3umcpqzkz8HPm60nhp8W5wgXhA0GJk/+2ug==; 24:CMYsVFGuKuloP/FuhKxIobaTtGjivKCU+m3TRyyn8kFV6R9nCZsGowXFzbkJZ78TEeX+v6Vp7Pd5cYvHfEUYjZtnvy6um7P1d1pTx8wLqpw= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2016 18:23:54.9182 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1781 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160218_102418_967471_B58EF9C4 X-CRM114-Status: GOOD ( 10.17 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: iommu@lists.linux-foundation.org, Geethasowjanya.Akula@caviumnetworks.com, linux-arm-kernel@lists.infradead.org, tchalamarla@caviumnetworks.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tirumalesh Chalamarla ARM-SMMUv2 supports upto 16 bit VMID. This patch enables 16 bit VMID when requested from device-tree. Signed-off-by: Tirumalesh Chalamarla --- .../devicetree/bindings/iommu/arm,smmu.txt | 2 ++ drivers/iommu/arm-smmu.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt index 7180745..bb7e569 100644 --- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt +++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt @@ -55,6 +55,8 @@ conditions. aliases of secure registers have to be used during SMMU configuration. +- smmu-enable-vmid16 : Enable 16 bit VMID, if allowed. + Example: smmu { diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 59ee4b8..003c442 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -93,6 +93,7 @@ #define sCR0_VMIDPNE (1 << 11) #define sCR0_PTM (1 << 12) #define sCR0_FB (1 << 13) +#define sCR0_VMID16EN (1 << 31) #define sCR0_BSU_SHIFT 14 #define sCR0_BSU_MASK 0x3 @@ -140,6 +141,7 @@ #define ID2_PTFS_4K (1 << 12) #define ID2_PTFS_16K (1 << 13) #define ID2_PTFS_64K (1 << 14) +#define ID2_VMID16 (1 << 15) /* Global TLB invalidation */ #define ARM_SMMU_GR0_TLBIVMID 0x64 @@ -189,6 +191,8 @@ #define ARM_SMMU_GR1_CBA2R(n) (0x800 + ((n) << 2)) #define CBA2R_RW64_32BIT (0 << 0) #define CBA2R_RW64_64BIT (1 << 0) +#define CBA2R_VMID_SHIFT 16 +#define CBA2R_VMID_MASK 0xffff /* Translation context bank */ #define ARM_SMMU_CB_BASE(smmu) ((smmu)->base + ((smmu)->size >> 1)) @@ -300,6 +304,7 @@ struct arm_smmu_device { u32 features; #define ARM_SMMU_OPT_SECURE_CFG_ACCESS (1 << 0) +#define ARM_SMMU_OPT_ENABLE_VMID16 (1 << 1) u32 options; enum arm_smmu_arch_version version; @@ -361,6 +366,7 @@ struct arm_smmu_option_prop { static struct arm_smmu_option_prop arm_smmu_options[] = { { ARM_SMMU_OPT_SECURE_CFG_ACCESS, "calxeda,smmu-secure-config-access" }, + { ARM_SMMU_OPT_ENABLE_VMID16, "smmu-enable-vmid16" }, { 0, NULL}, }; @@ -736,6 +742,10 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, #else reg = CBA2R_RW64_32BIT; #endif + /* if 16bit VMID required set VMID in CBA2R */ + if (smmu->options & ARM_SMMU_OPT_ENABLE_VMID16) + reg |= ARM_SMMU_CB_VMID(cfg) << CBA2R_VMID_SHIFT; + writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBA2R(cfg->cbndx)); } @@ -751,7 +761,8 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, if (stage1) { reg |= (CBAR_S1_BPSHCFG_NSH << CBAR_S1_BPSHCFG_SHIFT) | (CBAR_S1_MEMATTR_WB << CBAR_S1_MEMATTR_SHIFT); - } else { + } else if (!(smmu->options & ARM_SMMU_OPT_ENABLE_VMID16)) { + /*16 bit VMID is not enabled set 8 bit VMID here */ reg |= ARM_SMMU_CB_VMID(cfg) << CBAR_VMID_SHIFT; } writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBAR(cfg->cbndx)); @@ -1508,6 +1519,14 @@ static void arm_smmu_device_reset(struct arm_smmu_device *smmu) /* Don't upgrade barriers */ reg &= ~(sCR0_BSU_MASK << sCR0_BSU_SHIFT); + /* See if 16bit VMID is required */ + if (smmu->options & ARM_SMMU_OPT_ENABLE_VMID16) { + u32 id = readl_relaxed(gr0_base + ARM_SMMU_GR0_ID2); + /* Check to see if HW accepts */ + if (id & ID2_VMID16) + reg |= (sCR0_VMID16EN); + } + /* Push the button */ __arm_smmu_tlb_sync(smmu); writel(reg, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);