Re: [PATCH net] net: dlink: mask rx_coalesce/rx_timeout before writing RxDMAIntCtrl
From: Paolo Abeni
Date: Tue Dec 30 2025 - 05:57:43 EST
On 12/23/25 10:43 AM, Andrew Lunn wrote:
> On Tue, Dec 23, 2025 at 09:10:06AM +0900, Yeounsu Moon wrote:
>> RxDMAIntCtrl encodes rx_coalesce in the low 16 bits
>> and rx_timeout in the high 16 bits. If either value exceeds
>> the field width, the current code may truncate the value and/or
>> corrupt adjacent bits when programming the register.
>>
>> Mask both values to 16 bits and cast to u32 before shifting
>> so only the intended fields are written.
>
> It would be better to do range checks in rio_probe1() and call
> netdev_err() and return -EINVAL?
>
> Anybody trying to use very large values then gets an error message
> rather than it working, but not as expected.
I'm not sure we can do such change: any eventual user with bad setting
will get a broken setup after kernel update. I think we should avoid
such regression, and use something similar to this patch.
@Yeounsu: the type cast in the current patch is not needed, please drop
it, thanks!
Paolo