From: Brian Norris <computersforpeace@gmail.com>
To: Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, <linux-kernel@vger.kernel.org>,
Brian Norris <computersforpeace@gmail.com>
Subject: [RFC PATCH] firmware: qcom_scm: disable SDI at boot
Date: Tue, 21 Jul 2020 01:00:54 -0700 [thread overview]
Message-ID: <20200721080054.2803881-1-computersforpeace@gmail.com> (raw)
*** Disclaimer: I know extremely little about Qualcomm's undocumented
SMC API. ***
I'm trying to get upstream support for an IPQ4019 device I have, and by
default, warm boot does not work properly -- it appears to trap into
TrustZone. I find that the downstream/vendor kernel makes this call at
boot, with notes about the watchdog and SDI configuration. It appears
some of this is leftover from when they had download-mode enabled, as
well as some other debug features, and they didn't get completely turned
off in the production bootloader. But I reall can't tell that well; I'm
just going off the minimal source code and git logs.
Because this is so undocumented, I can't tell what the right thing to do
is -- should this go behind a DT property? Should I apply it only for
ipq4019? Is there a better way to describe and document the bits used in
this command?
If it helps, I can try to shop around for some testing on other systems.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/firmware/qcom_scm.c | 20 ++++++++++++++++++++
drivers/firmware/qcom_scm.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 0e7233a20f34..70c46f1668d1 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -394,6 +394,20 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
return qcom_scm_call(__scm->dev, &desc, NULL);
}
+static int __qcom_scm_disable_sdi(struct device *dev)
+{
+ struct qcom_scm_desc desc = {
+ .svc = QCOM_SCM_SVC_BOOT,
+ .cmd = QCOM_SCM_BOOT_CONFIG_SDI,
+ .arginfo = QCOM_SCM_ARGS(2),
+ .args[0] = 1 /* 1: disable watchdog debug */,
+ .args[1] = 0 /* 0: disable SDI */,
+ .owner = ARM_SMCCC_OWNER_SIP,
+ };
+
+ return qcom_scm_call(__scm->dev, &desc, NULL);
+}
+
static void qcom_scm_set_download_mode(bool enable)
{
bool avail;
@@ -1122,6 +1136,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
if (download_mode)
qcom_scm_set_download_mode(true);
+ /*
+ * Some bootloaders leave this enabled by default, which prevents
+ * normal warm reboot.
+ */
+ __qcom_scm_disable_sdi(__scm->dev);
+
return 0;
}
diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h
index d9ed670da222..39c3dc0dfc50 100644
--- a/drivers/firmware/qcom_scm.h
+++ b/drivers/firmware/qcom_scm.h
@@ -74,6 +74,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_CONFIG_SDI 0x09
#define QCOM_SCM_BOOT_SET_DLOAD_MODE 0x10
#define QCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a
#define QCOM_SCM_FLUSH_FLAG_MASK 0x3
--
2.27.0
reply other threads:[~2020-07-21 8:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200721080054.2803881-1-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).