From: Muhammad Usama Anjum <usama.anjum@collabora.com>
To: jeff.johnson@oss.qualcomm.com, Jeff Johnson <jjohnson@kernel.org>
Cc: usama.anjum@collabora.com, kernel@collabora.com,
linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
linux-kernel@vger.kernel.org, quic_bqiang@quicinc.com
Subject: Re: [PATCH v5] wifi: ath11k: Fix memory reuse logic
Date: Mon, 5 May 2025 13:11:23 +0500 [thread overview]
Message-ID: <d2ce1fd8-cd84-4744-9847-2ac393bf99eb@collabora.com> (raw)
In-Reply-To: <20250428080242.466901-1-usama.anjum@collabora.com>
Reminder to pick this patch.
On 4/28/25 1:02 PM, Muhammad Usama Anjum wrote:
> Firmware requests 2 segments at first. The first segment is of 6799360
> whose allocation fails due to dma remapping not available. The success
> is returned to firmware. Then firmware asks for 22 smaller segments
> instead of 2 big ones. Those get allocated successfully. At suspend/
> hibernation time, these segments aren't freed as they will be reused
> by firmware after resuming.
>
> After resuming, the firmware asks for the 2 segments again with the
> first segment of 6799360 size. Since chunk->vaddr is not NULL, the
> type and size are compared with the previous type and size to know if
> it can be reused or not. Unfortunately, it is detected that it cannot
> be reused and this first smaller segment is freed. Then we continue to
> allocate 6799360 size memory which fails and ath11k_qmi_free_target_mem_chunk()
> is called which frees the second smaller segment as well. Later success
> is returned to firmware which asks for 22 smaller segments again. But
> as we had freed 2 segments already, we'll allocate the first 2 new
> smaller segments again and reuse the remaining 20. Hence 20 small
> segments are being reused instead of 22.
>
> Add skip logic when vaddr is set, but size/type don't match. Use the
> same skip and success logic as used when dma_alloc_coherent() fails.
> By skipping, the possibility of resume failure due to kernel failing to
> allocate memory for QMI can be avoided.
>
> kernel: ath11k_pci 0000:03:00.0: failed to allocate dma memory for qmi (524288 B type 1)
> ath11k_pci 0000:03:00.0: failed to allocate qmi target memory: -22
>
> Tested-on: WCN6855 WLAN.HSP.1.1-03926.13-QCAHSPSWPL_V2_SILICONZ_CE-2.52297.6
>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> Changes since v1:
> - Update description
>
> Changes since v2:
> - Update description and title of patch
>
> Changes since v3:
> - Update description and title of patch
>
> Changes since v4:
> - Update title of the patch
> ---
> drivers/net/wireless/ath/ath11k/qmi.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
> index 47b9d4126d3a9..2782f4723e413 100644
> --- a/drivers/net/wireless/ath/ath11k/qmi.c
> +++ b/drivers/net/wireless/ath/ath11k/qmi.c
> @@ -1993,6 +1993,15 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
> chunk->prev_size == chunk->size)
> continue;
>
> + if (ab->qmi.mem_seg_count <= ATH11K_QMI_FW_MEM_REQ_SEGMENT_CNT) {
> + ath11k_dbg(ab, ATH11K_DBG_QMI,
> + "size/type mismatch (current %d %u) (prev %d %u), try later with small size\n",
> + chunk->size, chunk->type,
> + chunk->prev_size, chunk->prev_type);
> + ab->qmi.target_mem_delayed = true;
> + return 0;
> + }
> +
> /* cannot reuse the existing chunk */
> dma_free_coherent(ab->dev, chunk->prev_size,
> chunk->vaddr, chunk->paddr);
--
Regards,
Usama
next prev parent reply other threads:[~2025-05-05 8:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 8:02 [PATCH v5] wifi: ath11k: Fix memory reuse logic Muhammad Usama Anjum
2025-04-29 2:39 ` Baochen Qiang
2025-05-05 8:11 ` Muhammad Usama Anjum [this message]
2025-05-05 19:17 ` Jeff Johnson
2025-05-06 6:41 ` Baochen Qiang
2025-05-06 6:43 ` Baochen Qiang
2025-05-06 14:42 ` Jeff Johnson
2025-05-06 13:10 ` Muhammad Usama Anjum
2025-05-06 14:37 ` Jeff Johnson
2025-05-07 2:12 ` Baochen Qiang
2025-05-16 18:33 ` Jeff Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2ce1fd8-cd84-4744-9847-2ac393bf99eb@collabora.com \
--to=usama.anjum@collabora.com \
--cc=ath11k@lists.infradead.org \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_bqiang@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox