037-net-mvneta-Fix-for_each_present_cpu-usage.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From: Gregory CLEMENT <gregory.clement@free-electrons.com>
  2. Date: Thu, 4 Feb 2016 22:09:23 +0100
  3. Subject: [PATCH] net: mvneta: Fix for_each_present_cpu usage
  4. This patch convert the for_each_present in on_each_cpu, instead of
  5. applying on the present cpus it will be applied only on the online cpus.
  6. This fix a bug reported on
  7. http://thread.gmane.org/gmane.linux.ports.arm.kernel/468173.
  8. Using the macro on_each_cpu (instead of a for_each_* loop) also ensures
  9. that all the calls will be done all at once.
  10. Fixes: f86428854480 ("net: mvneta: Statically assign queues to CPUs")
  11. Reported-by: Stefan Roese <stefan.roese@gmail.com>
  12. Suggested-by: Jisheng Zhang <jszhang@marvell.com>
  13. Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
  14. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
  15. Signed-off-by: David S. Miller <davem@davemloft.net>
  16. ---
  17. --- a/drivers/net/ethernet/marvell/mvneta.c
  18. +++ b/drivers/net/ethernet/marvell/mvneta.c
  19. @@ -2562,7 +2562,7 @@ static void mvneta_start_dev(struct mvne
  20. mvneta_port_enable(pp);
  21. /* Enable polling on the port */
  22. - for_each_present_cpu(cpu) {
  23. + for_each_online_cpu(cpu) {
  24. struct mvneta_pcpu_port *port = per_cpu_ptr(pp->ports, cpu);
  25. napi_enable(&port->napi);
  26. @@ -2587,7 +2587,7 @@ static void mvneta_stop_dev(struct mvnet
  27. phy_stop(pp->phy_dev);
  28. - for_each_present_cpu(cpu) {
  29. + for_each_online_cpu(cpu) {
  30. struct mvneta_pcpu_port *port = per_cpu_ptr(pp->ports, cpu);
  31. napi_disable(&port->napi);
  32. @@ -3055,13 +3055,11 @@ err_cleanup_rxqs:
  33. static int mvneta_stop(struct net_device *dev)
  34. {
  35. struct mvneta_port *pp = netdev_priv(dev);
  36. - int cpu;
  37. mvneta_stop_dev(pp);
  38. mvneta_mdio_remove(pp);
  39. unregister_cpu_notifier(&pp->cpu_notifier);
  40. - for_each_present_cpu(cpu)
  41. - smp_call_function_single(cpu, mvneta_percpu_disable, pp, true);
  42. + on_each_cpu(mvneta_percpu_disable, pp, true);
  43. free_percpu_irq(dev->irq, pp->ports);
  44. mvneta_cleanup_rxqs(pp);
  45. mvneta_cleanup_txqs(pp);