From: Johan Hovold <johan@kernel.org>
To: Miaoqing Pan <quic_miaoqing@quicinc.com>
Cc: quic_jjohnson@quicinc.com, ath11k@lists.infradead.org,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
johan+linaro@kernel.org
Subject: Re: [PATCH v3 ath-next 2/2] wifi: ath11k: fix HTC rx insufficient length
Date: Fri, 14 Mar 2025 09:20:55 +0100 [thread overview]
Message-ID: <Z9Pm56Xx7kYZl8fk@hovoldconsulting.com> (raw)
In-Reply-To: <20250314061353.106194-3-quic_miaoqing@quicinc.com>
On Fri, Mar 14, 2025 at 02:13:53PM +0800, Miaoqing Pan wrote:
> A relatively unusual race condition occurs between host software
> and hardware, where the host sees the updated destination ring head
> pointer before the hardware updates the corresponding descriptor.
> When this situation occurs, the length of the descriptor returns 0.
>
> The current error handling method is to increment descriptor tail
> pointer by 1, but 'sw_index' is not updated, causing descriptor and
> skb to not correspond one-to-one, resulting in the following error:
>
> ath11k_pci 0006:01:00.0: HTC Rx: insufficient length, got 1488, expected 1492
> ath11k_pci 0006:01:00.0: HTC Rx: insufficient length, got 1460, expected 1484
>
> To address this problem and work around the broken hardware,
> temporarily skip processing the current descriptor and handle it
> again next time. However, to prevent this descriptor from
> continuously returning 0, use the skb control block (cb) to set
> a flag. If the length returns 0 again, this descriptor will be
> discarded.
>
> Tested-on: QCA6698AQ hw2.1 PCI WLAN.HSP.1.1-04546-QCAHSPSWPL_V1_V2_SILICONZ_IOE-1
>
> Reported-by: Johan Hovold <johan+linaro@kernel.org>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218623
> Signed-off-by: Miaoqing Pan <quic_miaoqing@quicinc.com>
> @@ -387,18 +387,36 @@ static int ath11k_ce_completed_recv_next(struct ath11k_ce_pipe *pipe,
>
> ath11k_hal_srng_access_begin(ab, srng);
>
> - desc = ath11k_hal_srng_dst_get_next_entry(ab, srng);
> + desc = ath11k_hal_srng_dst_peek(ab, srng);
> if (!desc) {
> ret = -EIO;
> goto err;
> }
>
> *nbytes = ath11k_hal_ce_dst_status_get_length(desc);
As I mentioned elsewhere, this function also sets the length field in
the descriptor to zero. So if there's a racing update, you may never see
the updated length.
> - if (*nbytes == 0) {
> - ret = -EIO;
> - goto err;
> + if (unlikely(*nbytes == 0)) {
> + struct ath11k_skb_rxcb *rxcb =
> + ATH11K_SKB_RXCB(pipe->dest_ring->skb[sw_index]);
> +
> + /* A relatively unusual race condition occurs between host
> + * software and hardware, where the host sees the updated
> + * destination ring head pointer before the hardware updates
> + * the corresponding descriptor.
> + *
> + * Temporarily skip processing the current descriptor and handle
> + * it again next time. However, to prevent this descriptor from
> + * continuously returning 0, set 'is_desc_len0' flag. If the
> + * length returns 0 again, this descriptor will be discarded.
> + */
> + if (!rxcb->is_desc_len0) {
> + rxcb->is_desc_len0 = true;
> + ret = -EIO;
> + goto err;
> + }
If you add the memory barrier and make sure not to clear the length
field above, do you still see the length sometimes always reading zero
if you retry more than once (i.e. drop the is_desc_len0 flag)?
Perhaps the device is really passing you a zero-length descriptor that
can simply be discarded straight away?
Johan
next prev parent reply other threads:[~2025-03-14 8:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 6:13 [PATCH v3 ath-next 0/2] wifi: ath11k: fix HTC rx insufficient length Miaoqing Pan
2025-03-14 6:13 ` [PATCH v3 ath-next 1/2] wifi: ath11k: add function to get next srng desc Miaoqing Pan
2025-03-14 6:13 ` [PATCH v3 ath-next 2/2] wifi: ath11k: fix HTC rx insufficient length Miaoqing Pan
2025-03-14 8:20 ` Johan Hovold [this message]
2025-03-14 13:56 ` Miaoqing Pan
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=Z9Pm56Xx7kYZl8fk@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=ath11k@lists.infradead.org \
--cc=johan+linaro@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_jjohnson@quicinc.com \
--cc=quic_miaoqing@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