All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sumit Garg via OP-TEE <op-tee@lists.trustedfirmware.org>
To: Aristo Chen <jj251510319013@gmail.com>
Cc: linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org,
	harshal.dev@oss.qualcomm.com, mario.limonciello@amd.com,
	Rijo-john.Thomas@amd.com, amirreza.zarrabi@oss.qualcomm.com,
	Aristo Chen <aristo.chen@canonical.com>
Subject: Re: [PATCH v6 2/2] tee: optee: store OS revision for TEE core
Date: Mon, 12 Jan 2026 16:52:20 +0530	[thread overview]
Message-ID: <aWTZbH3G-PgOz4cz@sumit-xelite> (raw)
In-Reply-To: <CAJwFiG+GKKa-vYwWzY8Dyw7GsaTq90kAyHWz1NJ28Bni43-nTQ@mail.gmail.com>

On Fri, Jan 09, 2026 at 11:07:40PM +0800, Aristo Chen wrote:
> Hi Sumit
> 
> Sumit Garg <sumit.garg@kernel.org> 於 2026年1月9日週五 下午7:50寫道:
> >
> > On Thu, Jan 08, 2026 at 02:45:09PM +0800, Aristo Chen wrote:
> > > Collect OP-TEE OS revision from secure world for both SMC and FF-A
> > > ABIs, store it in the OP-TEE driver, and expose it through the
> > > generic get_tee_revision() callback.
> > >
> > > Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
> > > ---
> > >  drivers/tee/optee/core.c          | 23 +++++++++++++
> > >  drivers/tee/optee/ffa_abi.c       | 57 ++++++++++++++++++++++++-------
> > >  drivers/tee/optee/optee_private.h | 19 +++++++++++
> > >  drivers/tee/optee/smc_abi.c       | 15 ++++++--
> > >  4 files changed, 99 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> > > index 5b62139714ce..2d807bc748bc 100644
> > > --- a/drivers/tee/optee/core.c
> > > +++ b/drivers/tee/optee/core.c
> > > @@ -63,6 +63,29 @@ int optee_set_dma_mask(struct optee *optee, u_int pa_width)
> > >       return dma_coerce_mask_and_coherent(&optee->teedev->dev, mask);
> > >  }
> > >
> > > +int optee_get_revision(struct tee_device *teedev, char *buf, size_t len)
> > > +{
> > > +     struct optee *optee = tee_get_drvdata(teedev);
> > > +     u64 build_id;
> > > +
> > > +     if (!optee)
> > > +             return -ENODEV;
> > > +     if (!buf || !len)
> > > +             return -EINVAL;
> > > +
> > > +     build_id = optee->revision.os_build_id;
> > > +     if (build_id)
> > > +             scnprintf(buf, len, "%u.%u (%016llx)",
> > > +                       optee->revision.os_major,
> > > +                       optee->revision.os_minor,
> > > +                       (unsigned long long)build_id);
> > > +     else
> > > +             scnprintf(buf, len, "%u.%u", optee->revision.os_major,
> > > +                       optee->revision.os_minor);
> > > +
> > > +     return 0;
> > > +}
> > > +
> > >  static void optee_bus_scan(struct work_struct *work)
> > >  {
> > >       WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
> > > diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> > > index bf8390789ecf..82dbed1c87e5 100644
> > > --- a/drivers/tee/optee/ffa_abi.c
> > > +++ b/drivers/tee/optee/ffa_abi.c
> > > @@ -775,6 +775,42 @@ static int optee_ffa_reclaim_protmem(struct optee *optee,
> > >   * with a matching configuration.
> > >   */
> > >
> > > +static bool optee_ffa_get_os_revision(struct ffa_device *ffa_dev,
> > > +                                     const struct ffa_ops *ops,
> > > +                                     struct optee_revision *revision,
> > > +                                     bool log)
> > > +{
> > > +     const struct ffa_msg_ops *msg_ops = ops->msg_ops;
> > > +     struct ffa_send_direct_data data = {
> > > +             .data0 = OPTEE_FFA_GET_OS_VERSION,
> > > +     };
> > > +     int rc;
> > > +
> > > +     msg_ops->mode_32bit_set(ffa_dev);
> > > +
> > > +     rc = msg_ops->sync_send_receive(ffa_dev, &data);
> > > +     if (rc) {
> > > +             pr_err("Unexpected error %d\n", rc);
> > > +             return false;
> > > +     }
> > > +
> > > +     if (revision) {
> > > +             revision->os_major = data.data0;
> > > +             revision->os_minor = data.data1;
> > > +             revision->os_build_id = data.data2;
> > > +     }
> > > +
> > > +     if (log) {
> > > +             if (data.data2)
> > > +                     pr_info("revision %lu.%lu (%08lx)",
> > > +                             data.data0, data.data1, data.data2);
> > > +             else
> > > +                     pr_info("revision %lu.%lu", data.data0, data.data1);
> > > +     }
> > > +
> > > +     return true;
> > > +}
> > > +
> > >  static bool optee_ffa_api_is_compatible(struct ffa_device *ffa_dev,
> > >                                       const struct ffa_ops *ops)
> > >  {
> > > @@ -798,19 +834,8 @@ static bool optee_ffa_api_is_compatible(struct ffa_device *ffa_dev,
> > >               return false;
> > >       }
> > >
> > > -     data = (struct ffa_send_direct_data){
> > > -             .data0 = OPTEE_FFA_GET_OS_VERSION,
> > > -     };
> > > -     rc = msg_ops->sync_send_receive(ffa_dev, &data);
> > > -     if (rc) {
> > > -             pr_err("Unexpected error %d\n", rc);
> > > +     if (!optee_ffa_get_os_revision(ffa_dev, ops, NULL, true))
> >
> > Why do you need to invoke optee_ffa_get_os_revision() here?
> 
> I’m calling optee_ffa_get_os_revision() here to avoid duplicating the
> GET_OS_VERSION call/printing logic. The original code in
> optee_ffa_api_is_compatible() already did the OS version query and
> printed it; after factoring it out, the helper keeps that behavior in one
> place. If we don’t call it there, we’d either lose the existing dmesg log
> or re‑implement the same OS‑version query/print block again, which I’m
> trying to avoid.
> 
> If you’d rather avoid the extra call at this stage, maybe we can always
> print the log in the optee_ffa_get_os_revision() and remove the call
> from optee_ffa_api_is_compatible() entirely.

Yeah move the print to optee_ffa_get_os_revision() and drop the extra
call.

-Sumit

WARNING: multiple messages have this Message-ID (diff)
From: Sumit Garg <sumit.garg@kernel.org>
To: Aristo Chen <jj251510319013@gmail.com>
Cc: linux-kernel@vger.kernel.org, jens.wiklander@linaro.org,
	op-tee@lists.trustedfirmware.org, harshal.dev@oss.qualcomm.com,
	mario.limonciello@amd.com, Rijo-john.Thomas@amd.com,
	amirreza.zarrabi@oss.qualcomm.com,
	Aristo Chen <aristo.chen@canonical.com>
Subject: Re: [PATCH v6 2/2] tee: optee: store OS revision for TEE core
Date: Mon, 12 Jan 2026 16:52:20 +0530	[thread overview]
Message-ID: <aWTZbH3G-PgOz4cz@sumit-xelite> (raw)
In-Reply-To: <CAJwFiG+GKKa-vYwWzY8Dyw7GsaTq90kAyHWz1NJ28Bni43-nTQ@mail.gmail.com>

On Fri, Jan 09, 2026 at 11:07:40PM +0800, Aristo Chen wrote:
> Hi Sumit
> 
> Sumit Garg <sumit.garg@kernel.org> 於 2026年1月9日週五 下午7:50寫道:
> >
> > On Thu, Jan 08, 2026 at 02:45:09PM +0800, Aristo Chen wrote:
> > > Collect OP-TEE OS revision from secure world for both SMC and FF-A
> > > ABIs, store it in the OP-TEE driver, and expose it through the
> > > generic get_tee_revision() callback.
> > >
> > > Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
> > > ---
> > >  drivers/tee/optee/core.c          | 23 +++++++++++++
> > >  drivers/tee/optee/ffa_abi.c       | 57 ++++++++++++++++++++++++-------
> > >  drivers/tee/optee/optee_private.h | 19 +++++++++++
> > >  drivers/tee/optee/smc_abi.c       | 15 ++++++--
> > >  4 files changed, 99 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> > > index 5b62139714ce..2d807bc748bc 100644
> > > --- a/drivers/tee/optee/core.c
> > > +++ b/drivers/tee/optee/core.c
> > > @@ -63,6 +63,29 @@ int optee_set_dma_mask(struct optee *optee, u_int pa_width)
> > >       return dma_coerce_mask_and_coherent(&optee->teedev->dev, mask);
> > >  }
> > >
> > > +int optee_get_revision(struct tee_device *teedev, char *buf, size_t len)
> > > +{
> > > +     struct optee *optee = tee_get_drvdata(teedev);
> > > +     u64 build_id;
> > > +
> > > +     if (!optee)
> > > +             return -ENODEV;
> > > +     if (!buf || !len)
> > > +             return -EINVAL;
> > > +
> > > +     build_id = optee->revision.os_build_id;
> > > +     if (build_id)
> > > +             scnprintf(buf, len, "%u.%u (%016llx)",
> > > +                       optee->revision.os_major,
> > > +                       optee->revision.os_minor,
> > > +                       (unsigned long long)build_id);
> > > +     else
> > > +             scnprintf(buf, len, "%u.%u", optee->revision.os_major,
> > > +                       optee->revision.os_minor);
> > > +
> > > +     return 0;
> > > +}
> > > +
> > >  static void optee_bus_scan(struct work_struct *work)
> > >  {
> > >       WARN_ON(optee_enumerate_devices(PTA_CMD_GET_DEVICES_SUPP));
> > > diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> > > index bf8390789ecf..82dbed1c87e5 100644
> > > --- a/drivers/tee/optee/ffa_abi.c
> > > +++ b/drivers/tee/optee/ffa_abi.c
> > > @@ -775,6 +775,42 @@ static int optee_ffa_reclaim_protmem(struct optee *optee,
> > >   * with a matching configuration.
> > >   */
> > >
> > > +static bool optee_ffa_get_os_revision(struct ffa_device *ffa_dev,
> > > +                                     const struct ffa_ops *ops,
> > > +                                     struct optee_revision *revision,
> > > +                                     bool log)
> > > +{
> > > +     const struct ffa_msg_ops *msg_ops = ops->msg_ops;
> > > +     struct ffa_send_direct_data data = {
> > > +             .data0 = OPTEE_FFA_GET_OS_VERSION,
> > > +     };
> > > +     int rc;
> > > +
> > > +     msg_ops->mode_32bit_set(ffa_dev);
> > > +
> > > +     rc = msg_ops->sync_send_receive(ffa_dev, &data);
> > > +     if (rc) {
> > > +             pr_err("Unexpected error %d\n", rc);
> > > +             return false;
> > > +     }
> > > +
> > > +     if (revision) {
> > > +             revision->os_major = data.data0;
> > > +             revision->os_minor = data.data1;
> > > +             revision->os_build_id = data.data2;
> > > +     }
> > > +
> > > +     if (log) {
> > > +             if (data.data2)
> > > +                     pr_info("revision %lu.%lu (%08lx)",
> > > +                             data.data0, data.data1, data.data2);
> > > +             else
> > > +                     pr_info("revision %lu.%lu", data.data0, data.data1);
> > > +     }
> > > +
> > > +     return true;
> > > +}
> > > +
> > >  static bool optee_ffa_api_is_compatible(struct ffa_device *ffa_dev,
> > >                                       const struct ffa_ops *ops)
> > >  {
> > > @@ -798,19 +834,8 @@ static bool optee_ffa_api_is_compatible(struct ffa_device *ffa_dev,
> > >               return false;
> > >       }
> > >
> > > -     data = (struct ffa_send_direct_data){
> > > -             .data0 = OPTEE_FFA_GET_OS_VERSION,
> > > -     };
> > > -     rc = msg_ops->sync_send_receive(ffa_dev, &data);
> > > -     if (rc) {
> > > -             pr_err("Unexpected error %d\n", rc);
> > > +     if (!optee_ffa_get_os_revision(ffa_dev, ops, NULL, true))
> >
> > Why do you need to invoke optee_ffa_get_os_revision() here?
> 
> I’m calling optee_ffa_get_os_revision() here to avoid duplicating the
> GET_OS_VERSION call/printing logic. The original code in
> optee_ffa_api_is_compatible() already did the OS version query and
> printed it; after factoring it out, the helper keeps that behavior in one
> place. If we don’t call it there, we’d either lose the existing dmesg log
> or re‑implement the same OS‑version query/print block again, which I’m
> trying to avoid.
> 
> If you’d rather avoid the extra call at this stage, maybe we can always
> print the log in the optee_ffa_get_os_revision() and remove the call
> from optee_ffa_api_is_compatible() entirely.

Yeah move the print to optee_ffa_get_os_revision() and drop the extra
call.

-Sumit

  reply	other threads:[~2026-01-12 11:22 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21 14:12 [PATCH v1 1/1] tee: optee: expose OS revision via sysfs Wei Ming Chen
2025-11-21 14:12 ` Wei Ming Chen
2025-11-22  7:36 ` Harshal Dev via OP-TEE
2025-11-22  7:36   ` Harshal Dev
2025-11-22 14:59 ` [PATCH v2 " Wei Ming Chen
2025-11-22 14:59   ` Wei Ming Chen
2025-11-24  7:15   ` Jens Wiklander
2025-11-24  7:15     ` Jens Wiklander
2025-11-24 14:28     ` Thomas, Rijo-john via OP-TEE
2025-11-25  7:53     ` Sumit Garg via OP-TEE
2025-11-25  7:53       ` Sumit Garg
2025-11-25  7:55       ` Sumit Garg via OP-TEE
2025-11-25  7:55         ` Sumit Garg
2025-12-01 11:47         ` Aristo Chen
2025-12-01 11:47           ` Aristo Chen
2025-12-01 13:06           ` Jens Wiklander
2025-12-02  9:54             ` Aristo Chen
2025-12-03  7:50               ` Jens Wiklander
2025-12-07 14:01                 ` Aristo Chen
2025-12-09  8:30                   ` Jens Wiklander
2025-12-19 15:38                     ` Aristo Chen
2025-12-22  8:34                       ` Jens Wiklander
2025-12-22 10:07                         ` Sumit Garg via OP-TEE
2025-12-22 10:07                           ` Sumit Garg
2025-12-23  3:33                           ` Aristo Chen via OP-TEE
2025-12-26 13:19   ` [PATCH v3 " Aristo Chen
2025-12-26 13:19     ` Aristo Chen
2025-12-29  4:59     ` Sumit Garg via OP-TEE
2025-12-29  4:59       ` Sumit Garg
2025-12-30  5:17     ` [PATCH v4 1/2] tee: add revision sysfs attribute Aristo Chen
2025-12-30  5:17       ` Aristo Chen
2025-12-30  5:17       ` [PATCH v4 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2025-12-30  5:17         ` Aristo Chen
2026-01-05  5:20         ` Sumit Garg via OP-TEE
2026-01-05  5:20           ` Sumit Garg
2026-01-05  8:13           ` Aristo Chen
2026-01-05  8:13             ` Aristo Chen
2026-01-05  8:48             ` Sumit Garg via OP-TEE
2026-01-05  8:48               ` Sumit Garg
2026-01-05  4:53       ` [PATCH v4 1/2] tee: add revision sysfs attribute Sumit Garg via OP-TEE
2026-01-05  4:53         ` Sumit Garg
2026-01-07 15:26       ` [PATCH v5 " Aristo Chen
2026-01-07 15:26         ` Aristo Chen
2026-01-07 15:26         ` [PATCH v5 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-07 15:26           ` Aristo Chen
2026-01-07 15:28         ` [PATCH v5 1/2] tee: add revision sysfs attribute Mario Limonciello via OP-TEE
2026-01-07 15:28           ` Mario Limonciello
2026-01-08  2:55           ` Aristo Chen
2026-01-08  2:55             ` Aristo Chen
2026-01-08  3:01             ` Mario Limonciello (AMD) (kernel.org) via OP-TEE
2026-01-08  3:01               ` Mario Limonciello (AMD) (kernel.org)
2026-01-08  6:45         ` [PATCH v6 " Aristo Chen
2026-01-08  6:45           ` Aristo Chen
2026-01-08  6:45           ` [PATCH v6 2/2] tee: optee: store OS revision for TEE core Aristo Chen
2026-01-08  6:45             ` Aristo Chen
2026-01-09 11:50             ` Sumit Garg via OP-TEE
2026-01-09 11:50               ` Sumit Garg
2026-01-09 15:07               ` Aristo Chen
2026-01-09 15:07                 ` Aristo Chen
2026-01-12 11:22                 ` Sumit Garg via OP-TEE [this message]
2026-01-12 11:22                   ` Sumit Garg
2026-01-12  9:55             ` Jens Wiklander
2026-01-12 10:43               ` Aristo Chen
2026-01-09 11:48           ` [PATCH v6 1/2] tee: add revision sysfs attribute Sumit Garg via OP-TEE
2026-01-09 11:48             ` Sumit Garg
2026-01-12  9:50           ` Jens Wiklander
2026-01-12 15:48           ` [PATCH v7 " Aristo Chen via OP-TEE
2026-01-12 15:48             ` Aristo Chen
2026-01-12 15:48             ` [PATCH v7 2/2] tee: optee: store OS revision for TEE core Aristo Chen via OP-TEE
2026-01-12 15:48               ` Aristo Chen
2026-01-14 15:43               ` Jens Wiklander
2026-01-15  6:18               ` Sumit Garg via OP-TEE
2026-01-15  6:18                 ` Sumit Garg
2026-01-14 15:42             ` [PATCH v7 1/2] tee: add revision sysfs attribute Jens Wiklander

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=aWTZbH3G-PgOz4cz@sumit-xelite \
    --to=op-tee@lists.trustedfirmware.org \
    --cc=Rijo-john.Thomas@amd.com \
    --cc=amirreza.zarrabi@oss.qualcomm.com \
    --cc=aristo.chen@canonical.com \
    --cc=harshal.dev@oss.qualcomm.com \
    --cc=jj251510319013@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=sumit.garg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.