Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs
@ 2026-08-31 18:42 Danesh Petigara
  2026-08-31 18:42 ` [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor Danesh Petigara
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Danesh Petigara @ 2026-08-31 18:42 UTC (permalink / raw)
  To: justin.chen, florian.fainelli, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: horms, bcm-kernel-feedback-list, netdev, linux-kernel,
	Danesh Petigara

Two fixes for TX descriptor ring handling in the bcmasp driver:

  - tx_spb_ring_full() re-initialized next_index from
    intf->tx_spb_index on every loop iteration instead of advancing
    it, so it only ever checked a single descriptor slot regardless
    of cnt. This let bcmasp_xmit() proceed even when the ring didn't
    actually have enough free slots for the SKB's fragments.

  - bcmasp_xmit() only set txcb->last for the final fragment of an
    SKB, leaving stale true values in reused descriptor slots from a
    prior transmission. Combined with the ring-full miscount above,
    this could cause bcmasp_tx_reclaim() to treat a mid-SKB
    descriptor as the last one and free the sk_buff while later
    fragments were still in flight.

Patch 1 clears txcb->last unconditionally before it is set, and
patch 2 fixes the ring-full slot check to advance through each
candidate slot.

Justin Chen (2):
  net: bcmasp: clear txcb->last before writing each descriptor
  net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times

 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor
  2026-08-31 18:42 [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs Danesh Petigara
@ 2026-08-31 18:42 ` Danesh Petigara
  2026-09-03 22:39   ` Florian Fainelli
  2026-08-31 18:42 ` [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times Danesh Petigara
  2026-09-04  0:00 ` [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Danesh Petigara @ 2026-08-31 18:42 UTC (permalink / raw)
  To: justin.chen, florian.fainelli, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: horms, bcm-kernel-feedback-list, netdev, linux-kernel,
	Danesh Petigara

From: Justin Chen <justin.chen@broadcom.com>

bcmasp_xmit() only wrote txcb->last = true for the final fragment
of an SKB; non-final fragments left the field untouched.  If a
descriptor slot was reused while it still held a stale true from
a previous SKB (possible when tx_spb_ring_full() underreported
fullness), bcmasp_tx_reclaim() would see last == true mid-SKB and
call dev_consume_skb_any() prematurely, freeing the sk_buff while
its remaining fragments were still in flight.

Unconditionally clear txcb->last before the conditional set so every
descriptor slot starts from a known false state regardless of what a
prior transmission left behind.

Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Justin Chen <justin.chen@broadcom.com>
Assisted-by: Claude:claude-sonnet-4-6 vscode
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
---
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
index ed0977832ce4..2bd035f74fa2 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
@@ -301,6 +301,7 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)
 		txcb->bytes_sent = total_bytes;
 		dma_unmap_addr_set(txcb, dma_addr, mapping);
 		dma_unmap_len_set(txcb, dma_len, size);
+		txcb->last = false;
 		if (!i) {
 			desc->flags |= DESC_SOF;
 			if (csum_hw)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times
  2026-08-31 18:42 [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs Danesh Petigara
  2026-08-31 18:42 ` [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor Danesh Petigara
@ 2026-08-31 18:42 ` Danesh Petigara
  2026-09-03 22:39   ` Florian Fainelli
  2026-09-04  0:00 ` [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Danesh Petigara @ 2026-08-31 18:42 UTC (permalink / raw)
  To: justin.chen, florian.fainelli, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: horms, bcm-kernel-feedback-list, netdev, linux-kernel,
	Danesh Petigara

From: Justin Chen <justin.chen@broadcom.com>

The loop initialised next_index from intf->tx_spb_index on every
iteration, so incr_ring() always produced the same result and only
one slot was ever tested.  Move the initialisation before the loop
so each iteration advances next_index and the function correctly
checks that cnt consecutive descriptor slots are available before
allowing a new transmission.

Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Justin Chen <justin.chen@broadcom.com>
Assisted-by: Claude:claude-sonnet-4-6 vscode
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
---
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
index 2bd035f74fa2..f2176ef3a127 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
@@ -148,8 +148,9 @@ static int tx_spb_ring_full(struct bcmasp_intf *intf, int cnt)
 	int next_index, i;
 
 	/* Check if we have enough room for cnt descriptors */
+	next_index = intf->tx_spb_index;
 	for (i = 0; i < cnt; i++) {
-		next_index = incr_ring(intf->tx_spb_index, DESC_RING_COUNT);
+		next_index = incr_ring(next_index, DESC_RING_COUNT);
 		if (next_index == intf->tx_spb_clean_index)
 			return 1;
 	}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor
  2026-08-31 18:42 ` [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor Danesh Petigara
@ 2026-09-03 22:39   ` Florian Fainelli
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2026-09-03 22:39 UTC (permalink / raw)
  To: Danesh Petigara, justin.chen, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: horms, bcm-kernel-feedback-list, netdev, linux-kernel

On 8/31/26 11:42, Danesh Petigara wrote:
> From: Justin Chen <justin.chen@broadcom.com>
> 
> bcmasp_xmit() only wrote txcb->last = true for the final fragment
> of an SKB; non-final fragments left the field untouched.  If a
> descriptor slot was reused while it still held a stale true from
> a previous SKB (possible when tx_spb_ring_full() underreported
> fullness), bcmasp_tx_reclaim() would see last == true mid-SKB and
> call dev_consume_skb_any() prematurely, freeing the sk_buff while
> its remaining fragments were still in flight.
> 
> Unconditionally clear txcb->last before the conditional set so every
> descriptor slot starts from a known false state regardless of what a
> prior transmission left behind.
> 
> Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
> Signed-off-by: Justin Chen <justin.chen@broadcom.com>
> Assisted-by: Claude:claude-sonnet-4-6 vscode
> Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times
  2026-08-31 18:42 ` [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times Danesh Petigara
@ 2026-09-03 22:39   ` Florian Fainelli
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2026-09-03 22:39 UTC (permalink / raw)
  To: Danesh Petigara, justin.chen, andrew+netdev, davem, edumazet,
	kuba, pabeni
  Cc: horms, bcm-kernel-feedback-list, netdev, linux-kernel

On 8/31/26 11:42, Danesh Petigara wrote:
> From: Justin Chen <justin.chen@broadcom.com>
> 
> The loop initialised next_index from intf->tx_spb_index on every
> iteration, so incr_ring() always produced the same result and only
> one slot was ever tested.  Move the initialisation before the loop
> so each iteration advances next_index and the function correctly
> checks that cnt consecutive descriptor slots are available before
> allowing a new transmission.
> 
> Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
> Signed-off-by: Justin Chen <justin.chen@broadcom.com>
> Assisted-by: Claude:claude-sonnet-4-6 vscode
> Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs
  2026-08-31 18:42 [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs Danesh Petigara
  2026-08-31 18:42 ` [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor Danesh Petigara
  2026-08-31 18:42 ` [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times Danesh Petigara
@ 2026-09-04  0:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-04  0:00 UTC (permalink / raw)
  To: Danesh Petigara
  Cc: justin.chen, florian.fainelli, andrew+netdev, davem, edumazet,
	kuba, pabeni, horms, bcm-kernel-feedback-list, netdev,
	linux-kernel

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 31 Aug 2026 11:42:33 -0700 you wrote:
> Two fixes for TX descriptor ring handling in the bcmasp driver:
> 
>   - tx_spb_ring_full() re-initialized next_index from
>     intf->tx_spb_index on every loop iteration instead of advancing
>     it, so it only ever checked a single descriptor slot regardless
>     of cnt. This let bcmasp_xmit() proceed even when the ring didn't
>     actually have enough free slots for the SKB's fragments.
> 
> [...]

Here is the summary with links:
  - [net,1/2] net: bcmasp: clear txcb->last before writing each descriptor
    https://git.kernel.org/netdev/net/c/18e5e0ec0e92
  - [net,2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times
    https://git.kernel.org/netdev/net/c/0c5cf62e72d7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-04  0:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 18:42 [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs Danesh Petigara
2026-08-31 18:42 ` [PATCH net 1/2] net: bcmasp: clear txcb->last before writing each descriptor Danesh Petigara
2026-09-03 22:39   ` Florian Fainelli
2026-08-31 18:42 ` [PATCH net 2/2] net: bcmasp: fix tx_spb_ring_full() checking same slot cnt times Danesh Petigara
2026-09-03 22:39   ` Florian Fainelli
2026-09-04  0:00 ` [PATCH net 0/2] net: bcmasp: fix TX ring accounting bugs patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox