Skip to content

Commit f6f9296

Browse files
Carl HuangKalle Valo
authored andcommitted
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: Carl Huang <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 30d0850 commit f6f9296

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

drivers/net/wireless/ath/ath11k/qmi.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
16601660
struct qmi_wlanfw_respond_mem_resp_msg_v01 resp;
16611661
struct qmi_txn txn = {};
16621662
int ret = 0, i;
1663+
bool delayed;
16631664

16641665
req = kzalloc(sizeof(*req), GFP_KERNEL);
16651666
if (!req)
@@ -1672,11 +1673,13 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
16721673
* failure to FW and FW will then request mulitple blocks of small
16731674
* chunk size memory.
16741675
*/
1675-
if (!ab->bus_params.fixed_mem_region && ab->qmi.mem_seg_count <= 2) {
1676+
if (!ab->bus_params.fixed_mem_region && ab->qmi.target_mem_delayed) {
1677+
delayed = true;
16761678
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n",
16771679
ab->qmi.mem_seg_count);
16781680
memset(req, 0, sizeof(*req));
16791681
} else {
1682+
delayed = false;
16801683
req->mem_seg_len = ab->qmi.mem_seg_count;
16811684

16821685
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)
17081711
}
17091712

17101713
if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
1714+
/* the error response is expected when
1715+
* target_mem_delayed is true.
1716+
*/
1717+
if (delayed && resp.resp.error == 0)
1718+
goto out;
1719+
17111720
ath11k_warn(ab, "Respond mem req failed, result: %d, err: %d\n",
17121721
resp.resp.result, resp.resp.error);
17131722
ret = -EINVAL;
@@ -1742,13 +1751,24 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
17421751
int i;
17431752
struct target_mem_chunk *chunk;
17441753

1754+
ab->qmi.target_mem_delayed = false;
1755+
17451756
for (i = 0; i < ab->qmi.mem_seg_count; i++) {
17461757
chunk = &ab->qmi.target_mem[i];
17471758
chunk->vaddr = dma_alloc_coherent(ab->dev,
17481759
chunk->size,
17491760
&chunk->paddr,
17501761
GFP_KERNEL);
17511762
if (!chunk->vaddr) {
1763+
if (ab->qmi.mem_seg_count <= 2) {
1764+
ath11k_dbg(ab, ATH11K_DBG_QMI,
1765+
"qmi dma allocation failed (%d B type %u), will try later with small size\n",
1766+
chunk->size,
1767+
chunk->type);
1768+
ath11k_qmi_free_target_mem_chunk(ab);
1769+
ab->qmi.target_mem_delayed = true;
1770+
return 0;
1771+
}
17521772
ath11k_err(ab, "failed to alloc memory, size: 0x%x, type: %u\n",
17531773
chunk->size,
17541774
chunk->type);
@@ -2517,7 +2537,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl,
25172537
ret);
25182538
return;
25192539
}
2520-
} else if (msg->mem_seg_len > 2) {
2540+
} else {
25212541
ret = ath11k_qmi_alloc_target_mem_chunk(ab);
25222542
if (ret) {
25232543
ath11k_warn(ab, "qmi failed to alloc target memory: %d\n",

drivers/net/wireless/ath/ath11k/qmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ struct ath11k_qmi {
125125
struct target_mem_chunk target_mem[ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
126126
u32 mem_seg_count;
127127
u32 target_mem_mode;
128+
bool target_mem_delayed;
128129
u8 cal_done;
129130
struct target_info target;
130131
struct m3_mem_region m3_mem;

0 commit comments

Comments
 (0)