History

net: ethernet: cortina: Fix budget accounting

The gmac_rx() function returns the remaining NAPI budget, but its caller treats the return value as the number of packets received. An idle poll therefore reports a full budget and remains scheduled. Return the number of received packets instead. Preserve the existing free queue refill accounting by adding that count directly; continuing to subtract it from the budget would invert the refill behavior.

Linus Walleij committed 2 months ago

Commit a0de06d1 parent c51fe221 file · +5 −3Browse files

Unified · Split

drivers/net/ethernet/cortina/gemini.c+5−3
@@ -1450,6 +1450,7 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) · 1449 unmodified lines
14501450 unsigned int frame_len, frag_len;
14511451 struct gmac_rxdesc *rx = NULL;
14521452 struct gmac_queue_page *gpage;
1453+ unsigned int received = 0;
14531454 union gmac_rxdesc_0 word0;
14541455 union gmac_rxdesc_1 word1;
14551456 union gmac_rxdesc_3 word3;
@@ -1545,7 +1546,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) · 89 unmodified lines
15451546 napi_gro_frags(&port->napi);
15461547 skb = NULL;
15471548 frag_nr = 0;
1548− --budget;
1549+ budget--;
1550+ received++;
15491551 }
15501552 continue;
15511553
@@ -1565,7 +1567,7 @@ err_drop: · 13 unmodified lines
15651567 port->rx_skb = skb;
15661568 port->rx_frag_nr = frag_nr;
15671569 writew(r, ptr_reg);
1568− return budget;
1570+ return received;
15691571 }
15701572
15711573 static int gmac_napi_poll(struct napi_struct *napi, int budget)
@@ -1586,7 +1588,7 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget) · 14 unmodified lines
15861588 ++port->rx_napi_exits;
15871589 }
15881590
1589− port->freeq_refill += (budget - received);
1591+ port->freeq_refill += received;
15901592 if (port->freeq_refill > freeq_threshold) {
15911593 port->freeq_refill -= freeq_threshold;
15921594 geth_fill_freeq(geth, true);