1
0

hardirq.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2012 ARM Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __ASM_HARDIRQ_H
  17. #define __ASM_HARDIRQ_H
  18. #include <linux/cache.h>
  19. #include <linux/percpu.h>
  20. #include <linux/threads.h>
  21. #include <asm/barrier.h>
  22. #include <asm/irq.h>
  23. #include <asm/kvm_arm.h>
  24. #include <asm/sysreg.h>
  25. #define NR_IPI 7
  26. typedef struct {
  27. unsigned int __softirq_pending;
  28. unsigned int ipi_irqs[NR_IPI];
  29. } ____cacheline_aligned irq_cpustat_t;
  30. #include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
  31. #define __inc_irq_stat(cpu, member) __IRQ_STAT(cpu, member)++
  32. #define __get_irq_stat(cpu, member) __IRQ_STAT(cpu, member)
  33. u64 smp_irq_stat_cpu(unsigned int cpu);
  34. #define arch_irq_stat_cpu smp_irq_stat_cpu
  35. #define __ARCH_IRQ_EXIT_IRQS_DISABLED 1
  36. struct nmi_ctx {
  37. u64 hcr;
  38. };
  39. DECLARE_PER_CPU(struct nmi_ctx, nmi_contexts);
  40. #define arch_nmi_enter() \
  41. do { \
  42. if (is_kernel_in_hyp_mode()) { \
  43. struct nmi_ctx *nmi_ctx = this_cpu_ptr(&nmi_contexts); \
  44. nmi_ctx->hcr = read_sysreg(hcr_el2); \
  45. if (!(nmi_ctx->hcr & HCR_TGE)) { \
  46. write_sysreg(nmi_ctx->hcr | HCR_TGE, hcr_el2); \
  47. isb(); \
  48. } \
  49. } \
  50. } while (0)
  51. #define arch_nmi_exit() \
  52. do { \
  53. if (is_kernel_in_hyp_mode()) { \
  54. struct nmi_ctx *nmi_ctx = this_cpu_ptr(&nmi_contexts); \
  55. if (!(nmi_ctx->hcr & HCR_TGE)) \
  56. write_sysreg(nmi_ctx->hcr, hcr_el2); \
  57. } \
  58. } while (0)
  59. static inline void ack_bad_irq(unsigned int irq)
  60. {
  61. extern unsigned long irq_err_count;
  62. irq_err_count++;
  63. }
  64. #endif /* __ASM_HARDIRQ_H */