dbell.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Author: Kumar Gala <galak@kernel.crashing.org>
  3. *
  4. * Copyright 2009 Freescale Semiconductor Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/smp.h>
  14. #include <linux/threads.h>
  15. #include <asm/dbell.h>
  16. #ifdef CONFIG_SMP
  17. unsigned long dbell_smp_message[NR_CPUS];
  18. void smp_dbell_message_pass(int target, int msg)
  19. {
  20. int i;
  21. if(target < NR_CPUS) {
  22. set_bit(msg, &dbell_smp_message[target]);
  23. ppc_msgsnd(PPC_DBELL, 0, target);
  24. }
  25. else if(target == MSG_ALL_BUT_SELF) {
  26. for_each_online_cpu(i) {
  27. if (i == smp_processor_id())
  28. continue;
  29. set_bit(msg, &dbell_smp_message[i]);
  30. ppc_msgsnd(PPC_DBELL, 0, i);
  31. }
  32. }
  33. else { /* target == MSG_ALL */
  34. for_each_online_cpu(i)
  35. set_bit(msg, &dbell_smp_message[i]);
  36. ppc_msgsnd(PPC_DBELL, PPC_DBELL_MSG_BRDCAST, 0);
  37. }
  38. }
  39. void doorbell_exception(struct pt_regs *regs)
  40. {
  41. int cpu = smp_processor_id();
  42. int msg;
  43. if (num_online_cpus() < 2)
  44. return;
  45. for (msg = 0; msg < 4; msg++)
  46. if (test_and_clear_bit(msg, &dbell_smp_message[cpu]))
  47. smp_message_recv(msg);
  48. }
  49. #else /* CONFIG_SMP */
  50. void doorbell_exception(struct pt_regs *regs)
  51. {
  52. printk(KERN_WARNING "Received doorbell on non-smp system\n");
  53. }
  54. #endif /* CONFIG_SMP */