ipq40xx: Move reserved-memory DT to qcom-ipq4019.dtsi
authorSven Eckelmann <sven.eckelmann@openmesh.com>
Wed, 18 Apr 2018 07:48:51 +0000 (09:48 +0200)
committerMathias Kresin <dev@kresin.me>
Fri, 20 Apr 2018 18:58:52 +0000 (20:58 +0200)
The tz and smem reserved-memory information handled in the upstream Linux
sources by the SoC specific dtsi and not by the the boards dts. Using the
same approach in OpenWrt avoids unneccessary duplication.

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4018-a42.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4018-ex61x0v2.dtsi
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4018-fritz4040.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4018-jalapeno.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4018-rt-ac58u.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4028-wpj428.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4029-gl-b1300.dts
target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4029-mr33.dts
target/linux/ipq40xx/patches-4.14/864-07-dts-ipq4019-ap-dk01.1-c1-add-spi-and-ram-nodes.patch
target/linux/ipq40xx/patches-4.14/865-ARM-dts-ipq4019-Add-TZ-and-SMEM-reserved-regions.patch [new file with mode: 0644]

index 3838f884a8355d31d30fa05507af0bc754a234fa..20330afc664f3d24668b23ee059cd59fc17b6150 100644 (file)
        model = "OpenMesh A42";
        compatible = "openmesh,a42", "qcom,ipq4019";
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index 14c1caa969895d0e46f874296c93eeba177e83a0..dd0098eb8bd7ccba479c8b87cf61e79f2c4823d0 100644 (file)
        model = "Netgear EX61X0v2";
        compatible = "netgear,ex61x0v2", "qcom,ipq4019";
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index 865e1fb1cefc83828352c64ffa8ef2c65aaa0854..3768cd87b9d83d52a7e3c2d2744309296f343ba2 100644 (file)
                led-upgrade = &flash;
        };
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index f9ea31acb4b4af33e17ce9736d05ee0b93cb37e9..ee203b0f1e24aea7c41ef95295337cc8f788f9a7 100644 (file)
        model = "8devices Jalapeno";
        compatible = "8dev,jalapeno", "qcom,ipq4019";
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index 446da0451b1086c7194b7416f1e7e08865d529e2..e0bb968f5bb4603da7d9948d57a41630ed6b2136 100644 (file)
                led-upgrade = &power;
        };
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index e970e769a6ded046f2cef23f0b92ab45cd1cd339..f9f0f96ae9c9adcff159f060038af8e539e6a8ca 100644 (file)
        model = "Compex WPJ428";
        compatible = "compex,wpj428", "qcom,ipq4019";
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index a34d2cd1c9edbb34b20ac57be4cb021aeb0a6d1c..b55d9453bf82d53ab4439cadd2431c5d57477fa1 100644 (file)
                reg = <0x80000000 0x10000000>;
        };
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index c52bcf1b02e5b30e3e17cc3c2f712b11578a196a..8bbfb0ba0bb1e1efed969d189cf7c129eeac0b1c 100644 (file)
                reg = <0x80000000 0x10000000>;
        };
 
-       reserved-memory {
-               #address-cells = <0x1>;
-               #size-cells = <0x1>;
-               ranges;
-
-               smem@87e00000 {
-                       reg = <0x87e00000 0x080000>;
-                       no-map;
-               };
-
-               tz@87e80000 {
-                       reg = <0x87e80000 0x180000>;
-                       no-map;
-               };
-       };
-
        soc {
                mdio@90000 {
                        status = "okay";
index 3043d63f3e3ed43402c23fb7522fbeff675b30f0..a358a56eae69b534de71f4bb60a26d7c081fdb72 100644 (file)
@@ -1,6 +1,6 @@
 --- a/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1-c1.dts
 +++ b/arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1-c1.dts
-@@ -19,4 +19,87 @@
+@@ -19,4 +19,71 @@
  / {
        model = "Qualcomm Technologies, Inc. IPQ40xx/AP-DK01.1-C1";
  
@@ -8,22 +8,6 @@
 +              device_type = "memory";
 +              reg = <0x80000000 0x10000000>;
 +      };
-+
-+      reserved-memory {
-+              #address-cells = <0x1>;
-+              #size-cells = <0x1>;
-+              ranges;
-+
-+              smem@87e00000 {
-+                      reg = <0x87e00000 0x080000>;
-+                      no-map;
-+              };
-+
-+              tz@87e80000 {
-+                      reg = <0x87e80000 0x180000>;
-+                      no-map;
-+              };
-+      };
 +};
 +
 +&spi_0 {
diff --git a/target/linux/ipq40xx/patches-4.14/865-ARM-dts-ipq4019-Add-TZ-and-SMEM-reserved-regions.patch b/target/linux/ipq40xx/patches-4.14/865-ARM-dts-ipq4019-Add-TZ-and-SMEM-reserved-regions.patch
new file mode 100644 (file)
index 0000000..56ae66b
--- /dev/null
@@ -0,0 +1,88 @@
+From fc566294610fa49e9d8c31c4ecc9c82f49b11f59 Mon Sep 17 00:00:00 2001
+From: Sven Eckelmann <sven.eckelmann@openmesh.com>
+Date: Wed, 18 Apr 2018 09:10:44 +0200
+Subject: [PATCH] ARM: dts: ipq4019: Add TZ and SMEM reserved regions
+
+The QSEE (trustzone) is started on IPQ4019 before Linux is started.
+According to QCA, it is placed in in the the memory region
+0x87e80000-0x88000000 and must not be accessed directly. There is an
+additional memory region 0x87e00000-0x87E80000 smem which which can be used
+for communication with the TZ. The driver for the latter is not yet ready
+but it is still not allowed to use this memory region like any other
+memory region.
+
+Not reserving this memory region either leads to kernel crashes, kernel
+hangs (often during the boot) or bus errors for userspace programs. The
+latter happens when a program is using a memory region which is mapped to
+these physical memory regions.
+
+  [  571.758058] Unhandled fault: imprecise external abort (0xc06) at 0x01715ff8
+  [  571.758099] pgd = cebec000
+  [  571.763826] [01715ff8] *pgd=8e7fa835, *pte=87e7f75f, *ppte=87e7fc7f
+  Bus error
+
+Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
+
+Forwarded: https://patchwork.kernel.org/patch/10347459/
+---
+Cc: Sricharan Ramabadhran <srichara@qti.qualcomm.com>
+Cc: Senthilkumar N L <snlakshm@qti.qualcomm.com>
+
+There are additional memory regions which have to be initialized first by
+Linux. So they are currently not used. We were told by QCA that the
+features QSDK uses them for are:
+
+* crash dump feature
+  - a couple of regions used when 'qca,scm_restart_reason' dt node has the
+    value 'dload_status' not set to 1
+    + apps_bl <0x87000000 0x400000>
+    + sbl <0x87400000 0x100000>
+    + cnss_debug <0x87400000 0x100000>
+    + cpu_context_dump <0x87b00000 0x080000>
+  - required driver not available in Linux
+  - safe to remove
+* QSEE app execution
+  - region tz_apps <0x87b80000 0x280000>
+  - required driver not available in Linux
+  - safe to remove
+* communication with TZ/QSEE
+  - region smem <0x87b80000 0x280000>
+  - driver changes not yet upstreamed
+  - must not be removed because any access can crash kernel/program
+* trustzone (QSEE) private memory
+  - region tz <0x87e80000 0x180000>
+  - must not be removed because any access can crash kernel/program
+
+The problem with the missing regions was reported in 2016 [1]. So maybe
+this change qualifies for a stable@vger.kernel.org submission.
+
+[1] https://www.spinics.net/lists/linux-arm-msm/msg21536.html
+---
+ arch/arm/boot/dts/qcom-ipq4019.dtsi | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
++++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
+@@ -23,6 +23,22 @@
+       compatible = "qcom,ipq4019";
+       interrupt-parent = <&intc>;
++      reserved-memory {
++              #address-cells = <0x1>;
++              #size-cells = <0x1>;
++              ranges;
++
++              smem_region: smem@87e00000 {
++                      reg = <0x87e00000 0x080000>;
++                      no-map;
++              };
++
++              tz@87e80000 {
++                      reg = <0x87e80000 0x180000>;
++                      no-map;
++              };
++      };
++
+       aliases {
+               spi0 = &spi_0;
+               spi1 = &spi_1;