netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] r8169: improve rtl_tx
@ 2020-11-11 21:56 Heiner Kallweit
  2020-11-14  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2020-11-11 21:56 UTC (permalink / raw)
  To: Jakub Kicinski, David Miller, Realtek linux nic maintainers
  Cc: netdev@vger.kernel.org

We can simplify the for() condition and eliminate variable tx_left.
The change also considers that tp->cur_tx may be incremented by a
racing rtl8169_start_xmit().
In addition replace the write to tp->dirty_tx and the following
smp_mb() with an equivalent call to smp_store_mb(). This implicitly
adds a WRITE_ONCE() to the write.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/realtek/r8169_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 641c94a46..8910e900e 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -4362,11 +4362,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
 static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
 		   int budget)
 {
-	unsigned int dirty_tx, tx_left, bytes_compl = 0, pkts_compl = 0;
+	unsigned int dirty_tx, bytes_compl = 0, pkts_compl = 0;
 
 	dirty_tx = tp->dirty_tx;
 
-	for (tx_left = READ_ONCE(tp->cur_tx) - dirty_tx; tx_left; tx_left--) {
+	while (READ_ONCE(tp->cur_tx) != dirty_tx) {
 		unsigned int entry = dirty_tx % NUM_TX_DESC;
 		struct sk_buff *skb = tp->tx_skb[entry].skb;
 		u32 status;
@@ -4389,7 +4389,6 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
 		netdev_completed_queue(dev, pkts_compl, bytes_compl);
 		dev_sw_netstats_tx_add(dev, pkts_compl, bytes_compl);
 
-		tp->dirty_tx = dirty_tx;
 		/* Sync with rtl8169_start_xmit:
 		 * - publish dirty_tx ring index (write barrier)
 		 * - refresh cur_tx ring index and queue status (read barrier)
@@ -4397,7 +4396,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
 		 * a racing xmit thread can only have a right view of the
 		 * ring status.
 		 */
-		smp_mb();
+		smp_store_mb(tp->dirty_tx, dirty_tx);
 		if (netif_queue_stopped(dev) &&
 		    rtl_tx_slots_avail(tp, MAX_SKB_FRAGS)) {
 			netif_wake_queue(dev);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] r8169: improve rtl_tx
  2020-11-11 21:56 [PATCH net-next] r8169: improve rtl_tx Heiner Kallweit
@ 2020-11-14  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-11-14  0:40 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: kuba, davem, nic_swsd, netdev

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed, 11 Nov 2020 22:56:29 +0100 you wrote:
> We can simplify the for() condition and eliminate variable tx_left.
> The change also considers that tp->cur_tx may be incremented by a
> racing rtl8169_start_xmit().
> In addition replace the write to tp->dirty_tx and the following
> smp_mb() with an equivalent call to smp_store_mb(). This implicitly
> adds a WRITE_ONCE() to the write.
> 
> [...]

Here is the summary with links:
  - [net-next] r8169: improve rtl_tx
    https://git.kernel.org/netdev/net-next/c/ca1ab89cd2d6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-14  0:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-11 21:56 [PATCH net-next] r8169: improve rtl_tx Heiner Kallweit
2020-11-14  0:40 ` patchwork-bot+netdevbpf

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).