iommu/arm-smmu: Pass io-pgtable config to implementation specific function
authorJordan Crouse <jcrouse@codeaurora.org>
Sat, 5 Sep 2020 20:04:18 +0000 (13:04 -0700)
committerWill Deacon <will@kernel.org>
Mon, 21 Sep 2020 21:14:05 +0000 (22:14 +0100)
Construct the io-pgtable config before calling the implementation specific
init_context function and pass it so the implementation specific function
can get a chance to change it before the io-pgtable is created.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu/arm-smmu-impl.c
drivers/iommu/arm/arm-smmu/arm-smmu.c
drivers/iommu/arm/arm-smmu/arm-smmu.h

index f4ff124..a9861dc 100644 (file)
@@ -68,7 +68,8 @@ static int cavium_cfg_probe(struct arm_smmu_device *smmu)
        return 0;
 }
 
-static int cavium_init_context(struct arm_smmu_domain *smmu_domain)
+static int cavium_init_context(struct arm_smmu_domain *smmu_domain,
+               struct io_pgtable_cfg *pgtbl_cfg)
 {
        struct cavium_smmu *cs = container_of(smmu_domain->smmu,
                                              struct cavium_smmu, smmu);
index 09c42af..37d8d49 100644 (file)
@@ -795,11 +795,6 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
                cfg->asid = cfg->cbndx;
 
        smmu_domain->smmu = smmu;
-       if (smmu->impl && smmu->impl->init_context) {
-               ret = smmu->impl->init_context(smmu_domain);
-               if (ret)
-                       goto out_unlock;
-       }
 
        pgtbl_cfg = (struct io_pgtable_cfg) {
                .pgsize_bitmap  = smmu->pgsize_bitmap,
@@ -810,6 +805,12 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
                .iommu_dev      = smmu->dev,
        };
 
+       if (smmu->impl && smmu->impl->init_context) {
+               ret = smmu->impl->init_context(smmu_domain, &pgtbl_cfg);
+               if (ret)
+                       goto out_clear_smmu;
+       }
+
        if (smmu_domain->non_strict)
                pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT;
 
index d890a4a..8329451 100644 (file)
@@ -386,7 +386,8 @@ struct arm_smmu_impl {
                            u64 val);
        int (*cfg_probe)(struct arm_smmu_device *smmu);
        int (*reset)(struct arm_smmu_device *smmu);
-       int (*init_context)(struct arm_smmu_domain *smmu_domain);
+       int (*init_context)(struct arm_smmu_domain *smmu_domain,
+                       struct io_pgtable_cfg *cfg);
        void (*tlb_sync)(struct arm_smmu_device *smmu, int page, int sync,
                         int status);
        int (*def_domain_type)(struct device *dev);