From d4239b89f65a525d897bd81c62527ee0c5127bf2 Mon Sep 17 00:00:00 2001 From: Arun Kumar Khandavalli Date: Tue, 15 Feb 2022 10:13:30 +0530 Subject: [PATCH] qcacmn: Dont add the wmi header size while allocating the wmi buff Currently whenever the wmi message is allocated the wmi header length is also added to check with against the max size supported by the firmware, there is no need to add the extra wmi header size as the max length shared by firmware has the wmi header size included. Below is the breakdown: Max CE2 transfer size is 2048 bytes HTC header is 8 bytes WMI header is 4 bytes Max payload can be (MAX CE2 Transfer size - (HTC header+ WMI header) (2048 - (8 +4)) = 2036 During the htc handshake this max wmi length is recevied by the host as 2040 bytes which is including the wmi header so host adding the extra 4 bytes is redundant and can be removed. HTC buffer->actual_length = 2036 + WMI(4) = 2040 bytes Change-Id: Ib958a938506c5c96347dec5304ca30aa8690d459 CRs-Fixed: 3130493 --- wmi/src/wmi_unified.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index a267c05b45..b8b490b960 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -1677,7 +1677,10 @@ wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint32_t len, { wmi_buf_t wmi_buf; - if (roundup(len + sizeof(WMI_CMD_HDR), 4) > wmi_handle->max_msg_len) { + if (roundup(len, 4) > wmi_handle->max_msg_len) { + wmi_err("Invalid length %u (via %s:%u) max size: %u", + len, func_name, line_num, + wmi_handle->max_msg_len); QDF_ASSERT(0); return NULL; } @@ -1718,9 +1721,9 @@ wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len, { wmi_buf_t wmi_buf; - if (roundup(len + sizeof(WMI_CMD_HDR), 4) > wmi_handle->max_msg_len) { - QDF_DEBUG_PANIC("Invalid length %u (via %s:%u)", - len, func, line); + if (roundup(len, 4) > wmi_handle->max_msg_len) { + QDF_DEBUG_PANIC("Invalid length %u (via %s:%u) max size: %u", + len, func, line, wmi_handle->max_msg_len); return NULL; }