ipq40xx: use upstreamed SDI disable support
authorRobert Marko <robimarko@gmail.com>
Sat, 30 Sep 2023 11:19:30 +0000 (13:19 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Mon, 2 Oct 2023 17:03:30 +0000 (19:03 +0200)
Google WiFi board has what seems as debug version of TZ/QSEE and it is
always enabling SDI (Secure Debug Image) and in order to do a regular
reboot it must be disabled, as otherwise you are stuck in a debug state
where you are supposed to extract debug logs via QCA tooling which is not
helpfull at all for regular users.

So, instead of using our downstream version to disable SDI lets use the
version that was merged upstream and relies on a boolean property in the
SCM node instead of checking the compatible.

Signed-off-by: Robert Marko <robimarko@gmail.com>
Tested-by: Brian Norris <computersforpeace@gmail.com>
target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wifi.dts
target/linux/ipq40xx/patches-6.1/004-v6.7-firmware-qcom_scm-disable-SDI-if-required.patch [new file with mode: 0644]
target/linux/ipq40xx/patches-6.1/100-ARM-dts-qcom-ipq4019-add-label-to-SCM.patch [new file with mode: 0644]
target/linux/ipq40xx/patches-6.1/420-firmware-qcom-scm-Add-SDI-disable-support.patch [deleted file]
target/linux/ipq40xx/patches-6.1/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch [deleted file]

index f92c28973810a56a87f256e0ab171b9c0575ea6e..f2e39c87aef43e4017c25a86dbec16cee6ba5224 100644 (file)
        };
 };
 
+&scm {
+       qcom,sdi-enabled;
+};
+
 &tlmm {
        fw_pinmux: fw_pinmux {
                wp {
diff --git a/target/linux/ipq40xx/patches-6.1/004-v6.7-firmware-qcom_scm-disable-SDI-if-required.patch b/target/linux/ipq40xx/patches-6.1/004-v6.7-firmware-qcom_scm-disable-SDI-if-required.patch
new file mode 100644 (file)
index 0000000..1ef46d9
--- /dev/null
@@ -0,0 +1,83 @@
+From ff4aa3bc98258a240b9bbab53fd8d2fb8184c485 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Wed, 16 Aug 2023 18:45:39 +0200
+Subject: [PATCH] firmware: qcom_scm: disable SDI if required
+
+IPQ5018 has SDI (Secure Debug Image) enabled by TZ by default, and that
+means that WDT being asserted or just trying to reboot will hang the board
+in the debug mode and only pulling the power and repowering will help.
+Some IPQ4019 boards like Google WiFI have it enabled as well.
+
+Luckily, SDI can be disabled via an SCM call.
+
+So, lets use the boolean DT property to identify boards that have SDI
+enabled by default and use the SCM call to disable SDI during SCM probe.
+It is important to disable it as soon as possible as we might have a WDT
+assertion at any time which would then leave the board in debug mode,
+thus disabling it during SCM removal is not enough.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+Reviewed-by: Guru Das Srinagesh <quic_gurus@quicinc.com>
+Link: https://lore.kernel.org/r/20230816164641.3371878-2-robimarko@gmail.com
+Signed-off-by: Bjorn Andersson <andersson@kernel.org>
+---
+ drivers/firmware/qcom_scm.c | 30 ++++++++++++++++++++++++++++++
+ drivers/firmware/qcom_scm.h |  1 +
+ 2 files changed, 31 insertions(+)
+
+--- a/drivers/firmware/qcom_scm.c
++++ b/drivers/firmware/qcom_scm.c
+@@ -400,6 +400,29 @@ int qcom_scm_set_remote_state(u32 state,
+ }
+ EXPORT_SYMBOL(qcom_scm_set_remote_state);
++static int qcom_scm_disable_sdi(void)
++{
++      int ret;
++      struct qcom_scm_desc desc = {
++              .svc = QCOM_SCM_SVC_BOOT,
++              .cmd = QCOM_SCM_BOOT_SDI_CONFIG,
++              .args[0] = 1, /* Disable watchdog debug */
++              .args[1] = 0, /* Disable SDI */
++              .arginfo = QCOM_SCM_ARGS(2),
++              .owner = ARM_SMCCC_OWNER_SIP,
++      };
++      struct qcom_scm_res res;
++
++      ret = qcom_scm_clk_enable();
++      if (ret)
++              return ret;
++      ret = qcom_scm_call(__scm->dev, &desc, &res);
++
++      qcom_scm_clk_disable();
++
++      return ret ? : res.result[0];
++}
++
+ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
+ {
+       struct qcom_scm_desc desc = {
+@@ -1404,6 +1427,13 @@ static int qcom_scm_probe(struct platfor
+       __get_convention();
++
++      /*
++       * Disable SDI if indicated by DT that it is enabled by default.
++       */
++      if (of_property_read_bool(pdev->dev.of_node, "qcom,sdi-enabled"))
++              qcom_scm_disable_sdi();
++
+       /*
+        * If requested enable "download mode", from this point on warmboot
+        * will cause the boot stages to enter download mode, unless
+--- a/drivers/firmware/qcom_scm.h
++++ b/drivers/firmware/qcom_scm.h
+@@ -77,6 +77,7 @@ extern int scm_legacy_call(struct device
+ #define QCOM_SCM_SVC_BOOT             0x01
+ #define QCOM_SCM_BOOT_SET_ADDR                0x01
+ #define QCOM_SCM_BOOT_TERMINATE_PC    0x02
++#define QCOM_SCM_BOOT_SDI_CONFIG      0x09
+ #define QCOM_SCM_BOOT_SET_DLOAD_MODE  0x10
+ #define QCOM_SCM_BOOT_SET_ADDR_MC     0x11
+ #define QCOM_SCM_BOOT_SET_REMOTE_STATE        0x0a
diff --git a/target/linux/ipq40xx/patches-6.1/100-ARM-dts-qcom-ipq4019-add-label-to-SCM.patch b/target/linux/ipq40xx/patches-6.1/100-ARM-dts-qcom-ipq4019-add-label-to-SCM.patch
new file mode 100644 (file)
index 0000000..8b9352e
--- /dev/null
@@ -0,0 +1,24 @@
+From ea9fba16d972becc84cd2a82d25030975dc609a5 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Sat, 30 Sep 2023 13:09:27 +0200
+Subject: [PATCH] ARM: dts: qcom: ipq4019: add label to SCM
+
+Some IPQ4019 boards require SDI to be disabled by adding a property to the
+SCM node, so lets make that easy by adding a label to the SCM node.
+
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+---
+ arch/arm/boot/dts/qcom-ipq4019.dtsi | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
++++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
+@@ -155,7 +155,7 @@
+       };
+       firmware {
+-              scm {
++              scm: scm {
+                       compatible = "qcom,scm-ipq4019", "qcom,scm";
+               };
+       };
diff --git a/target/linux/ipq40xx/patches-6.1/420-firmware-qcom-scm-Add-SDI-disable-support.patch b/target/linux/ipq40xx/patches-6.1/420-firmware-qcom-scm-Add-SDI-disable-support.patch
deleted file mode 100644 (file)
index 732f3c5..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-From b514bc3c0a5a57bc83843dc66c72788b9c9435ac Mon Sep 17 00:00:00 2001
-From: Robert Marko <robimarko@gmail.com>
-Date: Thu, 18 May 2023 16:02:23 +0200
-Subject: [PATCH 1/3] firmware: qcom: scm: Add SDI disable support
-
-Some SoC-s like IPQ5018 require SDI(Secure Debug Image) to be disabled
-before trying to reboot, otherwise board will just hang after reboot has
-been issued via PSCI.
-
-So, provide a call to SCM that allows disabling it.
-
-Signed-off-by: Robert Marko <robimarko@gmail.com>
-Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
----
- drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++
- drivers/firmware/qcom_scm.h |  1 +
- 2 files changed, 24 insertions(+)
-
---- a/drivers/firmware/qcom_scm.c
-+++ b/drivers/firmware/qcom_scm.c
-@@ -400,6 +400,29 @@ int qcom_scm_set_remote_state(u32 state,
- }
- EXPORT_SYMBOL(qcom_scm_set_remote_state);
-+static int qcom_scm_disable_sdi(void)
-+{
-+      int ret;
-+      struct qcom_scm_desc desc = {
-+              .svc = QCOM_SCM_SVC_BOOT,
-+              .cmd = QCOM_SCM_BOOT_SDI_CONFIG,
-+              .args[0] = 1, /* Disable watchdog debug */
-+              .args[1] = 0, /* Disable SDI */
-+              .arginfo = QCOM_SCM_ARGS(2),
-+              .owner = ARM_SMCCC_OWNER_SIP,
-+      };
-+      struct qcom_scm_res res;
-+
-+      ret = qcom_scm_clk_enable();
-+      if (ret)
-+              return ret;
-+      ret = qcom_scm_call(__scm->dev, &desc, &res);
-+
-+      qcom_scm_clk_disable();
-+
-+      return ret ? : res.result[0];
-+}
-+
- static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
- {
-       struct qcom_scm_desc desc = {
---- a/drivers/firmware/qcom_scm.h
-+++ b/drivers/firmware/qcom_scm.h
-@@ -77,6 +77,7 @@ extern int scm_legacy_call(struct device
- #define QCOM_SCM_SVC_BOOT             0x01
- #define QCOM_SCM_BOOT_SET_ADDR                0x01
- #define QCOM_SCM_BOOT_TERMINATE_PC    0x02
-+#define QCOM_SCM_BOOT_SDI_CONFIG      0x09
- #define QCOM_SCM_BOOT_SET_DLOAD_MODE  0x10
- #define QCOM_SCM_BOOT_SET_ADDR_MC     0x11
- #define QCOM_SCM_BOOT_SET_REMOTE_STATE        0x0a
diff --git a/target/linux/ipq40xx/patches-6.1/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch b/target/linux/ipq40xx/patches-6.1/421-firmware-qcom-scm-disable-SDI-on-Google-WiFi.patch
deleted file mode 100644 (file)
index ff788c5..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-From a658ad57c2b9d46eb5395c7bb8cf83b8e0f289e7 Mon Sep 17 00:00:00 2001
-From: Brian Norris <computersforpeace@gmail.com>
-Date: Fri, 28 Jul 2023 12:02:19 +0200
-Subject: [PATCH 2/3] firmware: qcom: scm: disable SDI on Google WiFi
-
-Google WiFi seems to have SDI (Secure Debug Image) enabled by default which
-prevents normal reboot from working causing the board to just hang after
-reboot is called.
-
-So lets disable SDI during SCM probe on Google WiFi boards in order to
-avoid a state where WDT will kick in and then the board will just hang
-in the debug mode.
-
-Signed-off-by: Brian Norris <computersforpeace@gmail.com>
----
- drivers/firmware/qcom_scm.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
---- a/drivers/firmware/qcom_scm.c
-+++ b/drivers/firmware/qcom_scm.c
-@@ -1435,6 +1435,13 @@ static int qcom_scm_probe(struct platfor
-       if (download_mode)
-               qcom_scm_set_download_mode(true);
-+      /*
-+       * Factory firmware leaves SDI (a debug interface), which prevents
-+       * clean reboot.
-+       */
-+      if (of_machine_is_compatible("google,wifi"))
-+              qcom_scm_disable_sdi();
-+
-       return 0;
- }