Skip to content

Commit 238d51c

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 3502a50 commit 238d51c

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);
@@ -1417,9 +1409,11 @@ static int apple_dart_probe(struct platform_device *pdev)
14171409
}
14181410

14191411
dart->locked = apple_dart_is_locked(dart);
1420-
ret = apple_dart_hw_reset(dart);
1421-
if (ret)
1422-
goto err_clk_disable;
1412+
if (!dart->locked) {
1413+
ret = apple_dart_hw_reset(dart);
1414+
if (ret)
1415+
goto err_clk_disable;
1416+
}
14231417

14241418
ret = request_irq(dart->irq, apple_dart_irq, IRQF_SHARED,
14251419
"apple-dart fault handler", dart);
@@ -1466,7 +1460,9 @@ static void apple_dart_remove(struct platform_device *pdev)
14661460
{
14671461
struct apple_dart *dart = platform_get_drvdata(pdev);
14681462

1469-
apple_dart_hw_reset(dart);
1463+
if (!dart->locked)
1464+
apple_dart_hw_reset(dart);
1465+
14701466
free_irq(dart->irq, dart);
14711467

14721468
iommu_device_unregister(&dart->iommu);
@@ -1584,6 +1580,10 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
15841580
struct apple_dart *dart = dev_get_drvdata(dev);
15851581
unsigned int sid, idx;
15861582

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

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

0 commit comments

Comments
 (0)