[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231030155901.80673-2-sumit.garg@linaro.org>
Date: Mon, 30 Oct 2023 21:29:00 +0530
From: Sumit Garg <sumit.garg@...aro.org>
To: jens.wiklander@...aro.org, op-tee@...ts.trustedfirmware.org
Cc: jan.kiszka@...mens.com, arnd@...aro.org, ardb@...nel.org,
jerome.forissier@...aro.org, ilias.apalodimas@...aro.org,
masahisa.kojima@...aro.org, maxim.uvarov@...aro.org,
jarkko.sakkinen@...ux.intel.com, linux-kernel@...r.kernel.org,
diogo.ivo@...mens.com, Sumit Garg <sumit.garg@...aro.org>
Subject: [PATCH v3 1/2] tee: optee: Fix supplicant based device enumeration
Currently supplicant dependent optee device enumeration only registers
devices whenever tee-supplicant is invoked for the first time. But it
forgets to remove devices when tee-supplicant daemon stops running and
closes its context gracefully. This leads to following error for fTPM
driver during reboot/shutdown:
[ 73.466791] tpm tpm0: ftpm_tee_tpm_op_send: SUBMIT_COMMAND invoke error: 0xffff3024
Fix this by separating supplicant dependent devices so that the
user-space service can detach supplicant devices before closing the
supplicant.
Reported-by: Jan Kiszka <jan.kiszka@...mens.com>
Link: https://github.com/OP-TEE/optee_os/issues/6094
Fixes: 5f178bb71e3a ("optee: enable support for multi-stage bus enumeration")
Tested-by: Jan Kiszka <jan.kiszka@...mens.com>
Tested-by: Masahisa Kojima <masahisa.kojima@...aro.org>
Signed-off-by: Sumit Garg <sumit.garg@...aro.org>
---
drivers/tee/optee/device.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
index 64f0e047c23d..78fc0a15c463 100644
--- a/drivers/tee/optee/device.c
+++ b/drivers/tee/optee/device.c
@@ -60,9 +60,10 @@ static void optee_release_device(struct device *dev)
kfree(optee_device);
}
-static int optee_register_device(const uuid_t *device_uuid)
+static int optee_register_device(const uuid_t *device_uuid, u32 func)
{
struct tee_client_device *optee_device = NULL;
+ const char *dev_name_fmt = NULL;
int rc;
optee_device = kzalloc(sizeof(*optee_device), GFP_KERNEL);
@@ -71,7 +72,13 @@ static int optee_register_device(const uuid_t *device_uuid)
optee_device->dev.bus = &tee_bus_type;
optee_device->dev.release = optee_release_device;
- if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
+
+ if (func == PTA_CMD_GET_DEVICES_SUPP)
+ dev_name_fmt = "optee-ta-supp-%pUb";
+ else
+ dev_name_fmt = "optee-ta-%pUb";
+
+ if (dev_set_name(&optee_device->dev, dev_name_fmt, device_uuid)) {
kfree(optee_device);
return -ENOMEM;
}
@@ -142,7 +149,7 @@ static int __optee_enumerate_devices(u32 func)
num_devices = shm_size / sizeof(uuid_t);
for (idx = 0; idx < num_devices; idx++) {
- rc = optee_register_device(&device_uuid[idx]);
+ rc = optee_register_device(&device_uuid[idx], func);
if (rc)
goto out_shm;
}
--
2.34.1
Powered by blists - more mailing lists