linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] ARM: mach-shmobile: Parse DT to get ARCH timer memory region
@ 2019-05-10 16:22 Oleksandr Tyshchenko
  2019-05-13  9:19 ` Julien Grall
  0 siblings, 1 reply; 8+ messages in thread
From: Oleksandr Tyshchenko @ 2019-05-10 16:22 UTC (permalink / raw)
  To: linux-renesas-soc, linux-kernel
  Cc: julien.grall, horms, magnus.damm, linux, Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Don't use hardcoded address, retrieve it from device-tree instead.

And besides, this patch fixes the memory error when running
on top of Xen hypervisor:

(XEN) traps.c:1999:d0v0 HSR=0x93830007 pc=0xc0b097f8 gva=0xf0805000
      gpa=0x000000e6080000

Which shows that VCPU0 in Dom0 is trying to access an address in memory
it is not allowed to access (0x000000e6080000).
Put simply, Xen doesn't know that it is a device's register memory
since it wasn't described in a host device tree (which Xen parses)
and as the result this memory region wasn't assigned to Dom0 at
domain creation time.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

---

This patch is meant to get feedback from the community before
proceeding further. If we decide to go this direction, all Gen2
device-trees should be updated (add memory region) before
this patch going in.

e.g. r8a7790.dtsi:

...
timer {
	compatible = "arm,armv7-timer";
	interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
			      <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
			      <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
			      <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>;
+	 reg = <0 0xe6080000 0 0x1000>;
};
...

---
 arch/arm/mach-shmobile/setup-rcar-gen2.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c
index 35dda21..153e3f5 100644
--- a/arch/arm/mach-shmobile/setup-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c
@@ -15,6 +15,7 @@
 #include <linux/kernel.h>
 #include <linux/memblock.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
 #include <asm/mach/arch.h>
@@ -61,6 +62,8 @@ static unsigned int __init get_extal_freq(void)
 
 void __init rcar_gen2_timer_init(void)
 {
+	struct device_node *np;
+	struct resource res;
 	void __iomem *base;
 	u32 freq;
 
@@ -72,6 +75,13 @@ void __init rcar_gen2_timer_init(void)
 	if (!psci_smp_available())
 		secure_cntvoff_init();
 
+	np = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
+	if (!np)
+		goto out;
+
+	if (of_address_to_resource(np, 0, &res))
+		goto out;
+
 	if (of_machine_is_compatible("renesas,r8a7745") ||
 	    of_machine_is_compatible("renesas,r8a77470") ||
 	    of_machine_is_compatible("renesas,r8a7792") ||
@@ -88,7 +98,9 @@ void __init rcar_gen2_timer_init(void)
 	}
 
 	/* Remap "armgcnt address map" space */
-	base = ioremap(0xe6080000, PAGE_SIZE);
+	base = ioremap(res.start, resource_size(&res));
+	if (!base)
+		goto out;
 
 	/*
 	 * Update the timer if it is either not running, or is not at the
@@ -109,6 +121,9 @@ void __init rcar_gen2_timer_init(void)
 
 	iounmap(base);
 
+out:
+	of_node_put(np);
+
 	of_clk_init(NULL);
 	timer_probe();
 }
-- 
2.7.4


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

end of thread, other threads:[~2019-05-14 13:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 16:22 [RFC PATCH] ARM: mach-shmobile: Parse DT to get ARCH timer memory region Oleksandr Tyshchenko
2019-05-13  9:19 ` Julien Grall
2019-05-13  9:56   ` Geert Uytterhoeven
2019-05-13 14:06   ` Oleksandr
2019-05-13 15:13     ` Geert Uytterhoeven
2019-05-13 16:00       ` Oleksandr
2019-05-14  7:16         ` Geert Uytterhoeven
2019-05-14 13:58           ` Oleksandr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).