dbell.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <linux/hardirq.h>
  16. #include <asm/dbell.h>
  17. #include <asm/irq_regs.h>
  18. #include <asm/kvm_ppc.h>
  19. #ifdef CONFIG_SMP
  20. void doorbell_setup_this_cpu(void)
  21. {
  22. unsigned long tag = mfspr(SPRN_DOORBELL_CPUTAG) & PPC_DBELL_TAG_MASK;
  23. smp_muxed_ipi_set_data(smp_processor_id(), tag);
  24. }
  25. void doorbell_cause_ipi(int cpu, unsigned long data)
  26. {
  27. /* Order previous accesses vs. msgsnd, which is treated as a store */
  28. mb();
  29. ppc_msgsnd(PPC_DBELL_MSGTYPE, 0, data);
  30. }
  31. void doorbell_exception(struct pt_regs *regs)
  32. {
  33. struct pt_regs *old_regs = set_irq_regs(regs);
  34. irq_enter();
  35. may_hard_irq_enable();
  36. kvmppc_set_host_ipi(smp_processor_id(), 0);
  37. __this_cpu_inc(irq_stat.doorbell_irqs);
  38. smp_ipi_demux();
  39. irq_exit();
  40. set_irq_regs(old_regs);
  41. }
  42. #else /* CONFIG_SMP */
  43. void doorbell_exception(struct pt_regs *regs)
  44. {
  45. printk(KERN_WARNING "Received doorbell on non-smp system\n");
  46. }
  47. #endif /* CONFIG_SMP */