sun4v_ivec.S 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. .text
  8. .align 32
  9. sun4v_cpu_mondo:
  10. /* Head offset in %g2, tail offset in %g4.
  11. * If they are the same, no work.
  12. */
  13. mov INTRQ_CPU_MONDO_HEAD, %g2
  14. ldxa [%g2] ASI_QUEUE, %g2
  15. mov INTRQ_CPU_MONDO_TAIL, %g4
  16. ldxa [%g4] ASI_QUEUE, %g4
  17. cmp %g2, %g4
  18. be,pn %xcc, sun4v_cpu_mondo_queue_empty
  19. nop
  20. /* Get &trap_block[smp_processor_id()] into %g3. */
  21. ldxa [%g0] ASI_SCRATCHPAD, %g3
  22. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  23. /* Get CPU mondo queue base phys address into %g7. */
  24. ldx [%g3 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
  25. /* Now get the cross-call arguments and handler PC, same
  26. * layout as sun4u:
  27. *
  28. * 1st 64-bit word: low half is 32-bit PC, put into %g3 and jmpl to it
  29. * high half is context arg to MMU flushes, into %g5
  30. * 2nd 64-bit word: 64-bit arg, load into %g1
  31. * 3rd 64-bit word: 64-bit arg, load into %g7
  32. */
  33. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g3
  34. add %g2, 0x8, %g2
  35. srlx %g3, 32, %g5
  36. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  37. add %g2, 0x8, %g2
  38. srl %g3, 0, %g3
  39. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g7
  40. add %g2, 0x40 - 0x8 - 0x8, %g2
  41. /* Update queue head pointer. */
  42. sethi %hi(8192 - 1), %g4
  43. or %g4, %lo(8192 - 1), %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 %g3. */
  62. ldxa [%g0] ASI_SCRATCHPAD, %g3
  63. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  64. /* Get DEV mondo queue base phys address into %g5. */
  65. ldx [%g3 + 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. sethi %hi(8192 - 1), %g4
  77. or %g4, %lo(8192 - 1), %g4
  78. and %g2, %g4, %g2
  79. mov INTRQ_DEVICE_MONDO_HEAD, %g4
  80. stxa %g2, [%g4] ASI_QUEUE
  81. membar #Sync
  82. /* Get &__irq_work[smp_processor_id()] into %g1. */
  83. TRAP_LOAD_IRQ_WORK(%g1, %g4)
  84. /* Get &ivector_table[IVEC] into %g4. */
  85. sethi %hi(ivector_table), %g4
  86. sllx %g3, 5, %g3
  87. or %g4, %lo(ivector_table), %g4
  88. add %g4, %g3, %g4
  89. /* Load IRQ %pil into %g5. */
  90. ldub [%g4 + 0x04], %g5
  91. /* Insert ivector_table[] entry into __irq_work[] queue. */
  92. sllx %g5, 2, %g3
  93. lduw [%g1 + %g3], %g2 /* g2 = irq_work(cpu, pil) */
  94. stw %g2, [%g4 + 0x00] /* bucket->irq_chain = g2 */
  95. stw %g4, [%g1 + %g3] /* irq_work(cpu, pil) = bucket */
  96. /* Signal the interrupt by setting (1 << pil) in %softint. */
  97. mov 1, %g2
  98. sllx %g2, %g5, %g2
  99. wr %g2, 0x0, %set_softint
  100. sun4v_dev_mondo_queue_empty:
  101. retry
  102. sun4v_res_mondo:
  103. /* Head offset in %g2, tail offset in %g4. */
  104. mov INTRQ_RESUM_MONDO_HEAD, %g2
  105. ldxa [%g2] ASI_QUEUE, %g2
  106. mov INTRQ_RESUM_MONDO_TAIL, %g4
  107. ldxa [%g4] ASI_QUEUE, %g4
  108. cmp %g2, %g4
  109. be,pn %xcc, sun4v_res_mondo_queue_empty
  110. nop
  111. /* Get &trap_block[smp_processor_id()] into %g3. */
  112. ldxa [%g0] ASI_SCRATCHPAD, %g3
  113. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  114. /* Get RES mondo queue base phys address into %g5. */
  115. ldx [%g3 + TRAP_PER_CPU_RESUM_MONDO_PA], %g5
  116. /* Get RES kernel buffer base phys address into %g7. */
  117. ldx [%g3 + TRAP_PER_CPU_RESUM_KBUF_PA], %g7
  118. /* If the first word is non-zero, queue is full. */
  119. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  120. brnz,pn %g1, sun4v_res_mondo_queue_full
  121. nop
  122. /* Remember this entry's offset in %g1. */
  123. mov %g2, %g1
  124. /* Copy 64-byte queue entry into kernel buffer. */
  125. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  126. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  127. add %g2, 0x08, %g2
  128. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  129. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  130. add %g2, 0x08, %g2
  131. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  132. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  133. add %g2, 0x08, %g2
  134. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  135. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  136. add %g2, 0x08, %g2
  137. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  138. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  139. add %g2, 0x08, %g2
  140. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  141. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  142. add %g2, 0x08, %g2
  143. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  144. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  145. add %g2, 0x08, %g2
  146. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  147. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  148. add %g2, 0x08, %g2
  149. /* Update queue head pointer. */
  150. sethi %hi(8192 - 1), %g4
  151. or %g4, %lo(8192 - 1), %g4
  152. and %g2, %g4, %g2
  153. mov INTRQ_RESUM_MONDO_HEAD, %g4
  154. stxa %g2, [%g4] ASI_QUEUE
  155. membar #Sync
  156. /* Disable interrupts and save register state so we can call
  157. * C code. The etrap handling will leave %g4 in %l4 for us
  158. * when it's done.
  159. */
  160. rdpr %pil, %g2
  161. wrpr %g0, 15, %pil
  162. mov %g1, %g4
  163. ba,pt %xcc, etrap_irq
  164. rd %pc, %g7
  165. /* Log the event. */
  166. add %sp, PTREGS_OFF, %o0
  167. call sun4v_resum_error
  168. mov %l4, %o1
  169. /* Return from trap. */
  170. ba,pt %xcc, rtrap_irq
  171. nop
  172. sun4v_res_mondo_queue_empty:
  173. retry
  174. sun4v_res_mondo_queue_full:
  175. /* The queue is full, consolidate our damage by setting
  176. * the head equal to the tail. We'll just trap again otherwise.
  177. * Call C code to log the event.
  178. */
  179. mov INTRQ_RESUM_MONDO_HEAD, %g2
  180. stxa %g4, [%g2] ASI_QUEUE
  181. membar #Sync
  182. rdpr %pil, %g2
  183. wrpr %g0, 15, %pil
  184. ba,pt %xcc, etrap_irq
  185. rd %pc, %g7
  186. call sun4v_resum_overflow
  187. add %sp, PTREGS_OFF, %o0
  188. ba,pt %xcc, rtrap_irq
  189. nop
  190. sun4v_nonres_mondo:
  191. /* Head offset in %g2, tail offset in %g4. */
  192. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  193. ldxa [%g2] ASI_QUEUE, %g2
  194. mov INTRQ_NONRESUM_MONDO_TAIL, %g4
  195. ldxa [%g4] ASI_QUEUE, %g4
  196. cmp %g2, %g4
  197. be,pn %xcc, sun4v_nonres_mondo_queue_empty
  198. nop
  199. /* Get &trap_block[smp_processor_id()] into %g3. */
  200. ldxa [%g0] ASI_SCRATCHPAD, %g3
  201. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  202. /* Get RES mondo queue base phys address into %g5. */
  203. ldx [%g3 + TRAP_PER_CPU_NONRESUM_MONDO_PA], %g5
  204. /* Get RES kernel buffer base phys address into %g7. */
  205. ldx [%g3 + TRAP_PER_CPU_NONRESUM_KBUF_PA], %g7
  206. /* If the first word is non-zero, queue is full. */
  207. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  208. brnz,pn %g1, sun4v_nonres_mondo_queue_full
  209. nop
  210. /* Remember this entry's offset in %g1. */
  211. mov %g2, %g1
  212. /* Copy 64-byte queue entry into kernel buffer. */
  213. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  214. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  215. add %g2, 0x08, %g2
  216. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  217. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  218. add %g2, 0x08, %g2
  219. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  220. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  221. add %g2, 0x08, %g2
  222. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  223. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  224. add %g2, 0x08, %g2
  225. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  226. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  227. add %g2, 0x08, %g2
  228. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  229. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  230. add %g2, 0x08, %g2
  231. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  232. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  233. add %g2, 0x08, %g2
  234. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  235. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  236. add %g2, 0x08, %g2
  237. /* Update queue head pointer. */
  238. sethi %hi(8192 - 1), %g4
  239. or %g4, %lo(8192 - 1), %g4
  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. /* Log the event. */
  254. add %sp, PTREGS_OFF, %o0
  255. call sun4v_nonresum_error
  256. mov %l4, %o1
  257. /* Return from trap. */
  258. ba,pt %xcc, rtrap_irq
  259. nop
  260. sun4v_nonres_mondo_queue_empty:
  261. retry
  262. sun4v_nonres_mondo_queue_full:
  263. /* The queue is full, consolidate our damage by setting
  264. * the head equal to the tail. We'll just trap again otherwise.
  265. * Call C code to log the event.
  266. */
  267. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  268. stxa %g4, [%g2] ASI_QUEUE
  269. membar #Sync
  270. rdpr %pil, %g2
  271. wrpr %g0, 15, %pil
  272. ba,pt %xcc, etrap_irq
  273. rd %pc, %g7
  274. call sun4v_nonresum_overflow
  275. add %sp, PTREGS_OFF, %o0
  276. ba,pt %xcc, rtrap_irq
  277. nop