Skip to content

Commit 3408005

Browse files
committed
Merge tag 'optee-cleanup-for-v6.8' of https://git.linaro.org/people/jens.wiklander/linux-tee into soc/drivers
OP-TEE cleanup - Remove a redundant custom workqueue in the OP-TEE driver. - Fix a missing description of an argument to optee_handle_rpc(). * tag 'optee-cleanup-for-v6.8' of https://git.linaro.org/people/jens.wiklander/linux-tee: optee: add missing description of RPC argument reference tee: optee: Remove redundant custom workqueue tee: optee: Fix supplicant based device enumeration Link: https://lore.kernel.org/r/20231214132237.GA3092763@rayden Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents feb69ea + b19773a commit 3408005

5 files changed

Lines changed: 27 additions & 15 deletions

File tree

Documentation/ABI/testing/sysfs-bus-optee-devices

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ Description:
66
OP-TEE bus provides reference to registered drivers under this directory. The <uuid>
77
matches Trusted Application (TA) driver and corresponding TA in secure OS. Drivers
88
are free to create needed API under optee-ta-<uuid> directory.
9+
10+
What: /sys/bus/tee/devices/optee-ta-<uuid>/need_supplicant
11+
Date: November 2023
12+
KernelVersion: 6.7
13+
Contact: op-tee@lists.trustedfirmware.org
14+
Description:
15+
Allows to distinguish whether an OP-TEE based TA/device requires user-space
16+
tee-supplicant to function properly or not. This attribute will be present for
17+
devices which depend on tee-supplicant to be running.

drivers/tee/optee/core.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/string.h>
1616
#include <linux/tee_drv.h>
1717
#include <linux/types.h>
18-
#include <linux/workqueue.h>
1918
#include "optee_private.h"
2019

2120
int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
@@ -112,12 +111,7 @@ int optee_open(struct tee_context *ctx, bool cap_memref_null)
112111

113112
if (!optee->scan_bus_done) {
114113
INIT_WORK(&optee->scan_bus_work, optee_bus_scan);
115-
optee->scan_bus_wq = create_workqueue("optee_bus_scan");
116-
if (!optee->scan_bus_wq) {
117-
kfree(ctxdata);
118-
return -ECHILD;
119-
}
120-
queue_work(optee->scan_bus_wq, &optee->scan_bus_work);
114+
schedule_work(&optee->scan_bus_work);
121115
optee->scan_bus_done = true;
122116
}
123117
}
@@ -161,10 +155,7 @@ void optee_release_supp(struct tee_context *ctx)
161155
struct optee *optee = tee_get_drvdata(ctx->teedev);
162156

163157
optee_release_helper(ctx, optee_close_session_helper);
164-
if (optee->scan_bus_wq) {
165-
destroy_workqueue(optee->scan_bus_wq);
166-
optee->scan_bus_wq = NULL;
167-
}
158+
168159
optee_supp_release(&optee->supp);
169160
}
170161

drivers/tee/optee/device.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ static void optee_release_device(struct device *dev)
6060
kfree(optee_device);
6161
}
6262

63-
static int optee_register_device(const uuid_t *device_uuid)
63+
static ssize_t need_supplicant_show(struct device *dev,
64+
struct device_attribute *attr,
65+
char *buf)
66+
{
67+
return 0;
68+
}
69+
70+
static DEVICE_ATTR_RO(need_supplicant);
71+
72+
static int optee_register_device(const uuid_t *device_uuid, u32 func)
6473
{
6574
struct tee_client_device *optee_device = NULL;
6675
int rc;
@@ -83,6 +92,10 @@ static int optee_register_device(const uuid_t *device_uuid)
8392
put_device(&optee_device->dev);
8493
}
8594

95+
if (func == PTA_CMD_GET_DEVICES_SUPP)
96+
device_create_file(&optee_device->dev,
97+
&dev_attr_need_supplicant);
98+
8699
return rc;
87100
}
88101

@@ -142,7 +155,7 @@ static int __optee_enumerate_devices(u32 func)
142155
num_devices = shm_size / sizeof(uuid_t);
143156

144157
for (idx = 0; idx < num_devices; idx++) {
145-
rc = optee_register_device(&device_uuid[idx]);
158+
rc = optee_register_device(&device_uuid[idx], func);
146159
if (rc)
147160
goto out_shm;
148161
}

drivers/tee/optee/optee_private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ struct optee_ops {
199199
* @pool: shared memory pool
200200
* @rpc_param_count: If > 0 number of RPC parameters to make room for
201201
* @scan_bus_done flag if device registation was already done.
202-
* @scan_bus_wq workqueue to scan optee bus and register optee drivers
203202
* @scan_bus_work workq to scan optee bus and register optee drivers
204203
*/
205204
struct optee {
@@ -218,7 +217,6 @@ struct optee {
218217
struct tee_shm_pool *pool;
219218
unsigned int rpc_param_count;
220219
bool scan_bus_done;
221-
struct workqueue_struct *scan_bus_wq;
222220
struct work_struct scan_bus_work;
223221
};
224222

drivers/tee/optee/smc_abi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ static void handle_rpc_func_cmd(struct tee_context *ctx, struct optee *optee,
803803
/**
804804
* optee_handle_rpc() - handle RPC from secure world
805805
* @ctx: context doing the RPC
806+
* @rpc_arg: pointer to RPC arguments if any, or NULL if none
806807
* @param: value of registers for the RPC
807808
* @call_ctx: call context. Preserved during one OP-TEE invocation
808809
*

0 commit comments

Comments
 (0)