From 5d6700f5d6420d048184e823c11ccdd875d4bdbf Mon Sep 17 00:00:00 2001 From: Chris Goldsworthy Date: Wed, 6 Jul 2022 09:54:36 -0700 Subject: [PATCH] arm-smmu: Add the IGNORE_NUMPAGENDXB option We sometimes might want to ignore the SMMU global address space size being reported to us in SMMU_IDR1.NUMPAGENDXB, and assume instead that the TCU address space size we report in our device tree is equal twice the size of the global address space (such that the context bank address space and global address space are equal in size, with the context bank address space taking the upper half). Using this assumption, we can then use the DT-provided size (in the "reg =" property) to determine the layout of the global and context bank address spaces. Define ARM_SMMU_OPT_IGNORE_NUMPAGENDXB to allow users to allow this override to occur. Move the parse_driver_options() call earlier into the probe process since we need to read the options earlier now. Change-Id: I775cd40e1308da89b5d5e4b11f963f783ce172ab Signed-off-by: Chris Goldsworthy --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 9 +++++++-- drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 1b3a6cc641d9..aae095a60709 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -96,6 +96,7 @@ static struct arm_smmu_option_prop arm_smmu_options[] = { { ARM_SMMU_OPT_NO_ASID_RETENTION, "qcom,no-asid-retention" }, { ARM_SMMU_OPT_DISABLE_ATOS, "qcom,disable-atos" }, { ARM_SMMU_OPT_CONTEXT_FAULT_RETRY, "qcom,context-fault-retry" }, + { ARM_SMMU_OPT_IGNORE_NUMPAGENDXB, "qcom,ignore-numpagendxb" }, { 0, NULL}, }; @@ -3148,7 +3149,10 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) "SMMU address space size (0x%x) differs from mapped region size (0x%x)!\n", 2 * size << smmu->pgshift, smmu->numpage); /* Now properly encode NUMPAGE to subsequently derive SMMU_CB_BASE */ - smmu->numpage = size; + if (!(smmu->options & ARM_SMMU_OPT_IGNORE_NUMPAGENDXB)) + smmu->numpage = size; + else + smmu->numpage = (smmu->numpage / 2) >> smmu->pgshift; smmu->num_s2_context_banks = FIELD_GET(ARM_SMMU_ID1_NUMS2CB, id); smmu->num_context_banks = FIELD_GET(ARM_SMMU_ID1_NUMCB, id); @@ -3365,6 +3369,8 @@ static int arm_smmu_device_dt_probe(struct arm_smmu_device *smmu, if (of_dma_is_coherent(dev->of_node)) smmu->features |= ARM_SMMU_FEAT_COHERENT_WALK; + parse_driver_options(smmu); + return 0; } @@ -3537,7 +3543,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) /* QCOM Additions */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); smmu->phys_addr = res->start; - parse_driver_options(smmu); err = arm_smmu_handoff_cbs(smmu); if (err) goto out_power_off; diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h index 0786a4879b95..44ea32c912fd 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h @@ -381,6 +381,7 @@ struct arm_smmu_device { #define ARM_SMMU_OPT_NO_ASID_RETENTION (1 << 3) #define ARM_SMMU_OPT_DISABLE_ATOS (1 << 4) #define ARM_SMMU_OPT_CONTEXT_FAULT_RETRY (1 << 5) +#define ARM_SMMU_OPT_IGNORE_NUMPAGENDXB (1 << 6) u32 options; enum arm_smmu_arch_version version; enum arm_smmu_implementation model;