Re: [PATCH net-next 5/5] net/mlx4: flush pending doorbell when dropping a TX skb
From: Joe Damato
Date: Tue Nov 17 2026 - 10:33:19 EST
On Thu, Nov 12, 2026 at 02:43:46PM +0100, Daniel Machon wrote:
> > If mlx4_en_xmit drops an skb (for example because DMA mapping fails) and
> > that skb happens to be the last one in the batch, the doorbell for the
> > WQEs posted earlier in the batch isn't written.
> >
> > The queue stays awake, though, so those WQEs are eventually announced to
> > the HW after the next TX, but that depends on traffic and could induce
> > latency.
> >
> > Avoid all of that by writing the pending doorbell in the drop path.
> >
> > Signed-off-by: Joe Damato <joe@xxxxxxx>
> > ---
> > drivers/net/ethernet/mellanox/mlx4/en_tx.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > index 123071a47bed..3166837711be 100644
> > --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
> > @@ -1135,6 +1135,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
> >
> > tx_drop_count:
> > ring->tx_dropped++;
> > + /* an earlier skb in this batch may have deferred the doorbell */
> > + if (ring->doorbell_pending)
>
> I think checking !netdev_xmit_more() here would let you ditch the new ring
> state, but it seems bnxt does it the same way, so fine by me.
I need the state for the SW USO followup I mentioned in the cover letter.
That aside, every mlx4 doorbell site today writes it only after posting at
least one WQE. I think replacing this with !netdev_xmit_more() might write a
doorbell with no new WQEs and idk if that is supported by the hardware. It
looks like the XDP path gates against that specifically.
> > + mlx4_en_xmit_doorbell(ring);
> > tx_drop:
> > dev_kfree_skb_any(skb);
> > return NETDEV_TX_OK;
> > --
> > 2.53.0-Meta
> >
>
> Reviewed-by: Daniel Machon <daniel.machon@xxxxxxxxxxxxx>
Thanks