]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/arm-smmu-v3: Introduce strtab init helper
authorShameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Wed, 15 Jun 2022 10:10:41 +0000 (11:10 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 6 Jul 2022 10:51:11 +0000 (12:51 +0200)
Introduce a helper to check the sid range and to init the l2 strtab
entries(bypass). This will be useful when we have to initialize the
l2 strtab with bypass for RMR SIDs.

Tested-by: Hanjun Guo <guohanjun@huawei.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20220615101044.1972-7-shameerali.kolothum.thodi@huawei.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

index 88817a3376ef01a92f217639dea8351ff6fb140b..17d4f3432df2ae3dd5ffcdaae207b4534fcdfb14 100644 (file)
@@ -2537,6 +2537,19 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid)
        return sid < limit;
 }
 
+static int arm_smmu_init_sid_strtab(struct arm_smmu_device *smmu, u32 sid)
+{
+       /* Check the SIDs are in range of the SMMU and our stream table */
+       if (!arm_smmu_sid_in_range(smmu, sid))
+               return -ERANGE;
+
+       /* Ensure l2 strtab is initialised */
+       if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB)
+               return arm_smmu_init_l2_strtab(smmu, sid);
+
+       return 0;
+}
+
 static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
                                  struct arm_smmu_master *master)
 {
@@ -2560,20 +2573,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu,
                new_stream->id = sid;
                new_stream->master = master;
 
-               /*
-                * Check the SIDs are in range of the SMMU and our stream table
-                */
-               if (!arm_smmu_sid_in_range(smmu, sid)) {
-                       ret = -ERANGE;
+               ret = arm_smmu_init_sid_strtab(smmu, sid);
+               if (ret)
                        break;
-               }
-
-               /* Ensure l2 strtab is initialised */
-               if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) {
-                       ret = arm_smmu_init_l2_strtab(smmu, sid);
-                       if (ret)
-                               break;
-               }
 
                /* Insert into SID tree */
                new_node = &(smmu->streams.rb_node);