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 <quic_cgoldswo@quicinc.com>
This commit is contained in:
Chris Goldsworthy 2022-07-06 09:54:36 -07:00
parent 8e1b2c93b4
commit 5d6700f5d6
2 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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;