@@ -1924,6 +1924,31 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
return 0;
}
+struct iommu_domain *arm_smmu_alloc_identity_domain(struct arm_smmu_device *smmu)
+{
+ struct iommu_domain *identity;
+ int ret;
+
+ /* Create a IDENTITY domain to use for all inherited streams */
+ identity = arm_smmu_domain_alloc(IOMMU_DOMAIN_IDENTITY);
+ if (!identity) {
+ dev_err(smmu->dev, "failed to create identity domain\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ identity->pgsize_bitmap = smmu->pgsize_bitmap;
+ identity->type = IOMMU_DOMAIN_IDENTITY;
+ identity->ops = &arm_smmu_ops;
+
+ ret = arm_smmu_init_domain_context(identity, smmu, NULL);
+ if (ret < 0) {
+ dev_err(smmu->dev, "failed to initialize identity domain: %d\n", ret);
+ return ERR_PTR(ret);
+ }
+
+ return identity;
+}
+
struct arm_smmu_match_data {
enum arm_smmu_arch_version version;
enum arm_smmu_implementation model;
@@ -537,4 +537,6 @@ struct arm_smmu_device *qcom_adreno_smmu_impl_init(struct arm_smmu_device *smmu)
void arm_smmu_write_context_bank(struct arm_smmu_device *smmu, int idx);
int arm_mmu500_reset(struct arm_smmu_device *smmu);
+struct iommu_domain *arm_smmu_alloc_identity_domain(struct arm_smmu_device *smmu);
+
#endif /* _ARM_SMMU_H */
Some platform implementations needs to be able to allocate a domain for emulating identity mappings using a context bank without translation. Provide a helper function to allocate such a domain. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- Changes since v2: - Extracted from previous arm_smmu_setup_identity() implementation drivers/iommu/arm/arm-smmu/arm-smmu.c | 25 +++++++++++++++++++++++++ drivers/iommu/arm/arm-smmu/arm-smmu.h | 2 ++ 2 files changed, 27 insertions(+) -- 2.28.0