Skip to contentSkip to conversation

net: ag71xx: NAPI weight, MMIO drain, and TX OOM fix

PATCH Superseded Rosen Penev 1 participant 4 messages Jun 28

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover net: ag71xx: NAPI weight, MMIO drain, and TX OOM fix

Drop the custom NAPI weight in favour of the core default, remove unnecessary MMIO read-back drains from register writes for a small performance gain, and fix a TX stall that occurs when the RX ring runs out of buffers.

Rosen Penev (3):
net: ag71xx: Use default NAPI weight
net: ag71xx: remove MMIO read-back drain from register writes
net: ag71xx: re-enable TX interrupts on RX OOM

 drivers/net/ethernet/atheros/ag71xx.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/3 net: ag71xx: Use default NAPI weight

Drop the custom NAPI weight and let netif_napi_add() use the core default.

The old comment claimed larger weights wasted cycles and cache, but recent RX and TX path changes altered those tradeoffs. Keep the driver on the standard default unless measurements show a device-specific value is needed.

iperf3:

Before:

[ ID][Role] Interval Transfer Bitrate Retr

[  5][TX-C]   0.00-10.00  sec   327 MBytes   274 Mbits/sec   31            sender
[  5][TX-C]   0.00-10.00  sec   325 MBytes   273 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   170 MBytes   143 Mbits/sec    0            sender
[  7][RX-C]   0.00-10.00  sec   170 MBytes   143 Mbits/sec                  receiver

After:

[ ID][Role] Interval Transfer Bitrate Retr

[  5][TX-C]   0.00-10.00  sec   341 MBytes   286 Mbits/sec   30            sender
[  5][TX-C]   0.00-10.00  sec   338 MBytes   284 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   184 MBytes   154 Mbits/sec    0            sender
[  7][RX-C]   0.00-10.00  sec   184 MBytes   154 Mbits/sec                  receiver
Assisted-by Codex:GPT-5.5
---
 drivers/net/ethernet/atheros/ag71xx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/net/ethernet/atheros/ag71xx.c +1 -7
index ac4eadb9190a..1def2ad4c5ce 100644
@@ -40,11 +40,6 @@
 #include <linux/io.h>
 #include <net/selftests.h>
 
-/* For our NAPI weight bigger does *NOT* mean better - it means more
- * D-cache misses and lots more wasted cycles than we'll ever
- * possibly gain from saving instructions.
- */
-#define AG71XX_NAPI_WEIGHT	32
 #define AG71XX_OOM_REFILL	(1 + HZ / 10)
 
 #define AG71XX_INT_ERR	(AG71XX_INT_RX_BE | AG71XX_INT_TX_BE)
@@ -1913,8 +1908,7 @@ static int ag71xx_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	netif_napi_add_weight(ndev, &ag->napi, ag71xx_poll,
-			      AG71XX_NAPI_WEIGHT);
+	netif_napi_add(ndev, &ag->napi, ag71xx_poll);
 
 	ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, 0);
 
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/3 net: ag71xx: remove MMIO read-back drain from register writes

In reply to Rosen Penev

ag71xx_wr(), ag71xx_sb() and ag71xx_cb() issue a synchronous ioread32() after every iowrite32() under the assumption that the write must be flushed to the device before any subsequent operation.

On the ath79 on-chip MMIO bus the uncached __raw_writel used by iowrite32() is non-posted - the write completes before the next instruction executes. The extra ioread32() therefore serves no ordering purpose and costs at least one uncached bus round-trip per call.

Remove the read-back and the associated comments, leaving the barrier that iowrite32() already provides.

Small iperf3 improvement:

Before:

[ ID][Role] Interval Transfer Bitrate Retr

[  5][TX-C]   0.00-10.00  sec   343 MBytes   288 Mbits/sec   32            sender
[  5][TX-C]   0.00-10.00  sec   341 MBytes   286 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   183 MBytes   153 Mbits/sec    0            sender
[  7][RX-C]   0.00-10.00  sec   183 MBytes   153 Mbits/sec                  receiver

After:

[ ID][Role] Interval Transfer Bitrate Retr

[  5][TX-C]   0.00-10.00  sec   349 MBytes   292 Mbits/sec   28            sender
[  5][TX-C]   0.00-10.00  sec   346 MBytes   291 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   180 MBytes   151 Mbits/sec    0            sender
[  7][RX-C]   0.00-10.00  sec   180 MBytes   151 Mbits/sec                  receiver
Assisted-by opencode:big-pickle
---
 drivers/net/ethernet/atheros/ag71xx.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/net/ethernet/atheros/ag71xx.c +6 -10
index 1def2ad4c5ce..77f8e75e98ac 100644
@@ -397,11 +397,13 @@ static bool ag71xx_is(struct ag71xx *ag, enum ag71xx_type type)
 	return ag->dcfg->type == type;
 }
 
+/* ath79 on-chip MMIO bus is non-posted - iowrite32/iowrite32be completes
+ * before the next instruction executes. No read-back drain is needed.
+ */
+
 static void ag71xx_wr(struct ag71xx *ag, unsigned int reg, u32 value)
 {
 	iowrite32(value, ag->mac_base + reg);
-	/* flush write */
-	(void)ioread32(ag->mac_base + reg);
 }
 
 static u32 ag71xx_rr(struct ag71xx *ag, unsigned int reg)
@@ -411,22 +413,16 @@ static u32 ag71xx_rr(struct ag71xx *ag, unsigned int reg)
 
 static void ag71xx_sb(struct ag71xx *ag, unsigned int reg, u32 mask)
 {
-	void __iomem *r;
+	void __iomem *r = ag->mac_base + reg;
 
-	r = ag->mac_base + reg;
 	iowrite32(ioread32(r) | mask, r);
-	/* flush write */
-	(void)ioread32(r);
 }
 
 static void ag71xx_cb(struct ag71xx *ag, unsigned int reg, u32 mask)
 {
-	void __iomem *r;
+	void __iomem *r = ag->mac_base + reg;
 
-	r = ag->mac_base + reg;
 	iowrite32(ioread32(r) & ~mask, r);
-	/* flush write */
-	(void)ioread32(r);
 }
 
 static void ag71xx_int_enable(struct ag71xx *ag, u32 ints)
Signature · 1 line
2.54.0
#3 lore raw

PATCH 3/3 net: ag71xx: re-enable TX interrupts on RX OOM

In reply to Rosen Penev

When the RX ring runs out of buffers the OOM path calls napi_complete() but does not re-enable interrupts. Because INT_POLL masks both RX and TX events, TX completions are blocked until the OOM timer fires (~100 ms), which can cause TX ring exhaustion and dropped packets.

Restore TX interrupt delivery so the engine can drain completed descriptors while NAPI waits for RX buffer memory.

Assisted-by opencode:big-pickle
---
 drivers/net/ethernet/atheros/ag71xx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/atheros/ag71xx.c +1 -0
index 77f8e75e98ac..a4e52bc42091 100644
@@ -1720,6 +1720,7 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
 
 	mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
 	napi_complete(napi);
+	ag71xx_int_enable(ag, AG71XX_INT_TX);
 	return 0;
 }
 
Signature · 1 line
2.54.0