iommu/arm-smmu: Add an optional "input-address-size" property
Subsystems (3)
cover iommu/arm-smmu: Add an optional "input-address-size" property
This series of patches add an optional DT property to allow an SoC to specify how many bits being physically connected to its SMMU instance, depending on the SoC design.
Nicolin Chen (2):
dt-bindings: arm-smmu: Add an optional "input-address-size" property iommu/arm-smmu: Read optional "input-address-size" property
Documentation/devicetree/bindings/iommu/arm,smmu.txt | 7 +++++++ drivers/iommu/arm-smmu.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 dt-bindings: arm-smmu: Add an optional "input-address-size" property
Some SMMU instances may not connect all input address lines physically but drive some upper address bits to logical zero, depending on their SoC designs. Some of them even connect only 39 bits that is not in the list of IAS/OAS from SMMU internal IDR registers.
Since this can be an SoC design decision, this patch adds an optional property to specify how many input bits being physically connected.
--- Documentation/devicetree/bindings/iommu/arm,smmu.txt | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/iommu/arm,smmu.txt +7 -0
@@ -97,6 +97,13 @@ conditions. - power-domains: Specifiers for power domains required to be powered on for the SMMU to operate, as per generic power domain bindings. +- input-address-size: Number of address bits being physically connected to an + SMMU instance, as the input virtual address width. SoC might + tie some upper address bits to logical zero inside the SMMU + wrapper, so SMMU would only support a virtual address input + size, corresponding to physically connected bits, instead of + the reading from register. + ** Deprecated properties: - mmu-masters (deprecated in favour of the generic "iommus" binding) :
Signature · 1 line
2.17.1
PATCH 2/2 iommu/arm-smmu: Read optional "input-address-size" property
In reply to Nicolin ChenSome SMMU instances may not connect all input address lines physically but drive some upper address bits to logical zero, depending on their SoC designs. Some of them even connect only 39 bits that is not in the list of IAS/OAS from SMMU internal IDR registers.
After the "input-address-size" property is added to DT bindings, this patch reads and applies to va_size as an input virtual address width.
--- drivers/iommu/arm-smmu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/iommu/arm-smmu.c +8 -2
@@ -1805,12 +1805,14 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu) "failed to set DMA mask for table walker\n");if (smmu->version <ARM_SMMU_V2 ) { - smmu->va_size = smmu->ipa_size; +if (!smmu->va_size) + smmu->va_size = smmu->ipa_size;if (smmu->version ==ARM_SMMU_V1_64K ) smmu->features |=ARM_SMMU_FEAT_FMT_AARCH64_64K ; }else { size =FIELD_GET (ID2_UBS , id); - smmu->va_size =arm_smmu_id_size_to_bits (size); +if (!smmu->va_size) + smmu->va_size =arm_smmu_id_size_to_bits (size);if (id &ID2_PTFS_4K ) smmu->features |=ARM_SMMU_FEAT_FMT_AARCH64_4K ;if (id &ID2_PTFS_16K )
@@ -1950,6 +1952,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,const struct arm_smmu_match_data *data;struct device *dev = &pdev->dev;bool legacy_binding; +u32 va_size;if (of_property_read_u32 (dev->of_node,"#global-interrupts" , &smmu->num_global_irqs)) {
@@ -1976,6 +1979,9 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev,if (of_dma_is_coherent (dev->of_node)) smmu->features |=ARM_SMMU_FEAT_COHERENT_WALK ; +if (!of_property_read_u32 (dev->of_node,"input-address-size" , &va_size)) + smmu->va_size = va_size; +return 0 ; }
Signature · 1 line
2.17.1
Robin Murphy
reviewerQuoted 3 lines · Nicolin Chen
This series of patches add an optional DT property to allow an SoC to specify how many bits being physically connected to its SMMU instance, depending on the SoC design.
This has come up before, and it doesn't work in general because a single SMMU instance can have many master interfaces, with potentially different sizes of address bus wired up to each. It's also a conceptually-wrong approach anyway, since this isn't a property of the SMMU; it's a property of the interconnect(s) upstream of the SMMU.
IIRC you were working on Tegra - if so, Thierry already has a plan, see this thread: https://lore.kernel.org/linux-arm-kernel/20190930133510.GA1904140@ulmo/
Robin.
Quoted 9 lines
Nicolin Chen (2):
dt-bindings: arm-smmu: Add an optional "input-address-size" property iommu/arm-smmu: Read optional "input-address-size" propertyDocumentation/devicetree/bindings/iommu/arm,smmu.txt | 7 +++++++ drivers/iommu/arm-smmu.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
Quoted 11 lines · Robin Murphy
Quoted 3 lines · Nicolin Chen
This series of patches add an optional DT property to allow an SoC to specify how many bits being physically connected to its SMMU instance, depending on the SoC design.
This has come up before, and it doesn't work in general because a single SMMU instance can have many master interfaces, with potentially different sizes of address bus wired up to each. It's also a conceptually-wrong approach anyway, since this isn't a property of the SMMU; it's a property of the interconnect(s) upstream of the SMMU.
Quoted 3 lines
IIRC you were working on Tegra - if so, Thierry already has a plan, see this thread:
https://lore.kernel.org/linux-arm-kernel/20190930133510.GA1904140@ulmo/
Thanks for the reply and link!