* [PATCH net] dpaa2-eth: fix race condition with bql frame accounting
@ 2019-03-25 13:06 Ioana Ciornei
2019-03-26 18:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Ioana Ciornei @ 2019-03-25 13:06 UTC (permalink / raw)
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Ioana Ciocoi Radulescu, Ioana Ciornei
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>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 1a68052..dc339dc 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -815,6 +815,14 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
*/
queue_mapping = skb_get_queue_mapping(skb);
fq = &priv->fq[queue_mapping];
+
+ fd_len = dpaa2_fd_get_len(&fd);
+ nq = netdev_get_tx_queue(net_dev, queue_mapping);
+ netdev_tx_sent_queue(nq, fd_len);
+
+ /* Everything that happens after this enqueues might race with
+ * the Tx confirmation callback for this frame
+ */
for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
err = priv->enqueue(priv, fq, &fd, 0);
if (err != -EBUSY)
@@ -825,13 +833,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
percpu_stats->tx_errors++;
/* Clean up everything, including freeing the skb */
free_tx_fd(priv, fq, &fd, false);
+ netdev_tx_completed_queue(nq, 1, fd_len);
} else {
- fd_len = dpaa2_fd_get_len(&fd);
percpu_stats->tx_packets++;
percpu_stats->tx_bytes += fd_len;
-
- nq = netdev_get_tx_queue(net_dev, queue_mapping);
- netdev_tx_sent_queue(nq, fd_len);
}
return NETDEV_TX_OK;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] dpaa2-eth: fix race condition with bql frame accounting
2019-03-25 13:06 [PATCH net] dpaa2-eth: fix race condition with bql frame accounting Ioana Ciornei
@ 2019-03-26 18:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-26 18:44 UTC (permalink / raw)
To: ioana.ciornei; +Cc: netdev, ruxandra.radulescu
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Mon, 25 Mar 2019 13:06:22 +0000
> 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>
Please always use 12 digits of signifigance for SHA1 values in Fixes: tags
as per the patch submission guidelines.
I fixed it up for you this time.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-26 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-25 13:06 [PATCH net] dpaa2-eth: fix race condition with bql frame accounting Ioana Ciornei
2019-03-26 18:44 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).