0065-net-mediatek-fix-stop-and-wakeup-of-queue.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  5. The driver supports 2 MACs. Both run on the same DMA ring. If we go
  6. above/below the TX rings thershold value, we always need to wake/stop
  7. the queu of both devices. Not doing to can cause TX stalls and packet
  8. drops on one of the devices.
  9. Signed-off-by: John Crispin <blogic@openwrt.org>
  10. ---
  11. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 37 +++++++++++++++++++--------
  12. 1 file changed, 27 insertions(+), 10 deletions(-)
  13. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  15. @@ -684,6 +684,28 @@ static inline int mtk_cal_txd_req(struct
  16. return nfrags;
  17. }
  18. +static void mtk_wake_queue(struct mtk_eth *eth)
  19. +{
  20. + int i;
  21. +
  22. + for (i = 0; i < MTK_MAC_COUNT; i++) {
  23. + if (!eth->netdev[i])
  24. + continue;
  25. + netif_wake_queue(eth->netdev[i]);
  26. + }
  27. +}
  28. +
  29. +static void mtk_stop_queue(struct mtk_eth *eth)
  30. +{
  31. + int i;
  32. +
  33. + for (i = 0; i < MTK_MAC_COUNT; i++) {
  34. + if (!eth->netdev[i])
  35. + continue;
  36. + netif_stop_queue(eth->netdev[i]);
  37. + }
  38. +}
  39. +
  40. static int mtk_start_xmit(struct sk_buff *skb, struct net_device *dev)
  41. {
  42. struct mtk_mac *mac = netdev_priv(dev);
  43. @@ -695,7 +717,7 @@ static int mtk_start_xmit(struct sk_buff
  44. tx_num = mtk_cal_txd_req(skb);
  45. if (unlikely(atomic_read(&ring->free_count) <= tx_num)) {
  46. - netif_stop_queue(dev);
  47. + mtk_stop_queue(eth);
  48. netif_err(eth, tx_queued, dev,
  49. "Tx Ring full when queue awake!\n");
  50. return NETDEV_TX_BUSY;
  51. @@ -720,10 +742,10 @@ static int mtk_start_xmit(struct sk_buff
  52. goto drop;
  53. if (unlikely(atomic_read(&ring->free_count) <= ring->thresh)) {
  54. - netif_stop_queue(dev);
  55. + mtk_stop_queue(eth);
  56. if (unlikely(atomic_read(&ring->free_count) >
  57. ring->thresh))
  58. - netif_wake_queue(dev);
  59. + mtk_wake_queue(eth);
  60. }
  61. return NETDEV_TX_OK;
  62. @@ -897,13 +919,8 @@ static int mtk_poll_tx(struct mtk_eth *e
  63. if (!total)
  64. return 0;
  65. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  66. - if (!eth->netdev[i] ||
  67. - unlikely(!netif_queue_stopped(eth->netdev[i])))
  68. - continue;
  69. - if (atomic_read(&ring->free_count) > ring->thresh)
  70. - netif_wake_queue(eth->netdev[i]);
  71. - }
  72. + if (atomic_read(&ring->free_count) > ring->thresh)
  73. + mtk_wake_queue(eth);
  74. return total;
  75. }