Re: [PATCH net] net: sundance: fix sign extension of the octet counters

From: Jakub Kicinski

Date: Tue Oct 20 2026 - 21:11:27 EST


On Wed, 21 Oct 2026 02:44:34 +0300 Rand Deeb wrote:
> get_stats() adds the upper halves of the 32-bit TxOctets and RxOctets
> hardware counters to the byte statistics with
>
> dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsHigh) << 16;
>
> On architectures that use the ioread16() from asm-generic/io.h, which
> returns u16, the value is promoted to int before the shift. When the
> high word is 0x8000 or more, the result does not fit in a positive int
> and ends up negative, and adding it to the unsigned long counter
> sign-extends it. On 64-bit kernels tx_bytes and rx_bytes then end up
> 2^32 lower than they should be. x86 and m68k are not affected, because
> their ioread16() comes from asm-generic/iomap.h and returns unsigned int.
>
> Cast the high word to u32 before shifting, so the result is the same on
> all architectures.

We don't take LLM slop fixes for ancient hw
--
pw-bot: reject