Commit f6f92968 authored by Carl Huang's avatar Carl Huang Committed by Kalle Valo

ath11k: qmi: try to allocate a big block of DMA memory first

Not all firmware versions support allocating DMA memory in smaller blocks so
first try to allocate big block of DMA memory for QMI. If the allocation fails,
let firmware request multiple blocks of DMA memory with smaller size.

This also fixes an unnecessary error message seen during ath11k probe on
QCA6390:

ath11k_pci 0000:06:00.0: Respond mem req failed, result: 1, err: 0
ath11k_pci 0000:06:00.0: qmi failed to respond fw mem req:-22

Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
Signed-off-by: default avatarCarl Huang <cjhuang@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/1608127593-15192-1-git-send-email-kvalo@codeaurora.org
parent 30d08503
...@@ -1660,6 +1660,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) ...@@ -1660,6 +1660,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
struct qmi_wlanfw_respond_mem_resp_msg_v01 resp; struct qmi_wlanfw_respond_mem_resp_msg_v01 resp;
struct qmi_txn txn = {}; struct qmi_txn txn = {};
int ret = 0, i; int ret = 0, i;
bool delayed;
req = kzalloc(sizeof(*req), GFP_KERNEL); req = kzalloc(sizeof(*req), GFP_KERNEL);
if (!req) if (!req)
...@@ -1672,11 +1673,13 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) ...@@ -1672,11 +1673,13 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
* failure to FW and FW will then request mulitple blocks of small * failure to FW and FW will then request mulitple blocks of small
* chunk size memory. * chunk size memory.
*/ */
if (!ab->bus_params.fixed_mem_region && ab->qmi.mem_seg_count <= 2) { if (!ab->bus_params.fixed_mem_region && ab->qmi.target_mem_delayed) {
delayed = true;
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n", ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n",
ab->qmi.mem_seg_count); ab->qmi.mem_seg_count);
memset(req, 0, sizeof(*req)); memset(req, 0, sizeof(*req));
} else { } else {
delayed = false;
req->mem_seg_len = ab->qmi.mem_seg_count; req->mem_seg_len = ab->qmi.mem_seg_count;
for (i = 0; i < req->mem_seg_len ; i++) { for (i = 0; i < req->mem_seg_len ; i++) {
...@@ -1708,6 +1711,12 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) ...@@ -1708,6 +1711,12 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
} }
if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
/* the error response is expected when
* target_mem_delayed is true.
*/
if (delayed && resp.resp.error == 0)
goto out;
ath11k_warn(ab, "Respond mem req failed, result: %d, err: %d\n", ath11k_warn(ab, "Respond mem req failed, result: %d, err: %d\n",
resp.resp.result, resp.resp.error); resp.resp.result, resp.resp.error);
ret = -EINVAL; ret = -EINVAL;
...@@ -1742,6 +1751,8 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) ...@@ -1742,6 +1751,8 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
int i; int i;
struct target_mem_chunk *chunk; struct target_mem_chunk *chunk;
ab->qmi.target_mem_delayed = false;
for (i = 0; i < ab->qmi.mem_seg_count; i++) { for (i = 0; i < ab->qmi.mem_seg_count; i++) {
chunk = &ab->qmi.target_mem[i]; chunk = &ab->qmi.target_mem[i];
chunk->vaddr = dma_alloc_coherent(ab->dev, chunk->vaddr = dma_alloc_coherent(ab->dev,
...@@ -1749,6 +1760,15 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) ...@@ -1749,6 +1760,15 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
&chunk->paddr, &chunk->paddr,
GFP_KERNEL); GFP_KERNEL);
if (!chunk->vaddr) { if (!chunk->vaddr) {
if (ab->qmi.mem_seg_count <= 2) {
ath11k_dbg(ab, ATH11K_DBG_QMI,
"qmi dma allocation failed (%d B type %u), will try later with small size\n",
chunk->size,
chunk->type);
ath11k_qmi_free_target_mem_chunk(ab);
ab->qmi.target_mem_delayed = true;
return 0;
}
ath11k_err(ab, "failed to alloc memory, size: 0x%x, type: %u\n", ath11k_err(ab, "failed to alloc memory, size: 0x%x, type: %u\n",
chunk->size, chunk->size,
chunk->type); chunk->type);
...@@ -2517,7 +2537,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl, ...@@ -2517,7 +2537,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl,
ret); ret);
return; return;
} }
} else if (msg->mem_seg_len > 2) { } else {
ret = ath11k_qmi_alloc_target_mem_chunk(ab); ret = ath11k_qmi_alloc_target_mem_chunk(ab);
if (ret) { if (ret) {
ath11k_warn(ab, "qmi failed to alloc target memory: %d\n", ath11k_warn(ab, "qmi failed to alloc target memory: %d\n",
......
...@@ -125,6 +125,7 @@ struct ath11k_qmi { ...@@ -125,6 +125,7 @@ struct ath11k_qmi {
struct target_mem_chunk target_mem[ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01]; struct target_mem_chunk target_mem[ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
u32 mem_seg_count; u32 mem_seg_count;
u32 target_mem_mode; u32 target_mem_mode;
bool target_mem_delayed;
u8 cal_done; u8 cal_done;
struct target_info target; struct target_info target;
struct m3_mem_region m3_mem; struct m3_mem_region m3_mem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment