0074-net-mediatek-fix-mtk_pending_work.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 46e02ea6c0468ce01b6e370a20f01a7f7311af34 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Tue, 29 Mar 2016 17:00:47 +0200
  4. Subject: [PATCH 74/90] net: mediatek: fix mtk_pending_work
  5. The driver supports 2 MACs. Both run on the same DMA ring. If we hit a TX
  6. timeout we need to stop both netdevs before retarting them again. If we
  7. dont do thsi, mtk_stop() wont shutdown DMA and the consecutive call to
  8. mtk_open() wont restart DMA and enable IRQs.
  9. Signed-off-by: John Crispin <[email protected]>
  10. ---
  11. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 +++++++++++++++++++--------
  12. 1 file changed, 21 insertions(+), 9 deletions(-)
  13. diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. index 04bdb9d..26eeb1a 100644
  15. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  16. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  17. @@ -1430,19 +1430,31 @@ static int mtk_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  18. static void mtk_pending_work(struct work_struct *work)
  19. {
  20. - struct mtk_mac *mac = container_of(work, struct mtk_mac, pending_work);
  21. - struct mtk_eth *eth = mac->hw;
  22. - struct net_device *dev = eth->netdev[mac->id];
  23. - int err;
  24. + struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
  25. + int err, i;
  26. + unsigned long restart = 0;
  27. rtnl_lock();
  28. - mtk_stop(dev);
  29. - err = mtk_open(dev);
  30. - if (err) {
  31. - netif_alert(eth, ifup, dev,
  32. + /* stop all devices to make sure that dma is properly shut down */
  33. + for (i = 0; i < MTK_MAC_COUNT; i++) {
  34. + if (!netif_oper_up(eth->netdev[i]))
  35. + continue;
  36. + mtk_stop(eth->netdev[i]);
  37. + __set_bit(i, &restart);
  38. + }
  39. +
  40. +
  41. + /* restart DMA and enable IRQs */
  42. + for (i = 0; i < MTK_MAC_COUNT; i++) {
  43. + if (!test_bit(i, &restart))
  44. + continue;
  45. + err = mtk_open(eth->netdev[i]);
  46. + if (err) {
  47. + netif_alert(eth, ifup, eth->netdev[i],
  48. "Driver up/down cycle failed, closing device.\n");
  49. - dev_close(dev);
  50. + dev_close(eth->netdev[i]);
  51. + }
  52. }
  53. rtnl_unlock();
  54. }
  55. --
  56. 1.7.10.4