1
0

077-05-bgmac-leave-interrupts-disabled-as-long-as-there-is-.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Sun, 12 Apr 2015 10:08:04 +0200
  3. Subject: [PATCH] bgmac: leave interrupts disabled as long as there is work
  4. to do
  5. Always poll rx and tx during NAPI poll instead of relying on the status
  6. of the first interrupt. This prevents bgmac_poll from leaving unfinished
  7. work around until the next IRQ.
  8. In my tests this makes bridging/routing throughput under heavy load more
  9. stable and ensures that no new IRQs arrive as long as bgmac_poll uses up
  10. the entire budget.
  11. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  12. ---
  13. --- a/drivers/net/ethernet/broadcom/bgmac.c
  14. +++ b/drivers/net/ethernet/broadcom/bgmac.c
  15. @@ -1109,8 +1109,6 @@ static void bgmac_chip_reset(struct bgma
  16. bgmac_phy_init(bgmac);
  17. netdev_reset_queue(bgmac->net_dev);
  18. -
  19. - bgmac->int_status = 0;
  20. }
  21. static void bgmac_chip_intrs_on(struct bgmac *bgmac)
  22. @@ -1225,14 +1223,13 @@ static irqreturn_t bgmac_interrupt(int i
  23. if (!int_status)
  24. return IRQ_NONE;
  25. - /* Ack */
  26. - bgmac_write(bgmac, BGMAC_INT_STATUS, int_status);
  27. + int_status &= ~(BGMAC_IS_TX0 | BGMAC_IS_RX);
  28. + if (int_status)
  29. + bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", int_status);
  30. /* Disable new interrupts until handling existing ones */
  31. bgmac_chip_intrs_off(bgmac);
  32. - bgmac->int_status = int_status;
  33. -
  34. napi_schedule(&bgmac->napi);
  35. return IRQ_HANDLED;
  36. @@ -1241,25 +1238,17 @@ static irqreturn_t bgmac_interrupt(int i
  37. static int bgmac_poll(struct napi_struct *napi, int weight)
  38. {
  39. struct bgmac *bgmac = container_of(napi, struct bgmac, napi);
  40. - struct bgmac_dma_ring *ring;
  41. int handled = 0;
  42. - if (bgmac->int_status & BGMAC_IS_TX0) {
  43. - ring = &bgmac->tx_ring[0];
  44. - bgmac_dma_tx_free(bgmac, ring);
  45. - bgmac->int_status &= ~BGMAC_IS_TX0;
  46. - }
  47. + /* Ack */
  48. + bgmac_write(bgmac, BGMAC_INT_STATUS, ~0);
  49. - if (bgmac->int_status & BGMAC_IS_RX) {
  50. - ring = &bgmac->rx_ring[0];
  51. - handled += bgmac_dma_rx_read(bgmac, ring, weight);
  52. - bgmac->int_status &= ~BGMAC_IS_RX;
  53. - }
  54. + bgmac_dma_tx_free(bgmac, &bgmac->tx_ring[0]);
  55. + handled += bgmac_dma_rx_read(bgmac, &bgmac->rx_ring[0], weight);
  56. - if (bgmac->int_status) {
  57. - bgmac_err(bgmac, "Unknown IRQs: 0x%08X\n", bgmac->int_status);
  58. - bgmac->int_status = 0;
  59. - }
  60. + /* Poll again if more events arrived in the meantime */
  61. + if (bgmac_read(bgmac, BGMAC_INT_STATUS) & (BGMAC_IS_TX0 | BGMAC_IS_RX))
  62. + return handled;
  63. if (handled < weight) {
  64. napi_complete(napi);
  65. --- a/drivers/net/ethernet/broadcom/bgmac.h
  66. +++ b/drivers/net/ethernet/broadcom/bgmac.h
  67. @@ -452,7 +452,6 @@ struct bgmac {
  68. /* Int */
  69. u32 int_mask;
  70. - u32 int_status;
  71. /* Current MAC state */
  72. int mac_speed;