interrupts.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ==========
  2. Interrupts
  3. ==========
  4. 2.5.2-rmk5:
  5. This is the first kernel that contains a major shake up of some of the
  6. major architecture-specific subsystems.
  7. Firstly, it contains some pretty major changes to the way we handle the
  8. MMU TLB. Each MMU TLB variant is now handled completely separately -
  9. we have TLB v3, TLB v4 (without write buffer), TLB v4 (with write buffer),
  10. and finally TLB v4 (with write buffer, with I TLB invalidate entry).
  11. There is more assembly code inside each of these functions, mainly to
  12. allow more flexible TLB handling for the future.
  13. Secondly, the IRQ subsystem.
  14. The 2.5 kernels will be having major changes to the way IRQs are handled.
  15. Unfortunately, this means that machine types that touch the irq_desc[]
  16. array (basically all machine types) will break, and this means every
  17. machine type that we currently have.
  18. Lets take an example. On the Assabet with Neponset, we have::
  19. GPIO25 IRR:2
  20. SA1100 ------------> Neponset -----------> SA1111
  21. IIR:1
  22. -----------> USAR
  23. IIR:0
  24. -----------> SMC9196
  25. The way stuff currently works, all SA1111 interrupts are mutually
  26. exclusive of each other - if you're processing one interrupt from the
  27. SA1111 and another comes in, you have to wait for that interrupt to
  28. finish processing before you can service the new interrupt. Eg, an
  29. IDE PIO-based interrupt on the SA1111 excludes all other SA1111 and
  30. SMC9196 interrupts until it has finished transferring its multi-sector
  31. data, which can be a long time. Note also that since we loop in the
  32. SA1111 IRQ handler, SA1111 IRQs can hold off SMC9196 IRQs indefinitely.
  33. The new approach brings several new ideas...
  34. We introduce the concept of a "parent" and a "child". For example,
  35. to the Neponset handler, the "parent" is GPIO25, and the "children"d
  36. are SA1111, SMC9196 and USAR.
  37. We also bring the idea of an IRQ "chip" (mainly to reduce the size of
  38. the irqdesc array). This doesn't have to be a real "IC"; indeed the
  39. SA11x0 IRQs are handled by two separate "chip" structures, one for
  40. GPIO0-10, and another for all the rest. It is just a container for
  41. the various operations (maybe this'll change to a better name).
  42. This structure has the following operations::
  43. struct irqchip {
  44. /*
  45. * Acknowledge the IRQ.
  46. * If this is a level-based IRQ, then it is expected to mask the IRQ
  47. * as well.
  48. */
  49. void (*ack)(unsigned int irq);
  50. /*
  51. * Mask the IRQ in hardware.
  52. */
  53. void (*mask)(unsigned int irq);
  54. /*
  55. * Unmask the IRQ in hardware.
  56. */
  57. void (*unmask)(unsigned int irq);
  58. /*
  59. * Re-run the IRQ
  60. */
  61. void (*rerun)(unsigned int irq);
  62. /*
  63. * Set the type of the IRQ.
  64. */
  65. int (*type)(unsigned int irq, unsigned int, type);
  66. };
  67. ack
  68. - required. May be the same function as mask for IRQs
  69. handled by do_level_IRQ.
  70. mask
  71. - required.
  72. unmask
  73. - required.
  74. rerun
  75. - optional. Not required if you're using do_level_IRQ for all
  76. IRQs that use this 'irqchip'. Generally expected to re-trigger
  77. the hardware IRQ if possible. If not, may call the handler
  78. directly.
  79. type
  80. - optional. If you don't support changing the type of an IRQ,
  81. it should be null so people can detect if they are unable to
  82. set the IRQ type.
  83. For each IRQ, we keep the following information:
  84. - "disable" depth (number of disable_irq()s without enable_irq()s)
  85. - flags indicating what we can do with this IRQ (valid, probe,
  86. noautounmask) as before
  87. - status of the IRQ (probing, enable, etc)
  88. - chip
  89. - per-IRQ handler
  90. - irqaction structure list
  91. The handler can be one of the 3 standard handlers - "level", "edge" and
  92. "simple", or your own specific handler if you need to do something special.
  93. The "level" handler is what we currently have - its pretty simple.
  94. "edge" knows about the brokenness of such IRQ implementations - that you
  95. need to leave the hardware IRQ enabled while processing it, and queueing
  96. further IRQ events should the IRQ happen again while processing. The
  97. "simple" handler is very basic, and does not perform any hardware
  98. manipulation, nor state tracking. This is useful for things like the
  99. SMC9196 and USAR above.
  100. So, what's changed?
  101. ===================
  102. 1. Machine implementations must not write to the irqdesc array.
  103. 2. New functions to manipulate the irqdesc array. The first 4 are expected
  104. to be useful only to machine specific code. The last is recommended to
  105. only be used by machine specific code, but may be used in drivers if
  106. absolutely necessary.
  107. set_irq_chip(irq,chip)
  108. Set the mask/unmask methods for handling this IRQ
  109. set_irq_handler(irq,handler)
  110. Set the handler for this IRQ (level, edge, simple)
  111. set_irq_chained_handler(irq,handler)
  112. Set a "chained" handler for this IRQ - automatically
  113. enables this IRQ (eg, Neponset and SA1111 handlers).
  114. set_irq_flags(irq,flags)
  115. Set the valid/probe/noautoenable flags.
  116. set_irq_type(irq,type)
  117. Set active the IRQ edge(s)/level. This replaces the
  118. SA1111 INTPOL manipulation, and the set_GPIO_IRQ_edge()
  119. function. Type should be one of IRQ_TYPE_xxx defined in
  120. <linux/irq.h>
  121. 3. set_GPIO_IRQ_edge() is obsolete, and should be replaced by set_irq_type.
  122. 4. Direct access to SA1111 INTPOL is deprecated. Use set_irq_type instead.
  123. 5. A handler is expected to perform any necessary acknowledgement of the
  124. parent IRQ via the correct chip specific function. For instance, if
  125. the SA1111 is directly connected to a SA1110 GPIO, then you should
  126. acknowledge the SA1110 IRQ each time you re-read the SA1111 IRQ status.
  127. 6. For any child which doesn't have its own IRQ enable/disable controls
  128. (eg, SMC9196), the handler must mask or acknowledge the parent IRQ
  129. while the child handler is called, and the child handler should be the
  130. "simple" handler (not "edge" nor "level"). After the handler completes,
  131. the parent IRQ should be unmasked, and the status of all children must
  132. be re-checked for pending events. (see the Neponset IRQ handler for
  133. details).
  134. 7. fixup_irq() is gone, as is `arch/arm/mach-*/include/mach/irq.h`
  135. Please note that this will not solve all problems - some of them are
  136. hardware based. Mixing level-based and edge-based IRQs on the same
  137. parent signal (eg neponset) is one such area where a software based
  138. solution can't provide the full answer to low IRQ latency.