Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 569dac6a5a0d ("dpaa2-eth: bql support")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ioana Ciornei and committed by
David S. Miller
8c838f53 047a013f

+9 -4
+9 -4
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
··· 815 815 */ 816 816 queue_mapping = skb_get_queue_mapping(skb); 817 817 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 + */ 818 826 for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) { 819 827 err = priv->enqueue(priv, fq, &fd, 0); 820 828 if (err != -EBUSY) ··· 833 825 percpu_stats->tx_errors++; 834 826 /* Clean up everything, including freeing the skb */ 835 827 free_tx_fd(priv, fq, &fd, false); 828 + netdev_tx_completed_queue(nq, 1, fd_len); 836 829 } else { 837 - fd_len = dpaa2_fd_get_len(&fd); 838 830 percpu_stats->tx_packets++; 839 831 percpu_stats->tx_bytes += fd_len; 840 - 841 - nq = netdev_get_tx_queue(net_dev, queue_mapping); 842 - netdev_tx_sent_queue(nq, fd_len); 843 832 } 844 833 845 834 return NETDEV_TX_OK;