summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMahesh Kumar Kalikot Veetil <mkalikot@qca.qualcomm.com>2016-05-12 12:02:56 -0700
committerAnjaneedevi Kapparapu <akappa@codeaurora.org>2016-05-17 12:52:16 +0530
commit2e9dd9c8ecf81a66b32f858b58480b0fca6c5bb6 (patch)
treec325ebdb4cdb73db8c24d91be7460b1a5f7f5ac3
parent4162f2200b0c84fdea80697122da21b298aa14d7 (diff)
qcacld-2.0: Fix a deadlock in proto trace
There is a potential deadlock scenario with a spin lock between a tasklet and a thread context. Fix it by using spin_lock_bh because that will disable bottom halves on that CPU and thus prevent a dead lock that could otherwise occur if the process context code took the lock and then a software IRQ was run which attempt to acquire the same lock. Change-Id: I5f83cb7cecd7227e0ea9c9db001bb0420bf09c94 CRs-Fixed: 1014766
-rw-r--r--CORE/VOSS/src/vos_packet.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/CORE/VOSS/src/vos_packet.c b/CORE/VOSS/src/vos_packet.c
index c02713c5007e..21fdc39bf64b 100644
--- a/CORE/VOSS/src/vos_packet.c
+++ b/CORE/VOSS/src/vos_packet.c
@@ -69,9 +69,9 @@ typedef struct
char event_string[VOS_PKT_TRAC_MAX_STRING_LEN];
} vos_pkt_proto_trace_t;
-vos_pkt_proto_trace_t *trace_buffer = NULL;
+vos_pkt_proto_trace_t *trace_buffer = NULL;
unsigned int trace_buffer_order = 0;
-vos_spin_lock_t trace_buffer_lock;
+spinlock_t trace_buffer_lock;
#endif /* QCA_PKT_PROTO_TRACE */
/**
@@ -298,14 +298,10 @@ v_U8_t vos_pkt_get_proto_type
}
#ifdef QCA_PKT_PROTO_TRACE
-/*---------------------------------------------------------------------------
-
- * brief vos_pkt_trace_buf_update() -
- Update storage buffer with interest event string
-
- * event_string Event String may packet type or outstanding event
-
----------------------------------------------------------------------------*/
+/**
+ * vos_pkt_trace_buf_update - Update storage buffer with interested event string
+ * @event_string: A string for packet type or outstanding event
+ */
void vos_pkt_trace_buf_update
(
char *event_string
@@ -315,7 +311,7 @@ void vos_pkt_trace_buf_update
VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
"%s %d, %s", __func__, __LINE__, event_string);
- vos_spin_lock_acquire(&trace_buffer_lock);
+ spin_lock_bh(&trace_buffer_lock);
slot = trace_buffer_order % VOS_PKT_TRAC_MAX_TRACE_BUF;
trace_buffer[slot].order = trace_buffer_order;
trace_buffer[slot].event_time = vos_timer_get_system_time();
@@ -326,17 +322,14 @@ void vos_pkt_trace_buf_update
(VOS_PKT_TRAC_MAX_STRING_LEN < strlen(event_string))?
VOS_PKT_TRAC_MAX_STRING_LEN:strlen(event_string));
trace_buffer_order++;
- vos_spin_lock_release(&trace_buffer_lock);
+ spin_unlock_bh(&trace_buffer_lock);
return;
}
-/*---------------------------------------------------------------------------
-
- * brief vos_pkt_trace_buf_dump() -
- Dump stored information into kernel log
-
----------------------------------------------------------------------------*/
+/**
+ * vos_pkt_trace_buf_dump - Dump stored information into kernel log
+ */
void vos_pkt_trace_buf_dump
(
void
@@ -344,7 +337,7 @@ void vos_pkt_trace_buf_dump
{
v_U32_t slot, idx;
- vos_spin_lock_acquire(&trace_buffer_lock);
+ spin_lock_bh(&trace_buffer_lock);
VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
"PACKET TRACE DUMP START Current Timestamp %u",
(unsigned int)vos_timer_get_system_time());
@@ -376,24 +369,22 @@ void vos_pkt_trace_buf_dump
VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
"PACKET TRACE DUMP END");
- vos_spin_lock_release(&trace_buffer_lock);
+ spin_unlock_bh(&trace_buffer_lock);
return;
}
-/*---------------------------------------------------------------------------
-
- * brief vos_pkt_proto_trace_init() -
- Initialize protocol trace functionality, allocate required resource
-
----------------------------------------------------------------------------*/
+/**
+ * vos_pkt_proto_trace_init - Initialize protocol trace functionality and
+ * allocate required resources
+ */
void vos_pkt_proto_trace_init
(
void
)
{
/* Init spin lock to protect global memory */
- vos_spin_lock_init(&trace_buffer_lock);
+ spin_lock_init(&trace_buffer_lock);
trace_buffer_order = 0;
trace_buffer = vos_mem_malloc(
VOS_PKT_TRAC_MAX_TRACE_BUF * sizeof(vos_pkt_proto_trace_t));
@@ -420,7 +411,6 @@ void vos_pkt_proto_trace_close
VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
"%s %d", __func__, __LINE__);
vos_mem_free(trace_buffer);
- vos_spin_lock_destroy(&trace_buffer_lock);
return;
}