irq_64.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  3. *
  4. * This file contains the lowest level x86_64-specific interrupt
  5. * entry and irq statistics code. All the remaining irq logic is
  6. * done by the generic kernel/irq/ code and in the
  7. * x86_64-specific irq controller code. (e.g. i8259.c and
  8. * io_apic.c.)
  9. */
  10. #include <linux/kernel_stat.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/seq_file.h>
  13. #include <linux/module.h>
  14. #include <linux/delay.h>
  15. #include <asm/uaccess.h>
  16. #include <asm/io_apic.h>
  17. #include <asm/idle.h>
  18. #include <asm/smp.h>
  19. #ifdef CONFIG_DEBUG_STACKOVERFLOW
  20. /*
  21. * Probabilistic stack overflow check:
  22. *
  23. * Only check the stack in process context, because everything else
  24. * runs on the big interrupt stacks. Checking reliably is too expensive,
  25. * so we just check from interrupts.
  26. */
  27. static inline void stack_overflow_check(struct pt_regs *regs)
  28. {
  29. u64 curbase = (u64)task_stack_page(current);
  30. static unsigned long warned = -60*HZ;
  31. if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE &&
  32. regs->sp < curbase + sizeof(struct thread_info) + 128 &&
  33. time_after(jiffies, warned + 60*HZ)) {
  34. printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
  35. current->comm, curbase, regs->sp);
  36. show_stack(NULL,NULL);
  37. warned = jiffies;
  38. }
  39. }
  40. #endif
  41. /*
  42. * do_IRQ handles all normal device IRQ's (the special
  43. * SMP cross-CPU interrupts have their own specific
  44. * handlers).
  45. */
  46. asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
  47. {
  48. struct pt_regs *old_regs = set_irq_regs(regs);
  49. struct irq_desc *desc;
  50. /* high bit used in ret_from_ code */
  51. unsigned vector = ~regs->orig_ax;
  52. unsigned irq;
  53. exit_idle();
  54. irq_enter();
  55. irq = __get_cpu_var(vector_irq)[vector];
  56. #ifdef CONFIG_DEBUG_STACKOVERFLOW
  57. stack_overflow_check(regs);
  58. #endif
  59. desc = irq_to_desc(irq);
  60. if (likely(desc))
  61. generic_handle_irq_desc(irq, desc);
  62. else {
  63. if (!disable_apic)
  64. ack_APIC_irq();
  65. if (printk_ratelimit())
  66. printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
  67. __func__, smp_processor_id(), vector);
  68. }
  69. irq_exit();
  70. set_irq_regs(old_regs);
  71. return 1;
  72. }
  73. #ifdef CONFIG_HOTPLUG_CPU
  74. /* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
  75. void fixup_irqs(void)
  76. {
  77. unsigned int irq;
  78. static int warned;
  79. struct irq_desc *desc;
  80. for_each_irq_desc(irq, desc) {
  81. int break_affinity = 0;
  82. int set_affinity = 1;
  83. const struct cpumask *affinity;
  84. if (!desc)
  85. continue;
  86. if (irq == 2)
  87. continue;
  88. /* interrupt's are disabled at this point */
  89. spin_lock(&desc->lock);
  90. affinity = &desc->affinity;
  91. if (!irq_has_action(irq) ||
  92. cpumask_equal(affinity, cpu_online_mask)) {
  93. spin_unlock(&desc->lock);
  94. continue;
  95. }
  96. if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
  97. break_affinity = 1;
  98. affinity = cpu_all_mask;
  99. }
  100. if (desc->chip->mask)
  101. desc->chip->mask(irq);
  102. if (desc->chip->set_affinity)
  103. desc->chip->set_affinity(irq, affinity);
  104. else if (!(warned++))
  105. set_affinity = 0;
  106. if (desc->chip->unmask)
  107. desc->chip->unmask(irq);
  108. spin_unlock(&desc->lock);
  109. if (break_affinity && set_affinity)
  110. printk("Broke affinity for irq %i\n", irq);
  111. else if (!set_affinity)
  112. printk("Cannot set affinity for irq %i\n", irq);
  113. }
  114. /* That doesn't seem sufficient. Give it 1ms. */
  115. local_irq_enable();
  116. mdelay(1);
  117. local_irq_disable();
  118. }
  119. #endif
  120. extern void call_softirq(void);
  121. asmlinkage void do_softirq(void)
  122. {
  123. __u32 pending;
  124. unsigned long flags;
  125. if (in_interrupt())
  126. return;
  127. local_irq_save(flags);
  128. pending = local_softirq_pending();
  129. /* Switch to interrupt stack */
  130. if (pending) {
  131. call_softirq();
  132. WARN_ON_ONCE(softirq_count());
  133. }
  134. local_irq_restore(flags);
  135. }