Skip to content

Commit 0c8941b

Browse files
alyssarosenzweigjannau
authored andcommitted
iommu/dart: Support locked DARTs
Locked DARTs cannot be reconfigured, therefore the reset/restore procedure can't work and should not be needed. Skip it and allowing locked DARTs to probe. Co-developed-by: Hector Martin <marcan@marcan.st> Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 633e1be commit 0c8941b

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

drivers/iommu/apple-dart.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,9 @@ apple_dart_t8110_hw_invalidate_tlb(struct apple_dart_stream_map *stream_map)
550550

551551
static int apple_dart_hw_reset(struct apple_dart *dart)
552552
{
553-
u32 config;
554553
struct apple_dart_stream_map stream_map;
555554
int i;
556555

557-
config = readl(dart->regs + dart->hw->lock);
558-
if (config & dart->hw->lock_bit) {
559-
dev_err(dart->dev, "DART is locked down until reboot: %08x\n",
560-
config);
561-
return -EINVAL;
562-
}
563-
564556
stream_map.dart = dart;
565557
bitmap_zero(stream_map.sidmap, DART_MAX_STREAMS);
566558
bitmap_set(stream_map.sidmap, 0, dart->num_streams);
@@ -1422,9 +1414,11 @@ static int apple_dart_probe(struct platform_device *pdev)
14221414
}
14231415

14241416
dart->locked = apple_dart_is_locked(dart);
1425-
ret = apple_dart_hw_reset(dart);
1426-
if (ret)
1427-
goto err_clk_disable;
1417+
if (!dart->locked) {
1418+
ret = apple_dart_hw_reset(dart);
1419+
if (ret)
1420+
goto err_clk_disable;
1421+
}
14281422

14291423
ret = request_irq(dart->irq, apple_dart_irq, IRQF_SHARED,
14301424
"apple-dart fault handler", dart);
@@ -1471,7 +1465,9 @@ static void apple_dart_remove(struct platform_device *pdev)
14711465
{
14721466
struct apple_dart *dart = platform_get_drvdata(pdev);
14731467

1474-
apple_dart_hw_reset(dart);
1468+
if (!dart->locked)
1469+
apple_dart_hw_reset(dart);
1470+
14751471
free_irq(dart->irq, dart);
14761472

14771473
iommu_device_unregister(&dart->iommu);
@@ -1589,6 +1585,10 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
15891585
struct apple_dart *dart = dev_get_drvdata(dev);
15901586
unsigned int sid, idx;
15911587

1588+
/* Locked DARTs can't be restored so skip saving their registers/. */
1589+
if (dart->locked)
1590+
return 0;
1591+
15921592
for (sid = 0; sid < dart->num_streams; sid++) {
15931593
dart->save_tcr[sid] = readl(dart->regs + DART_TCR(dart, sid));
15941594
for (idx = 0; idx < dart->hw->ttbr_count; idx++)
@@ -1605,6 +1605,10 @@ static __maybe_unused int apple_dart_resume(struct device *dev)
16051605
unsigned int sid, idx;
16061606
int ret;
16071607

1608+
/* Locked DARTs can't be restored, and they should not need it */
1609+
if (dart->locked)
1610+
return 0;
1611+
16081612
ret = apple_dart_hw_reset(dart);
16091613
if (ret) {
16101614
dev_err(dev, "Failed to reset DART on resume\n");

0 commit comments

Comments
 (0)