From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22655356A10 for ; Mon, 12 Jan 2026 11:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768216949; cv=none; b=NM4UEj1Sn0B37oBzJiMLBZYu8fQG1aCzXFw6yRJ01EXHHDLrrIKneMtfD3z6y2h0YwbTV5YmahlNKlC5aftQBNgiidFjR3FW0Uc25y/LSbuEAQjf8/ya2Zor4Tm4QCvWQAP9rOqx0vqCdny9sJFY7kuMffYPuzU4a8JSBpUpxwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768216949; c=relaxed/simple; bh=ZNhUJoEkfFZHV8lEIh9qAH7JsrlKQ0N3Vtt30fWOdh8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZnC9itdsL40GXn4nQvROKYdeSenYcnhbpGlzemBpB8acs2lcf7o/ARiipZ6tyPHmwa0wUkrJ4drfnG+MOn76PySjBg5FA6bNpDYKUJcwoWYRU9HPJrY08daF4A5u4AkNF6Ppoz+f7fvjXr4y81Ze2fhWiT590yVE0gxpMMwdWn8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aZ0GmMFJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aZ0GmMFJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CC44C16AAE; Mon, 12 Jan 2026 11:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768216946; bh=ZNhUJoEkfFZHV8lEIh9qAH7JsrlKQ0N3Vtt30fWOdh8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aZ0GmMFJxammjEZzzQZRjD0eX4IF5kT9fvCTEfaPCBo7lQYrnCQpiUrBd3aOyyAmO RfKzh4D1frgE4GgAeCE0O/qI4gEQSiuirqhyfbmPTDRBQBP2aycPIKPFjLUg0CfyUN 7MSL/vgYZeHOnVnKQQH3Pk/3qlx/j+9GXwYuZEEBmeIbsMAub/5VC8oZ1/c6IVjgHi Ynq0s3nWT5OWN0eLNvVIVh0ozWfJ/VdEtdOIE2AZ8wfAy8u/+8LslxwathysQD3OzO noJ4XFIQdADkPDy20AnisIn1uiZEBTXPIsoLpqB08xc42ZIrS+nP9Q3Peh8iCfJE+U Bv34aHXRTfIdQ== Date: Mon, 12 Jan 2026 16:52:20 +0530 From: Sumit Garg To: Aristo Chen 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 Subject: Re: [PATCH v6 2/2] tee: optee: store OS revision for TEE core Message-ID: References: <20260107152607.902735-1-aristo.chen@canonical.com> <20260108064517.13854-1-aristo.chen@canonical.com> <20260108064517.13854-2-aristo.chen@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 09, 2026 at 11:07:40PM +0800, Aristo Chen wrote: > Hi Sumit > > Sumit Garg 於 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 > > > --- > > > 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