From 194b0bdb4d0623b4276d242995646cea04f12cf8 Mon Sep 17 00:00:00 2001 From: Jagadeesh Ponduru Date: Mon, 16 Aug 2021 15:29:01 +0530 Subject: [PATCH 1/2] msm: ipa3: code changes to fix kernel panic error This Issue is seen by Enabling CONFIG_DEBUG_ATOMIC_SLEEP=y and boot the device.To avoid going into kernel panic state,changed the function calls order of spin_lock() and idr_preload() after calling kmem_cache_zalloc().Originally, these two functions were called before calling kmem_cache_zalloc(). Change-Id: I2738548abd4148828e7d9436415c5c4d769680b9 Signed-off-by: Jagadeesh Ponduru --- drivers/platform/msm/ipa/ipa_v3/ipa_utils.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c index 8ff6f6b28b6c..0695a368e945 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c @@ -7120,16 +7120,13 @@ int ipa3_alloc_counter_id(struct ipa_ioc_flt_rt_counter_alloc *header) { int i, unused_cnt, unused_max, unused_start_id; struct ipa_ioc_flt_rt_counter_alloc *counter; - - idr_preload(GFP_KERNEL); - spin_lock(&ipa3_ctx->flt_rt_counters.hdl_lock); - counter = kmem_cache_zalloc(ipa3_ctx->fnr_stats_cache, GFP_KERNEL); if (!counter) { IPAERR_RL("failed to alloc fnr stats counter object\n"); - spin_unlock(&ipa3_ctx->flt_rt_counters.hdl_lock); return -ENOMEM; } + idr_preload(GFP_KERNEL); + spin_lock(&ipa3_ctx->flt_rt_counters.hdl_lock); memcpy(counter, header, sizeof(struct ipa_ioc_flt_rt_counter_alloc)); /* allocate hw counters */ counter->hw_counter.start_id = 0; From c0b30d82beb5d34e62a2fabf9ad7f31cc38fe483 Mon Sep 17 00:00:00 2001 From: Sivakanth Vaka Date: Tue, 17 Aug 2021 21:10:15 +0530 Subject: [PATCH 2/2] msm: ipa3: Change spin lock in release_gsi_channel Changed the spin_lock in ipa3_release_gsi_channel to spin_lock_irqsave to avoid getting interrupted while stop channel is command is executed. Signed-off-by: Sivakanth Vaka --- drivers/platform/msm/ipa/ipa_v3/ipa_client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_client.c b/drivers/platform/msm/ipa/ipa_v3/ipa_client.c index 9c92fd487e6e..8ca62014e5cf 100644 --- a/drivers/platform/msm/ipa/ipa_v3/ipa_client.c +++ b/drivers/platform/msm/ipa/ipa_v3/ipa_client.c @@ -1609,6 +1609,7 @@ int ipa3_release_gsi_channel(u32 clnt_hdl) struct ipa3_ep_context *ep; int result = -EFAULT; enum gsi_status gsi_res; + unsigned long flags; IPADBG("entry\n"); if (clnt_hdl >= ipa3_ctx->ipa_num_pipes || @@ -1623,10 +1624,9 @@ int ipa3_release_gsi_channel(u32 clnt_hdl) IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl)); /* Set the disconnect in progress flag to avoid calling cb.*/ - spin_lock(&ipa3_ctx->disconnect_lock); + spin_lock_irqsave(&ipa3_ctx->disconnect_lock, flags); atomic_set(&ep->disconnect_in_progress, 1); - spin_unlock(&ipa3_ctx->disconnect_lock); - + spin_unlock_irqrestore(&ipa3_ctx->disconnect_lock, flags); gsi_res = gsi_dealloc_channel(ep->gsi_chan_hdl); if (gsi_res != GSI_STATUS_SUCCESS) { @@ -1646,9 +1646,9 @@ int ipa3_release_gsi_channel(u32 clnt_hdl) if (!ep->keep_ipa_awake) IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl)); - spin_lock(&ipa3_ctx->disconnect_lock); + spin_lock_irqsave(&ipa3_ctx->disconnect_lock, flags); memset(&ipa3_ctx->ep[clnt_hdl], 0, sizeof(struct ipa3_ep_context)); - spin_unlock(&ipa3_ctx->disconnect_lock); + spin_unlock_irqrestore(&ipa3_ctx->disconnect_lock, flags); IPADBG("exit\n"); return 0;