mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
tee: optee: interrupt an RPC depend on shutdown flag
Fixes: e6c7ea7d4d ("tee: optee: interrupt an RPC when supplicant has been killed")
Change-Id: I33f33af02afb75bda5d68c9731fe636bb97132fe
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <linux/arm-smccc.h>
|
||||
#include <linux/crash_dump.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
@@ -624,6 +625,13 @@ static int optee_remove(struct platform_device *pdev)
|
||||
*/
|
||||
static void optee_shutdown(struct platform_device *pdev)
|
||||
{
|
||||
struct optee *optee = platform_get_drvdata(pdev);
|
||||
|
||||
/* Tell requesting thread to interrupt an RPC */
|
||||
smp_store_mb(optee->supp.shutdown, true);
|
||||
/* Wait requesting thread to release resources */
|
||||
mdelay(200);
|
||||
|
||||
optee_disable_shm_cache(platform_get_drvdata(pdev));
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ struct optee_supp {
|
||||
struct list_head reqs;
|
||||
struct idr idr;
|
||||
struct completion reqs_c;
|
||||
bool shutdown;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,7 +82,6 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
|
||||
struct optee_supp_req *req;
|
||||
bool interruptable;
|
||||
u32 ret;
|
||||
unsigned long timeleft;
|
||||
int id;
|
||||
struct optee_supp_req *get_req;
|
||||
|
||||
@@ -117,14 +116,12 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
|
||||
* exclusive access again.
|
||||
*/
|
||||
while (wait_for_completion_interruptible(&req->c)) {
|
||||
pr_err("Warning, Interrupting an RPC to supplicant!\n");
|
||||
timeleft = wait_for_completion_timeout(&req->c, msecs_to_jiffies(2000));
|
||||
if (timeleft) {
|
||||
/* get completion, it means tee-supplicant is alive. */
|
||||
break;
|
||||
} else {
|
||||
/* timeout, it means tee-supplicant is dead, interrupting an RPC. */
|
||||
if (supp->shutdown) {
|
||||
/* Reboot happen, tee-supplicant is dead, interrupt an RPC */
|
||||
interruptable = true;
|
||||
} else {
|
||||
/* Deep sleep, tee-supplicant is freeze, wait tee-supplicant */
|
||||
continue;
|
||||
}
|
||||
|
||||
mutex_lock(&supp->mutex);
|
||||
|
||||
Reference in New Issue
Block a user