From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 07/13] optee: add revision info to tee devinfo output
Date: Wed, 13 Aug 2025 16:33:39 +0200 [thread overview]
Message-ID: <20250813143345.3758653-8-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250813143345.3758653-1-a.fatoum@barebox.org>
We currently only report an implementation ID when doing devinfo on the
tee device. Improve upon that by translating the ID to a string and
printing the OP-TEE revision if possible.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
- use IS_ERR_OR_NULL to guard param getting
- use new get_param_value helper
---
drivers/tee/optee/smc_abi.c | 17 ++++++++++++-----
drivers/tee/tee_core.c | 20 +++++++++++++++++++-
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index aab8ebb186ed..56af3b1b2b29 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -549,8 +549,10 @@ static bool optee_msg_api_uid_is_optee_api(optee_invoke_fn *invoke_fn)
return false;
}
-static void optee_msg_get_os_revision(optee_invoke_fn *invoke_fn)
+static void optee_msg_get_os_revision(struct device *dev,
+ optee_invoke_fn *invoke_fn)
{
+ struct param_d *param;
union {
struct arm_smccc_res smccc;
struct optee_smc_call_get_os_revision_result result;
@@ -564,10 +566,15 @@ static void optee_msg_get_os_revision(optee_invoke_fn *invoke_fn)
&res.smccc);
if (res.result.build_id)
- pr_info("revision %lu.%lu (%08lx)\n", res.result.major,
- res.result.minor, res.result.build_id);
+ param = dev_add_param_fixed(dev, "revision", "%lu.%lu (%08lx)",
+ res.result.major, res.result.minor,
+ res.result.build_id);
else
- pr_info("revision %lu.%lu\n", res.result.major, res.result.minor);
+ param = dev_add_param_fixed(dev, "revision", "%lu.%lu",
+ res.result.major, res.result.minor);
+
+ if (!IS_ERR_OR_NULL(param))
+ pr_info("revision %s\n", get_param_value(param));
}
static bool optee_msg_api_revision_is_compatible(optee_invoke_fn *invoke_fn)
@@ -662,7 +669,7 @@ static int optee_probe(struct device *dev)
return -EINVAL;
}
- optee_msg_get_os_revision(invoke_fn);
+ optee_msg_get_os_revision(dev, invoke_fn);
if (!optee_msg_api_revision_is_compatible(invoke_fn)) {
pr_warn("api revision mismatch\n");
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index 653b04ff06af..a4bb9af46933 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -487,9 +487,27 @@ static void tee_devinfo(struct device *dev)
{
struct tee_device *teedev = dev->priv;
struct tee_ioctl_version_data vers;
+ const char *impl = NULL, *rev;
teedev->desc->ops->get_version(teedev, &vers);
- printf("Implementation ID: %d\n", vers.impl_id);
+
+ switch (vers.impl_id) {
+ case TEE_IMPL_ID_OPTEE:
+ impl = "optee";
+ break;
+ case TEE_IMPL_ID_AMDTEE:
+ impl = "amdtee";
+ break;
+ }
+
+ printf("Implementation ID: %d%s%s%s\n", vers.impl_id,
+ impl ? " ( " : "", impl, impl ? ")" : "");
+ if (!dev->parent)
+ return;
+
+ rev = dev_get_param(dev->parent, "revision");
+ if (rev)
+ printf("Revision: %s\n", rev);
}
/**
--
2.39.5
next prev parent reply other threads:[~2025-08-13 14:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 14:33 [PATCH v2 00/13] commands: add bfetch/buds of command redirection Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 01/13] common: introduce structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 02/13] ARM: cpuinfo: support structio output Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 03/13] commands: uptime: enable structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 04/13] string: implement strv_length helper Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 05/13] ARM: psci: client: add PSCI version/method parameters Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 06/13] net: move netmask_to_prefix into header Ahmad Fatoum
2025-08-13 14:33 ` Ahmad Fatoum [this message]
2025-08-13 14:33 ` [PATCH v2 08/13] tee: enable structured I/O in devinfo handler Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 09/13] security: blobgen: add easy way to check for existent providers Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 10/13] clk: implement clk_have_nonfixed_providers Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 11/13] commands: introduce bfetch command Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 12/13] configs: enable bfetch in some popular defconfigs Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 13/13] hush: structio: silence missing command error message Ahmad Fatoum
2025-08-14 10:53 ` [PATCH v2 00/13] commands: add bfetch/buds of command redirection Sascha Hauer
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=20250813143345.3758653-8-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.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