From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbdEHLVk (ORCPT ); Mon, 8 May 2017 07:21:40 -0400 Received: from foss.arm.com ([217.140.101.70]:41232 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752833AbdEHLVi (ORCPT ); Mon, 8 May 2017 07:21:38 -0400 Subject: Re: [PATCH v3 6/7] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126 To: Geetha sowjanya , will.deacon@arm.com, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, iommu@lists.linux-foundation.org References: <1493986091-30521-1-git-send-email-gakula@caviumnetworks.com> <1493986091-30521-7-git-send-email-gakula@caviumnetworks.com> 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 Sowjanya From: Robin Murphy Message-ID: Date: Mon, 8 May 2017 12:21:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1493986091-30521-7-git-send-email-gakula@caviumnetworks.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/05/17 13:08, Geetha sowjanya wrote: > From: Geetha Sowjanya > > Cavium ThunderX2 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 Sowjanya > --- > drivers/iommu/arm-smmu-v3.c | 32 ++++++++++++++++++++++++++++---- > 1 file changed, 28 insertions(+), 4 deletions(-) > > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > index 016b702..46428e7 100644 > --- a/drivers/iommu/arm-smmu-v3.c > +++ b/drivers/iommu/arm-smmu-v3.c > @@ -2236,10 +2236,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; I'd say just have this return IRQF_ONESHOT in the non-shared case... > +} > + > 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, > @@ -2254,9 +2274,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, ...and pass get_irq_flags(smmu, irq) directly as the argument here. The local variable and intermediate logic only seem to add unnecessary complexity, given that the two cases we actually end up with are: IRQF_ONESHOT | 0 vs. IRQF_ONESHOT | IRQF_SHARED | IRQF_ONESHOT neither of which looks particularly sensible. Robin. > "arm-smmu-v3-evtq", smmu); > if (ret < 0) > dev_warn(smmu->dev, "failed to enable evtq irq\n"); > @@ -2264,8 +2285,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"); > @@ -2273,8 +2295,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"); > } > @@ -2282,9 +2305,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) >