Skip to contentSkip to conversation

dt-bindings: firmware: qcom,scm: Document SDI disable

PATCH In review Robert Marko 5 participants 14 messages Aug 15, 2023 – Sep 15, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/5 dt-bindings: firmware: qcom,scm: Document SDI disable

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.

So, lets add a boolean property to indicate that SDI should be disabled.

---
 Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +8 -0
index 4233ea839bfc..bf753192498a 100644
@@ -89,6 +89,14 @@ properties:
       protocol to handle sleeping SCM calls.
     maxItems: 1
 
+  qcom,sdi-disable:
+    description:
+      Indicates that the SDI (Secure Debug Image) has been enabled by TZ
+      by default and it needs to be disabled.
+      If not disabled WDT assertion or reboot will cause the board to hang
+      in the debug mode.
+    type: boolean
+
   qcom,dload-mode:
     $ref: /schemas/types.yaml#/definitions/phandle-array
     items:
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 2/5 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.

---
 drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++
 drivers/firmware/qcom_scm.h |  1 +
 2 files changed, 24 insertions(+)
drivers/firmware/qcom_scm.c +23 -0
index 06fe8aca870d..abb54df663ea 100644
@@ -403,6 +403,29 @@ int qcom_scm_set_remote_state(u32 state, u32 id)
 }
 EXPORT_SYMBOL_GPL(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 = {
drivers/firmware/qcom_scm.h +1 -0
index e6e512bd57d1..7b68fa820495 100644
@@ -80,6 +80,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,
 #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
Signature · 1 line
2.41.0
#2 lore raw

Re: [PATCH v2 2/5] firmware: qcom: scm: Add SDI disable support

Quoted 4 lines · Robert Marko

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.

Quoted 8 lines

So, provide a call to SCM that allows disabling it.

---
 drivers/firmware/qcom_scm.c | 23 +++++++++++++++++++++++
 drivers/firmware/qcom_scm.h |  1 +
 2 files changed, 24 insertions(+)

This should be squashed with next patch. Adding local function without user is useless.

Best regards,
Krzysztof

#3 lore raw

PATCH v2 3/5 firmware: qcom_scm: disable SDI if required

In reply to Robert Marko

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.

So, lets use the boolean DT property 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.

---
 drivers/firmware/qcom_scm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/firmware/qcom_scm.c +6 -0
index abb54df663ea..71d886626233 100644
@@ -1491,6 +1491,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
 	if (download_mode)
 		qcom_scm_set_download_mode(true);
 
+	/*
+	 * Disable SDI if indicated by DT.
+	 */
+	if (of_property_read_bool(pdev->dev.of_node, "qcom,sdi-disable"))
+		qcom_scm_disable_sdi();
+
 	return 0;
 }
 
Signature · 1 line
2.41.0
#4 lore raw

PATCH v2 4/5 dt-bindings: firmware: qcom,scm: document IPQ5018 compatible

In reply to Robert Marko

It seems that IPQ5018 compatible was never documented in the bindings.

---
 Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +1 -0
index bf753192498a..212ad5f32408 100644
@@ -24,6 +24,7 @@ properties:
           - qcom,scm-apq8064
           - qcom,scm-apq8084
           - qcom,scm-ipq4019
+          - qcom,scm-ipq5018
           - qcom,scm-ipq5332
           - qcom,scm-ipq6018
           - qcom,scm-ipq806x
Signature · 1 line
2.41.0
#6 lore raw

Re: [PATCH v2 4/5] dt-bindings: firmware: qcom,scm: document IPQ5018 compatible

Quoted 9 lines · Krzysztof Kozlowski
Quoted 5 lines · Robert Marko

It seems that IPQ5018 compatible was never documented in the bindings.

---
  Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 1 +

I earlier posted this here, [1]

[1] https://www.spinics.net/lists/linux-mmc/msg77015.html

Regards,
Sricharan

#7 lore raw

Re: [PATCH v2 4/5] dt-bindings: firmware: qcom,scm: document IPQ5018 compatible

Quoted 10 lines · Sricharan Ramabadhran
Quoted 7 lines · Krzysztof Kozlowski
Quoted 5 lines · Robert Marko

It seems that IPQ5018 compatible was never documented in the bindings.

---
  Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 1 +
Quoted 6 lines
Quoted 2 lines

I earlier posted this here, [1]

[1] https://www.spinics.net/lists/linux-mmc/msg77015.html

So it should be applied... although status said superseded. No clue, please check with Bjorn.

https://patchwork.kernel.org/project/linux-arm-msm/list/?series=770464&state=*

Best regards,
Krzysztof

#8 lore raw

PATCH v2 5/5 arm64: dts: qcom: ipq5018: indicate that SDI should be disabled

In reply to Robert Marko

Now that SCM has support for disabling SDI if indicated by DT, lets set it for IPQ5018 as it has SDI enabled by default and it must be disabled.

---
 arch/arm64/boot/dts/qcom/ipq5018.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/ipq5018.dtsi +1 -0
index 9f13d2dcdfd5..3285c86824cf 100644
@@ -57,6 +57,7 @@ L2_0: l2-cache {
 	firmware {
 		scm {
 			compatible = "qcom,scm-ipq5018", "qcom,scm";
+			qcom,sdi-disable;
 		};
 	};
 
Signature · 1 line
2.41.0
#9 lore raw
In reply to Robert Marko
Quoted 17 lines · Robert Marko

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.

So, lets add a boolean property to indicate that SDI should be disabled.

---
 Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +0 -0
index 4233ea839bfc..bf753192498a 100644

Documentation/devicetree/bindings/firmware/qcom,scm.yaml properties: · line 92

Quoted 4 lines
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +1 -0
@@ -89,6 +89,14 @@ properties:
       protocol to handle sleeping SCM calls.
     maxItems: 1
 
+  qcom,sdi-disable:

The property should describe rather current hardware/firmware state, instead of expressing your intention for OS what to do. Therefore rather:
qcom,sdi-enabled
or
qcom,secure-debug-image

Best regards,
Krzysztof

maintainer
#10 lore raw
Quoted 21 lines · Krzysztof Kozlowski
Quoted 20 lines · Robert Marko

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.

So, lets add a boolean property to indicate that SDI should be disabled.

---
 Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +0 -0
index 4233ea839bfc..bf753192498a 100644
@@ -89,6 +89,14 @@ properties:
       protocol to handle sleeping SCM calls.
     maxItems: 1
 
Quoted 7 lines

Documentation/devicetree/bindings/firmware/qcom,scm.yaml properties: · line 92

Quoted 1 line
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +1 -0
+  qcom,sdi-disable:

The property should describe rather current hardware/firmware state, instead of expressing your intention for OS what to do. Therefore rather:
qcom,sdi-enabled
or
qcom,secure-debug-image

Why can't you just disable SDI unconditionally when going into debug mode? Is doing that when not enabled going to crash the system or something?

Rob

#11 lore raw
Quoted 31 lines · Rob Herring
Quoted 21 lines · Krzysztof Kozlowski
Quoted 20 lines · Robert Marko

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.

So, lets add a boolean property to indicate that SDI should be disabled.

---
 Documentation/devicetree/bindings/firmware/qcom,scm.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +0 -0
index 4233ea839bfc..bf753192498a 100644
@@ -89,6 +89,14 @@ properties:
       protocol to handle sleeping SCM calls.
     maxItems: 1
 
Quoted 7 lines

Documentation/devicetree/bindings/firmware/qcom,scm.yaml properties: · line 92

Quoted 1 line
Documentation/devicetree/bindings/firmware/qcom,scm.yaml +1 -0
+  qcom,sdi-disable:

The property should describe rather current hardware/firmware state, instead of expressing your intention for OS what to do. Therefore rather:
qcom,sdi-enabled
or
qcom,secure-debug-image

Quoted 3 lines

Why can't you just disable SDI unconditionally when going into debug mode? Is doing that when not enabled going to crash the system or something?

Because if not disabled you will enter the Secure Debug mode even on a regular reboot and then you have to pull the power in order to boot again. Even according to QCA docs they intended for the Linux to disable SDI as TZ/QSEE will always enable it as part of booting.

Regards,
Robert

Quoted 3 lines

Rob

#12 lore raw
Quoted 4 lines · Robert Marko
Quoted 3 lines · Rob Herring

Why can't you just disable SDI unconditionally when going into debug mode? Is doing that when not enabled going to crash the system or something?

I asked the same, to resounding silence:

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/ZNlhSdh0qDMieTAS@localhost/

Quoted 4 lines

Because if not disabled you will enter the Secure Debug mode even on a regular reboot and then you have to pull the power in order to boot again. Even according to QCA docs they intended for the Linux to disable SDI as TZ/QSEE will always enable it as part of booting.

NB: I've never read such docs. Presumably they're internal/private to Qualcomm and/or its direct partners? I'd love to see them.

But, I think you (robinmarko) are not really answering the same question that Rob (robh) is asking. Rob is asking why you ever *don't* want to disable SDI. You're answering why we ever need to disable it at all. I don't think the latter question is controversial.

FWIW, your description of those docs sounds like we should unconditionally *disable* SDI (like my first RFC above), which would answer Rob's question, and would agree with my RFC above :) And as a bonus, no Device Tree change would be required.

Brian

#13 lore raw
Quoted 12 lines · Brian Norris
Quoted 4 lines · Robert Marko
Quoted 3 lines · Rob Herring

Why can't you just disable SDI unconditionally when going into debug mode? Is doing that when not enabled going to crash the system or something?

I asked the same, to resounding silence:

https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/ZNlhSdh0qDMieTAS@localhost/

Quoted 7 lines
Quoted 4 lines

Because if not disabled you will enter the Secure Debug mode even on a regular reboot and then you have to pull the power in order to boot again. Even according to QCA docs they intended for the Linux to disable SDI as TZ/QSEE will always enable it as part of booting.

NB: I've never read such docs. Presumably they're internal/private to Qualcomm and/or its direct partners? I'd love to see them.

Sadly they are all behind the NDA.

Quoted 5 lines

But, I think you (robinmarko) are not really answering the same question that Rob (robh) is asking. Rob is asking why you ever *don't* want to disable SDI. You're answering why we ever need to disable it at all. I don't think the latter question is controversial.

I understood his question differently, hence my answer.

Quoted 5 lines

FWIW, your description of those docs sounds like we should unconditionally *disable* SDI (like my first RFC above), which would answer Rob's question, and would agree with my RFC above :) And as a bonus, no Device Tree change would be required.

Well, the thing is that I only have docs for some of the IPQ chips, and with the insane variety of SoC-s that use SCM and TZ/QSEE but completely different FW base or version something would break for sure so I would prefer to opt-in if its really required as SDI was something that was until IPQ5018 came along, always disabled by default, except for the weird Google WiFI board.

Regards,
Robert

Quoted 2 lines

Brian