diff options
author | Seungho Lee <sh1006.lee@samsung.com> | 2016-06-02 16:22:00 +0900 |
---|---|---|
committer | jino.cho <jino.cho@samsung.com> | 2017-03-03 17:02:44 +0900 |
commit | 00ce6f060746e4ee6f8da42d0d3758355ede120d (patch) | |
tree | 636578476f4c24d260c129cbf5ba85e690dc9ba0 | |
parent | 927dfecc93f75e2dd8e52d36d36ff2b9dbe61281 (diff) | |
download | linux-3.10-artik-00ce6f060746e4ee6f8da42d0d3758355ede120d.tar.gz linux-3.10-artik-00ce6f060746e4ee6f8da42d0d3758355ede120d.tar.bz2 linux-3.10-artik-00ce6f060746e4ee6f8da42d0d3758355ede120d.zip |
misc: artiktee: handle tz command request time.
If tzdev occurs timeout, all requests will be closed
and handle other TA's requests sequentially.
Change-Id: Ib08a3a937681aa2ca2cc93c151be2c45879a8c04
Signed-off-by: Seungho Lee <sh1006.lee@samsung.com>
-rwxr-xr-x[-rw-r--r--] | drivers/misc/artiktee/smc_interface.h | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | drivers/misc/artiktee/tzdev.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | drivers/misc/artiktee/tzdev_main.c | 25 |
3 files changed, 22 insertions, 7 deletions
diff --git a/drivers/misc/artiktee/smc_interface.h b/drivers/misc/artiktee/smc_interface.h index dcf63f3a565..f63bbbc6465 100644..100755 --- a/drivers/misc/artiktee/smc_interface.h +++ b/drivers/misc/artiktee/smc_interface.h @@ -1,5 +1,6 @@ /********************************************************* * Copyright (C) 2011 - 2015 Samsung Electronics Co., Ltd All Rights Reserved + * Author: Jaroslaw Pelczar <j.pelczar@samsung.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -26,8 +27,6 @@ #define SMC_STD_REGISTER_SYSPAGE 1 /* R1 - wsm id page */ #define SMC_STD_REGISTER_MINIDUMP 2 -/* R1 - address, R2 - size, R3 - flags, R4 - tee context ID */ -#define SMC_STD_REGISTER_WSM 3 /* R1 - wsm ID */ #define SMC_STD_UNREGISTER_WSM 4 /* R1 - wsm ID */ diff --git a/drivers/misc/artiktee/tzdev.h b/drivers/misc/artiktee/tzdev.h index 739190bd4a8..730513fa790 100644..100755 --- a/drivers/misc/artiktee/tzdev.h +++ b/drivers/misc/artiktee/tzdev.h @@ -44,6 +44,7 @@ struct tzio_message { __u32 endpoint; __u32 length; int32_t context_id; + uint32_t timeout_seconds; char payload[]; }; diff --git a/drivers/misc/artiktee/tzdev_main.c b/drivers/misc/artiktee/tzdev_main.c index 1fc6d262e75..ceddf2d6e83 100644..100755 --- a/drivers/misc/artiktee/tzdev_main.c +++ b/drivers/misc/artiktee/tzdev_main.c @@ -69,6 +69,7 @@ struct tzio_context { void *payload; size_t payload_size; int softlock_timer; + unsigned int timeout_seconds; struct completion comp; struct file *owner; int state; @@ -306,7 +307,7 @@ static void tzio_reset_softlock_timer(int cpu) #endif /* !CONFIG_PSCI */ void tzio_init_context(struct tzio_context *ctx, struct file *filp, - void *payload) + void *payload, uint32_t seconds) { init_completion(&ctx->comp); @@ -315,6 +316,7 @@ void tzio_init_context(struct tzio_context *ctx, struct file *filp, ctx->payload_size = 0; ctx->softlock_timer = 0; ctx->owner = filp; + ctx->timeout_seconds = seconds; } void tzio_rbtree_list_context_node(void) @@ -333,11 +335,10 @@ void tzio_rbtree_list_context_node(void) tzlog_print(TZLOG_DEBUG, "End list all context node in rbtree\n"); } -void tzio_connection_closed(struct scm_msg_link *msg) +void tzio_connection_closed(int epid) { struct tzio_context *tmp_node; int id; - int epid = msg->channel & ~PAGE_MASK; unsigned long flags; tzlog_print(TZLOG_DEBUG, "TA of channel ID %d died\n", epid); @@ -516,7 +517,7 @@ static int tzio_pop_message(struct scm_buffer *ring) rx_taken += sizeof(struct scm_msg_link) + mtcp.length; rx_avail -= sizeof(struct scm_msg_link) + mtcp.length; - tzio_connection_closed(&mtcp); + tzio_connection_closed(mtcp.channel & ~PAGE_MASK); break; case SCM_LLC_DATA: spin_lock_irqsave(&tzio_context_slock, flags); @@ -796,6 +797,12 @@ int tzio_message_wait(struct tzio_message *__user msg, scm_softlockup(); } } + + if(context->timeout_seconds > 0 && context->softlock_timer > context->timeout_seconds) { + tzlog_print(TZLOG_ERROR, "TA %u timed out. Killing all requests\n", context->remote_id); + tzio_connection_closed(context->remote_id); + break; + } } /* soft lockup checking end */ } @@ -872,6 +879,7 @@ int tzio_exchange_message(struct file *filp, struct tzio_message *__user msg) unsigned int svc_flags; char __payload[TZIO_PAYLOAD_MAX]; int32_t restart_context_id; + uint32_t timeout_seconds; ret = get_user(restart_context_id, &msg->context_id); @@ -880,6 +888,13 @@ int tzio_exchange_message(struct file *filp, struct tzio_message *__user msg) return ret; } + ret = get_user(timeout_seconds, &msg->timeout_seconds); + + if (ret < 0) { + tzlog_print(TZLOG_ERROR, "get_user error\n"); + return ret; + } + if (restart_context_id) { return tzio_message_restart(msg, filp, restart_context_id); } @@ -913,7 +928,7 @@ int tzio_exchange_message(struct file *filp, struct tzio_message *__user msg) return -ENOMEM; } - tzio_init_context(context, filp, __payload); + tzio_init_context(context, filp, __payload, timeout_seconds); link = tzio_acquire_link(GFP_KERNEL); |