From patchwork Fri Feb 19 18:33:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tirumalesh Chalamarla X-Patchwork-Id: 8363431 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 1974AC0553 for ; Fri, 19 Feb 2016 18:37:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF29B20529 for ; Fri, 19 Feb 2016 18:37:35 +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 CA47520461 for ; Fri, 19 Feb 2016 18:37:34 +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 1aWptw-0003Mu-BY; Fri, 19 Feb 2016 18:35:36 +0000 Received: from mail-bn1bon0075.outbound.protection.outlook.com ([157.56.111.75] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aWpts-000341-TY for linux-arm-kernel@lists.infradead.org; Fri, 19 Feb 2016 18:35:34 +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 BY1PR0701MB1782.namprd07.prod.outlook.com (10.162.141.20) with Microsoft SMTP Server (TLS) id 15.1.409.15; Fri, 19 Feb 2016 18:35:09 +0000 From: To: , Subject: [PATCH V2] iommu/arm-smmu-v2: Add support for 16 bit VMID Date: Fri, 19 Feb 2016 10:33:33 -0800 Message-ID: <1455906813-9721-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: BY2PR04CA024.namprd04.prod.outlook.com (10.141.249.142) To BY1PR0701MB1782.namprd07.prod.outlook.com (25.162.141.20) X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1782; 2:hlWKFaQWxzke4U3Tc5cDoriUXtzW+xjhq3D5UxcchvsQsDntZRjqc77mLJ3ob1IvzXF33tfKecjqCc27zYLI5iAHd6BV7ZTWem/BoDyMYkq8FetTAVuUlmdsWvhY5HdjHLGrzdhcmYONhrCagc9gRQ==; 3:RWR0Aguc0g5lj1VHc0epZBX3W5P5McBtgdcpbXThBfkENnevLV2q51B1T6T/UrWpHHZOZ91Il7tdj2vbvMlpnhpwpN0efKeXlrAZ1/rMKTGdKrkaS2yLTGDq3201Hvos; 25:46gILUaBi7AfIdtcvSvOEHTF1zG+OFEhD3PkYI7vHh11bLijI5wjivCXoJjLNKrPvtpDZz5WPeENtI/1MT/nP8RC6TERnoRoAzz2i0YK4Py6OzPdBgoXvxoMIchgp/8J/c52/s8db9zm/d1ubCZIbuO8Hf1IiQs+8iSonqJgzTFno6jC2bbg6muJTVagkeZYLT7732y+J3mtGsRnXNMBf3VbXS4uE7K+2EQ8m1NsqrWOV/lQeMz2uAhA+fXCuKJ6LB5uymVQuTfyoSWTGXouTQIXfwmQZ197GghsMEKrwKcLl3qsO8DV11u1lPZsfGgB X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1782; X-MS-Office365-Filtering-Correlation-Id: 76ab8210-e2e4-46af-d467-08d3395b6574 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1782; 20:42LcTwUyeLchs0yPapzme4psBVxb7O8Z5niRz6C4zf9FWN1y/a+9Gr0X3oISWP5d+z1Iv1QJrvcd1mjdLJLu6cPcYqf3QJRuOV7+lwo9Ajf6o9EwEHUQqzwffuBHpPVG4aiXQYdMNQ+dY1ukbreFTiPIbWHckv0xvkaYP+4vjmTrJdkLL/LQ61BSv9OqVqY2v54K0EA1OOM7vsUac8/0DhsU4gKFrHVBy94O+bTA9A2N291VwI+57HByvYt7ONsxptu6HBmWQBKu/RO4SGybGd57Cp9snMrFKG+iiPUcjobsPirsJFEFIdpq7iSpYAM3H3M4sZxJR0FyyoapWJP8LENOW7AeTEZGsq/J0Jqwp/2u6agKTVGBEKlDVSK0J0kFYamyLIw2+nREqHEQZaYJeWmEj/Qva0TXmOCC1C8vWIztFQN22GMhOjxF51W8biqGqi2AqfxRaq027O8XC9RxjyRj8FJftRaZ/kzjvZ6C8SCMDbYzHQ+JbVNQKKamOc3P2ohQPtUpJ4x8eaFJvog0Uw4lsDDEGKD3lWRfU7nDwDoL+Jye6DMncIjEy7+zQrjbh3AElvbCbpduOHv7qF5SeK8xVCOknIuAyJChNx1KVO8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BY1PR0701MB1782; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1782; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1782; 4:yzsJW/o5jKHzHKMtz2ti7zFRo8dbrN/ECdQmZbIE6VHchPNJcYO3WUZqVihvorvqSZzk5Iu08A5KuV0SuDR2hhLZlzEw94vDMYZN2jgqtu64YKR+Fbhk7DwBJOA1UoNWBw04G+2g//9DGwCJEClXGR6Hwrz7bDpfx0cZRfpLtDCGK/MJkl5MkP3FrAFJHTPBlHEhP5qSAkGh0cI6tYlRX7PdIfZQ+y4YFr/drkQmzkg8u0EEUxPusCoKGF+g4PbQFIxGjF98zcD732UsoAlsT1uSG9e579E38y175XOPf+/Sex1NgTjAg70wmPvJARjXS2UmHOq2MUN4+tKOyRNzB9rfmzz/wlrwTbzYwBhu4KJG8h+xiApNP86MuRtY1Jik X-Forefront-PRVS: 08572BD77F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(50226001)(1096002)(5003940100001)(229853001)(5004730100002)(586003)(3846002)(87976001)(2876002)(92566002)(47776003)(33646002)(86152002)(4001430100002)(36756003)(6116002)(5008740100001)(2906002)(230783001)(50466002)(77096005)(42186005)(19580405001)(4326007)(53416004)(48376002)(50986999)(40100003)(107886002)(122386002)(19580395003)(5001770100001)(66066001)(189998001)(5001960100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1782; H:tiru-pc.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0701MB1782; 23:hNV7kd8nbzZw6Z3ul/gtY1zqpisj/L/K8xymwR0?= =?us-ascii?Q?gQt9BZWBQ7l3ycILxoeuw1PaysA/3OPdxbUMF0F7Ffys9sukx9dLN8xdqrzy?= =?us-ascii?Q?4jyjld6g8ruRIp1BS+GH87yQ0Ezk/YkJEQvsf4f0SeJ7pYZxdSbqPgDnDqaD?= =?us-ascii?Q?HLaWyMZI/ptrga+HyfHaMyIykWrb6200zUJQ3dK9aap+5c57vH5aJCC+GX10?= =?us-ascii?Q?qfU/SoHTqna1EJ9vsicHdC3Fi8irG6mu+jSC9Bi6r2xxYtC0Dz+k6/JNsTU/?= =?us-ascii?Q?SkTgYnC0JOb+xYfMm3B0ZYgmPffpv5BPKPCHXfH2hSY4jHawvaoL9lRTERwG?= =?us-ascii?Q?dp8MPRXe2nyFIwQqOGXMd7bQYOMO74a2kOcHWHURlMVeYjFtfn+PAJ36Fu9g?= =?us-ascii?Q?q/8XevPZXwCB5EHIKJxyhQ1QsiSOY/AlFhpMf6UKV6lOw3D/ajDIzh/5PFfI?= =?us-ascii?Q?p5feSAlUwyHz+yfFG1RonO7XaF0VOeHj4w5dDRBc9Lk74hPEXwHTOYWh2FIS?= =?us-ascii?Q?WVRd/YqeAZE6ZPj8ZB+7kBUgfAYZqEo1C82nlafOPwSNih0ULx1BkTydjHiV?= =?us-ascii?Q?NgSN89ftAvBMa5u2BUtuxNUJtpW36GtU3W0LWgOL81vA5D3HuX8jIATmYBUP?= =?us-ascii?Q?7TnrQ1rdHRVoksdYDkrlinnnU5RqQ2TN/IMYMQpOuDNUvgC8NthODNXhJgsO?= =?us-ascii?Q?MjzvN8jSxl4zFCCYpRw1EYkI4J8gCPPkTvxyubgE4OKnxPy/hePgdU7kln1C?= =?us-ascii?Q?xGiifpTprQADsyaxkjjawjnB+GexZ8Ngn/rJbeNgcld9OxIQRjxM/4Sml/kJ?= =?us-ascii?Q?k9+NmCpf5qbwa2+1oftz/DkdAqDKvUalVRDC1141qQ+8+HTQuO3TodvnnWhv?= =?us-ascii?Q?jEyM4BJulnTf2/1Z3/bjGfzTyooYjHTlvxi08ZAknAMiQsbeXsja8n+d/kmL?= =?us-ascii?Q?dno+ml2z+60acHTtB0zOg+pSGlpu6oFpvNYPYUfIML/Bi6Zqahg5PbscKbsQ?= =?us-ascii?Q?CYdrZM+Y7mVtQ6BqP02THNa+RyjMDRcrtpDuQiH8TyZpGXA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1782; 5:6c7HB6thl3uWyy8zoi+5iVcCPPPmUx26m4+E4AyOpunzqMLvNSXUwWxDp0d9gC2mfFTLR8AH6kIEOWm+u3klLopAGypSJFq25h7HzMsefO2KhhzyIR0MHa+kdHM3mVzCM3Fgkr+Fkb8kt4jqOPkk6w==; 24:fBURcTKIesxvlPSG4Q9LgSzjlhxkX6gk0WIyLYHGQ3RzcPB1h5Lam7njbTGZaDe/mk8KFFFBJ/J+Zo+SjQATxeJ8jMdvYnjioOwJ43jLggE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2016 18:35:09.5553 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1782 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160219_103533_256015_E924E55E X-CRM114-Status: UNSURE ( 9.74 ) X-CRM114-Notice: Please train this message. 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 HW supports. changes from V1: - Remove DT Property and enable 16 bit VMID if ID says. Signed-off-by: Tirumalesh Chalamarla --- drivers/iommu/arm-smmu.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 59ee4b8..92caab8 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)) @@ -297,6 +301,7 @@ struct arm_smmu_device { #define ARM_SMMU_FEAT_TRANS_S2 (1 << 3) #define ARM_SMMU_FEAT_TRANS_NESTED (1 << 4) #define ARM_SMMU_FEAT_TRANS_OPS (1 << 5) +#define ARM_SMMU_FEAT_VMID16 (1 << 6) u32 features; #define ARM_SMMU_OPT_SECURE_CFG_ACCESS (1 << 0) @@ -736,6 +741,10 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, #else reg = CBA2R_RW64_32BIT; #endif + /* if 16bit VMID supported set VMID in CBA2R */ + if (smmu->features & ARM_SMMU_FEAT_VMID16) + reg |= ARM_SMMU_CB_VMID(cfg) << CBA2R_VMID_SHIFT; + writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBA2R(cfg->cbndx)); } @@ -751,7 +760,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->features & ARM_SMMU_FEAT_VMID16)) { + /*16 bit VMID is not supported 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 +1518,9 @@ static void arm_smmu_device_reset(struct arm_smmu_device *smmu) /* Don't upgrade barriers */ reg &= ~(sCR0_BSU_MASK << sCR0_BSU_SHIFT); + if (smmu->features & ARM_SMMU_FEAT_VMID16) + reg |= sCR0_VMID16EN; + /* Push the button */ __arm_smmu_tlb_sync(smmu); writel(reg, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0); @@ -1658,6 +1671,10 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) size = arm_smmu_id_size_to_bits((id >> ID2_OAS_SHIFT) & ID2_OAS_MASK); smmu->pa_size = size; + /* See if 16bit VMID is supported */ + if (id & ID2_VMID16) + smmu->features = ARM_SMMU_FEAT_VMID16; + /* * What the page table walker can address actually depends on which * descriptor format is in use, but since a) we don't know that yet, @@ -1696,6 +1713,11 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) dev_notice(smmu->dev, "\tStage-2: %lu-bit IPA -> %lu-bit PA\n", smmu->ipa_size, smmu->pa_size); + if (smmu->features & ARM_SMMU_FEAT_VMID16) + dev_notice(smmu->dev, "\t 16 bit VMID Supported.\n"); + else + dev_notice(smmu->dev, "\t Only 8 bit VMID Supported.\n"); + return 0; }