Advertisement
zhubr

Untitled

Jul 8th, 2021
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.25 KB | None | 0 0
  1. --- 8139too.c.orig      2021-02-10 11:12:10.000000000 +0300
  2. +++ 8139too.c   2021-07-08 21:01:09.974947976 +0300
  3. @@ -356,6 +356,7 @@
  4.         RxOK            = 0x01,
  5.  
  6.         RxAckBits       = RxFIFOOver | RxOverflow | RxOK,
  7. +       OtherAckBits    = PCIErr | PCSTimeout | RxUnderrun | RxErr | TxOK | TxErr,
  8.  };
  9.  
  10.  enum TxStatusBits {
  11. @@ -2128,21 +2129,49 @@
  12.         struct rtl8139_private *tp = container_of(napi, struct rtl8139_private, napi);
  13.         struct net_device *dev = tp->dev;
  14.         void __iomem *ioaddr = tp->mmio_addr;
  15. +       int link_changed = 0; /* avoid bogus "uninit" warning */
  16. +       unsigned long flags;
  17. +       u32 status;
  18. +       u16 ackstat;
  19.         int work_done;
  20.  
  21.         spin_lock(&tp->rx_lock);
  22.         work_done = 0;
  23. -       if (likely(RTL_R16(IntrStatus) & RxAckBits))
  24. +
  25. +       status = RTL_R16(IntrStatus);
  26. +       if (status & RxAckBits)
  27.                 work_done += rtl8139_rx(dev, tp, budget);
  28.  
  29. -       if (work_done < budget) {
  30. -               unsigned long flags;
  31. +       spin_lock_irqsave(&tp->lock, flags);
  32. +       if (status & OtherAckBits) {
  33. +               /* Acknowledge all of the current interrupt sources ASAP, but
  34. +                  an first get an additional status bit from CSCR. */
  35. +               if (unlikely(status & RxUnderrun))
  36. +                       link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
  37. +
  38. +               ackstat = status & ~(RxAckBits | TxErr);
  39. +               if (ackstat)
  40. +                       RTL_W16 (IntrStatus, ackstat);
  41. +
  42. +               /* Check uncommon events with one test. */
  43. +               if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
  44. +                       rtl8139_weird_interrupt (dev, tp, ioaddr,
  45. +                                        status, link_changed);
  46.  
  47. -               spin_lock_irqsave(&tp->lock, flags);
  48. -               if (napi_complete_done(napi, work_done))
  49. +               if (status & (TxOK | TxErr)) {
  50. +                       rtl8139_tx_interrupt (dev, tp, ioaddr);
  51. +                       if (status & TxErr)
  52. +                               RTL_W16 (IntrStatus, TxErr);
  53. +               }
  54. +       }
  55. +
  56. +       if (work_done < budget) {
  57. +               if (napi_complete_done(napi, work_done)) {
  58.                         RTL_W16_F(IntrMask, rtl8139_intr_mask);
  59. -               spin_unlock_irqrestore(&tp->lock, flags);
  60. +               }
  61.         }
  62. +
  63. +       spin_unlock_irqrestore(&tp->lock, flags);
  64.         spin_unlock(&tp->rx_lock);
  65.  
  66.         return work_done;
  67. @@ -2155,8 +2184,7 @@
  68.         struct net_device *dev = (struct net_device *) dev_instance;
  69.         struct rtl8139_private *tp = netdev_priv(dev);
  70.         void __iomem *ioaddr = tp->mmio_addr;
  71. -       u16 status, ackstat;
  72. -       int link_changed = 0; /* avoid bogus "uninit" warning */
  73. +       u16 status;
  74.         int handled = 0;
  75.  
  76.         spin_lock (&tp->lock);
  77. @@ -2178,33 +2206,9 @@
  78.                 goto out;
  79.         }
  80.  
  81. -       /* Acknowledge all of the current interrupt sources ASAP, but
  82. -          an first get an additional status bit from CSCR. */
  83. -       if (unlikely(status & RxUnderrun))
  84. -               link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
  85. -
  86. -       ackstat = status & ~(RxAckBits | TxErr);
  87. -       if (ackstat)
  88. -               RTL_W16 (IntrStatus, ackstat);
  89. -
  90. -       /* Receive packets are processed by poll routine.
  91. -          If not running start it now. */
  92. -       if (status & RxAckBits){
  93. -               if (napi_schedule_prep(&tp->napi)) {
  94. -                       RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
  95. -                       __napi_schedule(&tp->napi);
  96. -               }
  97. -       }
  98. -
  99. -       /* Check uncommon events with one test. */
  100. -       if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
  101. -               rtl8139_weird_interrupt (dev, tp, ioaddr,
  102. -                                        status, link_changed);
  103. -
  104. -       if (status & (TxOK | TxErr)) {
  105. -               rtl8139_tx_interrupt (dev, tp, ioaddr);
  106. -               if (status & TxErr)
  107. -                       RTL_W16 (IntrStatus, TxErr);
  108. +       if (napi_schedule_prep(&tp->napi)) {
  109. +               RTL_W16_F (IntrMask, 0);
  110. +               __napi_schedule(&tp->napi);
  111.         }
  112.   out:
  113.         spin_unlock (&tp->lock);
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement