sun4v_ivec.S 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /* sun4v_ivec.S: Sun4v interrupt vector handling.
  2. *
  3. * Copyright (C) 2006 <davem@davemloft.net>
  4. */
  5. #include <asm/cpudata.h>
  6. #include <asm/intr_queue.h>
  7. #include <asm/pil.h>
  8. .text
  9. .align 32
  10. sun4v_cpu_mondo:
  11. /* Head offset in %g2, tail offset in %g4.
  12. * If they are the same, no work.
  13. */
  14. mov INTRQ_CPU_MONDO_HEAD, %g2
  15. ldxa [%g2] ASI_QUEUE, %g2
  16. mov INTRQ_CPU_MONDO_TAIL, %g4
  17. ldxa [%g4] ASI_QUEUE, %g4
  18. cmp %g2, %g4
  19. be,pn %xcc, sun4v_cpu_mondo_queue_empty
  20. nop
  21. /* Get &trap_block[smp_processor_id()] into %g4. */
  22. ldxa [%g0] ASI_SCRATCHPAD, %g4
  23. sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4
  24. /* Get CPU mondo queue base phys address into %g7. */
  25. ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
  26. /* Now get the cross-call arguments and handler PC, same
  27. * layout as sun4u:
  28. *
  29. * 1st 64-bit word: low half is 32-bit PC, put into %g3 and jmpl to it
  30. * high half is context arg to MMU flushes, into %g5
  31. * 2nd 64-bit word: 64-bit arg, load into %g1
  32. * 3rd 64-bit word: 64-bit arg, load into %g7
  33. */
  34. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g3
  35. add %g2, 0x8, %g2
  36. srlx %g3, 32, %g5
  37. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  38. add %g2, 0x8, %g2
  39. srl %g3, 0, %g3
  40. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g7
  41. add %g2, 0x40 - 0x8 - 0x8, %g2
  42. /* Update queue head pointer. */
  43. lduw [%g4 + TRAP_PER_CPU_CPU_MONDO_QMASK], %g4
  44. and %g2, %g4, %g2
  45. mov INTRQ_CPU_MONDO_HEAD, %g4
  46. stxa %g2, [%g4] ASI_QUEUE
  47. membar #Sync
  48. jmpl %g3, %g0
  49. nop
  50. sun4v_cpu_mondo_queue_empty:
  51. retry
  52. sun4v_dev_mondo:
  53. /* Head offset in %g2, tail offset in %g4. */
  54. mov INTRQ_DEVICE_MONDO_HEAD, %g2
  55. ldxa [%g2] ASI_QUEUE, %g2
  56. mov INTRQ_DEVICE_MONDO_TAIL, %g4
  57. ldxa [%g4] ASI_QUEUE, %g4
  58. cmp %g2, %g4
  59. be,pn %xcc, sun4v_dev_mondo_queue_empty
  60. nop
  61. /* Get &trap_block[smp_processor_id()] into %g4. */
  62. ldxa [%g0] ASI_SCRATCHPAD, %g4
  63. sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4
  64. /* Get DEV mondo queue base phys address into %g5. */
  65. ldx [%g4 + TRAP_PER_CPU_DEV_MONDO_PA], %g5
  66. /* Load IVEC into %g3. */
  67. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  68. add %g2, 0x40, %g2
  69. /* XXX There can be a full 64-byte block of data here.
  70. * XXX This is how we can get at MSI vector data.
  71. * XXX Current we do not capture this, but when we do we'll
  72. * XXX need to add a 64-byte storage area in the struct ino_bucket
  73. * XXX or the struct irq_desc.
  74. */
  75. /* Update queue head pointer, this frees up some registers. */
  76. lduw [%g4 + TRAP_PER_CPU_DEV_MONDO_QMASK], %g4
  77. and %g2, %g4, %g2
  78. mov INTRQ_DEVICE_MONDO_HEAD, %g4
  79. stxa %g2, [%g4] ASI_QUEUE
  80. membar #Sync
  81. /* Get &__irq_work[smp_processor_id()] into %g1. */
  82. TRAP_LOAD_IRQ_WORK(%g1, %g4)
  83. /* Get &ivector_table[IVEC] into %g4. */
  84. sethi %hi(ivector_table), %g4
  85. sllx %g3, 3, %g3
  86. or %g4, %lo(ivector_table), %g4
  87. add %g4, %g3, %g4
  88. /* Insert ivector_table[] entry into __irq_work[] queue. */
  89. lduw [%g1], %g2 /* g2 = irq_work(cpu) */
  90. stw %g2, [%g4 + 0x00] /* bucket->irq_chain = g2 */
  91. stw %g4, [%g1] /* irq_work(cpu) = bucket */
  92. /* Signal the interrupt by setting (1 << pil) in %softint. */
  93. wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
  94. sun4v_dev_mondo_queue_empty:
  95. retry
  96. sun4v_res_mondo:
  97. /* Head offset in %g2, tail offset in %g4. */
  98. mov INTRQ_RESUM_MONDO_HEAD, %g2
  99. ldxa [%g2] ASI_QUEUE, %g2
  100. mov INTRQ_RESUM_MONDO_TAIL, %g4
  101. ldxa [%g4] ASI_QUEUE, %g4
  102. cmp %g2, %g4
  103. be,pn %xcc, sun4v_res_mondo_queue_empty
  104. nop
  105. /* Get &trap_block[smp_processor_id()] into %g3. */
  106. ldxa [%g0] ASI_SCRATCHPAD, %g3
  107. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  108. /* Get RES mondo queue base phys address into %g5. */
  109. ldx [%g3 + TRAP_PER_CPU_RESUM_MONDO_PA], %g5
  110. /* Get RES kernel buffer base phys address into %g7. */
  111. ldx [%g3 + TRAP_PER_CPU_RESUM_KBUF_PA], %g7
  112. /* If the first word is non-zero, queue is full. */
  113. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  114. brnz,pn %g1, sun4v_res_mondo_queue_full
  115. nop
  116. lduw [%g3 + TRAP_PER_CPU_RESUM_QMASK], %g4
  117. /* Remember this entry's offset in %g1. */
  118. mov %g2, %g1
  119. /* Copy 64-byte queue entry into kernel buffer. */
  120. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  121. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  122. add %g2, 0x08, %g2
  123. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  124. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  125. add %g2, 0x08, %g2
  126. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  127. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  128. add %g2, 0x08, %g2
  129. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  130. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  131. add %g2, 0x08, %g2
  132. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  133. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  134. add %g2, 0x08, %g2
  135. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  136. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  137. add %g2, 0x08, %g2
  138. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  139. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  140. add %g2, 0x08, %g2
  141. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  142. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  143. add %g2, 0x08, %g2
  144. /* Update queue head pointer. */
  145. and %g2, %g4, %g2
  146. mov INTRQ_RESUM_MONDO_HEAD, %g4
  147. stxa %g2, [%g4] ASI_QUEUE
  148. membar #Sync
  149. /* Disable interrupts and save register state so we can call
  150. * C code. The etrap handling will leave %g4 in %l4 for us
  151. * when it's done.
  152. */
  153. rdpr %pil, %g2
  154. wrpr %g0, 15, %pil
  155. mov %g1, %g4
  156. ba,pt %xcc, etrap_irq
  157. rd %pc, %g7
  158. #ifdef CONFIG_TRACE_IRQFLAGS
  159. call trace_hardirqs_off
  160. nop
  161. #endif
  162. /* Log the event. */
  163. add %sp, PTREGS_OFF, %o0
  164. call sun4v_resum_error
  165. mov %l4, %o1
  166. /* Return from trap. */
  167. ba,pt %xcc, rtrap_irq
  168. nop
  169. sun4v_res_mondo_queue_empty:
  170. retry
  171. sun4v_res_mondo_queue_full:
  172. /* The queue is full, consolidate our damage by setting
  173. * the head equal to the tail. We'll just trap again otherwise.
  174. * Call C code to log the event.
  175. */
  176. mov INTRQ_RESUM_MONDO_HEAD, %g2
  177. stxa %g4, [%g2] ASI_QUEUE
  178. membar #Sync
  179. rdpr %pil, %g2
  180. wrpr %g0, 15, %pil
  181. ba,pt %xcc, etrap_irq
  182. rd %pc, %g7
  183. #ifdef CONFIG_TRACE_IRQFLAGS
  184. call trace_hardirqs_off
  185. nop
  186. #endif
  187. call sun4v_resum_overflow
  188. add %sp, PTREGS_OFF, %o0
  189. ba,pt %xcc, rtrap_irq
  190. nop
  191. sun4v_nonres_mondo:
  192. /* Head offset in %g2, tail offset in %g4. */
  193. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  194. ldxa [%g2] ASI_QUEUE, %g2
  195. mov INTRQ_NONRESUM_MONDO_TAIL, %g4
  196. ldxa [%g4] ASI_QUEUE, %g4
  197. cmp %g2, %g4
  198. be,pn %xcc, sun4v_nonres_mondo_queue_empty
  199. nop
  200. /* Get &trap_block[smp_processor_id()] into %g3. */
  201. ldxa [%g0] ASI_SCRATCHPAD, %g3
  202. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  203. /* Get RES mondo queue base phys address into %g5. */
  204. ldx [%g3 + TRAP_PER_CPU_NONRESUM_MONDO_PA], %g5
  205. /* Get RES kernel buffer base phys address into %g7. */
  206. ldx [%g3 + TRAP_PER_CPU_NONRESUM_KBUF_PA], %g7
  207. /* If the first word is non-zero, queue is full. */
  208. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  209. brnz,pn %g1, sun4v_nonres_mondo_queue_full
  210. nop
  211. lduw [%g3 + TRAP_PER_CPU_NONRESUM_QMASK], %g4
  212. /* Remember this entry's offset in %g1. */
  213. mov %g2, %g1
  214. /* Copy 64-byte queue entry into kernel buffer. */
  215. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  216. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  217. add %g2, 0x08, %g2
  218. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  219. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  220. add %g2, 0x08, %g2
  221. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  222. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  223. add %g2, 0x08, %g2
  224. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  225. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  226. add %g2, 0x08, %g2
  227. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  228. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  229. add %g2, 0x08, %g2
  230. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  231. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  232. add %g2, 0x08, %g2
  233. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  234. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  235. add %g2, 0x08, %g2
  236. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  237. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  238. add %g2, 0x08, %g2
  239. /* Update queue head pointer. */
  240. and %g2, %g4, %g2
  241. mov INTRQ_NONRESUM_MONDO_HEAD, %g4
  242. stxa %g2, [%g4] ASI_QUEUE
  243. membar #Sync
  244. /* Disable interrupts and save register state so we can call
  245. * C code. The etrap handling will leave %g4 in %l4 for us
  246. * when it's done.
  247. */
  248. rdpr %pil, %g2
  249. wrpr %g0, 15, %pil
  250. mov %g1, %g4
  251. ba,pt %xcc, etrap_irq
  252. rd %pc, %g7
  253. #ifdef CONFIG_TRACE_IRQFLAGS
  254. call trace_hardirqs_off
  255. nop
  256. #endif
  257. /* Log the event. */
  258. add %sp, PTREGS_OFF, %o0
  259. call sun4v_nonresum_error
  260. mov %l4, %o1
  261. /* Return from trap. */
  262. ba,pt %xcc, rtrap_irq
  263. nop
  264. sun4v_nonres_mondo_queue_empty:
  265. retry
  266. sun4v_nonres_mondo_queue_full:
  267. /* The queue is full, consolidate our damage by setting
  268. * the head equal to the tail. We'll just trap again otherwise.
  269. * Call C code to log the event.
  270. */
  271. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  272. stxa %g4, [%g2] ASI_QUEUE
  273. membar #Sync
  274. rdpr %pil, %g2
  275. wrpr %g0, 15, %pil
  276. ba,pt %xcc, etrap_irq
  277. rd %pc, %g7
  278. #ifdef CONFIG_TRACE_IRQFLAGS
  279. call trace_hardirqs_off
  280. nop
  281. #endif
  282. call sun4v_nonresum_overflow
  283. add %sp, PTREGS_OFF, %o0
  284. ba,pt %xcc, rtrap_irq
  285. nop