From 4f7c1784fa1452299d7bfec2b758c905ccdd18c5 Mon Sep 17 00:00:00 2001 From: Amir Samuelov Date: Thu, 18 May 2017 16:10:01 +0300 Subject: [PATCH] spcom: increment channel reference count after successful glink_open() spcom_open() should increment the ref count only after successful glink open the channel. Otherwise, the following attempts to open the channel will fail. glink_open() failure was noticed after SP reset (SSR), when attempting to open the channel before the link between SP and HLOS is up. Change-Id: I8be28ce810f54cc3fa95d14c7244921acf7edaa7 Signed-off-by: Amir Samuelov --- drivers/soc/qcom/spcom.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c index c2af34926b37..f406292a6c4d 100644 --- a/drivers/soc/qcom/spcom.c +++ b/drivers/soc/qcom/spcom.c @@ -721,9 +721,6 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec) pr_err("channel [%s] already in use.\n", name); goto exit_err; } - ch->ref_count++; - ch->pid = current_pid(); - ch->txn_id = INITIAL_TXN_ID; pr_debug("ch [%s] opened by PID [%d], count [%d]\n", name, ch->pid, ch->ref_count); @@ -748,7 +745,12 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec) } else { pr_debug("glink_open [%s] ok.\n", name); } + + /* init channel context after successful open */ ch->glink_handle = handle; + ch->ref_count++; + ch->pid = current_pid(); + ch->txn_id = INITIAL_TXN_ID; pr_debug("Wait for connection on channel [%s] timeout_msec [%d].\n", name, timeout_msec);