Skip to content

Commit b0d4c86

Browse files
mszyprowjoergroedel
authored andcommitted
iommu/exynos: Remove dead code
__sysmmu_enable/disable functions were designed to do ref-count based operations, but current code always calls them only once, so the code for checking the conditions and invalid conditions can be simply removed without any influence to the driver operation. Signed-off-by: Marek Szyprowski <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent e7689f0 commit b0d4c86

File tree

1 file changed

+17
-48
lines changed

1 file changed

+17
-48
lines changed

drivers/iommu/exynos-iommu.c

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,6 @@ static bool __sysmmu_disable(struct sysmmu_drvdata *data)
491491
__sysmmu_disable_nocount(data);
492492

493493
dev_dbg(data->sysmmu, "Disabled\n");
494-
} else {
495-
dev_dbg(data->sysmmu, "%d times left to disable\n",
496-
data->activations);
497494
}
498495

499496
spin_unlock_irqrestore(&data->lock, flags);
@@ -541,29 +538,18 @@ static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data)
541538
static int __sysmmu_enable(struct sysmmu_drvdata *data, phys_addr_t pgtable,
542539
struct exynos_iommu_domain *domain)
543540
{
544-
int ret = 0;
545541
unsigned long flags;
546542

547543
spin_lock_irqsave(&data->lock, flags);
548544
if (set_sysmmu_active(data)) {
549545
data->pgtable = pgtable;
550546
data->domain = domain;
551-
552547
__sysmmu_enable_nocount(data);
553-
554548
dev_dbg(data->sysmmu, "Enabled\n");
555-
} else {
556-
ret = (pgtable == data->pgtable) ? 1 : -EBUSY;
557-
558-
dev_dbg(data->sysmmu, "already enabled\n");
559549
}
560-
561-
if (WARN_ON(ret < 0))
562-
set_sysmmu_inactive(data); /* decrement count */
563-
564550
spin_unlock_irqrestore(&data->lock, flags);
565551

566-
return ret;
552+
return 0;
567553
}
568554

569555
static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
@@ -831,8 +817,8 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
831817
spin_lock_irqsave(&domain->lock, flags);
832818

833819
list_for_each_entry_safe(data, next, &domain->clients, domain_node) {
834-
if (__sysmmu_disable(data))
835-
data->master = NULL;
820+
__sysmmu_disable(data);
821+
data->master = NULL;
836822
list_del_init(&data->domain_node);
837823
}
838824

@@ -867,31 +853,23 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain,
867853
phys_addr_t pagetable = virt_to_phys(domain->pgtable);
868854
struct sysmmu_drvdata *data, *next;
869855
unsigned long flags;
870-
bool found = false;
871856

872857
if (!has_sysmmu(dev) || owner->domain != iommu_domain)
873858
return;
874859

875860
spin_lock_irqsave(&domain->lock, flags);
876861
list_for_each_entry_safe(data, next, &domain->clients, domain_node) {
877-
if (data->master == dev) {
878-
if (__sysmmu_disable(data)) {
879-
data->master = NULL;
880-
list_del_init(&data->domain_node);
881-
}
882-
pm_runtime_put(data->sysmmu);
883-
found = true;
884-
}
862+
__sysmmu_disable(data);
863+
data->master = NULL;
864+
list_del_init(&data->domain_node);
865+
pm_runtime_put(data->sysmmu);
885866
}
886867
spin_unlock_irqrestore(&domain->lock, flags);
887868

888869
owner->domain = NULL;
889870

890-
if (found)
891-
dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n",
892-
__func__, &pagetable);
893-
else
894-
dev_err(dev, "%s: No IOMMU is attached\n", __func__);
871+
dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n", __func__,
872+
&pagetable);
895873
}
896874

897875
static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
@@ -902,7 +880,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
902880
struct sysmmu_drvdata *data;
903881
phys_addr_t pagetable = virt_to_phys(domain->pgtable);
904882
unsigned long flags;
905-
int ret = -ENODEV;
906883

907884
if (!has_sysmmu(dev))
908885
return -ENODEV;
@@ -912,27 +889,19 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
912889

913890
list_for_each_entry(data, &owner->controllers, owner_node) {
914891
pm_runtime_get_sync(data->sysmmu);
915-
ret = __sysmmu_enable(data, pagetable, domain);
916-
if (ret >= 0) {
917-
data->master = dev;
892+
__sysmmu_enable(data, pagetable, domain);
893+
data->master = dev;
918894

919-
spin_lock_irqsave(&domain->lock, flags);
920-
list_add_tail(&data->domain_node, &domain->clients);
921-
spin_unlock_irqrestore(&domain->lock, flags);
922-
}
923-
}
924-
925-
if (ret < 0) {
926-
dev_err(dev, "%s: Failed to attach IOMMU with pgtable %pa\n",
927-
__func__, &pagetable);
928-
return ret;
895+
spin_lock_irqsave(&domain->lock, flags);
896+
list_add_tail(&data->domain_node, &domain->clients);
897+
spin_unlock_irqrestore(&domain->lock, flags);
929898
}
930899

931900
owner->domain = iommu_domain;
932-
dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa %s\n",
933-
__func__, &pagetable, (ret == 0) ? "" : ", again");
901+
dev_dbg(dev, "%s: Attached IOMMU with pgtable %pa\n", __func__,
902+
&pagetable);
934903

935-
return ret;
904+
return 0;
936905
}
937906

938907
static sysmmu_pte_t *alloc_lv2entry(struct exynos_iommu_domain *domain,

0 commit comments

Comments
 (0)