Skip to content

Commit eb3709a

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 988ffc8 commit eb3709a

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);
@@ -1420,9 +1412,11 @@ static int apple_dart_probe(struct platform_device *pdev)
14201412
}
14211413

14221414
dart->locked = apple_dart_is_locked(dart);
1423-
ret = apple_dart_hw_reset(dart);
1424-
if (ret)
1425-
goto err_clk_disable;
1415+
if (!dart->locked) {
1416+
ret = apple_dart_hw_reset(dart);
1417+
if (ret)
1418+
goto err_clk_disable;
1419+
}
14261420

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

1472-
apple_dart_hw_reset(dart);
1466+
if (!dart->locked)
1467+
apple_dart_hw_reset(dart);
1468+
14731469
free_irq(dart->irq, dart);
14741470

14751471
iommu_device_unregister(&dart->iommu);
@@ -1587,6 +1583,10 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
15871583
struct apple_dart *dart = dev_get_drvdata(dev);
15881584
unsigned int sid, idx;
15891585

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

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

0 commit comments

Comments
 (0)