Skip to content

Commit 7053170

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 64f7c48 commit 7053170

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

534534
static int apple_dart_hw_reset(struct apple_dart *dart)
535535
{
536-
u32 config;
537536
struct apple_dart_stream_map stream_map;
538537
int i;
539538

540-
config = readl(dart->regs + dart->hw->lock);
541-
if (config & dart->hw->lock_bit) {
542-
dev_err(dart->dev, "DART is locked down until reboot: %08x\n",
543-
config);
544-
return -EINVAL;
545-
}
546-
547539
stream_map.dart = dart;
548540
bitmap_zero(stream_map.sidmap, DART_MAX_STREAMS);
549541
bitmap_set(stream_map.sidmap, 0, dart->num_streams);
@@ -1309,9 +1301,11 @@ static int apple_dart_probe(struct platform_device *pdev)
13091301
}
13101302

13111303
dart->locked = apple_dart_is_locked(dart);
1312-
ret = apple_dart_hw_reset(dart);
1313-
if (ret)
1314-
goto err_clk_disable;
1304+
if (!dart->locked) {
1305+
ret = apple_dart_hw_reset(dart);
1306+
if (ret)
1307+
goto err_clk_disable;
1308+
}
13151309

13161310
ret = request_irq(dart->irq, dart->hw->irq_handler, IRQF_SHARED,
13171311
"apple-dart fault handler", dart);
@@ -1355,7 +1349,9 @@ static void apple_dart_remove(struct platform_device *pdev)
13551349
{
13561350
struct apple_dart *dart = platform_get_drvdata(pdev);
13571351

1358-
apple_dart_hw_reset(dart);
1352+
if (!dart->locked)
1353+
apple_dart_hw_reset(dart);
1354+
13591355
free_irq(dart->irq, dart);
13601356

13611357
iommu_device_unregister(&dart->iommu);
@@ -1472,6 +1468,10 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
14721468
struct apple_dart *dart = dev_get_drvdata(dev);
14731469
unsigned int sid, idx;
14741470

1471+
/* Locked DARTs can't be restored so skip saving their registers/. */
1472+
if (dart->locked)
1473+
return 0;
1474+
14751475
for (sid = 0; sid < dart->num_streams; sid++) {
14761476
dart->save_tcr[sid] = readl(dart->regs + DART_TCR(dart, sid));
14771477
for (idx = 0; idx < dart->hw->ttbr_count; idx++)
@@ -1488,6 +1488,10 @@ static __maybe_unused int apple_dart_resume(struct device *dev)
14881488
unsigned int sid, idx;
14891489
int ret;
14901490

1491+
/* Locked DARTs can't be restored, and they should not need it */
1492+
if (dart->locked)
1493+
return 0;
1494+
14911495
ret = apple_dart_hw_reset(dart);
14921496
if (ret) {
14931497
dev_err(dev, "Failed to reset DART on resume\n");

0 commit comments

Comments
 (0)