065-8139cp-fixes.patch 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. commit 01ffc0a7f1c1801a2354719dedbc32aff45b987d
  2. Author: David Woodhouse <dwmw2@infradead.org>
  3. Date: Sat Nov 24 12:11:21 2012 +0000
  4. 8139cp: re-enable interrupts after tx timeout
  5. Recovery doesn't work too well if we leave interrupts disabled...
  6. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  7. Acked-by: Francois Romieu <romieu@fr.zoreil.com>
  8. Signed-off-by: David S. Miller <davem@davemloft.net>
  9. commit 871f0d4c153e1258d4becf306eca6761bf38b629
  10. Author: David Woodhouse <dwmw2@infradead.org>
  11. Date: Thu Nov 22 03:16:58 2012 +0000
  12. 8139cp: enable bql
  13. This adds support for byte queue limits on RTL8139C+
  14. Tested on real hardware.
  15. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  16. Acked-By: Dave Täht <dave.taht@bufferbloat.net>
  17. Signed-off-by: David S. Miller <davem@davemloft.net>
  18. commit a9dbe40fc10cea2efe6e1ff9e03c62dd7579c5ba
  19. Author: David Woodhouse <dwmw2@infradead.org>
  20. Date: Wed Nov 21 10:27:19 2012 +0000
  21. 8139cp: set ring address after enabling C+ mode
  22. This fixes (for me) a regression introduced by commit b01af457 ("8139cp:
  23. set ring address before enabling receiver"). That commit configured the
  24. descriptor ring addresses earlier in the initialisation sequence, in
  25. order to avoid the possibility of triggering stray DMA before the
  26. correct address had been set up.
  27. Unfortunately, it seems that the hardware will scribble garbage into the
  28. TxRingAddr registers when we enable "plus mode" Tx in the CpCmd
  29. register. Observed on a Traverse Geos router board.
  30. To deal with this, while not reintroducing the problem which led to the
  31. original commit, we augment cp_start_hw() to write to the CpCmd register
  32. *first*, then set the descriptor ring addresses, and then finally to
  33. enable Rx and Tx in the original 8139 Cmd register. The datasheet
  34. actually indicates that we should enable Tx/Rx in the Cmd register
  35. *before* configuring the descriptor addresses, but that would appear to
  36. re-introduce the problem that the offending commit b01af457 was trying
  37. to solve. And this variant appears to work fine on real hardware.
  38. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  39. Cc: stable@kernel.org [3.5+]
  40. Signed-off-by: David S. Miller <davem@davemloft.net>
  41. commit 071e3ef4a94a021b16a2912f3885c86f4ff36b49
  42. Author: David S. Miller <davem@davemloft.net>
  43. Date: Sun Nov 25 15:52:09 2012 -0500
  44. Revert "8139cp: revert "set ring address before enabling receiver""
  45. This reverts commit b26623dab7eeb1e9f5898c7a49458789dd492f20.
  46. This reverts the revert, in net-next we'll try another scheme
  47. to fix this bug using patches from David Woodhouse.
  48. Signed-off-by: David S. Miller <davem@davemloft.net>
  49. --- a/drivers/net/ethernet/realtek/8139cp.c
  50. +++ b/drivers/net/ethernet/realtek/8139cp.c
  51. @@ -645,6 +645,7 @@ static void cp_tx (struct cp_private *cp
  52. {
  53. unsigned tx_head = cp->tx_head;
  54. unsigned tx_tail = cp->tx_tail;
  55. + unsigned bytes_compl = 0, pkts_compl = 0;
  56. while (tx_tail != tx_head) {
  57. struct cp_desc *txd = cp->tx_ring + tx_tail;
  58. @@ -663,6 +664,9 @@ static void cp_tx (struct cp_private *cp
  59. le32_to_cpu(txd->opts1) & 0xffff,
  60. PCI_DMA_TODEVICE);
  61. + bytes_compl += skb->len;
  62. + pkts_compl++;
  63. +
  64. if (status & LastFrag) {
  65. if (status & (TxError | TxFIFOUnder)) {
  66. netif_dbg(cp, tx_err, cp->dev,
  67. @@ -694,6 +698,7 @@ static void cp_tx (struct cp_private *cp
  68. cp->tx_tail = tx_tail;
  69. + netdev_completed_queue(cp->dev, pkts_compl, bytes_compl);
  70. if (TX_BUFFS_AVAIL(cp) > (MAX_SKB_FRAGS + 1))
  71. netif_wake_queue(cp->dev);
  72. }
  73. @@ -840,6 +845,8 @@ static netdev_tx_t cp_start_xmit (struct
  74. wmb();
  75. }
  76. cp->tx_head = entry;
  77. +
  78. + netdev_sent_queue(dev, skb->len);
  79. netif_dbg(cp, tx_queued, cp->dev, "tx queued, slot %d, skblen %d\n",
  80. entry, skb->len);
  81. if (TX_BUFFS_AVAIL(cp) <= (MAX_SKB_FRAGS + 1))
  82. @@ -934,6 +941,8 @@ static void cp_stop_hw (struct cp_privat
  83. cp->rx_tail = 0;
  84. cp->tx_head = cp->tx_tail = 0;
  85. +
  86. + netdev_reset_queue(cp->dev);
  87. }
  88. static void cp_reset_hw (struct cp_private *cp)
  89. @@ -954,8 +963,38 @@ static void cp_reset_hw (struct cp_priva
  90. static inline void cp_start_hw (struct cp_private *cp)
  91. {
  92. + dma_addr_t ring_dma;
  93. +
  94. cpw16(CpCmd, cp->cpcmd);
  95. +
  96. + /*
  97. + * These (at least TxRingAddr) need to be configured after the
  98. + * corresponding bits in CpCmd are enabled. Datasheet v1.6 §6.33
  99. + * (C+ Command Register) recommends that these and more be configured
  100. + * *after* the [RT]xEnable bits in CpCmd are set. And on some hardware
  101. + * it's been observed that the TxRingAddr is actually reset to garbage
  102. + * when C+ mode Tx is enabled in CpCmd.
  103. + */
  104. + cpw32_f(HiTxRingAddr, 0);
  105. + cpw32_f(HiTxRingAddr + 4, 0);
  106. +
  107. + ring_dma = cp->ring_dma;
  108. + cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
  109. + cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
  110. +
  111. + ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
  112. + cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
  113. + cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
  114. +
  115. + /*
  116. + * Strictly speaking, the datasheet says this should be enabled
  117. + * *before* setting the descriptor addresses. But what, then, would
  118. + * prevent it from doing DMA to random unconfigured addresses?
  119. + * This variant appears to work fine.
  120. + */
  121. cpw8(Cmd, RxOn | TxOn);
  122. +
  123. + netdev_reset_queue(cp->dev);
  124. }
  125. static void cp_enable_irq(struct cp_private *cp)
  126. @@ -966,7 +1005,6 @@ static void cp_enable_irq(struct cp_priv
  127. static void cp_init_hw (struct cp_private *cp)
  128. {
  129. struct net_device *dev = cp->dev;
  130. - dma_addr_t ring_dma;
  131. cp_reset_hw(cp);
  132. @@ -989,17 +1027,6 @@ static void cp_init_hw (struct cp_privat
  133. cpw8(Config5, cpr8(Config5) & PMEStatus);
  134. - cpw32_f(HiTxRingAddr, 0);
  135. - cpw32_f(HiTxRingAddr + 4, 0);
  136. -
  137. - ring_dma = cp->ring_dma;
  138. - cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
  139. - cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
  140. -
  141. - ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
  142. - cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
  143. - cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
  144. -
  145. cpw16(MultiIntr, 0);
  146. cpw8_f(Cfg9346, Cfg9346_Lock);
  147. @@ -1188,6 +1215,7 @@ static void cp_tx_timeout(struct net_dev
  148. cp_clean_rings(cp);
  149. rc = cp_init_rings(cp);
  150. cp_start_hw(cp);
  151. + cp_enable_irq(cp);
  152. netif_wake_queue(dev);