From 056ae77554ced19cfd6bc7ef46b3636fa5d39960 Mon Sep 17 00:00:00 2001 From: Ashok Vuyyuru Date: Tue, 20 Oct 2020 14:54:13 +0530 Subject: [PATCH] msm: ipa3: Fix race condition during teardwon pipe When endpoint in polling mode possible to pipe teardown trigger parallel it leads to race condition. Adding changes to check in endpoint came out of polling mode and continue to teardown the endpoint. Change-Id: I0b22d6a7a1f5229acec2dbc9dd5cb76488c09faa Signed-off-by: Ashok Vuyyuru --- drivers/platform/msm/gsi/gsi.c | 6 ++++++ drivers/platform/msm/ipa/ipa_v3/ipa_dp.c | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c index 37f8ef44749c..f501fe088731 100644 --- a/drivers/platform/msm/gsi/gsi.c +++ b/drivers/platform/msm/gsi/gsi.c @@ -4008,6 +4008,12 @@ int gsi_poll_n_channel(unsigned long chan_hdl, return -GSI_STATUS_UNSUPPORTED_OP; } + /* Before going to poll packet make sure it was in allocated state */ + if (unlikely(ctx->state == GSI_CHAN_STATE_NOT_ALLOCATED)) { + GSIERR("bad state %d\n", ctx->state); + return -GSI_STATUS_UNSUPPORTED_OP; + } + if (!ctx->evtr) { GSIERR("no event ring associated chan_hdl=%lu\n", chan_hdl); return -GSI_STATUS_UNSUPPORTED_OP; diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c index 678fb5bc76bf..fcd0160ed462 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c @@ -1479,11 +1479,10 @@ int ipa3_teardown_sys_pipe(u32 clnt_hdl) return result; } - if (ep->sys->napi_obj) { - do { - usleep_range(95, 105); - } while (atomic_read(&ep->sys->curr_polling_state)); - } + /* Wait untill end point moving to interrupt mode before teardown */ + do { + usleep_range(95, 105); + } while (atomic_read(&ep->sys->curr_polling_state)); if (IPA_CLIENT_IS_CONS(ep->client)) cancel_delayed_work_sync(&ep->sys->replenish_rx_work);