1 From afc838dde560ab584d3fb0e4b011e4a6770dab3d Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 29 Mar 2016 16:41:07 +0200
4 Subject: [PATCH 065/102] net: mediatek: fix stop and wakeup of queue
6 The driver supports 2 MACs. Both run on the same DMA ring. If we go
7 above/below the TX rings thershold value, we always need to wake/stop
8 the queu of both devices. Not doing to can cause TX stalls and packet
9 drops on one of the devices.
11 Signed-off-by: John Crispin <blogic@openwrt.org>
13 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 37 +++++++++++++++++++--------
14 1 file changed, 27 insertions(+), 10 deletions(-)
16 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
17 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
18 @@ -684,6 +684,28 @@ static inline int mtk_cal_txd_req(struct
22 +static void mtk_wake_queue(struct mtk_eth *eth)
26 + for (i = 0; i < MTK_MAC_COUNT; i++) {
27 + if (!eth->netdev[i])
29 + netif_wake_queue(eth->netdev[i]);
33 +static void mtk_stop_queue(struct mtk_eth *eth)
37 + for (i = 0; i < MTK_MAC_COUNT; i++) {
38 + if (!eth->netdev[i])
40 + netif_stop_queue(eth->netdev[i]);
44 static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
46 struct mtk_mac *mac = netdev_priv(dev);
47 @@ -695,7 +717,7 @@ static int mtk_start_xmit(struct sk_buff
49 tx_num = mtk_cal_txd_req(skb);
50 if (unlikely(atomic_read(&ring->free_count) <= tx_num)) {
51 - netif_stop_queue(dev);
52 + mtk_stop_queue(eth);
53 netif_err(eth, tx_queued, dev,
54 "Tx Ring full when queue awake!\n");
55 return NETDEV_TX_BUSY;
56 @@ -720,10 +742,10 @@ static int mtk_start_xmit(struct sk_buff
59 if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) {
60 - netif_stop_queue(dev);
61 + mtk_stop_queue(eth);
62 if (unlikely(atomic_read(&ring->free_count) >
64 - netif_wake_queue(dev);
65 + mtk_wake_queue(eth);
69 @@ -897,13 +919,8 @@ static int mtk_poll_tx(struct mtk_eth *e
73 - for (i = 0; i < MTK_MAC_COUNT; i++) {
74 - if (!eth->netdev[i] ||
75 - unlikely(!netif_queue_stopped(eth->netdev[i])))
77 - if (atomic_read(&ring->free_count) > ring->thresh)
78 - netif_wake_queue(eth->netdev[i]);
80 + if (atomic_read(&ring->free_count) > ring->thresh)
81 + mtk_wake_queue(eth);