Skip to content

Commit 92798b4

Browse files
mszyprowjoergroedel
authored andcommitted
iommu/exynos: Set master device once on boot
To avoid possible races, set master device pointer in each SYSMMU controller once on boot. Suspend/resume callbacks now properly relies on the configured iommu domain to enable or disable SYSMMU controller. While changing the code, also update the sleep debug messages and make them conditional. Signed-off-by: Marek Szyprowski <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 47a574f commit 92798b4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/iommu/exynos-iommu.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,12 @@ static int exynos_sysmmu_suspend(struct device *dev)
638638
struct sysmmu_drvdata *data = dev_get_drvdata(dev);
639639
struct device *master = data->master;
640640

641-
dev_dbg(dev, "suspend\n");
642641
if (master) {
643-
__sysmmu_disable(data);
644642
pm_runtime_put(dev);
643+
if (data->domain) {
644+
dev_dbg(data->sysmmu, "saving state\n");
645+
__sysmmu_disable(data);
646+
}
645647
}
646648
return 0;
647649
}
@@ -651,10 +653,12 @@ static int exynos_sysmmu_resume(struct device *dev)
651653
struct sysmmu_drvdata *data = dev_get_drvdata(dev);
652654
struct device *master = data->master;
653655

654-
dev_dbg(dev, "resume\n");
655656
if (master) {
656657
pm_runtime_get_sync(dev);
657-
__sysmmu_enable(data);
658+
if (data->domain) {
659+
dev_dbg(data->sysmmu, "restoring state\n");
660+
__sysmmu_enable(data);
661+
}
658662
}
659663
return 0;
660664
}
@@ -768,7 +772,6 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
768772
__sysmmu_disable(data);
769773
data->pgtable = 0;
770774
data->domain = NULL;
771-
data->master = NULL;
772775
list_del_init(&data->domain_node);
773776
}
774777

@@ -810,7 +813,6 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain,
810813
spin_lock_irqsave(&domain->lock, flags);
811814
list_for_each_entry_safe(data, next, &domain->clients, domain_node) {
812815
__sysmmu_disable(data);
813-
data->master = NULL;
814816
data->pgtable = 0;
815817
data->domain = NULL;
816818
list_del_init(&data->domain_node);
@@ -844,7 +846,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
844846
data->domain = domain;
845847
pm_runtime_get_sync(data->sysmmu);
846848
__sysmmu_enable(data);
847-
data->master = dev;
848849

849850
spin_lock_irqsave(&domain->lock, flags);
850851
list_add_tail(&data->domain_node, &domain->clients);
@@ -1231,6 +1232,7 @@ static int exynos_iommu_of_xlate(struct device *dev,
12311232
}
12321233

12331234
list_add_tail(&data->owner_node, &owner->controllers);
1235+
data->master = dev;
12341236
return 0;
12351237
}
12361238

0 commit comments

Comments
 (0)