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 and clearing the flag. Suggested-by: Mark Bloch Signed-off-by: Joe Damato --- v3: - Add mlx4_en_flush_pending_doorbell which clears the flag. - Call it from mlx4_en_xmit (Mark). - Dropped Daniel's Reviewed-by drivers/net/ethernet/mellanox/mlx4/en_tx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 8a43c86f815c..8fd1850ba756 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -759,6 +759,14 @@ void mlx4_en_xmit_doorbell(struct mlx4_en_tx_ring *ring) (__force u32)ring->doorbell_qpn, ring->doorbell_address); } +static void mlx4_en_flush_pending_doorbell(struct mlx4_en_tx_ring *ring) +{ + if (ring->doorbell_pending) { + mlx4_en_xmit_doorbell(ring); + ring->doorbell_pending = false; + } +} + static void mlx4_en_tx_write_desc(struct mlx4_en_tx_ring *ring, struct mlx4_en_tx_desc *tx_desc, union mlx4_wqe_qpn_vlan qpn_vlan, @@ -1131,6 +1139,8 @@ 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 */ + mlx4_en_flush_pending_doorbell(ring); tx_drop: dev_kfree_skb_any(skb); return NETDEV_TX_OK; -- 2.53.1-Meta