IOMMU Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property
@ 2019-10-11  3:46 Nicolin Chen
  2019-10-11  3:46 ` [PATCH 1/2] dt-bindings: arm-smmu: " Nicolin Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-10-11  3:46 UTC (permalink / raw)
  To: joro, robh+dt, mark.rutland, will, robin.murphy
  Cc: devicetree, iommu, linux-arm-kernel, linux-kernel

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(-)

-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] dt-bindings: arm-smmu: Add an optional "input-address-size" property
  2019-10-11  3:46 [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property Nicolin Chen
@ 2019-10-11  3:46 ` " Nicolin Chen
  2019-10-11  3:46 ` [PATCH 2/2] iommu/arm-smmu: Read " Nicolin Chen
  2019-10-11  9:16 ` [PATCH 0/2] iommu/arm-smmu: Add an " Robin Murphy
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-10-11  3:46 UTC (permalink / raw)
  To: joro, robh+dt, mark.rutland, will, robin.murphy
  Cc: devicetree, iommu, linux-arm-kernel, linux-kernel

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.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
 Documentation/devicetree/bindings/iommu/arm,smmu.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index 3133f3ba7567..a9373a2964a3 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -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) :
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] iommu/arm-smmu: Read optional "input-address-size" property
  2019-10-11  3:46 [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property Nicolin Chen
  2019-10-11  3:46 ` [PATCH 1/2] dt-bindings: arm-smmu: " Nicolin Chen
@ 2019-10-11  3:46 ` " Nicolin Chen
  2019-10-11  9:16 ` [PATCH 0/2] iommu/arm-smmu: Add an " Robin Murphy
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-10-11  3:46 UTC (permalink / raw)
  To: joro, robh+dt, mark.rutland, will, robin.murphy
  Cc: devicetree, iommu, linux-arm-kernel, linux-kernel

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.

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.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
 drivers/iommu/arm-smmu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index b18aac4c105e..b80a869de45b 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -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;
 }
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property
  2019-10-11  3:46 [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property Nicolin Chen
  2019-10-11  3:46 ` [PATCH 1/2] dt-bindings: arm-smmu: " Nicolin Chen
  2019-10-11  3:46 ` [PATCH 2/2] iommu/arm-smmu: Read " Nicolin Chen
@ 2019-10-11  9:16 ` " Robin Murphy
  2019-10-11 23:55   ` Nicolin Chen
  2 siblings, 1 reply; 5+ messages in thread
From: Robin Murphy @ 2019-10-11  9:16 UTC (permalink / raw)
  To: Nicolin Chen, joro, robh+dt, mark.rutland, will
  Cc: devicetree, iommu, linux-arm-kernel, linux-kernel

On 2019-10-11 4:46 am, Nicolin Chen wrote:
> 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.

> 
> 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(-)
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property
  2019-10-11  9:16 ` [PATCH 0/2] iommu/arm-smmu: Add an " Robin Murphy
@ 2019-10-11 23:55   ` Nicolin Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-10-11 23:55 UTC (permalink / raw)
  To: Robin Murphy
  Cc: mark.rutland, devicetree, iommu, linux-kernel, robh+dt, will,
	linux-arm-kernel

On Fri, Oct 11, 2019 at 10:16:28AM +0100, Robin Murphy wrote:
> On 2019-10-11 4:46 am, Nicolin Chen wrote:
> > 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/

Thanks for the reply and link!
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11  3:46 [PATCH 0/2] iommu/arm-smmu: Add an optional "input-address-size" property Nicolin Chen
2019-10-11  3:46 ` [PATCH 1/2] dt-bindings: arm-smmu: " Nicolin Chen
2019-10-11  3:46 ` [PATCH 2/2] iommu/arm-smmu: Read " Nicolin Chen
2019-10-11  9:16 ` [PATCH 0/2] iommu/arm-smmu: Add an " Robin Murphy
2019-10-11 23:55   ` Nicolin Chen

IOMMU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iommu/0 linux-iommu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iommu linux-iommu/ https://lore.kernel.org/linux-iommu \
		iommu@lists.linux-foundation.org
	public-inbox-index linux-iommu

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linux-foundation.lists.iommu


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git