Re: [PATCH v4] wifi: ath12k: fix endianness handling for SRNG ring pointer accesses
From: Alexander Wilhelm
Date: Fri Mar 13 2026 - 02:45:57 EST
On Fri, Mar 13, 2026 at 10:44:52AM +0800, Baochen Qiang wrote:
>
>
> On 3/11/2026 6:24 PM, Alexander Wilhelm wrote:
> > The SRNG head and tail ring pointers are stored in device memory as
> > little-endian values. On big-endian systems, direct dereferencing of these
> > pointers leads to incorrect values being read or written, causing ring
> > management issues and potentially breaking data flow.
> >
> > This patch ensures all accesses to SRNG ring pointers use the appropriate
> > endianness conversions. This affects both read and write paths for source
> > and destination rings, as well as debug output. The changes guarantee
> > correct operation on both little- and big-endian architectures.
> >
> > Signed-off-by: Alexander Wilhelm <alexander.wilhelm@xxxxxxxxxxxx>
> > Reviewed-by: Baochen Qiang <baochen.qiang@xxxxxxxxxxxxxxxx>
> > ---
> > Changes in v4:
> > - Rebase on latest 'ath' master
> > - Remove volatile from `hp_addr` due to the `checkpatch.pl` warning
>
> by 'cgeckpatch.pl wanring' did you mean below ?
>
> "
> WARNING: Use of volatile is usually wrong: see
> Documentation/process/volatile-considered-harmful.rst
> #64: FILE: drivers/net/wireless/ath/ath12k/hal.c:504:
> + *(volatile __le32 *)srng->u.src_ring.tp_addr);
> "
>
> But the documentation clearly says that the case here is one of a few rare situations
> where volatile makes sense:
>
> "
> - Pointers to data structures in coherent memory which might be modified
> by I/O devices can, sometimes, legitimately be volatile. A ring buffer
> used by a network adapter, where that adapter changes pointers to
> indicate which descriptors have been processed, is an example of this
> type of situation.
> "
Oh, my fault. I'll fix it in the v5 iteration. Thank you for the response.
Best regards
Alexander Wilhelm