Enable clients' translation only after setting up the swgroups.

Signed-off-by: Navneet Kumar <navne...@nvidia.com>
---
 drivers/iommu/tegra-smmu.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index fa175d9..1a44cf6 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -353,6 +353,20 @@ static void tegra_smmu_enable(struct tegra_smmu *smmu, 
unsigned int swgroup,
        unsigned int i;
        u32 value;
 
+       group = tegra_smmu_find_swgroup(smmu, swgroup);
+       if (group) {
+               value = smmu_readl(smmu, group->reg);
+               value &= ~SMMU_ASID_MASK;
+               value |= SMMU_ASID_VALUE(asid);
+               value |= SMMU_ASID_ENABLE;
+               smmu_writel(smmu, value, group->reg);
+       } else {
+               pr_warn("%s group from swgroup %u not found\n", __func__,
+                               swgroup);
+               /* No point moving ahead if group was not found */
+               return;
+       }
+
        for (i = 0; i < smmu->soc->num_clients; i++) {
                const struct tegra_mc_client *client = &smmu->soc->clients[i];
 
@@ -363,15 +377,6 @@ static void tegra_smmu_enable(struct tegra_smmu *smmu, 
unsigned int swgroup,
                value |= BIT(client->smmu.bit);
                smmu_writel(smmu, value, client->smmu.reg);
        }
-
-       group = tegra_smmu_find_swgroup(smmu, swgroup);
-       if (group) {
-               value = smmu_readl(smmu, group->reg);
-               value &= ~SMMU_ASID_MASK;
-               value |= SMMU_ASID_VALUE(asid);
-               value |= SMMU_ASID_ENABLE;
-               smmu_writel(smmu, value, group->reg);
-       }
 }
 
 static void tegra_smmu_disable(struct tegra_smmu *smmu, unsigned int swgroup,
-- 
2.7.4

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to