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
1450 unsigned int frame_len, frag_len;1450 unsigned int frame_len, frag_len;
1451 struct gmac_rxdesc *rx = NULL;1451 struct gmac_rxdesc *rx = NULL;
1452 struct gmac_queue_page *gpage;1452 struct gmac_queue_page *gpage;
1453 unsigned int received = 0;
1453 union gmac_rxdesc_0 word0;1454 union gmac_rxdesc_0 word0;
1454 union gmac_rxdesc_1 word1;1455 union gmac_rxdesc_1 word1;
1455 union gmac_rxdesc_3 word3;1456 union gmac_rxdesc_3 word3;
@@ -1545,7 +1546,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget) · 89 unmodified lines
1545 napi_gro_frags(&port->napi);1546 napi_gro_frags(&port->napi);
1546 skb = NULL;1547 skb = NULL;
1547 frag_nr = 0;1548 frag_nr = 0;
1548 --budget;1549 budget--;
1550 received++;
1549 }1551 }
1550 continue;1552 continue;
1551 1553
@@ -1565,7 +1567,7 @@ err_drop: · 13 unmodified lines
1565 port->rx_skb = skb;1567 port->rx_skb = skb;
1566 port->rx_frag_nr = frag_nr;1568 port->rx_frag_nr = frag_nr;
1567 writew(r, ptr_reg);1569 writew(r, ptr_reg);
1568 return budget;1570 return received;
1569}1571}
1570 1572
1571static int gmac_napi_poll(struct napi_struct *napi, int budget)1573static 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
1586 ++port->rx_napi_exits;1588 ++port->rx_napi_exits;
1587 }1589 }
1588 1590
1589 port->freeq_refill += (budget - received);1591 port->freeq_refill += received;
1590 if (port->freeq_refill > freeq_threshold) {1592 if (port->freeq_refill > freeq_threshold) {
1591 port->freeq_refill -= freeq_threshold;1593 port->freeq_refill -= freeq_threshold;
1592 geth_fill_freeq(geth, true);1594 geth_fill_freeq(geth, true);