2017-03-12 05:44:09

by Magnus Damm

[permalink] [raw]
Subject: [PATCH v3 0/3] iommu/ipmmu-vmsa: r8a7796 support V3

iommu/ipmmu-vmsa: r8a7796 support V3

[PATCH v3 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding
[PATCH v3 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
[PATCH v3 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 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:
Signed-off-by: Magnus Damm <[email protected]>
Acked-by: Laurent Pinchart <[email protected]>
Acked-by: Rob Herring <[email protected]>
Acked-by: Simon Horman <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>

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

Signed-off-by: Magnus Damm <[email protected]>
---

Developed on top of v4.11-rc1 with the following series applied:
[PATCH v7 00/07] iommu/ipmmu-vmsa: IPMMU multi-arch update V7
[PATCH v3 00/09] iommu/ipmmu-vmsa: r8a7795 support V3

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


2017-03-12 05:44:20

by Magnus Damm

[permalink] [raw]
Subject: [PATCH v3 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.

Signed-off-by: Magnus Damm <[email protected]>
Acked-by: Laurent Pinchart <[email protected]>
Acked-by: Rob Herring <[email protected]>
Acked-by: Simon Horman <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>
---

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

--- 0001/Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt
+++ work/Documentation/devicetree/bindings/iommu/renesas,ipmmu-vmsa.txt 2017-03-12 14:09:01.920607110 +0900
@@ -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.

2017-03-12 05:44:33

by Magnus Damm

[permalink] [raw]
Subject: [PATCH v3 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48

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.

Signed-off-by: Magnus Damm <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---

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

--- 0020/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2017-03-12 14:11:23.020607110 +0900
@@ -213,7 +213,9 @@ static void set_archdata(struct device *
#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
@@ -223,7 +225,9 @@ static void set_archdata(struct device *
#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)
@@ -1164,7 +1168,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 = match->data;

2017-03-12 05:44:46

by Magnus Damm

[permalink] [raw]
Subject: [PATCH v3 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

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.

Signed-off-by: Magnus Damm <[email protected]>
---

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

--- 0024/drivers/iommu/ipmmu-vmsa.c
+++ work/drivers/iommu/ipmmu-vmsa.c 2017-03-12 14:14:32.550607110 +0900
@@ -1058,8 +1058,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 */ }
};

@@ -1082,7 +1083,7 @@ static int ipmmu_of_xlate_dma(struct dev
}

/* 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;

return ipmmu_init_platform_device(dev);
@@ -1127,7 +1128,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,
.has_eight_ctx = true,
@@ -1141,7 +1142,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 */
},
@@ -1333,6 +1337,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");

2017-03-12 09:31:51

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

On Sun, Mar 12, 2017 at 6:38 AM, Magnus Damm <[email protected]> wrote:
> 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.
>
> Signed-off-by: Magnus Damm <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

2017-03-22 14:24:08

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] iommu/ipmmu-vmsa: r8a7796 support V3

Hey Magnus,

On Sun, Mar 12, 2017 at 02:38:20PM +0900, Magnus Damm wrote:
> iommu/ipmmu-vmsa: r8a7796 support V3
>
> [PATCH v3 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding
> [PATCH v3 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
> [PATCH v3 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code

I just tried to apply a few of your patch-sets, but failed because they
don't apply cleanly and it is not clear what the dependencies are and in
which order they need to be applied.

So for now I skipped all ipmmu-vmsa patches that are currently in my
inbox. Please rebase your different series to v4.11-rc3 and resend them
in the right order, with all Reviewed-bys and other tags that people
gave you included. Then I am taking another look into applying them.


Thanks,

Joerg

2017-03-22 14:33:24

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] iommu/ipmmu-vmsa: r8a7796 support V3

Hi Jörg,

On Wed, Mar 22, 2017 at 3:23 PM, Joerg Roedel <[email protected]> wrote:
> On Sun, Mar 12, 2017 at 02:38:20PM +0900, Magnus Damm wrote:
>> iommu/ipmmu-vmsa: r8a7796 support V3
>>
>> [PATCH v3 1/3] iommu/ipmmu-vmsa: Add r8a7796 DT binding
>> [PATCH v3 2/3] iommu/ipmmu-vmsa: Increase maximum micro-TLBS to 48
>> [PATCH v3 3/3] iommu/ipmmu-vmsa: Hook up r8a7796 DT matching code
>
> I just tried to apply a few of your patch-sets, but failed because they
> don't apply cleanly and it is not clear what the dependencies are and in
> which order they need to be applied.
>
> So for now I skipped all ipmmu-vmsa patches that are currently in my
> inbox. Please rebase your different series to v4.11-rc3 and resend them
> in the right order, with all Reviewed-bys and other tags that people
> gave you included. Then I am taking another look into applying them.

For the record, they apply cleanly on v4.11-rc1, cfr.
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/r8a7796-ipmmu-v3

As I had no conflicts when creating
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/tag/?h=renesas-drivers-2017-03-21-v4.11-rc3
I expect them to apply cleanly to your next branch, too.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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