Skip to content

Commit 47cf99c

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 3ddcf76 commit 47cf99c

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
@@ -547,17 +547,9 @@ apple_dart_t8110_hw_invalidate_tlb(struct apple_dart_stream_map *stream_map)
547547

548548
static int apple_dart_hw_reset(struct apple_dart *dart)
549549
{
550-
u32 config;
551550
struct apple_dart_stream_map stream_map;
552551
int i;
553552

554-
config = readl(dart->regs + dart->hw->lock);
555-
if (config & dart->hw->lock_bit) {
556-
dev_err(dart->dev, "DART is locked down until reboot: %08x\n",
557-
config);
558-
return -EINVAL;
559-
}
560-
561553
stream_map.dart = dart;
562554
bitmap_zero(stream_map.sidmap, DART_MAX_STREAMS);
563555
bitmap_set(stream_map.sidmap, 0, dart->num_streams);
@@ -1419,9 +1411,11 @@ static int apple_dart_probe(struct platform_device *pdev)
14191411
}
14201412

14211413
dart->locked = apple_dart_is_locked(dart);
1422-
ret = apple_dart_hw_reset(dart);
1423-
if (ret)
1424-
goto err_clk_disable;
1414+
if (!dart->locked) {
1415+
ret = apple_dart_hw_reset(dart);
1416+
if (ret)
1417+
goto err_clk_disable;
1418+
}
14251419

14261420
ret = request_irq(dart->irq, apple_dart_irq, IRQF_SHARED,
14271421
"apple-dart fault handler", dart);
@@ -1468,7 +1462,9 @@ static void apple_dart_remove(struct platform_device *pdev)
14681462
{
14691463
struct apple_dart *dart = platform_get_drvdata(pdev);
14701464

1471-
apple_dart_hw_reset(dart);
1465+
if (!dart->locked)
1466+
apple_dart_hw_reset(dart);
1467+
14721468
free_irq(dart->irq, dart);
14731469

14741470
iommu_device_unregister(&dart->iommu);
@@ -1586,6 +1582,10 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
15861582
struct apple_dart *dart = dev_get_drvdata(dev);
15871583
unsigned int sid, idx;
15881584

1585+
/* Locked DARTs can't be restored so skip saving their registers/. */
1586+
if (dart->locked)
1587+
return 0;
1588+
15891589
for (sid = 0; sid < dart->num_streams; sid++) {
15901590
dart->save_tcr[sid] = readl(dart->regs + DART_TCR(dart, sid));
15911591
for (idx = 0; idx < dart->hw->ttbr_count; idx++)
@@ -1602,6 +1602,10 @@ static __maybe_unused int apple_dart_resume(struct device *dev)
16021602
unsigned int sid, idx;
16031603
int ret;
16041604

1605+
/* Locked DARTs can't be restored, and they should not need it */
1606+
if (dart->locked)
1607+
return 0;
1608+
16051609
ret = apple_dart_hw_reset(dart);
16061610
if (ret) {
16071611
dev_err(dev, "Failed to reset DART on resume\n");

0 commit comments

Comments
 (0)