Re: [PATCH net] net: ethernet: sunplus: check budget before calling napi_complete_done()
From: Janis Edvarts Lacis
Date: Mon Nov 16 2026 - 16:53:33 EST
On 15 Nov 16:50, Andrew Lunn wrote:
On Sun, Nov 15, 2026 at 12:27:44AM +0200, Janis Edvarts Lacis wrote:
Sunplus drivers currently do napi_complete() after each rx/tx poll is
done without checking whether budget was exhausted or not. Interrupts
are also unmasked before the call to napi_complete().
Replace napi_complete() with napi_complete_done() and add a check for
budget_left. Call napi_complete_done() only when the budget has been
not exhausted fully, e.g. budget_left > 0 and unmask interrupts only when
napi_complete_done() returns true.
I do not have the hardware necessary, this patch is not tested on real
hardware.
Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021")
Signed-off-by: Janis Edvarts Lacis <janislacis06@xxxxxxxxx>
Does this bother anybody? If not, net-next. No Fixes: tag.
Will do in the v2.
Given that you have not tested this, how confident are you it is
correct?
I am fairly confident the change is correct, as the documentation
supports it. When netpoll calls the poll function with budget = 0, napi_complete() returns false, but the driver ignores the return value and unmasks interrupts anyway.
During normal NAPI polling, budget is set to default (64), but the
driver has less descriptors and it looks at each one at most once.
Therefore, on this path, the only benefit of this patch is that
interrupts are unmasked after napi_complete_done() instead of before, as
in the old version.
Of course, actual testing on a device would be great though.
Best regards,
Janis