040-net-mvneta-Modify-the-queue-related-fields-from-each.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. From: Gregory CLEMENT <gregory.clement@free-electrons.com>
  2. Date: Thu, 4 Feb 2016 22:09:27 +0100
  3. Subject: [PATCH] net: mvneta: Modify the queue related fields from each cpu
  4. In the MVNETA_INTR_* registers, the queues related fields are per cpu,
  5. according to the datasheet (comment in [] are added by me):
  6. "In a multi-CPU system, bits of RX[or TX] queues for which the access by
  7. the reading[or writing] CPU is disabled are read as 0, and cannot be
  8. cleared[or written]."
  9. That means that each time we want to manipulate these bits we had to do
  10. it on each cpu and not only on the current cpu.
  11. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
  12. Signed-off-by: David S. Miller <davem@davemloft.net>
  13. ---
  14. --- a/drivers/net/ethernet/marvell/mvneta.c
  15. +++ b/drivers/net/ethernet/marvell/mvneta.c
  16. @@ -1036,6 +1036,43 @@ static void mvneta_set_autoneg(struct mv
  17. }
  18. }
  19. +static void mvneta_percpu_unmask_interrupt(void *arg)
  20. +{
  21. + struct mvneta_port *pp = arg;
  22. +
  23. + /* All the queue are unmasked, but actually only the ones
  24. + * mapped to this CPU will be unmasked
  25. + */
  26. + mvreg_write(pp, MVNETA_INTR_NEW_MASK,
  27. + MVNETA_RX_INTR_MASK_ALL |
  28. + MVNETA_TX_INTR_MASK_ALL |
  29. + MVNETA_MISCINTR_INTR_MASK);
  30. +}
  31. +
  32. +static void mvneta_percpu_mask_interrupt(void *arg)
  33. +{
  34. + struct mvneta_port *pp = arg;
  35. +
  36. + /* All the queue are masked, but actually only the ones
  37. + * mapped to this CPU will be masked
  38. + */
  39. + mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  40. + mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  41. + mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  42. +}
  43. +
  44. +static void mvneta_percpu_clear_intr_cause(void *arg)
  45. +{
  46. + struct mvneta_port *pp = arg;
  47. +
  48. + /* All the queue are cleared, but actually only the ones
  49. + * mapped to this CPU will be cleared
  50. + */
  51. + mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
  52. + mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
  53. + mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
  54. +}
  55. +
  56. /* This method sets defaults to the NETA port:
  57. * Clears interrupt Cause and Mask registers.
  58. * Clears all MAC tables.
  59. @@ -1053,14 +1090,10 @@ static void mvneta_defaults_set(struct m
  60. int max_cpu = num_present_cpus();
  61. /* Clear all Cause registers */
  62. - mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
  63. - mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
  64. - mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
  65. + on_each_cpu(mvneta_percpu_clear_intr_cause, pp, true);
  66. /* Mask all interrupts */
  67. - mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  68. - mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  69. - mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  70. + on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
  71. mvreg_write(pp, MVNETA_INTR_ENABLE, 0);
  72. /* Enable MBUS Retry bit16 */
  73. @@ -2526,31 +2559,6 @@ static int mvneta_setup_txqs(struct mvne
  74. return 0;
  75. }
  76. -static void mvneta_percpu_unmask_interrupt(void *arg)
  77. -{
  78. - struct mvneta_port *pp = arg;
  79. -
  80. - /* All the queue are unmasked, but actually only the ones
  81. - * maped to this CPU will be unmasked
  82. - */
  83. - mvreg_write(pp, MVNETA_INTR_NEW_MASK,
  84. - MVNETA_RX_INTR_MASK_ALL |
  85. - MVNETA_TX_INTR_MASK_ALL |
  86. - MVNETA_MISCINTR_INTR_MASK);
  87. -}
  88. -
  89. -static void mvneta_percpu_mask_interrupt(void *arg)
  90. -{
  91. - struct mvneta_port *pp = arg;
  92. -
  93. - /* All the queue are masked, but actually only the ones
  94. - * maped to this CPU will be masked
  95. - */
  96. - mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  97. - mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  98. - mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  99. -}
  100. -
  101. static void mvneta_start_dev(struct mvneta_port *pp)
  102. {
  103. int cpu;
  104. @@ -2601,13 +2609,10 @@ static void mvneta_stop_dev(struct mvnet
  105. mvneta_port_disable(pp);
  106. /* Clear all ethernet port interrupts */
  107. - mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
  108. - mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
  109. + on_each_cpu(mvneta_percpu_clear_intr_cause, pp, true);
  110. /* Mask all ethernet port interrupts */
  111. - mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  112. - mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  113. - mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  114. + on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
  115. mvneta_tx_reset(pp);
  116. mvneta_rx_reset(pp);
  117. @@ -2919,9 +2924,7 @@ static int mvneta_percpu_notifier(struct
  118. }
  119. /* Mask all ethernet port interrupts */
  120. - mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  121. - mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  122. - mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  123. + on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
  124. napi_enable(&port->napi);
  125. @@ -2936,14 +2939,8 @@ static int mvneta_percpu_notifier(struct
  126. */
  127. mvneta_percpu_elect(pp);
  128. - /* Unmask all ethernet port interrupts, as this
  129. - * notifier is called for each CPU then the CPU to
  130. - * Queue mapping is applied
  131. - */
  132. - mvreg_write(pp, MVNETA_INTR_NEW_MASK,
  133. - MVNETA_RX_INTR_MASK(rxq_number) |
  134. - MVNETA_TX_INTR_MASK(txq_number) |
  135. - MVNETA_MISCINTR_INTR_MASK);
  136. + /* Unmask all ethernet port interrupts */
  137. + on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
  138. mvreg_write(pp, MVNETA_INTR_MISC_MASK,
  139. MVNETA_CAUSE_PHY_STATUS_CHANGE |
  140. MVNETA_CAUSE_LINK_CHANGE |
  141. @@ -2954,9 +2951,7 @@ static int mvneta_percpu_notifier(struct
  142. case CPU_DOWN_PREPARE_FROZEN:
  143. netif_tx_stop_all_queues(pp->dev);
  144. /* Mask all ethernet port interrupts */
  145. - mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
  146. - mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
  147. - mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
  148. + on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
  149. napi_synchronize(&port->napi);
  150. napi_disable(&port->napi);
  151. @@ -2972,10 +2967,7 @@ static int mvneta_percpu_notifier(struct
  152. /* Check if a new CPU must be elected now this on is down */
  153. mvneta_percpu_elect(pp);
  154. /* Unmask all ethernet port interrupts */
  155. - mvreg_write(pp, MVNETA_INTR_NEW_MASK,
  156. - MVNETA_RX_INTR_MASK(rxq_number) |
  157. - MVNETA_TX_INTR_MASK(txq_number) |
  158. - MVNETA_MISCINTR_INTR_MASK);
  159. + on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
  160. mvreg_write(pp, MVNETA_INTR_MISC_MASK,
  161. MVNETA_CAUSE_PHY_STATUS_CHANGE |
  162. MVNETA_CAUSE_LINK_CHANGE |