From 47e89136630918bc9fabec8c87019e2b65276f88 Mon Sep 17 00:00:00 2001 From: Himateja Reddy Date: Tue, 7 Jul 2020 10:49:05 -0700 Subject: [PATCH] msm: adsprpc: Reserve contexts for all static handles Current code has contexts reserved only for kernel calls. If the context table is full during static handle invocation, it results in complete feature failure and hang. Reserve contexts in the context table for all kernel and static handle invocations. Change-Id: I21a6de9af86129beede059a66c5b41343d2b5a51 Signed-off-by: Himateja Reddy --- drivers/char/adsprpc.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index 1d1f44e44fdb..6402612ba101 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -101,14 +101,14 @@ * bits 0-3 : type of remote PD * bit 4 : type of job (sync/async) * bit 5 : reserved - * bits 6-14 : index in context table - * bits 15-63 : incrementing context ID + * bits 6-15 : index in context table + * bits 16-63 : incrementing context ID */ -#define FASTRPC_CTX_MAX (512) +#define FASTRPC_CTX_MAX (1024) #define FASTRPC_CTX_JOB_TYPE_POS (4) #define FASTRPC_CTX_TABLE_IDX_POS (6) -#define FASTRPC_CTX_JOBID_POS (15) +#define FASTRPC_CTX_JOBID_POS (16) #define FASTRPC_CTX_TABLE_IDX_MASK \ ((FASTRPC_CTX_MAX - 1) << FASTRPC_CTX_TABLE_IDX_POS) #define FASTRPC_ASYNC_JOB_MASK (1) @@ -116,10 +116,10 @@ #define GET_TABLE_IDX_FROM_CTXID(ctxid) \ ((ctxid & FASTRPC_CTX_TABLE_IDX_MASK) >> FASTRPC_CTX_TABLE_IDX_POS) -/* Reserve few entries in context table for critical kernel RPC calls - * to avoid user invocations from exhausting all entries. +/* Reserve few entries in context table for critical kernel and static RPC + * calls to avoid user invocations from exhausting all entries. */ -#define NUM_KERNEL_ONLY_CONTEXTS (10) +#define NUM_KERNEL_AND_STATIC_ONLY_CONTEXTS (70) #define NUM_DEVICES 2 /* adsprpc-smd, adsprpc-smd-secure */ #define MINOR_NUM_DEV 0 @@ -1693,7 +1693,8 @@ static int context_alloc(struct fastrpc_file *fl, uint32_t kernel, spin_lock_irqsave(&chan->ctxlock, irq_flags); me->jobid[cid]++; - for (ii = (kernel ? 0 : NUM_KERNEL_ONLY_CONTEXTS); + for (ii = ((kernel || ctx->handle < FASTRPC_STATIC_HANDLE_MAX) + ? 0 : NUM_KERNEL_AND_STATIC_ONLY_CONTEXTS); ii < FASTRPC_CTX_MAX; ii++) { if (!chan->ctxtable[ii]) { chan->ctxtable[ii] = ctx;