From d33659b98d3c8ef6a01c161ad5d62bb8f56a632f Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Fri, 22 Feb 2019 10:58:48 -0800 Subject: [PATCH] qcacmn: Provide reason to QDF_DEBUG_PANIC() A common pattern in WLAN to panic the driver is to log the reason and then unconditionally panic. QDF_DEBUG_PANIC() takes a reason string to help make the reason for the panic more obvious, but it is not always used. Ensure all callers of QDF_DEBUG_PANIC() provide a reason string. Additionally, make the reason string parameter of QDF_DEBUG_PANIC() mandatory. Change-Id: Ia3c7acfe590f7f465823fff3f2393653b2d20fe5 CRs-Fixed: 2403830 --- qdf/linux/src/i_qdf_trace.h | 7 ++++--- wmi/src/wmi_unified.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/qdf/linux/src/i_qdf_trace.h b/qdf/linux/src/i_qdf_trace.h index fc09eda2e7..a4330f7b33 100644 --- a/qdf/linux/src/i_qdf_trace.h +++ b/qdf/linux/src/i_qdf_trace.h @@ -278,12 +278,13 @@ static inline void __qdf_bug(void) /** * QDF_DEBUG_PANIC() - In debug builds, panic, otherwise do nothing - * @reason: An optional reason format string, followed by args + * @reason_fmt: a format string containing the reason for the panic + * @args: zero or more printf compatible logging arguments * * Return: None */ -#define QDF_DEBUG_PANIC(reason...) \ - QDF_DEBUG_PANIC_FL(__func__, __LINE__, "" reason) +#define QDF_DEBUG_PANIC(reason_fmt, args...) \ + QDF_DEBUG_PANIC_FL(__func__, __LINE__, reason_fmt, ## args) /** * QDF_DEBUG_PANIC_FL() - In debug builds, panic, otherwise do nothing diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index f1bb6d72f1..c9eb9406f8 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -1555,8 +1555,8 @@ wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len, wmi_buf_t wmi_buf; if (roundup(len + WMI_MIN_HEAD_ROOM, 4) > wmi_handle->max_msg_len) { - wmi_nofl_err("%s:%d, Invalid len:%d", func, line, len); - QDF_DEBUG_PANIC(); + QDF_DEBUG_PANIC("Invalid length %u (via %s:%u)", + len, func, line); return NULL; } @@ -1579,6 +1579,7 @@ wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len, * Set the length of the buffer to match the allocation size. */ qdf_nbuf_set_pktlen(wmi_buf, len); + return wmi_buf; } qdf_export_symbol(wmi_buf_alloc_fl); @@ -1666,15 +1667,14 @@ QDF_STATUS wmi_unified_cmd_send_fl(wmi_unified_t wmi_handle, wmi_buf_t buf, uint16_t htc_tag = 0; if (wmi_get_runtime_pm_inprogress(wmi_handle)) { - htc_tag = - (uint16_t)wmi_handle->ops->wmi_set_htc_tx_tag( - wmi_handle, buf, cmd_id); + htc_tag = wmi_handle->ops->wmi_set_htc_tx_tag(wmi_handle, buf, + cmd_id); } else if (qdf_atomic_read(&wmi_handle->is_target_suspended) && - (!wmi_is_pm_resume_cmd(cmd_id))) { - wmi_nofl_err("%s:%d, Target is suspended", func, line); - QDF_DEBUG_PANIC(); + !wmi_is_pm_resume_cmd(cmd_id)) { + QDF_DEBUG_PANIC("Target is suspended (via %s:%u)", func, line); return QDF_STATUS_E_BUSY; } + if (wmi_handle->wmi_stopinprogress) { wmi_nofl_err("%s:%d, WMI stop in progress", func, line); return QDF_STATUS_E_INVAL;