All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype
@ 2016-10-31 17:08 Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 1/5] arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map Geert Uytterhoeven
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Geert Uytterhoeven

	Hi all,

This series enables support for memory outside the 32-bit address space
("64-bit memory") on the R-Car M3-W-based Salvator-X development board,
and allows the RAVB Ethernet driver to use this memory without bounce
buffers.

The patch series consists of 3 parts:
  1. Patch 1 enables 64-bit memory in the DTS supplied with the kernel.
     Actually you're probably already running with 64-bit memory
     enabled, as the U-Boot versions provided with all firmware versions
     I've seen add all memory to the passed DTB anyway.
     Thanks to SWIOTLB, Linux falls back to using bounce buffers when a
     driver tries to use DMA to memory outside the 32-bit address
     space. So 64-bit memory already works ;-)

  2. Patches 2-4 enable the use of the IPMMU for RAVB Ethernet.

  3. Patch 5 widens the DMA mask in the R-Car DMAC driver, to enable DMA
     to the 40-bit address space for all devices using SYS-DMAC (e.g.
     SCIF serial).

Originally the plan was to disable CONFIG_DMA, to trap devices and DMA
engines not supporting memory outside the 32-bit address space. This
would be useful to validate proper operation when adding more device
support later.
Unfortunately CONFIG_DMA cannot be disabled on a stock arm64 kernel.
Applying a small patch (based on Mark Salter's "arm64: make
CONFIG_ZONE_DMA user settable") changes that. However:
  - With CONFIG_ZONE_DMA=n and memory present over 4G, swiotlb_init() is
    not called.
    This will lead to a NULL pointer dereference later, when
    dma_map_single() calls into an unitialized SWIOTLB subsystem through
    swiotlb_tbl_map_single().
  - With CONFIG_ZONE_DMA=n and no memory present over 4G, swiotlb_init()
    is also not called, but RAVB works fine.
Disabling CONFIG_SWIOTLB is non-trivial, as the arm64 DMA core always
uses swiotlb_dma_ops, and its operations depend a lot on SWIOTLB
helpers.

Hence I decided to keep on using CONFIG_ZONE_DMA=y, and handle the
checks in SWIOTLB. As this turned out to be fairly platform-independent,
I spun that off in a separate patch series, see "[PATCH 0/2] swiotlb:
Rate-limit printing and 64-bit memory debugging"
(https://www.mail-archive.com/linux-renesas-soc@vger.kernel.org/msg08384.html).
With that series applied, you can pass "swiotlb=nobounce", and all DMA
operations that would require bounce buffers will start to fail.
With just 64-bit memory enabled, this uncovered the following issues,
also fixed by this patch series:

  1. When using SCIF with DMA:

	rcar-dmac e7300000.dma-controller: Cannot do DMA to address 0x000000067a9b7000

     This is fixed by widening the DMA mask in the R-Car DMAC driver.

  2. When using RAVB:

	ravb e6800000.ethernet: Cannot do DMA to address 0x000000067aa07780

     This is fixed by enabling the IPMMU for RAVB.

     Note that while DHCP and ping work initially, and my NFS root is
     mounted succesfully, NFS root starts failing after a few seconds
     with:

	nfs: server XXX.XXX.XXX.XXX not responding, still trying

     This looks like an IPMMU issue, as NFS root works fine when the
     IPMMU is disabled (and "swiotlb=nobounce" is not specified, of
     course).

Dependencies:
  - r8a7796 Ethernet enablement,
  - r8a7796 IPMMU support,
  - r8a7796 SYS-DMAC support,
    (all three included in renesas-drivers-2016-10-25-v4.9-rc2)
  - "[PATCH 0/2] swiotlb: Rate-limit printing and 64-bit memory
    debugging", for debugging ("swiotlb=bounce")
    (https://www.mail-archive.com/linux-renesas-soc@vger.kernel.org/msg08384.html)

For your convenience, this series (incl. dependencies) is also available in the
topic/r8a7796-64b-mem+ravb-prototype-v1 branch of my renesas-drivers git
repository at
git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git

Thanks for your comments!

Geert Uytterhoeven (3):
  arm64: dts: r8a7796: Connect Ethernet AVB to IPMMU
  arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm
  dmaengine: rcar-dmac: Widen DMA mask to 40 bits

Magnus Damm (1):
  arm64: dts: r8a7796: Add IPMMU device nodes

Takeshi Kihara (1):
  arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map

 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts |  5 ++
 arch/arm64/boot/dts/renesas/r8a7796.dtsi           | 90 ++++++++++++++++++++++
 drivers/dma/sh/rcar-dmac.c                         |  1 +
 3 files changed, 96 insertions(+)

-- 
1.9.1

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] 11+ messages in thread

* [PATCH/RFC 1/5] arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map
  2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
@ 2016-10-31 17:08 ` Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 2/5] arm64: dts: r8a7796: Add IPMMU device nodes Geert Uytterhoeven
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Takeshi Kihara, Geert Uytterhoeven

From: Takeshi Kihara <takeshi.kihara.df@renesas.com>

This patch updates memory region:

  - After changes, the new map of the Salvator-X board on R8A7796 SoC
    Bank0: 2GiB RAM : 0x000048000000 -> 0x000bfffffff
    Bank1: 2GiB RAM : 0x000600000000 -> 0x0067fffffff

  - Before changes, the old map looked like this:
    Bank0: 2GiB RAM : 0x000048000000 -> 0x000bfffffff

Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com>
[geert: Correct size of old map]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Note: Depending on firmware version, this patch may not make a
difference at all!

Indeed, U-Boot may already add the second memory region to the "reg"
property of the first memory node in DT, regardless of the presence of a
second memory node. Fortunately Linux handles duplicate memory regions
just fine...
---
 arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts b/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
index f7c0ec47af7660b1..2fe75b06288c608e 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
+++ b/arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
@@ -32,6 +32,11 @@
 		reg = <0x0 0x48000000 0x0 0x78000000>;
 	};
 
+	memory@600000000 {
+		device_type = "memory";
+		reg = <0x6 0x00000000 0x0 0x80000000>;
+	};
+
 	reg_1p8v: regulator0 {
 		compatible = "regulator-fixed";
 		regulator-name = "fixed-1.8V";
-- 
1.9.1

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

* [PATCH/RFC 2/5] arm64: dts: r8a7796: Add IPMMU device nodes
  2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 1/5] arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map Geert Uytterhoeven
@ 2016-10-31 17:08 ` Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 3/5] arm64: dts: r8a7796: Connect Ethernet AVB to IPMMU Geert Uytterhoeven
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Magnus Damm, Geert Uytterhoeven

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

Add r8a7796 IPMMU nodes and keep all disabled by default.

Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 89 ++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index a0ba2fa47803762b..824d2c7831621386 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -234,6 +234,95 @@
 			reg = <0 0xe6060000 0 0x50c>;
 		};
 
+		ipmmu_vi: mmu@febd0000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xfebd0000 0 0x1000>; /* IPMMU-VI */
+			renesas,ipmmu-main = <&ipmmu_mm 9>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_vc0: mmu@fe6b0000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xfe6b0000 0 0x1000>; /* IPMMU-VC0 */
+			renesas,ipmmu-main = <&ipmmu_mm 8>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_pv0: mmu@fd800000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xfd800000 0 0x1000>; /* IPMMU-PV0 */
+			renesas,ipmmu-main = <&ipmmu_mm 5>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_pv1: mmu@fd950000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xfd950000 0 0x1000>; /* IPMMU-PV1 */
+			renesas,ipmmu-main = <&ipmmu_mm 6>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_ir: mmu@ff8b0000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xff8b0000 0 0x1000>; /* IPMMU-IR */
+			renesas,ipmmu-main = <&ipmmu_mm 3>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_hc: mmu@e6570000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xe6570000 0 0x1000>; /* IPMMU-HC */
+			renesas,ipmmu-main = <&ipmmu_mm 2>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_rt: mmu@ffc80000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xffc80000 0 0x1000>; /* IPMMU-RT */
+			renesas,ipmmu-main = <&ipmmu_mm 7>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_mp0: mmu@ec670000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xec670000 0 0x1000>; /* IPMMU-MP0 */
+			renesas,ipmmu-main = <&ipmmu_mm 4>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_ds0: mmu@e6740000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xe6740000 0 0x1000>; /* IPMMU-DS0 */
+			renesas,ipmmu-main = <&ipmmu_mm 0>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_ds1: mmu@e7740000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xe7740000 0 0x1000>; /* IPMMU-DS1 */
+			renesas,ipmmu-main = <&ipmmu_mm 1>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
+		ipmmu_mm: mmu@e67b0000 {
+			compatible = "renesas,ipmmu-r8a7796";
+			reg = <0 0xe67b0000 0 0x1000>; /* IPMMU-MM */
+			interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+			#iommu-cells = <1>;
+			status = "disabled";
+		};
+
 		cpg: clock-controller@e6150000 {
 			compatible = "renesas,r8a7796-cpg-mssr";
 			reg = <0 0xe6150000 0 0x1000>;
-- 
1.9.1

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

* [PATCH/RFC 3/5] arm64: dts: r8a7796: Connect Ethernet AVB to IPMMU
  2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 1/5] arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 2/5] arm64: dts: r8a7796: Add IPMMU device nodes Geert Uytterhoeven
@ 2016-10-31 17:08 ` Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm Geert Uytterhoeven
  2016-10-31 17:08 ` [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits Geert Uytterhoeven
  4 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Geert Uytterhoeven

Add IPMMU-DS0 to the Ethernet-AVB device node.

Based on a patch from Magnus Damm for r8a7795.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index 824d2c7831621386..f6d15805b75031bb 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -483,6 +483,7 @@
 			phy-mode = "rgmii-id";
 			#address-cells = <1>;
 			#size-cells = <0>;
+			iommus = <&ipmmu_ds0 16>;
 		};
 
 		i2c0: i2c@e6500000 {
-- 
1.9.1

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

* [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm
  2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2016-10-31 17:08 ` [PATCH/RFC 3/5] arm64: dts: r8a7796: Connect Ethernet AVB to IPMMU Geert Uytterhoeven
@ 2016-10-31 17:08 ` Geert Uytterhoeven
  2016-11-01 11:27   ` Sergei Shtylyov
  2016-10-31 17:08 ` [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits Geert Uytterhoeven
  4 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Geert Uytterhoeven

Enable the IPMMU for Ethernet AVB.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index f6d15805b75031bb..dc416c300968b0e2 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -303,7 +303,7 @@
 			reg = <0 0xe6740000 0 0x1000>; /* IPMMU-DS0 */
 			renesas,ipmmu-main = <&ipmmu_mm 0>;
 			#iommu-cells = <1>;
-			status = "disabled";
+			status = "okay";
 		};
 
 		ipmmu_ds1: mmu@e7740000 {
@@ -320,7 +320,7 @@
 			interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
 				     <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
 			#iommu-cells = <1>;
-			status = "disabled";
+			status = "okay";
 		};
 
 		cpg: clock-controller@e6150000 {
-- 
1.9.1

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

* [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits
  2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
                   ` (3 preceding siblings ...)
  2016-10-31 17:08 ` [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm Geert Uytterhoeven
@ 2016-10-31 17:08 ` Geert Uytterhoeven
  2016-11-25  9:00   ` Geert Uytterhoeven
  4 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-10-31 17:08 UTC (permalink / raw)
  To: Magnus Damm, Simon Horman, Laurent Pinchart, Niklas Söderlund
  Cc: linux-renesas-soc, Geert Uytterhoeven

By default, the DMA mask covers only the low 32-bit address space, which
causes SWIOTLB on arm64 to fall back to a bounce buffer for DMA
transfers involving memory outside the 32-bit address space.

The R-Car DMA controller hardware supports a 40-bit address space, hence
widen the DMA mask to 40 bits to actually make use of this feature.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/dma/sh/rcar-dmac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2e441d0ccd79a37a..93a69b992a51a7aa 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1716,6 +1716,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 
 	dmac->dev = &pdev->dev;
 	platform_set_drvdata(pdev, dmac);
+	dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
 
 	ret = rcar_dmac_parse_of(&pdev->dev, dmac);
 	if (ret < 0)
-- 
1.9.1

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

* Re: [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm
  2016-10-31 17:08 ` [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm Geert Uytterhoeven
@ 2016-11-01 11:27   ` Sergei Shtylyov
  0 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2016-11-01 11:27 UTC (permalink / raw)
  To: Geert Uytterhoeven, Magnus Damm, Simon Horman, Laurent Pinchart,
	Niklas Söderlund
  Cc: linux-renesas-soc

Hello.

On 10/31/2016 8:08 PM, Geert Uytterhoeven wrote:

> Enable the IPMMU for Ethernet AVB.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  arch/arm64/boot/dts/renesas/r8a7796.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
> index f6d15805b75031bb..dc416c300968b0e2 100644
> --- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
> +++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
> @@ -303,7 +303,7 @@
>  			reg = <0 0xe6740000 0 0x1000>; /* IPMMU-DS0 */
>  			renesas,ipmmu-main = <&ipmmu_mm 0>;
>  			#iommu-cells = <1>;
> -			status = "disabled";
> +			status = "okay";
>  		};
>
>  		ipmmu_ds1: mmu@e7740000 {
> @@ -320,7 +320,7 @@
>  			interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
>  				     <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
>  			#iommu-cells = <1>;
> -			status = "disabled";
> +			status = "okay";

    You could just omit the "status" prop in .dtsi -- the result should be the 
same.

[...]

MBR, Sergei

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

* Re: [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits
  2016-10-31 17:08 ` [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits Geert Uytterhoeven
@ 2016-11-25  9:00   ` Geert Uytterhoeven
  2016-11-25  9:01     ` Magnus Damm
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-11-25  9:00 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Magnus Damm, Simon Horman, Laurent Pinchart,
	Niklas Söderlund, Linux-Renesas

On Mon, Oct 31, 2016 at 6:08 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> By default, the DMA mask covers only the low 32-bit address space, which
> causes SWIOTLB on arm64 to fall back to a bounce buffer for DMA
> transfers involving memory outside the 32-bit address space.
>
> The R-Car DMA controller hardware supports a 40-bit address space, hence
> widen the DMA mask to 40 bits to actually make use of this feature.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Any comments? Thanks!

> ---
>  drivers/dma/sh/rcar-dmac.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 2e441d0ccd79a37a..93a69b992a51a7aa 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1716,6 +1716,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
>
>         dmac->dev = &pdev->dev;
>         platform_set_drvdata(pdev, dmac);
> +       dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
>
>         ret = rcar_dmac_parse_of(&pdev->dev, dmac);
>         if (ret < 0)

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] 11+ messages in thread

* Re: [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits
  2016-11-25  9:00   ` Geert Uytterhoeven
@ 2016-11-25  9:01     ` Magnus Damm
  2016-12-21  7:17       ` Kuninori Morimoto
  0 siblings, 1 reply; 11+ messages in thread
From: Magnus Damm @ 2016-11-25  9:01 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Geert Uytterhoeven, Simon Horman, Laurent Pinchart,
	Niklas Söderlund, Linux-Renesas

Hi Geert,

On Fri, Nov 25, 2016 at 6:00 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Mon, Oct 31, 2016 at 6:08 PM, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
>> By default, the DMA mask covers only the low 32-bit address space, which
>> causes SWIOTLB on arm64 to fall back to a bounce buffer for DMA
>> transfers involving memory outside the 32-bit address space.
>>
>> The R-Car DMA controller hardware supports a 40-bit address space, hence
>> widen the DMA mask to 40 bits to actually make use of this feature.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Any comments? Thanks!
>
>> ---
>>  drivers/dma/sh/rcar-dmac.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
>> index 2e441d0ccd79a37a..93a69b992a51a7aa 100644
>> --- a/drivers/dma/sh/rcar-dmac.c
>> +++ b/drivers/dma/sh/rcar-dmac.c
>> @@ -1716,6 +1716,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
>>
>>         dmac->dev = &pdev->dev;
>>         platform_set_drvdata(pdev, dmac);
>> +       dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));

This makes sense to me since the hardware and the driver both can
access more than 32-bits of physical address space.

Cheers,

/ magnus

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

* Re: [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits
  2016-11-25  9:01     ` Magnus Damm
@ 2016-12-21  7:17       ` Kuninori Morimoto
  2016-12-21  9:28         ` Geert Uytterhoeven
  0 siblings, 1 reply; 11+ messages in thread
From: Kuninori Morimoto @ 2016-12-21  7:17 UTC (permalink / raw)
  To: Magnus Damm
  Cc: Geert Uytterhoeven, Geert Uytterhoeven, Simon Horman,
	Laurent Pinchart, Niklas Söderlund, Linux-Renesas


Hi Geert, Magnus

> >> By default, the DMA mask covers only the low 32-bit address space, which
> >> causes SWIOTLB on arm64 to fall back to a bounce buffer for DMA
> >> transfers involving memory outside the 32-bit address space.
> >>
> >> The R-Car DMA controller hardware supports a 40-bit address space, hence
> >> widen the DMA mask to 40 bits to actually make use of this feature.
> >>
> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > Any comments? Thanks!
> >
> >> ---
> >>  drivers/dma/sh/rcar-dmac.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> >> index 2e441d0ccd79a37a..93a69b992a51a7aa 100644
> >> --- a/drivers/dma/sh/rcar-dmac.c
> >> +++ b/drivers/dma/sh/rcar-dmac.c
> >> @@ -1716,6 +1716,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
> >>
> >>         dmac->dev = &pdev->dev;
> >>         platform_set_drvdata(pdev, dmac);
> >> +       dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
> 
> This makes sense to me since the hardware and the driver both can
> access more than 32-bits of physical address space.

Unfortunately, this patch breaks H3 IPMMU at least
on SCIF/MSOIF/Sound. It could start works if we reverted
this patch (= 3e58e24ad844a41389c849cfc581e3339299690e)
I'm using renesas-drivers-next-2016-12-13-v4.9

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits
  2016-12-21  7:17       ` Kuninori Morimoto
@ 2016-12-21  9:28         ` Geert Uytterhoeven
  0 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-12-21  9:28 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Magnus Damm, Geert Uytterhoeven, Simon Horman, Laurent Pinchart,
	Niklas Söderlund, Linux-Renesas

Hi Morimoto-san, Magnus,

On Wed, Dec 21, 2016 at 8:17 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>> >> By default, the DMA mask covers only the low 32-bit address space, which
>> >> causes SWIOTLB on arm64 to fall back to a bounce buffer for DMA
>> >> transfers involving memory outside the 32-bit address space.
>> >>
>> >> The R-Car DMA controller hardware supports a 40-bit address space, hence
>> >> widen the DMA mask to 40 bits to actually make use of this feature.
>> >>
>> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> >
>> > Any comments? Thanks!
>> >
>> >> ---
>> >>  drivers/dma/sh/rcar-dmac.c | 1 +
>> >>  1 file changed, 1 insertion(+)
>> >>
>> >> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
>> >> index 2e441d0ccd79a37a..93a69b992a51a7aa 100644
>> >> --- a/drivers/dma/sh/rcar-dmac.c
>> >> +++ b/drivers/dma/sh/rcar-dmac.c
>> >> @@ -1716,6 +1716,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
>> >>
>> >>         dmac->dev = &pdev->dev;
>> >>         platform_set_drvdata(pdev, dmac);
>> >> +       dma_set_mask_and_coherent(dmac->dev, DMA_BIT_MASK(40));
>>
>> This makes sense to me since the hardware and the driver both can
>> access more than 32-bits of physical address space.
>
> Unfortunately, this patch breaks H3 IPMMU at least
> on SCIF/MSOIF/Sound. It could start works if we reverted
> this patch (= 3e58e24ad844a41389c849cfc581e3339299690e)
> I'm using renesas-drivers-next-2016-12-13-v4.9

I could reproduce this on salvator-x with both r8a7795 and r8a7796, after
enabling pimmu_{ds0,ds1,mm}, and binding the sys-dmacs to the ipmmu on
r8a7796.

ipmmu-vmsa e7740000.mmu: Unhandled fault: status 0x00000101 iova 0xfffff000

With DMA debugging enabled, I get:

ipmmu-vmsa e67b0000.mmu: DMA-API: device driver tries to sync DMA
memory it has not allocated [device address=0x0000000
7ba64018] [size=8 bytes]
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at lib/dma-debug.c:1234 check_sync+0xcc/0x568
Modules linked in:

CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.9.0-salvator-x-00438-g3c6a18a0b4e6f97a-dirty #995
Hardware name: Renesas Salvator-X board based on r8a7796 (DT)
task: ffffffc63b8ce080 task.stack: ffffffc63b8d0000
PC is at check_sync+0xcc/0x568
LR is at check_sync+0xcc/0x568
pc : [<ffffff800828a75c>] lr : [<ffffff800828a75c>] pstate: 604000c5
sp : ffffffc63b8d36b0
x29: ffffffc63b8d36b0 x28: ffffff8008c76560
x27: 000000067a14b000 x26: 0000000000001000
x25: ffffffc63ba64018 x24: 0000000000000001
x23: 00000000fffff000 x22: 0000000000000000
x21: ffffff8008c08000 x20: ffffffc63b8d3710
x19: ffffffc63ba2f810 x18: 0000000066a00782
x17: 00000000c0f4b676 x16: 000000007e7e7094
x15: 000000007369e22e x14: 735b205d38313034
x13: 3661623736303030 x12: 3030303078303d73
x11: 7365726464612065 x10: 63697665645b2064
x9 : 657461636f6c6c61 x8 : 20746f6e20736168
x7 : 2074692079726f6d x6 : ffffffc63b8ce080
x5 : 0000000000000000 x4 : 0000000000000000
x3 : 000000463754f000 x2 : 000000463754f000
x1 : ffffffc63b8ce080 x0 : 0000000000000090

---[ end trace df402ecfddb29a91 ]---
Call trace:
Exception stack(0xffffffc63b8d34e0 to 0xffffffc63b8d3610)
34e0: ffffffc63ba2f810 0000008000000000 0000000048d69000 ffffff800828a75c
3500: ffffff80087b7313 ffffff80087bec8b 000000013b8d3530 0000000000000007
3520: 000000000000022d 0000000100000000 ffffffc63b8d35d0 ffffff80080e8b68
3540: ffffffc63ba2f810 ffffffc63b8d3710 ffffff8008c08000 0000000000000000
3560: 00000000fffff000 0000000000000001 ffffffc63ba64018 0000000000001000
3580: 0000000000000090 ffffffc63b8ce080 000000463754f000 000000463754f000
35a0: 0000000000000000 0000000000000000 ffffffc63b8ce080 2074692079726f6d
35c0: 20746f6e20736168 657461636f6c6c61 63697665645b2064 7365726464612065
35e0: 3030303078303d73 3661623736303030 735b205d38313034 000000007369e22e
3600: 000000007e7e7094 00000000c0f4b676
[<ffffff800828a75c>] check_sync+0xcc/0x568
[<ffffff800828ac88>] debug_dma_sync_single_for_device+0x44/0x4c
[<ffffff8008310730>] __arm_lpae_set_pte.isra.1+0x8c/0x98
[<ffffff80083109bc>] __arm_lpae_map+0x280/0x2dc
[<ffffff8008310ee4>] arm_lpae_map+0xb0/0xc4
[<ffffff80083123c4>] ipmmu_map+0x20/0x30
[<ffffff800830cfb0>] iommu_map+0xdc/0x1d4
[<ffffff800830ef68>] __iommu_dma_map+0xb8/0xec
[<ffffff800830f650>] iommu_dma_map_page+0x50/0x58
[<ffffff800809797c>] __iommu_map_page+0x54/0x98
[<ffffff8008302a50>] sci_startup+0x1e8/0x424
[<ffffff800830069c>] uart_port_startup+0x78/0x118
[<ffffff8008300e9c>] uart_port_activate+0x5c/0x88
[<ffffff80082ed544>] tty_port_open+0x84/0xd4
[<ffffff80082ff498>] uart_open+0x34/0x44
[<ffffff80082e6d00>] tty_open+0x340/0x4d0
[<ffffff80081924a4>] chrdev_open+0x138/0x16c
[<ffffff800818ba40>] do_dentry_open.isra.17+0x1c4/0x2d8
[<ffffff800818c6e4>] vfs_open+0x60/0x6c
[<ffffff800819c134>] path_openat+0xaa4/0xc54
[<ffffff800819c320>] do_filp_open+0x3c/0x84
[<ffffff800818ca94>] do_sys_open+0x150/0x1e8
[<ffffff800818cb4c>] SyS_open+0x20/0x28
[<ffffff8008a00c4c>] kernel_init_freeable+0x16c/0x1e0
[<ffffff80085b0bd4>] kernel_init+0x10/0xfc
[<ffffff8008083080>] ret_from_fork+0x10/0x50

I believe I reported that before (yes, first time on Jan 18 ;-)

Any chance "iova 0xfffff000" in the fault message is related to
"x23: 00000000fffff000" in the backtrace, after truncation from 40-bit
to 32-bit?

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] 11+ messages in thread

end of thread, other threads:[~2016-12-21  9:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 17:08 [PATCH/RFC 0/5] arm64: r8a7796: 64-bit Memory and Ethernet Prototype Geert Uytterhoeven
2016-10-31 17:08 ` [PATCH/RFC 1/5] arm64: dts: r8a7796: salvator-x: Update memory node to 4 GiB map Geert Uytterhoeven
2016-10-31 17:08 ` [PATCH/RFC 2/5] arm64: dts: r8a7796: Add IPMMU device nodes Geert Uytterhoeven
2016-10-31 17:08 ` [PATCH/RFC 3/5] arm64: dts: r8a7796: Connect Ethernet AVB to IPMMU Geert Uytterhoeven
2016-10-31 17:08 ` [PATCH/RFC 4/5] arm64: dts: r8a7796: Enable ipmmu_ds0 and ipmmu_mm Geert Uytterhoeven
2016-11-01 11:27   ` Sergei Shtylyov
2016-10-31 17:08 ` [PATCH/RFC 5/5] dmaengine: rcar-dmac: Widen DMA mask to 40 bits Geert Uytterhoeven
2016-11-25  9:00   ` Geert Uytterhoeven
2016-11-25  9:01     ` Magnus Damm
2016-12-21  7:17       ` Kuninori Morimoto
2016-12-21  9:28         ` 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.