Skip to contentSkip to conversation

ARM: renesas: Use SMP jump stub SRAM region from DT

PATCH New Geert Uytterhoeven 4 participants 15 messages Jul 4, 2017 – Jul 10, 2017

Subsystems (4)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

cover ARM: renesas: Use SMP jump stub SRAM region from DT

Hi Magnus, Mark, Rob, Simon,

The R-Car Gen2 platform code for CPU core bringup needs to copy a jump stub to on-SoC SRAM. Currently it uses a hardcoded address pointing to ICRAM1.

This patch series adds support to specify this region from DT. It consists of 3 parts:
- DT binding documentation for reserving SRAM for the jump stub,
- A platform code update to retrieve the information from DT, if present (of course backwards-compatibility with old DTBs is preserved),
- DT updates to reserve an SRAM region in DT on all R-Car Gen2 and

    RZ/G1 SoCs.

The DT patches in this series depend on "[PATCH 0/7] ARM: dts: renesas:
Add Inter Connect RAM".

Note that the current jump stub in Linux is 12 bytes long. The patches reserve 16 bytes of SRAM. Should this be increased? The mapping granularity is PAGE_SIZE anyway.

Thanks for your comments!

Geert Uytterhoeven (9):
dt-bindings: sram: Document renesas,smp-sram
ARM: shmobile: rcar-gen2: Obtain jump stub region from DT
ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

 .../devicetree/bindings/sram/renesas,smp-sram.txt  | 27 ++++++++++++++++++
 arch/arm/boot/dts/r8a7743.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7745.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7790.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7791.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7792.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7793.dtsi                     |  8 ++++++
 arch/arm/boot/dts/r8a7794.dtsi                     |  8 ++++++
 arch/arm/mach-shmobile/pm-rcar-gen2.c              | 33 ++++++++++++++++++++--
 9 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sram/renesas,smp-sram.txt
Signature · 12 lines
2.7.4

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
author maintainer
#1 lore raw

PATCH 1/9 dt-bindings: sram: Document renesas,smp-sram

Document reserved SRAM for the SMP jump stub on Renesas R-Car Gen2 and RZ/G1 SoCs.

---
 .../devicetree/bindings/sram/renesas,smp-sram.txt  | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sram/renesas,smp-sram.txt
Documentation/devicetree/bindings/sram/renesas,smp-sram.txt new file +27 -0
new file mode 100644
index 0000000000000000..712d05e3e15eeb65
@@ -0,0 +1,27 @@
+* Renesas SMP SRAM
+
+Renesas R-Car Gen2 and RZ/G1 SoCs need a small piece of SRAM for the jump stub
+for secondary CPU bringup and CPU hotplug.
+This memory is reserved by adding a child node to a "mmio-sram" node, cfr.
+Documentation/devicetree/bindings/sram/sram.txt.
+
+Required child node properties:
+  - compatible: Must be "renesas,smp-sram",
+  - reg: Address and length of the reserved SRAM.
+    The full physical (bus) address must be aligned to a 256 KiB boundary.
+
+
+Example:
+
+	icram1:	sram at e63c0000 {
+		compatible = "mmio-sram";
+		reg = <0 0xe63c0000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0xe63c0000 0x1000>;
+
+		smp-sram at 0 {
+			compatible = "renesas,smp-sram";
+			reg = <0 0x10>;
+		};
+	};
Signature · 1 line
2.7.4
maintainer
#2 lore raw

PATCH 1/9 dt-bindings: sram: Document renesas,smp-sram

Quoted 8 lines · Geert Uytterhoeven

Document reserved SRAM for the SMP jump stub on Renesas R-Car Gen2 and RZ/G1 SoCs.

---
 .../devicetree/bindings/sram/renesas,smp-sram.txt  | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sram/renesas,smp-sram.txt
author maintainer
#3 lore raw

PATCH 2/9 ARM: shmobile: rcar-gen2: Obtain jump stub region from DT

In reply to Geert Uytterhoeven

Add support for obtaining from DT the SRAM region to store the jump stub for CPU core bringup, according to the renesas,smp-sram DT bindings.

If no region is specified in DT, the code falls back to hardcoded ICRAM1 as before, to maintain backwards compatibility.

---
 arch/arm/mach-shmobile/pm-rcar-gen2.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
arch/arm/mach-shmobile/pm-rcar-gen2.c +30 -3
index 0178da7ace82dcbd..e5f215c8b218100a 100644
@@ -11,7 +11,9 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/ioport.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/smp.h>
 #include <linux/soc/renesas/rcar-sysc.h>
 #include <asm/io.h>
@@ -69,8 +71,9 @@ void __init rcar_gen2_pm_init(void)
 	struct device_node *np, *cpus;
 	bool has_a7 = false;
 	bool has_a15 = false;
-	phys_addr_t boot_vector_addr = ICRAM1;
+	struct resource res;
 	u32 syscier = 0;
+	int error;
 
 	if (once++)
 		return;
@@ -91,14 +94,38 @@ void __init rcar_gen2_pm_init(void)
 	else if (of_machine_is_compatible("renesas,r8a7791"))
 		syscier = 0x00111003;
 
+	np = of_find_compatible_node(NULL, NULL, "renesas,smp-sram");
+	if (!np) {
+		/* No smp-sram in DT, fall back to hardcoded address */
+		res = (struct resource)DEFINE_RES_MEM(ICRAM1,
+						      shmobile_boot_size);
+		goto map;
+	}
+
+	error = of_address_to_resource(np, 0, &res);
+	if (error) {
+		pr_err("Failed to get smp-sram address: %d\n", error);
+		return;
+	}
+
+map:
 	/* RAM for jump stub, because BAR requires 256KB aligned address */
-	p = ioremap_nocache(boot_vector_addr, shmobile_boot_size);
+	if (res.start & (256 * 1024 - 1) ||
+	    resource_size(&res) < shmobile_boot_size) {
+		pr_err("Invalid smp-sram region\n");
+		return;
+	}
+
+	p = ioremap(res.start, resource_size(&res));
+	if (!p)
+		return;
+
 	memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
 	iounmap(p);
 
 	/* setup reset vectors */
 	p = ioremap_nocache(RST, 0x63);
-	bar = phys_to_sbar(boot_vector_addr);
+	bar = phys_to_sbar(res.start);
 	if (has_a15) {
 		writel_relaxed(bar, p + CA15BAR);
 		writel_relaxed(bar | SBAR_BAREN, p + CA15BAR);
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH 3/9 ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7743.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7743.dtsi +8 -0
index b8ce935f6fb196fe..4d59e498fb45fe15 100644
@@ -481,6 +481,14 @@
 		icram1:	sram at e63c0000 {
 			compatible = "mmio-sram";
 			reg = <0 0xe63c0000 0 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0 0xe63c0000 0x1000>;
+
+			smp-sram at 0 {
+				compatible = "renesas,smp-sram";
+				reg = <0 0x10>;
+			};
 		};
 
 		ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

PATCH 4/9 ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7745.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7745.dtsi +8 -0
index 88cf92bcd2f9b4fc..354534cdc5889cbc 100644
@@ -481,6 +481,14 @@
 		icram1:	sram at e63c0000 {
 			compatible = "mmio-sram";
 			reg = <0 0xe63c0000 0 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0 0xe63c0000 0x1000>;
+
+			smp-sram at 0 {
+				compatible = "renesas,smp-sram";
+				reg = <0 0x10>;
+			};
 		};
 
 		ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH 5/9 ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7790.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7790.dtsi +8 -0
index 4ee34995573cf505..ff986df23b62135f 100644
@@ -838,6 +838,14 @@
 	icram1:	sram at e63c0000 {
 		compatible = "mmio-sram";
 		reg = <0 0xe63c0000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0xe63c0000 0x1000>;
+
+		smp-sram at 0 {
+			compatible = "renesas,smp-sram";
+			reg = <0 0x10>;
+		};
 	};
 
 	ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
author maintainer
#7 lore raw

PATCH 6/9 ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7791.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7791.dtsi +8 -0
index f4748a9cb0375e4d..e135da440eed7b94 100644
@@ -898,6 +898,14 @@
 	icram1:	sram at e63c0000 {
 		compatible = "mmio-sram";
 		reg = <0 0xe63c0000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0xe63c0000 0x1000>;
+
+		smp-sram at 0 {
+			compatible = "renesas,smp-sram";
+			reg = <0 0x10>;
+		};
 	};
 
 	ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
author maintainer
#8 lore raw

PATCH 7/9 ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7792.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7792.dtsi +8 -0
index 136a86ac64974adb..2623f39bed2b73bb 100644
@@ -473,6 +473,14 @@
 		icram1:	sram at e63c0000 {
 			compatible = "mmio-sram";
 			reg = <0 0xe63c0000 0 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0 0xe63c0000 0x1000>;
+
+			smp-sram at 0 {
+				compatible = "renesas,smp-sram";
+				reg = <0 0x10>;
+			};
 		};
 
 		sdhi0: sd at ee100000 {
Signature · 1 line
2.7.4
author maintainer
#9 lore raw

PATCH 8/9 ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7793.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7793.dtsi +8 -0
index bc6a44272f555215..497716b6fbe24164 100644
@@ -856,6 +856,14 @@
 	icram1:	sram at e63c0000 {
 		compatible = "mmio-sram";
 		reg = <0 0xe63c0000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0xe63c0000 0x1000>;
+
+		smp-sram at 0 {
+			compatible = "renesas,smp-sram";
+			reg = <0 0x10>;
+		};
 	};
 
 	ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
author maintainer
#10 lore raw

PATCH 9/9 ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

In reply to Geert Uytterhoeven

Reserve SRAM for the jump stub for CPU core bringup.

---
 arch/arm/boot/dts/r8a7794.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7794.dtsi +8 -0
index 78973cee7185ffe6..f32b458e93285adc 100644
@@ -596,6 +596,14 @@
 	icram1:	sram at e63c0000 {
 		compatible = "mmio-sram";
 		reg = <0 0xe63c0000 0 0x1000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0xe63c0000 0x1000>;
+
+		smp-sram at 0 {
+			compatible = "renesas,smp-sram";
+			reg = <0 0x10>;
+		};
 	};
 
 	ether: ethernet at ee700000 {
Signature · 1 line
2.7.4
#11 lore raw

cover ARM: renesas: Use SMP jump stub SRAM region from DT

In reply to Geert Uytterhoeven
Quoted 22 lines · Geert Uytterhoeven

The R-Car Gen2 platform code for CPU core bringup needs to copy a jump stub to on-SoC SRAM. Currently it uses a hardcoded address pointing to ICRAM1.

This patch series adds support to specify this region from DT. It consists of 3 parts:
- DT binding documentation for reserving SRAM for the jump stub,
- A platform code update to retrieve the information from DT, if present (of course backwards-compatibility with old DTBs is preserved),
- DT updates to reserve an SRAM region in DT on all R-Car Gen2 and

    RZ/G1 SoCs.

The DT patches in this series depend on "[PATCH 0/7] ARM: dts: renesas:
Add Inter Connect RAM".

Note that the current jump stub in Linux is 12 bytes long. The patches reserve 16 bytes of SRAM. Should this be increased? The mapping granularity is PAGE_SIZE anyway.

Thanks for your comments!

Quoted 10 lines

Geert Uytterhoeven (9):
dt-bindings: sram: Document renesas,smp-sram
ARM: shmobile: rcar-gen2: Obtain jump stub region from DT
ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

Forgot to mention: this has been tested on r8a7790/lager, r8a7791/koelsch, r8a7792/blanche, r8a7793/gose, and r8a7794/alt (r8a7794 needs an unrelated fix to enable SMP).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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

#12 lore raw

cover ARM: renesas: Use SMP jump stub SRAM region from DT

Quoted 35 lines · Geert Uytterhoeven
Quoted 22 lines · Geert Uytterhoeven

The R-Car Gen2 platform code for CPU core bringup needs to copy a jump stub to on-SoC SRAM. Currently it uses a hardcoded address pointing to ICRAM1.

This patch series adds support to specify this region from DT. It consists of 3 parts:
- DT binding documentation for reserving SRAM for the jump stub,
- A platform code update to retrieve the information from DT, if present (of course backwards-compatibility with old DTBs is preserved),
- DT updates to reserve an SRAM region in DT on all R-Car Gen2 and

    RZ/G1 SoCs.

The DT patches in this series depend on "[PATCH 0/7] ARM: dts: renesas:
Add Inter Connect RAM".

Note that the current jump stub in Linux is 12 bytes long. The patches reserve 16 bytes of SRAM. Should this be increased? The mapping granularity is PAGE_SIZE anyway.

Thanks for your comments!

Quoted 10 lines

Geert Uytterhoeven (9):
dt-bindings: sram: Document renesas,smp-sram
ARM: shmobile: rcar-gen2: Obtain jump stub region from DT
ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

Quoted 3 lines

Forgot to mention: this has been tested on r8a7790/lager, r8a7791/koelsch, r8a7792/blanche, r8a7793/gose, and r8a7794/alt (r8a7794 needs an unrelated fix to enable SMP).

Geert, these seem nice and clean to me.
Are they ready to be applied?

#13 lore raw

cover ARM: renesas: Use SMP jump stub SRAM region from DT

Hi Simon,

Quoted 36 lines · Simon Horman
Quoted 35 lines · Geert Uytterhoeven
Quoted 32 lines · Geert Uytterhoeven

The R-Car Gen2 platform code for CPU core bringup needs to copy a jump stub to on-SoC SRAM. Currently it uses a hardcoded address pointing to ICRAM1.

This patch series adds support to specify this region from DT. It consists of 3 parts:
- DT binding documentation for reserving SRAM for the jump stub,
- A platform code update to retrieve the information from DT, if present (of course backwards-compatibility with old DTBs is preserved),
- DT updates to reserve an SRAM region in DT on all R-Car Gen2 and

    RZ/G1 SoCs.

The DT patches in this series depend on "[PATCH 0/7] ARM: dts: renesas:
Add Inter Connect RAM".

Note that the current jump stub in Linux is 12 bytes long. The patches reserve 16 bytes of SRAM. Should this be increased? The mapping granularity is PAGE_SIZE anyway.

Thanks for your comments!

Geert Uytterhoeven (9):
dt-bindings: sram: Document renesas,smp-sram
ARM: shmobile: rcar-gen2: Obtain jump stub region from DT
ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

Quoted 6 lines
Quoted 3 lines

Forgot to mention: this has been tested on r8a7790/lager, r8a7791/koelsch, r8a7792/blanche, r8a7793/gose, and r8a7794/alt (r8a7794 needs an unrelated fix to enable SMP).

Geert, these seem nice and clean to me.
Are they ready to be applied?

Now the binding has been Acked by Rob, I think they are. Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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

#14 lore raw

cover ARM: renesas: Use SMP jump stub SRAM region from DT

Quoted 43 lines · Geert Uytterhoeven

Hi Simon,

Quoted 40 lines · Simon Horman
Quoted 38 lines · Geert Uytterhoeven
Quoted 22 lines · Geert Uytterhoeven

The R-Car Gen2 platform code for CPU core bringup needs to copy a jump stub to on-SoC SRAM. Currently it uses a hardcoded address pointing to ICRAM1.

This patch series adds support to specify this region from DT. It consists of 3 parts:
- DT binding documentation for reserving SRAM for the jump stub,
- A platform code update to retrieve the information from DT, if present (of course backwards-compatibility with old DTBs is preserved),
- DT updates to reserve an SRAM region in DT on all R-Car Gen2 and

    RZ/G1 SoCs.

The DT patches in this series depend on "[PATCH 0/7] ARM: dts: renesas:
Add Inter Connect RAM".

Note that the current jump stub in Linux is 12 bytes long. The patches reserve 16 bytes of SRAM. Should this be increased? The mapping granularity is PAGE_SIZE anyway.

Thanks for your comments!

Quoted 10 lines

Geert Uytterhoeven (9):
dt-bindings: sram: Document renesas,smp-sram
ARM: shmobile: rcar-gen2: Obtain jump stub region from DT
ARM: dts: r8a7743: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7745: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7790: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7791: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7792: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7793: Reserve SRAM for the SMP jump stub
ARM: dts: r8a7794: Reserve SRAM for the SMP jump stub

Forgot to mention: this has been tested on r8a7790/lager, r8a7791/koelsch, r8a7792/blanche, r8a7793/gose, and r8a7794/alt (r8a7794 needs an unrelated fix to enable SMP).

Quoted 5 lines
Quoted 2 lines

Geert, these seem nice and clean to me.
Are they ready to be applied?

Now the binding has been Acked by Rob, I think they are. Thanks!

Thanks, all patches accepted for v4.14.