All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFT v5 0/3] iommu/ipmmu-vmsa: r8a779(6|70|95) support
@ 2017-11-14  8:34 Simon Horman
       [not found] ` <20171114083451.4052-1-horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Simon Horman @ 2017-11-14  8:34 UTC (permalink / raw
  To: Alex Williamson, Joerg Roedel
  Cc: Magnus Damm, iommu, linux-renesas-soc, Simon Horman

This series adds r8a7796 (R-Car M3-W), r8a77970 (R-Car V3M) and
r8a77995 (R-Car D3) support to the IPMMU driver.

The maximum number of micro-TLBs are increased and the driver is adjusted
to match on the new DT bindings posted separately.

Changes since V4:
 - Marked as RFC as I believe more consideration of driver support
   for these SoCs is required
 - Moved DT bindings documentation into separate patch-set
   "[PATCH 0/2] iommu/ipmmu-vmsa: Add r8a779(6|70|95) DT bindings"
   as I believe these are ready to be merged
 - Rebased
 - Collected driver updates for r8a7796, and r8a77970 and r8a77995 SoCs
   into a single patchset.

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

Magnus Damm (2):
  iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
  iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

Simon Horman (1):
  iommu/ipmmu-vmsa: Hook up r8a779(70|95) DT matching code

 drivers/iommu/ipmmu-vmsa.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

-- 
2.11.0

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

* [PATCH/RFT v5 1/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
  2017-11-14  8:34 [PATCH/RFT v5 0/3] iommu/ipmmu-vmsa: r8a779(6|70|95) support Simon Horman
@ 2017-11-14  8:34     ` Simon Horman
  2017-11-14  8:34 ` [PATCH/RFT v5 2/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code Simon Horman
  2017-11-14  8:34 ` [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) " Simon Horman
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2017-11-14  8:34 UTC (permalink / raw
  To: Alex Williamson, Joerg Roedel
  Cc: linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA, Magnus Damm,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Magnus Damm

From: Magnus Damm <damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>

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.

Signed-off-by: Magnus Damm <damm+renesas-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
 drivers/iommu/ipmmu-vmsa.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 8dce3a9de9d8..286af358d8ce 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -194,7 +194,9 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
 #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
@@ -204,7 +206,9 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
 #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)
@@ -955,7 +959,7 @@ static int ipmmu_probe(struct platform_device *pdev)
 	}
 
 	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);
-- 
2.11.0

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

* [PATCH/RFT v5 1/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
@ 2017-11-14  8:34     ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2017-11-14  8:34 UTC (permalink / raw
  To: Alex Williamson, Joerg Roedel
  Cc: Magnus Damm, iommu, linux-renesas-soc, Magnus Damm

From: Magnus Damm <damm+renesas@opensource.se>

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.

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/iommu/ipmmu-vmsa.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 8dce3a9de9d8..286af358d8ce 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -194,7 +194,9 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
 #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
@@ -204,7 +206,9 @@ static struct ipmmu_vmsa_device *to_ipmmu(struct device *dev)
 #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)
@@ -955,7 +959,7 @@ static int ipmmu_probe(struct platform_device *pdev)
 	}
 
 	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);
-- 
2.11.0

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

* [PATCH/RFT v5 2/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code
  2017-11-14  8:34 [PATCH/RFT v5 0/3] iommu/ipmmu-vmsa: r8a779(6|70|95) support Simon Horman
       [not found] ` <20171114083451.4052-1-horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
@ 2017-11-14  8:34 ` Simon Horman
  2017-11-14  8:34 ` [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) " Simon Horman
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2017-11-14  8:34 UTC (permalink / raw
  To: Alex Williamson, Joerg Roedel
  Cc: Magnus Damm, iommu, linux-renesas-soc, Magnus Damm

From: Magnus Damm <damm+renesas@opensource.se>

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

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/iommu/ipmmu-vmsa.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 286af358d8ce..f936f834984a 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -760,8 +760,9 @@ static bool ipmmu_slave_whitelist(struct device *dev)
 	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 */ }
 };
 
@@ -769,7 +770,7 @@ static int ipmmu_of_xlate(struct device *dev,
 			  struct of_phandle_args *spec)
 {
 	/* 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);
@@ -923,7 +924,7 @@ static const struct ipmmu_features ipmmu_features_default = {
 	.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,
@@ -937,7 +938,10 @@ static const struct of_device_id ipmmu_of_ids[] = {
 		.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 */
 	},
@@ -1123,6 +1127,8 @@ IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa",
 		 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");
-- 
2.11.0

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

* [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) DT matching code
  2017-11-14  8:34 [PATCH/RFT v5 0/3] iommu/ipmmu-vmsa: r8a779(6|70|95) support Simon Horman
       [not found] ` <20171114083451.4052-1-horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
  2017-11-14  8:34 ` [PATCH/RFT v5 2/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code Simon Horman
@ 2017-11-14  8:34 ` Simon Horman
  2017-11-15 14:19   ` Geert Uytterhoeven
  2 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2017-11-14  8:34 UTC (permalink / raw
  To: Alex Williamson, Joerg Roedel
  Cc: Magnus Damm, iommu, linux-renesas-soc, Simon Horman

Support the r8a77970 (R-Car V3M) and r8a77995 (R-Car D3) IPMMUs by sharing
feature flags with r8a7795 (R-Car H3) and r8a7796 (R-Car M3-W). Also update
IOMMU_OF_DECLARE to hook up the compat strings.

Based on work for the r8a7796 by Magnus Damm

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2
* Add reviewed-by tag from Geert Uytterhoeven
---
 drivers/iommu/ipmmu-vmsa.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index f936f834984a..49c6fc0c1ae6 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -763,6 +763,8 @@ static bool ipmmu_slave_whitelist(struct device *dev)
 static const struct soc_device_attribute soc_rcar_gen3[] = {
 	{ .soc_id = "r8a7795", },
 	{ .soc_id = "r8a7796", },
+	{ .soc_id = "r8a77970", },
+	{ .soc_id = "r8a77995", },
 	{ /* sentinel */ }
 };
 
@@ -943,6 +945,12 @@ static const struct of_device_id ipmmu_of_ids[] = {
 		.compatible = "renesas,ipmmu-r8a7796",
 		.data = &ipmmu_features_rcar_gen3,
 	}, {
+		.compatible = "renesas,ipmmu-r8a77970",
+		.data = &ipmmu_features_rcar_gen3,
+	}, {
+		.compatible = "renesas,ipmmu-r8a77995",
+		.data = &ipmmu_features_rcar_gen3,
+	}, {
 		/* Terminator */
 	},
 };
@@ -1129,6 +1137,10 @@ 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);
+IOMMU_OF_DECLARE(ipmmu_r8a77970_iommu_of, "renesas,ipmmu-r8a77970",
+		 ipmmu_vmsa_iommu_of_setup);
+IOMMU_OF_DECLARE(ipmmu_r8a77995_iommu_of, "renesas,ipmmu-r8a77995",
+		 ipmmu_vmsa_iommu_of_setup);
 #endif
 
 MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
-- 
2.11.0

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

* Re: [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) DT matching code
  2017-11-14  8:34 ` [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) " Simon Horman
@ 2017-11-15 14:19   ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-11-15 14:19 UTC (permalink / raw
  To: Simon Horman
  Cc: Alex Williamson, Joerg Roedel, Magnus Damm, iommu, Linux-Renesas

Hi Simon,

On Tue, Nov 14, 2017 at 9:34 AM, Simon Horman
<horms+renesas@verge.net.au> wrote:
> Support the r8a77970 (R-Car V3M) and r8a77995 (R-Car D3) IPMMUs by sharing
> feature flags with r8a7795 (R-Car H3) and r8a7796 (R-Car M3-W). Also update
> IOMMU_OF_DECLARE to hook up the compat strings.
>
> Based on work for the r8a7796 by Magnus Damm
>
> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> v2
> * Add reviewed-by tag from Geert Uytterhoeven
> ---
>  drivers/iommu/ipmmu-vmsa.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index f936f834984a..49c6fc0c1ae6 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -763,6 +763,8 @@ static bool ipmmu_slave_whitelist(struct device *dev)
>  static const struct soc_device_attribute soc_rcar_gen3[] = {
>         { .soc_id = "r8a7795", },
>         { .soc_id = "r8a7796", },
> +       { .soc_id = "r8a77970", },
> +       { .soc_id = "r8a77995", },

This array starts becoming a mirror of most entries in ipmmu_of_ids[].
As long as you don't need to match against a specific SoC revision, you could
store the whitelist check flag in struct ipmmu_features, as pointed to by
ipmmu_of_ids.data.

>         { /* sentinel */ }
>  };
>
> @@ -943,6 +945,12 @@ static const struct of_device_id ipmmu_of_ids[] = {
>                 .compatible = "renesas,ipmmu-r8a7796",
>                 .data = &ipmmu_features_rcar_gen3,
>         }, {
> +               .compatible = "renesas,ipmmu-r8a77970",
> +               .data = &ipmmu_features_rcar_gen3,
> +       }, {
> +               .compatible = "renesas,ipmmu-r8a77995",
> +               .data = &ipmmu_features_rcar_gen3,
> +       }, {
>                 /* Terminator */
>         },


Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2017-11-15 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-14  8:34 [PATCH/RFT v5 0/3] iommu/ipmmu-vmsa: r8a779(6|70|95) support Simon Horman
     [not found] ` <20171114083451.4052-1-horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2017-11-14  8:34   ` [PATCH/RFT v5 1/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48 Simon Horman
2017-11-14  8:34     ` Simon Horman
2017-11-14  8:34 ` [PATCH/RFT v5 2/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code Simon Horman
2017-11-14  8:34 ` [PATCH/RFT v5 3/3] iommu/ipmmu-vmsa: Hook up r8a779(70|95) " Simon Horman
2017-11-15 14:19   ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.