Skip to content

Commit 9d5cca8

Browse files
Geetha Sowjanya0day robot
Geetha Sowjanya
authored and
0day robot
committed
iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum torvalds#126
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 <[email protected]>
1 parent 4ab28d9 commit 9d5cca8

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

drivers/iommu/arm-smmu-v3.c

+28-4
Original file line numberDiff line numberDiff line change
@@ -2236,10 +2236,30 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu)
22362236
devm_add_action(dev, arm_smmu_free_msis, dev);
22372237
}
22382238

2239+
static int get_irq_flags(struct arm_smmu_device *smmu, int irq)
2240+
{
2241+
int match_count = 0;
2242+
2243+
if (irq == smmu->evtq.q.irq)
2244+
match_count++;
2245+
if (irq == smmu->cmdq.q.irq)
2246+
match_count++;
2247+
if (irq == smmu->gerr_irq)
2248+
match_count++;
2249+
if (irq == smmu->priq.q.irq)
2250+
match_count++;
2251+
2252+
if (match_count > 1)
2253+
return IRQF_SHARED | IRQF_ONESHOT;
2254+
2255+
return 0;
2256+
}
2257+
22392258
static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
22402259
{
22412260
int ret, irq;
22422261
u32 irqen_flags = IRQ_CTRL_EVTQ_IRQEN | IRQ_CTRL_GERROR_IRQEN;
2262+
u32 irqflags = 0;
22432263

22442264
/* Disable IRQs first */
22452265
ret = arm_smmu_write_reg_sync(smmu, 0, ARM_SMMU_IRQ_CTRL,
@@ -2254,37 +2274,41 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu)
22542274
/* Request interrupt lines */
22552275
irq = smmu->evtq.q.irq;
22562276
if (irq) {
2277+
irqflags = get_irq_flags(smmu, irq);
22572278
ret = devm_request_threaded_irq(smmu->dev, irq, NULL,
22582279
arm_smmu_evtq_thread,
2259-
IRQF_ONESHOT,
2280+
IRQF_ONESHOT | irqflags,
22602281
"arm-smmu-v3-evtq", smmu);
22612282
if (ret < 0)
22622283
dev_warn(smmu->dev, "failed to enable evtq irq\n");
22632284
}
22642285

22652286
irq = smmu->cmdq.q.irq;
22662287
if (irq) {
2288+
irqflags = get_irq_flags(smmu, irq);
22672289
ret = devm_request_irq(smmu->dev, irq,
2268-
arm_smmu_cmdq_sync_handler, 0,
2290+
arm_smmu_cmdq_sync_handler, irqflags,
22692291
"arm-smmu-v3-cmdq-sync", smmu);
22702292
if (ret < 0)
22712293
dev_warn(smmu->dev, "failed to enable cmdq-sync irq\n");
22722294
}
22732295

22742296
irq = smmu->gerr_irq;
22752297
if (irq) {
2298+
irqflags = get_irq_flags(smmu, irq);
22762299
ret = devm_request_irq(smmu->dev, irq, arm_smmu_gerror_handler,
2277-
0, "arm-smmu-v3-gerror", smmu);
2300+
irqflags, "arm-smmu-v3-gerror", smmu);
22782301
if (ret < 0)
22792302
dev_warn(smmu->dev, "failed to enable gerror irq\n");
22802303
}
22812304

22822305
if (smmu->features & ARM_SMMU_FEAT_PRI) {
22832306
irq = smmu->priq.q.irq;
22842307
if (irq) {
2308+
irqflags = get_irq_flags(smmu, irq);
22852309
ret = devm_request_threaded_irq(smmu->dev, irq, NULL,
22862310
arm_smmu_priq_thread,
2287-
IRQF_ONESHOT,
2311+
IRQF_ONESHOT | irqflags,
22882312
"arm-smmu-v3-priq",
22892313
smmu);
22902314
if (ret < 0)

0 commit comments

Comments
 (0)