Skip to content

Commit 9c7f01d

Browse files
committed
Merge tag 'optee-supplicant-fix-for-v6.7' of git://git.linaro.org:/people/jens.wiklander/linux-tee into arm/fixes
OP-TEE fix for supplicant based device enumeration Adds a sysfs attribute for devices depending on supplicant services so that the user-space service can detect and detach those devices before closing the supplicant * tag 'optee-supplicant-fix-for-v6.7' of git://git.linaro.org:/people/jens.wiklander/linux-tee: tee: optee: Fix supplicant based device enumeration Link: https://lore.kernel.org/r/20231114153113.GA1310615@rayden Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 2cc14f5 + 7269cba commit 9c7f01d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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+
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/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
}

0 commit comments

Comments
 (0)