039-net-mvneta-Use-on_each_cpu-when-possible.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From: Gregory CLEMENT <gregory.clement@free-electrons.com>
  2. Date: Thu, 4 Feb 2016 22:09:25 +0100
  3. Subject: [PATCH] net: mvneta: Use on_each_cpu when possible
  4. Instead of using a for_each_* loop in which we just call the
  5. smp_call_function_single macro, it is more simple to directly use the
  6. on_each_cpu macro. Moreover, this macro ensures that the calls will be
  7. done all at once.
  8. Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
  9. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
  10. Signed-off-by: David S. Miller <davem@davemloft.net>
  11. ---
  12. --- a/drivers/net/ethernet/marvell/mvneta.c
  13. +++ b/drivers/net/ethernet/marvell/mvneta.c
  14. @@ -2558,7 +2558,7 @@ static void mvneta_percpu_mask_interrupt
  15. static void mvneta_start_dev(struct mvneta_port *pp)
  16. {
  17. - unsigned int cpu;
  18. + int cpu;
  19. mvneta_max_rx_size_set(pp, pp->pkt_size);
  20. mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
  21. @@ -2574,9 +2574,8 @@ static void mvneta_start_dev(struct mvne
  22. }
  23. /* Unmask interrupts. It has to be done from each CPU */
  24. - for_each_online_cpu(cpu)
  25. - smp_call_function_single(cpu, mvneta_percpu_unmask_interrupt,
  26. - pp, true);
  27. + on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
  28. +
  29. mvreg_write(pp, MVNETA_INTR_MISC_MASK,
  30. MVNETA_CAUSE_PHY_STATUS_CHANGE |
  31. MVNETA_CAUSE_LINK_CHANGE |
  32. @@ -2995,7 +2994,7 @@ static int mvneta_percpu_notifier(struct
  33. static int mvneta_open(struct net_device *dev)
  34. {
  35. struct mvneta_port *pp = netdev_priv(dev);
  36. - int ret, cpu;
  37. + int ret;
  38. pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu);
  39. pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) +
  40. @@ -3028,9 +3027,7 @@ static int mvneta_open(struct net_device
  41. /* Enable per-CPU interrupt on all the CPU to handle our RX
  42. * queue interrupts
  43. */
  44. - for_each_online_cpu(cpu)
  45. - smp_call_function_single(cpu, mvneta_percpu_enable,
  46. - pp, true);
  47. + on_each_cpu(mvneta_percpu_enable, pp, true);
  48. /* Register a CPU notifier to handle the case where our CPU
  49. @@ -3317,9 +3314,7 @@ static int mvneta_config_rss(struct mvn
  50. netif_tx_stop_all_queues(pp->dev);
  51. - for_each_online_cpu(cpu)
  52. - smp_call_function_single(cpu, mvneta_percpu_mask_interrupt,
  53. - pp, true);
  54. + on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
  55. /* We have to synchronise on the napi of each CPU */
  56. for_each_online_cpu(cpu) {