* [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend
2026-11-20 22:42 [PATCH net v2 0/5] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
@ 2026-11-20 22:42 ` Nicolai Buchwitz
2026-11-21 0:19 ` Florian Fainelli
2026-11-20 22:42 ` [PATCH net v2 2/5] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-11-20 22:42 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Nicolai Buchwitz
A close or WoL suspend cancels the pending profile work and can leave
DIM in DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive
coalescing then stays stuck after the next open or resume, and the
profile index no longer matches the hardware. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.
Run net_dim() before completing NAPI and flush the work instead of
cancelling it, so the pending profile gets applied. Also 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 | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 4d2be2a21ed1..f702916e7bfa 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2502,15 +2502,16 @@ static int bcmgenet_rx_poll(struct napi_struct *napi, int budget)
work_done = bcmgenet_desc_rx(ring, budget);
- if (work_done < budget && napi_complete_done(napi, work_done))
- bcmgenet_rx_ring_int_enable(ring);
-
+ /* net_dim() can queue work, so run it while NAPI is still owned */
if (ring->dim.use_dim) {
dim_update_sample(ring->dim.event_ctr, ring->dim.packets,
ring->dim.bytes, &dim_sample);
net_dim(&ring->dim.dim, &dim_sample);
}
+ if (work_done < budget && napi_complete_done(napi, work_done))
+ bcmgenet_rx_ring_int_enable(ring);
+
return work_done;
}
@@ -2702,8 +2703,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;
@@ -3014,7 +3018,8 @@ static void bcmgenet_disable_rx_napi(struct bcmgenet_priv *priv)
for (i = 0; i <= priv->hw_params->rx_queues; ++i) {
ring = &priv->rx_rings[i];
napi_disable(&ring->napi);
- cancel_work_sync(&ring->dim.dim.work);
+ /* Cancelling would leave DIM stuck in DIM_APPLY_NEW_PROFILE */
+ flush_work(&ring->dim.dim.work);
}
}
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend
2026-11-20 22:42 ` [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend Nicolai Buchwitz
@ 2026-11-21 0:19 ` Florian Fainelli
0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2026-11-21 0:19 UTC (permalink / raw)
To: Nicolai Buchwitz, Doug Berger, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel
On 11/20/26 14:42, Nicolai Buchwitz wrote:
> A close or WoL suspend cancels the pending profile work and can leave
> DIM in DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive
> coalescing then stays stuck after the next open or resume, and the
> profile index no longer matches the hardware. The poll also calls
> net_dim() after napi_complete_done(), so it can queue new work after
> napi_disable() has returned.
>
> Run net_dim() before completing NAPI and flush the work instead of
> cancelling it, so the pending profile gets applied. Also 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>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v2 2/5] net: bcmgenet: accumulate the DIM packet and byte counters
2026-11-20 22:42 [PATCH net v2 0/5] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend Nicolai Buchwitz
@ 2026-11-20 22:42 ` Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 3/5] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-11-20 22:42 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Nicolai Buchwitz
net_dim() computes rates from the difference between two samples and
needs running totals, but bcmgenet_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
On a CM4 at a steady 300 Mbit/s UDP, DIM changed profile about 1000
times in 20 s. With the fix it settles, and Rx interrupts drop from about
4500/s to 2240/s.
Accumulate the counters instead.
Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index f702916e7bfa..f9f38445568f 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2486,8 +2486,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
bcmgenet_rdma_ring_writel(priv, ring->index, ring->c_index, RDMA_CONS_INDEX);
}
- ring->dim.bytes = bytes_processed;
- ring->dim.packets = rxpktprocessed;
+ ring->dim.bytes += bytes_processed;
+ ring->dim.packets += rxpktprocessed;
return rxpktprocessed;
}
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v2 3/5] net: bcmgenet: reset the Rx discard count with the ring
2026-11-20 22:42 [PATCH net v2 0/5] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 1/5] net: bcmgenet: keep DIM from getting stuck after close or suspend Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 2/5] net: bcmgenet: accumulate the DIM packet and byte counters Nicolai Buchwitz
@ 2026-11-20 22:42 ` Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 4/5] net: systemport: restart DIM from the default profile on start Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 5/5] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
4 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-11-20 22:42 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Nicolai Buchwitz
Ring init clears the hardware discard counter but not
ring->old_discards. Discards after an ifdown and ifup or a resume are
then missing from rx_missed. On a CM4, after an ifdown and ifup, 3666
discards showed up as 0 in rx_missed.
Reset old_discards together with the ring.
Fixes: d26ea6cc48da ("net: bcmgenet: collect Rx discarded packet count")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index f9f38445568f..b81408e6293c 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2826,6 +2826,8 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv,
ring->read_ptr = start_ptr;
ring->cb_ptr = start_ptr;
ring->end_ptr = end_ptr - 1;
+ /* Zeroing RDMA_PROD_INDEX below also clears the discard counter */
+ ring->old_discards = 0;
ret = bcmgenet_rx_ring_create_pool(priv, ring);
if (ret)
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v2 4/5] net: systemport: restart DIM from the default profile on start
2026-11-20 22:42 [PATCH net v2 0/5] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
` (2 preceding siblings ...)
2026-11-20 22:42 ` [PATCH net v2 3/5] net: bcmgenet: reset the Rx discard count with the ring Nicolai Buchwitz
@ 2026-11-20 22:42 ` Nicolai Buchwitz
2026-11-20 22:42 ` [PATCH net v2 5/5] net: systemport: accumulate the DIM packet and byte counters Nicolai Buchwitz
4 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-11-20 22:42 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Nicolai Buchwitz
A close or suspend 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 or resume. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.
Run net_dim() before completing NAPI. Reset the DIM state on start and
begin from the default profile, which is what
bcm_sysport_init_rx_coalesce() programs.
Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index bc88a27da16b..29e608e7daaf 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1012,18 +1012,19 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget)
else
rdma_writel(priv, priv->rx_c_index << 16, RDMA_CONS_INDEX);
- if (work_done < budget) {
- napi_complete_done(napi, work_done);
- /* re-enable RX interrupts */
- intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
- }
-
+ /* net_dim() can queue work, so run it while NAPI is still owned */
if (priv->dim.use_dim) {
dim_update_sample(priv->dim.event_ctr, priv->dim.packets,
priv->dim.bytes, &dim_sample);
net_dim(&priv->dim.dim, &dim_sample);
}
+ if (work_done < budget) {
+ napi_complete_done(napi, work_done);
+ /* re-enable RX interrupts */
+ intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
+ }
+
return work_done;
}
@@ -1452,8 +1453,11 @@ static void bcm_sysport_init_dim(struct bcm_sysport_priv *priv,
{
struct bcm_sysport_net_dim *dim = &priv->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 bcm_sysport_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
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v2 5/5] net: systemport: accumulate the DIM packet and byte counters
2026-11-20 22:42 [PATCH net v2 0/5] net: bcmgenet, systemport: DIM and Rx discard fixes Nicolai Buchwitz
` (3 preceding siblings ...)
2026-11-20 22:42 ` [PATCH net v2 4/5] net: systemport: restart DIM from the default profile on start Nicolai Buchwitz
@ 2026-11-20 22:42 ` Nicolai Buchwitz
4 siblings, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-11-20 22:42 UTC (permalink / raw)
To: Doug Berger, Florian Fainelli, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Justin Chen, Petri Gynther, Broadcom internal kernel review list,
netdev, linux-kernel, Nicolai Buchwitz
net_dim() computes rates from the difference between two samples and
needs running totals, but bcm_sysport_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
Accumulate the counters instead.
Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 29e608e7daaf..0902dd0dd94b 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -844,8 +844,8 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
priv->rx_read_ptr = 0;
}
- priv->dim.packets = processed;
- priv->dim.bytes = processed_bytes;
+ priv->dim.packets += processed;
+ priv->dim.bytes += processed_bytes;
return processed;
}
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread