aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroki Negishi <hiroki.negishi.bx@renesas.com>2019-01-24 20:38:38 +0900
committerRyo Kataoka <ryo.kataoka.wt@renesas.com>2019-03-22 20:50:13 +0900
commit940b2f6016df46b976c05b4fb6365d93d81a1952 (patch)
treefbeb2bb61b009353dbb5d77d2a81a1ce3f9c0ace
parent5a502ea6069a126227d05b31f1b310ff3421c4f0 (diff)
downloadrenesas-bsp-940b2f6016df46b976c05b4fb6365d93d81a1952.tar.gz
tee: optee: Modify duration of spinlock for list
R-Car OP-TEE driver acquires spinlock only for the duration of list_del() when deleting entries from the debug log list. This may cause that a debug log is left in list until a next RPC is received. And list_for_each_entry_safe() is not safe for deleting entries from the list if the spin lock is released and reacquired during the list iteration. Therefore, this patch replaces list_for_each_entry_safe() with checking if list is empty and removing the first entry in each iteration, and lock for the duration of the sequence. Signed-off-by: Hiroki Negishi <hiroki.negishi.bx@renesas.com>
-rw-r--r--drivers/tee/optee/rcar.c12
-rw-r--r--drivers/tee/optee/rcar_version.h4
2 files changed, 11 insertions, 5 deletions
diff --git a/drivers/tee/optee/rcar.c b/drivers/tee/optee/rcar.c
index 2f62764c6842d..f7f907b112d41 100644
--- a/drivers/tee/optee/rcar.c
+++ b/drivers/tee/optee/rcar.c
@@ -52,22 +52,28 @@ static int debug_log_kthread(void *arg)
{
struct rcar_debug_log_info *dlog;
struct rcar_debug_log_node *node;
- struct rcar_debug_log_node *ntmp;
bool thread_exit = false;
dlog = (struct rcar_debug_log_info *)arg;
while (1) {
- list_for_each_entry_safe(node, ntmp, &dlog->queue, list) {
+ spin_lock(&dlog->q_lock);
+ while (!list_empty(&dlog->queue)) {
+ node = list_first_entry(&dlog->queue,
+ struct rcar_debug_log_node,
+ list);
+ spin_unlock(&dlog->q_lock);
+
if (node->logmsg)
pr_alert("%s", node->logmsg);
else
thread_exit = true;
+
spin_lock(&dlog->q_lock);
list_del(&node->list);
- spin_unlock(&dlog->q_lock);
kfree(node);
}
+ spin_unlock(&dlog->q_lock);
if (thread_exit)
break;
wait_event_interruptible(dlog->waitq,
diff --git a/drivers/tee/optee/rcar_version.h b/drivers/tee/optee/rcar_version.h
index be0bca2e04013..3cea9dd8a88c9 100644
--- a/drivers/tee/optee/rcar_version.h
+++ b/drivers/tee/optee/rcar_version.h
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2015-2018, Renesas Electronics Corporation
+ * Copyright (c) 2015-2019, Renesas Electronics Corporation
* All rights reserved.
*/
#ifndef RCAR_VERSION_H
#define RCAR_VERSION_H
-#define VERSION_OF_RENESAS "1.0.9"
+#define VERSION_OF_RENESAS "1.0.10"
#endif /* RCAR_VERSION_H */