Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162129AbdD0MFz (ORCPT ); Thu, 27 Apr 2017 08:05:55 -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 S967384AbdD0MFo (ORCPT ); Thu, 27 Apr 2017 08:05:44 -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 3/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 Date: Thu, 27 Apr 2017 17:16:24 +0530 Message-Id: <1493293584-20287-4-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: 3c8cbde1-5116-48b8-6e4e-08d48d65ba36 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BN3PR07MB2500; X-Microsoft-Exchange-Diagnostics: 1;BN3PR07MB2500;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4VWiD9IwH9eouyxpA383kW6S+;20:sH9fGhlWNg80AT5aJGVA4XcgYvb6yZ25QxZDE1fcH1VVYwnF1JkymC0zbN05Kef3QaODlX1M8LQCSnz+v0KEs16DxX9DTyiz2u3ZKUj+HYQ0BYxNCZKADgzQT71J9SnJatnC/q8ZCB1WPLq0uRXbVN4gYMYghxG7qpcfw4tvwD1QneOLpvTh+rqKRvbFI7qygeUyGZtUih6wNA2iI4Px7aXqQgkS7ouakUAZd0aePYpmjWitgx3esorc/4+uIJobi056Abay+E5cc8gtHTWkQXl2Kf/O3s8xoFtUKu/4F6DM4nxLNJxzNYvI+iN4nQG1B8Mk61adMHMl/ZuN11rIaIiykNT+Iv/1Vdz0uhKZe6dfre25vKfwppEh2jQ2lrkbJueD9kaWxwLJO7bcB7XZqueQkQgNKfJnKYwX4H2urDIYNdcCIbvA6Xp9Jmaq8NwwgwQRVjLhzZqTR5UjMYucqY6EWgkXRNmgJJ6Iex3/DXjvkp/vCfMi8pY7VGrNRRcRyoso0tjTSncVIzDqFP1MvZPKeSTa5JlFc5vuBRfDHSxS5HB7YHkM56Ep7Ay4IX4csQIigwdqteg5nGItfIUVGEJIZ+fIsRCNkPALNFyfT8M= 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:CDVLK/1itt+D0+dj4QCPYxywmziy++b9vDFrzYeun2WL5xE8duwC5nFcslA6zPs3wd8UIezhzB1Mp4TqNF5k33QavUtNMrO8RXm6EFPPDifi0cOj582RbcputvVAeVna7LYuE1O6wJrzas+zB+r5Qj8VWvJ4VRxq1iRDglzuXSNHJNAASRfzJEAQ4va2ddc7GuO3iCF+/tmCeDeTbdGSGa9f7wMpM7wbie6iIyHVZSigJCJ3GGG8UHxNCXotuGGuTiGU6cRcRdZuOJ2RSoaOqLz9ZVrPtTq8LyCpKXSwjg3Il4p1yTe0HLwH3cy0cc31OgNpJU79Fpuq7/JB9Wiat/TzEds9FHLWwueDpUrnEltUbXjsq3hudookATaFCeu9izWON7yNppn2wj4cb9xyR/gzHaR1hSVc0dKhvMc5T38mMGdwTTsgL5NfkQDq6T9Qidv3m4Nsgb1As1Mef7v3ZorOamaEEgmnu6d6RNkCOQxhEOAO086nN1FiTcNCanYguvLBggtRDVRdFRzcMAPku7EaGydU224GgFo3ceMZqMCPI6p8YEMFA+QxezPf8wWn7X3FBnZO09mUayUnfoDLqT0kN0qIZndFVh9xH5NQlPj8VIjcGoDacJqrkKqEQ+hub1Fb1F9fQz3yCf8r+5rpILx3RImCMsB5yoWioRId3lRrz+yQtMIicj1gatxmUDRI5EqyKS84UIWv5iIenAu/eg== 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:LrU/xtlVF01DIPv23ZS6K7S2DaweKBLCKSHJWGUEq?= =?us-ascii?Q?hZjfdrCIFMclMLbOZxFkrIW/gNbhs18D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iBvXH7gUtERVhzbLraIUmN0eF4Fs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR07MB2500;7:YToLtOXrfmYqUyYcqsVKA2ijq+AGzZNmxLTBKS6Y5OsHeEaXP6PtFEAUNGBMe7+v1HO2jc/JvrdlmT5L38dAd/kdrvxbIF3VwFr32mtKK7lHZfUMToL692Qk3rvnoq2L/rpb1fOpvmYTrlc3cKpnyqrDsTQr9kzN7KZd+N0DknVTOo4ONG6KkvKlr1BT4T03qb24w9GSSfHP+h4ehTe3L9D5cqBVHjK08aVtgT0XFX5PVF23VkxA336woeNl3gJN+mdNjVCr8dXoDJ3LLh8osndOAR5CPZYfeCtz/BjiI05odPsHbHaFW0Bz/7qCFUsH4jHNlYx4DDwrQd/eimueVQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2017 12:05:38.2122 (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: 3972 Lines: 109 From: Geetha Cavium 99xx SMMU doesn't support MSI and also doesn't have unique irq lines for gerror, eventq and cmdq-sync. This patch addresses the issue by checking if any interrupt sources are using same irq number, then they are registered as shared irqs. Signed-off-by: Geetha --- Documentation/arm64/silicon-errata.txt | 1 + drivers/iommu/arm-smmu-v3.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Documentation/arm64/silicon-errata.txt b/Documentation/arm64/silicon-errata.txt index 629e2ce..cc15f25 100644 --- a/Documentation/arm64/silicon-errata.txt +++ b/Documentation/arm64/silicon-errata.txt @@ -62,6 +62,7 @@ stable kernels. | Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 | | Cavium | ThunderX SMMUv2 | #27704 | N/A | | Cavium | ThunderX2 SMMUv3| #74 | N/A | +| Cavium | ThunderX2 SMMUv3| #126 | N/A | | | | | | | Freescale/NXP | LS2080A/LS1043A | A-008585 | FSL_ERRATUM_A008585 | | | | | | diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index ee23ccd..eb55d38 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2211,10 +2211,30 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) devm_add_action(dev, arm_smmu_free_msis, dev); } +static int get_irq_flags(struct arm_smmu_device *smmu, int irq) +{ + int match_count = 0; + + if (irq == smmu->evtq.q.irq) + match_count++; + if (irq == smmu->cmdq.q.irq) + match_count++; + if (irq == smmu->gerr_irq) + match_count++; + if (irq == smmu->priq.q.irq) + match_count++; + + if (match_count > 1) + return IRQF_SHARED | IRQF_ONESHOT; + + return 0; +} + static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) { int ret, irq; u32 irqen_flags = IRQ_CTRL_EVTQ_IRQEN | IRQ_CTRL_GERROR_IRQEN; + u32 irqflags = 0; /* Disable IRQs first */ ret = arm_smmu_write_reg_sync(smmu, 0, ARM_SMMU_IRQ_CTRL, @@ -2229,9 +2249,10 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) /* Request interrupt lines */ irq = smmu->evtq.q.irq; if (irq) { + irqflags = get_irq_flags(smmu, irq); ret = devm_request_threaded_irq(smmu->dev, irq, NULL, arm_smmu_evtq_thread, - IRQF_ONESHOT, + IRQF_ONESHOT | irqflags, "arm-smmu-v3-evtq", smmu); if (ret < 0) dev_warn(smmu->dev, "failed to enable evtq irq\n"); @@ -2239,8 +2260,9 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) irq = smmu->cmdq.q.irq; if (irq) { + irqflags = get_irq_flags(smmu, irq); ret = devm_request_irq(smmu->dev, irq, - arm_smmu_cmdq_sync_handler, 0, + arm_smmu_cmdq_sync_handler, irqflags, "arm-smmu-v3-cmdq-sync", smmu); if (ret < 0) dev_warn(smmu->dev, "failed to enable cmdq-sync irq\n"); @@ -2248,8 +2270,9 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) irq = smmu->gerr_irq; if (irq) { + irqflags = get_irq_flags(smmu, irq); ret = devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler, - 0, "arm-smmu-v3-gerror", smmu); + irqflags, "arm-smmu-v3-gerror", smmu); if (ret < 0) dev_warn(smmu->dev, "failed to enable gerror irq\n"); } @@ -2257,9 +2280,10 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) if (smmu->features & ARM_SMMU_FEAT_PRI) { irq = smmu->priq.q.irq; if (irq) { + irqflags = get_irq_flags(smmu, irq); ret = devm_request_threaded_irq(smmu->dev, irq, NULL, arm_smmu_priq_thread, - IRQF_ONESHOT, + IRQF_ONESHOT | irqflags, "arm-smmu-v3-priq", smmu); if (ret < 0) -- 1.9.1