irq.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * linux/arch/x86_64/kernel/irq.c
  3. *
  4. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  5. *
  6. * This file contains the lowest level x86_64-specific interrupt
  7. * entry and irq statistics code. All the remaining irq logic is
  8. * done by the generic kernel/irq/ code and in the
  9. * x86_64-specific irq controller code. (e.g. i8259.c and
  10. * io_apic.c.)
  11. */
  12. #include <linux/kernel_stat.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/seq_file.h>
  15. #include <linux/module.h>
  16. #include <linux/delay.h>
  17. #include <asm/uaccess.h>
  18. #include <asm/io_apic.h>
  19. #include <asm/idle.h>
  20. atomic_t irq_err_count;
  21. #ifdef CONFIG_X86_IO_APIC
  22. #ifdef APIC_MISMATCH_DEBUG
  23. atomic_t irq_mis_count;
  24. #endif
  25. #endif
  26. /*
  27. * Generic, controller-independent functions:
  28. */
  29. int show_interrupts(struct seq_file *p, void *v)
  30. {
  31. int i = *(loff_t *) v, j;
  32. struct irqaction * action;
  33. unsigned long flags;
  34. if (i == 0) {
  35. seq_printf(p, " ");
  36. for (j=0; j<NR_CPUS; j++)
  37. if (cpu_online(j))
  38. seq_printf(p, "CPU%d ",j);
  39. seq_putc(p, '\n');
  40. }
  41. if (i < NR_IRQS) {
  42. spin_lock_irqsave(&irq_desc[i].lock, flags);
  43. action = irq_desc[i].action;
  44. if (!action)
  45. goto skip;
  46. seq_printf(p, "%3d: ",i);
  47. #ifndef CONFIG_SMP
  48. seq_printf(p, "%10u ", kstat_irqs(i));
  49. #else
  50. for (j=0; j<NR_CPUS; j++)
  51. if (cpu_online(j))
  52. seq_printf(p, "%10u ",
  53. kstat_cpu(j).irqs[i]);
  54. #endif
  55. seq_printf(p, " %14s", irq_desc[i].handler->typename);
  56. seq_printf(p, " %s", action->name);
  57. for (action=action->next; action; action = action->next)
  58. seq_printf(p, ", %s", action->name);
  59. seq_putc(p, '\n');
  60. skip:
  61. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  62. } else if (i == NR_IRQS) {
  63. seq_printf(p, "NMI: ");
  64. for (j = 0; j < NR_CPUS; j++)
  65. if (cpu_online(j))
  66. seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
  67. seq_putc(p, '\n');
  68. #ifdef CONFIG_X86_LOCAL_APIC
  69. seq_printf(p, "LOC: ");
  70. for (j = 0; j < NR_CPUS; j++)
  71. if (cpu_online(j))
  72. seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
  73. seq_putc(p, '\n');
  74. #endif
  75. seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
  76. #ifdef CONFIG_X86_IO_APIC
  77. #ifdef APIC_MISMATCH_DEBUG
  78. seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
  79. #endif
  80. #endif
  81. }
  82. return 0;
  83. }
  84. /*
  85. * do_IRQ handles all normal device IRQ's (the special
  86. * SMP cross-CPU interrupts have their own specific
  87. * handlers).
  88. */
  89. asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
  90. {
  91. /* high bits used in ret_from_ code */
  92. unsigned irq = regs->orig_rax & 0xff;
  93. exit_idle();
  94. irq_enter();
  95. __do_IRQ(irq, regs);
  96. irq_exit();
  97. return 1;
  98. }
  99. #ifdef CONFIG_HOTPLUG_CPU
  100. void fixup_irqs(cpumask_t map)
  101. {
  102. unsigned int irq;
  103. static int warned;
  104. for (irq = 0; irq < NR_IRQS; irq++) {
  105. cpumask_t mask;
  106. if (irq == 2)
  107. continue;
  108. cpus_and(mask, irq_affinity[irq], map);
  109. if (any_online_cpu(mask) == NR_CPUS) {
  110. printk("Breaking affinity for irq %i\n", irq);
  111. mask = map;
  112. }
  113. if (irq_desc[irq].handler->set_affinity)
  114. irq_desc[irq].handler->set_affinity(irq, mask);
  115. else if (irq_desc[irq].action && !(warned++))
  116. printk("Cannot set affinity for irq %i\n", irq);
  117. }
  118. /* That doesn't seem sufficient. Give it 1ms. */
  119. local_irq_enable();
  120. mdelay(1);
  121. local_irq_disable();
  122. }
  123. #endif
  124. extern void call_softirq(void);
  125. asmlinkage void do_softirq(void)
  126. {
  127. __u32 pending;
  128. unsigned long flags;
  129. if (in_interrupt())
  130. return;
  131. local_irq_save(flags);
  132. pending = local_softirq_pending();
  133. /* Switch to interrupt stack */
  134. if (pending)
  135. call_softirq();
  136. local_irq_restore(flags);
  137. }
  138. EXPORT_SYMBOL(do_softirq);