Skip to content

Commit 8c838f5

Browse files
IoanaCiorneidavem330
authored andcommitted
dpaa2-eth: fix race condition with bql frame accounting
It might happen that Tx conf acknowledges a frame before it was subscribed in bql, as subscribing was previously done after the enqueue operation. This patch moves the netdev_tx_sent_queue call before the actual frame enqueue, so that this can never happen. Fixes: 569dac6 ("dpaa2-eth: bql support") Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 047a013 commit 8c838f5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,14 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
815815
*/
816816
queue_mapping = skb_get_queue_mapping(skb);
817817
fq = &priv->fq[queue_mapping];
818+
819+
fd_len = dpaa2_fd_get_len(&fd);
820+
nq = netdev_get_tx_queue(net_dev, queue_mapping);
821+
netdev_tx_sent_queue(nq, fd_len);
822+
823+
/* Everything that happens after this enqueues might race with
824+
* the Tx confirmation callback for this frame
825+
*/
818826
for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
819827
err = priv->enqueue(priv, fq, &fd, 0);
820828
if (err != -EBUSY)
@@ -825,13 +833,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
825833
percpu_stats->tx_errors++;
826834
/* Clean up everything, including freeing the skb */
827835
free_tx_fd(priv, fq, &fd, false);
836+
netdev_tx_completed_queue(nq, 1, fd_len);
828837
} else {
829-
fd_len = dpaa2_fd_get_len(&fd);
830838
percpu_stats->tx_packets++;
831839
percpu_stats->tx_bytes += fd_len;
832-
833-
nq = netdev_get_tx_queue(net_dev, queue_mapping);
834-
netdev_tx_sent_queue(nq, fd_len);
835840
}
836841

837842
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)