From 635a1c8eb971b2da45c2bad23afc832baa831c37 Mon Sep 17 00:00:00 2001 From: Pavankumar Nandeshwar Date: Thu, 6 May 2021 04:45:13 -0700 Subject: [PATCH] qcacmn: update the wmi context during unregister When unregistering wmi handlers, the position of the old handler is replaced with the last handler in the table. But at this stage only handler was getting replaced, but not the context. Hence, make sure to update the context as well. Change-Id: If90ea9d7663fb105e8e8ad7d7e6c70da20264e44 --- wmi/src/wmi_unified.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index 0a10f2f2f7..4ab6ec7d1f 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -2216,8 +2216,14 @@ QDF_STATUS wmi_unified_unregister_event(wmi_unified_t wmi_handle, { uint32_t idx = 0; uint32_t evt_id; - struct wmi_soc *soc = wmi_handle->soc; + struct wmi_soc *soc; + if (!wmi_handle) { + wmi_err("WMI handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + + soc = wmi_handle->soc; if (event_id >= wmi_events_max || wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO, @@ -2241,6 +2247,15 @@ QDF_STATUS wmi_unified_unregister_event(wmi_unified_t wmi_handle, wmi_handle->event_id[idx] = wmi_handle->event_id[soc->max_event_idx]; + qdf_spin_lock_bh(&soc->ctx_lock); + + wmi_handle->ctx[idx].exec_ctx = + wmi_handle->ctx[soc->max_event_idx].exec_ctx; + wmi_handle->ctx[idx].buff_type = + wmi_handle->ctx[soc->max_event_idx].buff_type; + + qdf_spin_unlock_bh(&soc->ctx_lock); + return QDF_STATUS_SUCCESS; } @@ -2279,6 +2294,15 @@ QDF_STATUS wmi_unified_unregister_event_handler(wmi_unified_t wmi_handle, wmi_handle->event_id[idx] = wmi_handle->event_id[soc->max_event_idx]; + qdf_spin_lock_bh(&soc->ctx_lock); + + wmi_handle->ctx[idx].exec_ctx = + wmi_handle->ctx[soc->max_event_idx].exec_ctx; + wmi_handle->ctx[idx].buff_type = + wmi_handle->ctx[soc->max_event_idx].buff_type; + + qdf_spin_unlock_bh(&soc->ctx_lock); + return QDF_STATUS_SUCCESS; } qdf_export_symbol(wmi_unified_unregister_event_handler);