Skip to contentSkip to conversation

r8169: remove unneeded memory barrier in rtl_tx

PATCH Applied Heiner Kallweit 2 participants 2 messages Oct 29, 2020 – Oct 31, 2020

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 r8169: remove unneeded memory barrier in rtl_tx

tp->dirty_tx isn't changed outside rtl_tx(). Therefore I see no need to guarantee a specific order of reading tp->dirty_tx and tp->cur_tx. Having said that we can remove the memory barrier.
In addition use READ_ONCE() when reading tp->cur_tx because it can change in parallel to rtl_tx().

---
 drivers/net/ethernet/realtek/r8169_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -2
index b6c11aaa5..75df476c6 100644
@@ -4364,9 +4364,8 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
 	unsigned int dirty_tx, tx_left, bytes_compl = 0, pkts_compl = 0;
 
 	dirty_tx = tp->dirty_tx;
-	smp_rmb();
 
-	for (tx_left = tp->cur_tx - dirty_tx; tx_left > 0; tx_left--) {
+	for (tx_left = READ_ONCE(tp->cur_tx) - dirty_tx; tx_left; tx_left--) {
 		unsigned int entry = dirty_tx % NUM_TX_DESC;
 		struct sk_buff *skb = tp->tx_skb[entry].skb;
 		u32 status;
Signature · 1 line
2.29.1
maintainer Applied
#1 lore raw
Quoted 7 lines · On Thu, 29 Oct 2020 18:56:06 +0100 Heiner Kallweit wrote:

tp->dirty_tx isn't changed outside rtl_tx(). Therefore I see no need to guarantee a specific order of reading tp->dirty_tx and tp->cur_tx. Having said that we can remove the memory barrier.
In addition use READ_ONCE() when reading tp->cur_tx because it can change in parallel to rtl_tx().

Applied, thanks!