Skip to contentSkip to conversation

iommu/ipmmu-vmsa: r8a7796 support V4

PATCH In review Magnus Damm 2 participants 6 messages Jun 19, 2017 – Sep 12, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover iommu/ipmmu-vmsa: r8a7796 support V4

iommu/ipmmu-vmsa: r8a7796 support V4

[PATCH v4 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding [PATCH v4 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48 [PATCH v4 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

This series adds r8a7796 support to the IPMMU driver. The DT binding gets updated, maximum number of micro-TLBs are increased and the driver is adjusted to match on the new DT binding.

Changes since V3:
- Rebased on top of [PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795 support V4
- Patch 3/3 updated with Reviewed-by - thanks Geert!

Changes since V2:
- Patch 2/3 updated with an outer set of () - thanks Ramesh!
- Patch 2/3 updated with Reviewed-by - thanks Geert!
- Patch 3/3 updated to include white list support

Changes since V1:
- Patch 1/3 updated with more Acked-by tags
- Patch 2/3 updated with high I/O register range support

Patch 1/3 is ready for upstream merge and includes the following tags:

Patch 2/3 and 3/3 are quite trivial but have no acked-by so far.

---

Developed on top of next-20170614 with the following series applied [PATCH 00/04] iommu/ipmmu-vmsa: 32-bit ARM update
[PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795 support V4

 Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt |    1 
 drivers/iommu/ipmmu-vmsa.c                                     |   24 +++++++---
 2 files changed, 18 insertions(+), 7 deletions(-)
#1 lore raw

PATCH v4 1/3 iommu/ipmmu-vmsa: Add r8a7796 DT binding

From: Magnus Damm <[email protected]>

Update the IPMMU DT binding documentation to include the r8a7796 compat string for R-Car M3-W.

---

Changes since V3:
- None

Changes since V2:
- None

Changes since V1:
- Included in series, added Acked-by from Geert - thanks!

 Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt |    1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt +1 -0
@@ -16,6 +16,7 @@ Required Properties:
     - "renesas,ipmmu-r8a7793" for the R8A7793 (R-Car M2-N) IPMMU.
     - "renesas,ipmmu-r8a7794" for the R8A7794 (R-Car E2) IPMMU.
     - "renesas,ipmmu-r8a7795" for the R8A7795 (R-Car H3) IPMMU.
+    - "renesas,ipmmu-r8a7796" for the R8A7796 (R-Car M3-W) IPMMU.
     - "renesas,ipmmu-vmsa" for generic R-Car Gen2 VMSA-compatible IPMMU.
 
   - reg: Base address and size of the IPMMU registers.
#2 lore raw

PATCH v4 2/3 iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Bump up the maximum numbers of micro-TLBS to 48.

Each IPMMU device instance get micro-TLB assignment via the "iommus" property in DT. Older SoCs tend to use a maximum number of 32 micro-TLBs per IPMMU instance however newer SoCs such as r8a7796 make use of up to 48 micro-TLBs.

At this point no SoC specific handling is done to validate the maximum number of micro-TLBs, and because of that the DT information is assumed to be within correct range for each particular SoC.

If needed in the future SoC specific feature flags can be added to handle the maximum number of micro-TLBs without requiring DT changes, however at this point this does not seem necessary.

---

Changes since V3:
- None

Changes since V2:
- Added outer set of () to IMUASID() and IMUCTR() - thanks Ramesh!
- Added Reviewed-by from Geert - thanks!

Changes since V1:
- Added support for the second I/O range at 0x600.

 drivers/iommu/ipmmu-vmsa.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/iommu/ipmmu-vmsa.c +7 -3
@@ -199,7 +199,9 @@ static struct ipmmu_vmsa_iommu_priv *to_
 #define IMPMBA(n)			(0x0280 + ((n) * 4))
 #define IMPMBD(n)			(0x02c0 + ((n) * 4))
 
-#define IMUCTR(n)			(0x0300 + ((n) * 16))
+#define IMUCTR(n)			((n) < 32 ? IMUCTR0(n) : IMUCTR32(n))
+#define IMUCTR0(n)			(0x0300 + ((n) * 16))
+#define IMUCTR32(n)			(0x0600 + (((n) - 32) * 16))
 #define IMUCTR_FIXADDEN			(1 << 31)
 #define IMUCTR_FIXADD_MASK		(0xff << 16)
 #define IMUCTR_FIXADD_SHIFT		16
@@ -209,7 +211,9 @@ static struct ipmmu_vmsa_iommu_priv *to_
 #define IMUCTR_FLUSH			(1 << 1)
 #define IMUCTR_MMUEN			(1 << 0)
 
-#define IMUASID(n)			(0x0308 + ((n) * 16))
+#define IMUASID(n)			((n) < 32 ? IMUASID0(n) : IMUASID32(n))
+#define IMUASID0(n)			(0x0308 + ((n) * 16))
+#define IMUASID32(n)			(0x0608 + (((n) - 32) * 16))
 #define IMUASID_ASID8_MASK		(0xff << 8)
 #define IMUASID_ASID8_SHIFT		8
 #define IMUASID_ASID0_MASK		(0xff << 0)
@@ -1066,7 +1070,7 @@ static int ipmmu_probe(struct platform_d
 	}
 
 	mmu->dev = &pdev->dev;
-	mmu->num_utlbs = 32;
+	mmu->num_utlbs = 48;
 	spin_lock_init(&mmu->lock);
 	bitmap_zero(mmu->ctx, IPMMU_CTX_MAX);
 	mmu->features = of_device_get_match_data(&pdev->dev);
#3 lore raw

PATCH v4 3/3 iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Support the r8a7796 IPMMU by sharing feature flags between r8a7795 and r8a7796. Also update IOMMU_OF_DECLARE to hook up the updated compat string.

---

Changes since V3:
- Added Reviewed-by from Geert - thanks!

Changes since V2:
- Updated to include white list suppport

Changes since V1:
- None

 drivers/iommu/ipmmu-vmsa.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/iommu/ipmmu-vmsa.c +10 -4
@@ -755,8 +755,9 @@ static bool ipmmu_slave_whitelist(struct
 	return false;
 }
 
-static const struct soc_device_attribute soc_r8a7795[] = {
+static const struct soc_device_attribute soc_rcar_gen3[] = {
 	{ .soc_id = "r8a7795", },
+	{ .soc_id = "r8a7796", },
 	{ /* sentinel */ }
 };
 
@@ -772,7 +773,7 @@ static int ipmmu_of_xlate(struct device
 	}
 
 	/* For R-Car Gen3 use a white list to opt-in slave devices */
-	if (soc_device_match(soc_r8a7795) && !ipmmu_slave_whitelist(dev))
+	if (soc_device_match(soc_rcar_gen3) && !ipmmu_slave_whitelist(dev))
 		return -ENODEV;
 
 	iommu_fwspec_add_ids(dev, spec->args, 1);
@@ -1034,7 +1035,7 @@ static const struct ipmmu_features ipmmu
 	.twobit_imttbcr_sl0 = false,
 };
 
-static const struct ipmmu_features ipmmu_features_r8a7795 = {
+static const struct ipmmu_features ipmmu_features_rcar_gen3 = {
 	.use_ns_alias_offset = false,
 	.has_cache_leaf_nodes = true,
 	.number_of_contexts = 8,
@@ -1048,7 +1049,10 @@ static const struct of_device_id ipmmu_o
 		.data = &ipmmu_features_default,
 	}, {
 		.compatible = "renesas,ipmmu-r8a7795",
-		.data = &ipmmu_features_r8a7795,
+		.data = &ipmmu_features_rcar_gen3,
+	}, {
+		.compatible = "renesas,ipmmu-r8a7796",
+		.data = &ipmmu_features_rcar_gen3,
 	}, {
 		/* Terminator */
 	},
@@ -1229,6 +1233,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "r
 		 ipmmu_vmsa_iommu_of_setup);
 IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795",
 		 ipmmu_vmsa_iommu_of_setup);
+IOMMU_OF_DECLARE(ipmmu_r8a7796_iommu_of, "renesas,ipmmu-r8a7796",
+		 ipmmu_vmsa_iommu_of_setup);
 #endif
 
 MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
#4 lore raw
In reply to Magnus Damm

Hi, Magnus, maintainers, all.

Quoted 9 lines · Magnus Damm

iommu/ipmmu-vmsa: r8a7796 support V4

[PATCH v4 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding [PATCH v4 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48 [PATCH v4 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

This series adds r8a7796 support to the IPMMU driver. The DT binding gets updated, maximum number of micro-TLBs are increased and the driver is adjusted to match on the new DT binding.

I am interested in adding IPMMU-VMSA support to Xen hypervisor.

I did some preparations for making IPMMU-VMSA to feel comfortable [1] inside Xen followed by direct porting Linux IPMMU-VMSA driver and ARM LPAE page-table allocator [2] to it.

I decided to base on the "BSP" driver [3] because it had more complete support than the "mainline" one [4].

During review I got a feedback that "BSP" driver wasn't the best choice to be ported.
Xen ARM maintainers worry about "BSP" driver which haven't had a thorough review by the Linux community and as the result might have bugs which will never be fixed, etc.

So, for the IPMMU-VMSA support to be accepted by Xen community I should either write our own driver based on BSP/mainline/whatever which contains only relevant to Xen things or direct port from "mainline" driver. As the second option relies on the required support [5] which isn't in mainline yet, it is not clear when this support gets merged and how it will be modified/reworked before, we preliminarily decided to follow the first option. But, I would like to consider second option again. Despite the complexity of second option, it has one significant benefit.

I see that Linux driver is being developed quite actively and looking over all related patch series I got a feeling that required support was about to reach upstream.

Could you, please, clarify some questions which, I hope, help us to make a decision:
1. Do you have approximate time-frame for getting this support in?
2. Are fundamental/significant changes planned for this support?

Also, may I ask for a link to github branch which contains current (and likely r8a7795 and 32-bit ARM update) patch series?

Thank you in advance!

And sorry for the most likely incorrect format of this email.

[1] https://www.mail-archive.com/[email protected]/msg115901.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-07/msg02679.html
[3] https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/tree/drivers/iommu/ipmmu-vmsa.c?h=v4.9/rcar-3.5.3
[4] http://elixir.free-electrons.com/linux/latest/source/drivers/iommu/ipmmu-vmsa.c
[5] https://lists.linuxfoundation.org/pipermail/iommu/2017-June/022567.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-June/022577.html

    https://lkml.org/lkml/2017/7/17/393
Quoted 33 lines

Changes since V3:
- Rebased on top of [PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795 support V4
- Patch 3/3 updated with Reviewed-by - thanks Geert!

Changes since V2:
- Patch 2/3 updated with an outer set of () - thanks Ramesh!
- Patch 2/3 updated with Reviewed-by - thanks Geert!
- Patch 3/3 updated to include white list support

Changes since V1:
- Patch 1/3 updated with more Acked-by tags
- Patch 2/3 updated with high I/O register range support

Patch 1/3 is ready for upstream merge and includes the following tags:

Patch 2/3 and 3/3 are quite trivial but have no acked-by so far.

---

Developed on top of next-20170614 with the following series applied [PATCH 00/04] iommu/ipmmu-vmsa: 32-bit ARM update
[PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795 support V4

  Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt |    1
  drivers/iommu/ipmmu-vmsa.c                                     |   24 +++++++---
  2 files changed, 18 insertions(+), 7 deletions(-)
#5 lore raw

Hi, all.

Gentle reminder.

Quoted 81 lines · Oleksandr

Hi, Magnus, maintainers, all.

Quoted 9 lines · Magnus Damm

iommu/ipmmu-vmsa: r8a7796 support V4

[PATCH v4 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding [PATCH v4 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48 [PATCH v4 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

This series adds r8a7796 support to the IPMMU driver. The DT binding gets updated, maximum number of micro-TLBs are increased and the driver is adjusted to match on the new DT binding.

I am interested in adding IPMMU-VMSA support to Xen hypervisor.

I did some preparations for making IPMMU-VMSA to feel comfortable [1] inside Xen followed by direct porting Linux IPMMU-VMSA driver and ARM LPAE page-table allocator [2] to it.

I decided to base on the "BSP" driver [3] because it had more complete support than the "mainline" one [4].

During review I got a feedback that "BSP" driver wasn't the best choice to be ported.
Xen ARM maintainers worry about "BSP" driver which haven't had a thorough review by the Linux community and as the result might have bugs which will never be fixed, etc.

So, for the IPMMU-VMSA support to be accepted by Xen community I should either write our own driver based on BSP/mainline/whatever which contains only relevant to Xen things or direct port from "mainline" driver. As the second option relies on the required support [5] which isn't in mainline yet, it is not clear when this support gets merged and how it will be modified/reworked before, we preliminarily decided to follow the first option. But, I would like to consider second option again. Despite the complexity of second option, it has one significant benefit.

I see that Linux driver is being developed quite actively and looking over all related patch series I got a feeling that required support was about to reach upstream.

Could you, please, clarify some questions which, I hope, help us to make a decision:
1. Do you have approximate time-frame for getting this support in?
2. Are fundamental/significant changes planned for this support?

Also, may I ask for a link to github branch which contains current (and likely r8a7795 and 32-bit ARM update) patch series?

Thank you in advance!

And sorry for the most likely incorrect format of this email.

[1] https://www.mail-archive.com/[email protected]/msg115901.html
[2] https://lists.xen.org/archives/html/xen-devel/2017-07/msg02679.html
[3] https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas-bsp.git/tree/drivers/iommu/ipmmu-vmsa.c?h=v4.9/rcar-3.5.3
[4] http://elixir.free-electrons.com/linux/latest/source/drivers/iommu/ipmmu-vmsa.c
[5] https://lists.linuxfoundation.org/pipermail/iommu/2017-June/022567.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-June/022577.html

    https://lkml.org/lkml/2017/7/17/393
Quoted 34 lines

Changes since V3:
- Rebased on top of [PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795
support V4
- Patch 3/3 updated with Reviewed-by - thanks Geert!

Changes since V2:
- Patch 2/3 updated with an outer set of () - thanks Ramesh!
- Patch 2/3 updated with Reviewed-by - thanks Geert!
- Patch 3/3 updated to include white list support

Changes since V1:
- Patch 1/3 updated with more Acked-by tags
- Patch 2/3 updated with high I/O register range support

Patch 1/3 is ready for upstream merge and includes the following tags:

Patch 2/3 and 3/3 are quite trivial but have no acked-by so far.

---

Developed on top of next-20170614 with the following series applied [PATCH 00/04] iommu/ipmmu-vmsa: 32-bit ARM update
[PATCH v4 00/09] iommu/ipmmu-vmsa: r8a7795 support V4

  Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt |    1
  drivers/iommu/ipmmu-vmsa.c |   24 +++++++---
  2 files changed, 18 insertions(+), 7 deletions(-)