๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Nicolai Buchwitz Wed, 18 Nov 2026 19:55
[PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init
#18734
Author: Nicolai Buchwitz
Date: Wed, 18 Nov 2026 19:55
33 lines
9646 bytes
A close can cancel the pending profile work and leave DIM in
DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive coalescing
then stays stuck after the next open.

Reset the DIM state on ring init and start from the default profile,
which is what bcmgenet_init_rx_coalesce() programs.

Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 70c6a6465c81..96620d298677 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2702,8 +2702,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
 {
 	struct bcmgenet_net_dim *dim = &ring->dim;
 
+	memset(&dim->dim, 0, sizeof(dim->dim));
 	INIT_WORK(&dim->dim.work, cb);
 	dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+	/* Match the profile bcmgenet_init_rx_coalesce() programs */
+	dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
 	dim->event_ctr = 0;
 	dim->packets = 0;
 	dim->bytes = 0;

-- 
2.53.0
Re: [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init
#19359
Author: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 20:31
104 lines
11870 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch fixes the 'cancelled profile work leaves DIM stuck in
  DIM_APPLY_NEW_PROFILE' bug only for close/open.

--

net: bcmgenet: restart DIM from the default profile on ring init

The patch clears struct dim in bcmgenet_init_dim() and sets profile_ix to
NET_DIM_DEF_PROFILE_EQE. A close that cancels the pending DIM profile
work can leave the state machine in DIM_APPLY_NEW_PROFILE, and this reset
keeps it from staying stuck after the next open.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 70c6a6465c81e..96620d2986777 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -2702,8 +2702,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
>  {
>  	struct bcmgenet_net_dim *dim = &ring->dim;
>  
> +	memset(&dim->dim, 0, sizeof(dim->dim));
>  	INIT_WORK(&dim->dim.work, cb);
>  	dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
> +	/* Match the profile bcmgenet_init_rx_coalesce() programs */
> +	dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;

[Severity: High]
Can the same stuck DIM state still happen through Wake-on-LAN
suspend/resume?

The reset only runs from bcmgenet_init_dim(). Its only caller is
bcmgenet_init_rx_ring(), which is reached through bcmgenet_init_dma().

The WoL branch of bcmgenet_suspend() goes through the same cancel that
the commit message describes for close:

bcmgenet_suspend()
    if (device_may_wakeup(d) && priv->wolopts) {
        ...
        bcmgenet_disable_rx_napi(priv);
        disable_irq(priv->irq1);
        ...
    }

bcmgenet_disable_rx_napi()
    napi_disable(&ring->napi);
    cancel_work_sync(&ring->dim.dim.work);

Suppose the last net_dim() call set dim->state = DIM_APPLY_NEW_PROFILE
and scheduled the work just before this point. The work is cancelled,
and bcmgenet_dim_work() never runs. It is the only place that moves the
state back to DIM_START_MEASURE.

On resume, the fast path in bcmgenet_resume() re-enables RX NAPI without
reinitializing the rings:

bcmgenet_resume()
    if (priv->tx_cbs && (reg & CMD_RX_EN)) {
        /* Successfully exited WoL, just resume data flows */
        ...
        bcmgenet_enable_rx_napi(priv);

That means bcmgenet_init_dim() is not called, so the new memset and
profile_ix reset never run. After that, every net_dim() call hits:

    case DIM_APPLY_NEW_PROFILE:
        break;

Adaptive RX coalescing stays frozen until the next ifdown/ifup. Also,
profile_ix already points at the new profile, while the
DMA_MBUF_DONE_THRESH and DMA_RING0_TIMEOUT registers still hold the old
values.

Toggling adaptive coalescing through ethtool doesn't seem to recover
from this, since bcmgenet_set_ring_rx_coalesce() never touches
dim.state.

Would it work better to reset ring->dim.dim.state, and re-sync
profile_ix, in bcmgenet_disable_rx_napi() right after
cancel_work_sync()? That would cover both close and WoL suspend.

The later patches in this series ("net: bcmgenet: reset the Rx discard
count with the ring" and "net: systemport: accumulate the DIM packet and
byte counters") don't touch this path, so the gap is still there at the
end of the series.

>  	dim->event_ctr = 0;
>  	dim->packets = 0;
>  	dim->bytes = 0;

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-nb-genet-dim-stats-net-v1-0-13b275f1e088%40tipi-net.de
Re: [PATCH net 2/4] net: bcmgenet: restart DIM from the default profile on ring init
#19949
Author: Nicolai Buchwitz
Date: Fri, 20 Nov 2026 20:16
77 lines
11151 bytes
On 19.11.2026 21:31, netdev-bot+sashiko@kernel.org wrote:
> [...]

> [Severity: High]
> Can the same stuck DIM state still happen through Wake-on-LAN
> suspend/resume?
> 
> The reset only runs from bcmgenet_init_dim(). Its only caller is
> bcmgenet_init_rx_ring(), which is reached through bcmgenet_init_dma().
> 
> The WoL branch of bcmgenet_suspend() goes through the same cancel that
> the commit message describes for close:
> 
> bcmgenet_suspend()
>     if (device_may_wakeup(d) && priv->wolopts) {
>         ...
>         bcmgenet_disable_rx_napi(priv);
>         disable_irq(priv->irq1);
>         ...
>     }
> 
> bcmgenet_disable_rx_napi()
>     napi_disable(&ring->napi);
>     cancel_work_sync(&ring->dim.dim.work);
> 
> Suppose the last net_dim() call set dim->state = DIM_APPLY_NEW_PROFILE
> and scheduled the work just before this point. The work is cancelled,
> and bcmgenet_dim_work() never runs. It is the only place that moves the
> state back to DIM_START_MEASURE.
> 
> On resume, the fast path in bcmgenet_resume() re-enables RX NAPI 
> without
> reinitializing the rings:
> 
> bcmgenet_resume()
>     if (priv->tx_cbs && (reg & CMD_RX_EN)) {
>         /* Successfully exited WoL, just resume data flows */
>         ...
>         bcmgenet_enable_rx_napi(priv);
> 
> That means bcmgenet_init_dim() is not called, so the new memset and
> profile_ix reset never run. After that, every net_dim() call hits:
> 
>     case DIM_APPLY_NEW_PROFILE:
>         break;
> 
> Adaptive RX coalescing stays frozen until the next ifdown/ifup. Also,
> profile_ix already points at the new profile, while the
> DMA_MBUF_DONE_THRESH and DMA_RING0_TIMEOUT registers still hold the old
> values.
> 
> Toggling adaptive coalescing through ethtool doesn't seem to recover
> from this, since bcmgenet_set_ring_rx_coalesce() never touches
> dim.state.
> 
> Would it work better to reset ring->dim.dim.state, and re-sync
> profile_ix, in bcmgenet_disable_rx_napi() right after
> cancel_work_sync()? That would cover both close and WoL suspend.
> 
> The later patches in this series ("net: bcmgenet: reset the Rx discard
> count with the ring" and "net: systemport: accumulate the DIM packet 
> and
> byte counters") don't touch this path, so the gap is still there at the
> end of the series.
> 
>>  	dim->event_ctr = 0;
>>  	dim->packets = 0;
>>  	dim->bytes = 0;

Valid point. I will use flush_work() instead, which is IMHO a better 
fit.
It applies the pending profile, so profile_ix and the hardware stay in
sync, and it covers both close and WoL suspend.

--
pw-bot: cr
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads