Skip to content

Commit 6dea635

Browse files
committed
optee: provide optee_do_bottom_half() as a common function
Provides optee_do_bottom_half() and optee_stop_async_notif() as common functions callable from the FF-A ABI part of the driver too. Signed-off-by: Jens Wiklander <[email protected]> Reviewed-by: Sumit Garg <[email protected]>
1 parent 4b391c9 commit 6dea635

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

drivers/tee/optee/call.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2015-2021, Linaro Limited
3+
* Copyright (c) 2015-2021, 2023 Linaro Limited
44
*/
55
#include <linux/device.h>
66
#include <linux/err.h>
@@ -640,3 +640,32 @@ int optee_check_mem_type(unsigned long start, size_t num_pages)
640640

641641
return rc;
642642
}
643+
644+
static int simple_call_with_arg(struct tee_context *ctx, u32 cmd)
645+
{
646+
struct optee *optee = tee_get_drvdata(ctx->teedev);
647+
struct optee_shm_arg_entry *entry;
648+
struct optee_msg_arg *msg_arg;
649+
struct tee_shm *shm;
650+
u_int offs;
651+
652+
msg_arg = optee_get_msg_arg(ctx, 0, &entry, &shm, &offs);
653+
if (IS_ERR(msg_arg))
654+
return PTR_ERR(msg_arg);
655+
656+
msg_arg->cmd = cmd;
657+
optee->ops->do_call_with_arg(ctx, shm, offs, false);
658+
659+
optee_free_msg_arg(ctx, entry, offs);
660+
return 0;
661+
}
662+
663+
int optee_do_bottom_half(struct tee_context *ctx)
664+
{
665+
return simple_call_with_arg(ctx, OPTEE_MSG_CMD_DO_BOTTOM_HALF);
666+
}
667+
668+
int optee_stop_async_notif(struct tee_context *ctx)
669+
{
670+
return simple_call_with_arg(ctx, OPTEE_MSG_CMD_STOP_ASYNC_NOTIF);
671+
}

drivers/tee/optee/optee_private.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3-
* Copyright (c) 2015-2021, Linaro Limited
3+
* Copyright (c) 2015-2021, 2023 Linaro Limited
44
*/
55

66
#ifndef OPTEE_PRIVATE_H
@@ -346,6 +346,9 @@ void optee_rpc_cmd_free_suppl(struct tee_context *ctx, struct tee_shm *shm);
346346
void optee_rpc_cmd(struct tee_context *ctx, struct optee *optee,
347347
struct optee_msg_arg *arg);
348348

349+
int optee_do_bottom_half(struct tee_context *ctx);
350+
int optee_stop_async_notif(struct tee_context *ctx);
351+
349352
/*
350353
* Small helpers
351354
*/

drivers/tee/optee/smc_abi.c

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (c) 2015-2021, Linaro Limited
3+
* Copyright (c) 2015-2021, 2023 Linaro Limited
44
* Copyright (c) 2016, EPAM Systems
55
*/
66

@@ -967,34 +967,6 @@ static int optee_smc_do_call_with_arg(struct tee_context *ctx,
967967
return rc;
968968
}
969969

970-
static int simple_call_with_arg(struct tee_context *ctx, u32 cmd)
971-
{
972-
struct optee_shm_arg_entry *entry;
973-
struct optee_msg_arg *msg_arg;
974-
struct tee_shm *shm;
975-
u_int offs;
976-
977-
msg_arg = optee_get_msg_arg(ctx, 0, &entry, &shm, &offs);
978-
if (IS_ERR(msg_arg))
979-
return PTR_ERR(msg_arg);
980-
981-
msg_arg->cmd = cmd;
982-
optee_smc_do_call_with_arg(ctx, shm, offs, false);
983-
984-
optee_free_msg_arg(ctx, entry, offs);
985-
return 0;
986-
}
987-
988-
static int optee_smc_do_bottom_half(struct tee_context *ctx)
989-
{
990-
return simple_call_with_arg(ctx, OPTEE_MSG_CMD_DO_BOTTOM_HALF);
991-
}
992-
993-
static int optee_smc_stop_async_notif(struct tee_context *ctx)
994-
{
995-
return simple_call_with_arg(ctx, OPTEE_MSG_CMD_STOP_ASYNC_NOTIF);
996-
}
997-
998970
/*
999971
* 5. Asynchronous notification
1000972
*/
@@ -1050,7 +1022,7 @@ static irqreturn_t notif_irq_thread_fn(int irq, void *dev_id)
10501022
{
10511023
struct optee *optee = dev_id;
10521024

1053-
optee_smc_do_bottom_half(optee->ctx);
1025+
optee_do_bottom_half(optee->ctx);
10541026

10551027
return IRQ_HANDLED;
10561028
}
@@ -1088,7 +1060,7 @@ static void notif_pcpu_irq_work_fn(struct work_struct *work)
10881060
notif_pcpu_work);
10891061
struct optee *optee = container_of(optee_smc, struct optee, smc);
10901062

1091-
optee_smc_do_bottom_half(optee->ctx);
1063+
optee_do_bottom_half(optee->ctx);
10921064
}
10931065

10941066
static int init_pcpu_irq(struct optee *optee, u_int irq)
@@ -1160,7 +1132,7 @@ static void uninit_pcpu_irq(struct optee *optee)
11601132
static void optee_smc_notif_uninit_irq(struct optee *optee)
11611133
{
11621134
if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_ASYNC_NOTIF) {
1163-
optee_smc_stop_async_notif(optee->ctx);
1135+
optee_stop_async_notif(optee->ctx);
11641136
if (optee->smc.notif_irq) {
11651137
if (irq_is_percpu_devid(optee->smc.notif_irq))
11661138
uninit_pcpu_irq(optee);

0 commit comments

Comments
 (0)