sun4v_ivec.S 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. TRAP_LOAD_IRQ_WORK_PA(%g1, %g4)
  82. /* For VIRQs, cookie is encoded as ~bucket_phys_addr */
  83. brlz,pt %g3, 1f
  84. xnor %g3, %g0, %g4
  85. /* Get __pa(&ivector_table[IVEC]) into %g4. */
  86. sethi %hi(ivector_table_pa), %g4
  87. ldx [%g4 + %lo(ivector_table_pa)], %g4
  88. sllx %g3, 4, %g3
  89. add %g4, %g3, %g4
  90. 1: ldx [%g1], %g2
  91. stxa %g2, [%g4] ASI_PHYS_USE_EC
  92. stx %g4, [%g1]
  93. /* Signal the interrupt by setting (1 << pil) in %softint. */
  94. wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
  95. sun4v_dev_mondo_queue_empty:
  96. retry
  97. sun4v_res_mondo:
  98. /* Head offset in %g2, tail offset in %g4. */
  99. mov INTRQ_RESUM_MONDO_HEAD, %g2
  100. ldxa [%g2] ASI_QUEUE, %g2
  101. mov INTRQ_RESUM_MONDO_TAIL, %g4
  102. ldxa [%g4] ASI_QUEUE, %g4
  103. cmp %g2, %g4
  104. be,pn %xcc, sun4v_res_mondo_queue_empty
  105. nop
  106. /* Get &trap_block[smp_processor_id()] into %g3. */
  107. ldxa [%g0] ASI_SCRATCHPAD, %g3
  108. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  109. /* Get RES mondo queue base phys address into %g5. */
  110. ldx [%g3 + TRAP_PER_CPU_RESUM_MONDO_PA], %g5
  111. /* Get RES kernel buffer base phys address into %g7. */
  112. ldx [%g3 + TRAP_PER_CPU_RESUM_KBUF_PA], %g7
  113. /* If the first word is non-zero, queue is full. */
  114. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  115. brnz,pn %g1, sun4v_res_mondo_queue_full
  116. nop
  117. lduw [%g3 + TRAP_PER_CPU_RESUM_QMASK], %g4
  118. /* Remember this entry's offset in %g1. */
  119. mov %g2, %g1
  120. /* Copy 64-byte queue entry into kernel buffer. */
  121. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  122. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  123. add %g2, 0x08, %g2
  124. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  125. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  126. add %g2, 0x08, %g2
  127. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  128. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  129. add %g2, 0x08, %g2
  130. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  131. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  132. add %g2, 0x08, %g2
  133. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  134. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  135. add %g2, 0x08, %g2
  136. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  137. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  138. add %g2, 0x08, %g2
  139. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  140. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  141. add %g2, 0x08, %g2
  142. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  143. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  144. add %g2, 0x08, %g2
  145. /* Update queue head pointer. */
  146. and %g2, %g4, %g2
  147. mov INTRQ_RESUM_MONDO_HEAD, %g4
  148. stxa %g2, [%g4] ASI_QUEUE
  149. membar #Sync
  150. /* Disable interrupts and save register state so we can call
  151. * C code. The etrap handling will leave %g4 in %l4 for us
  152. * when it's done.
  153. */
  154. rdpr %pil, %g2
  155. wrpr %g0, PIL_NORMAL_MAX, %pil
  156. mov %g1, %g4
  157. ba,pt %xcc, etrap_irq
  158. rd %pc, %g7
  159. #ifdef CONFIG_TRACE_IRQFLAGS
  160. call trace_hardirqs_off
  161. nop
  162. #endif
  163. /* Log the event. */
  164. add %sp, PTREGS_OFF, %o0
  165. call sun4v_resum_error
  166. mov %l4, %o1
  167. /* Return from trap. */
  168. ba,pt %xcc, rtrap_irq
  169. nop
  170. sun4v_res_mondo_queue_empty:
  171. retry
  172. sun4v_res_mondo_queue_full:
  173. /* The queue is full, consolidate our damage by setting
  174. * the head equal to the tail. We'll just trap again otherwise.
  175. * Call C code to log the event.
  176. */
  177. mov INTRQ_RESUM_MONDO_HEAD, %g2
  178. stxa %g4, [%g2] ASI_QUEUE
  179. membar #Sync
  180. rdpr %pil, %g2
  181. wrpr %g0, PIL_NORMAL_MAX, %pil
  182. ba,pt %xcc, etrap_irq
  183. rd %pc, %g7
  184. #ifdef CONFIG_TRACE_IRQFLAGS
  185. call trace_hardirqs_off
  186. nop
  187. #endif
  188. call sun4v_resum_overflow
  189. add %sp, PTREGS_OFF, %o0
  190. ba,pt %xcc, rtrap_irq
  191. nop
  192. sun4v_nonres_mondo:
  193. /* Head offset in %g2, tail offset in %g4. */
  194. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  195. ldxa [%g2] ASI_QUEUE, %g2
  196. mov INTRQ_NONRESUM_MONDO_TAIL, %g4
  197. ldxa [%g4] ASI_QUEUE, %g4
  198. cmp %g2, %g4
  199. be,pn %xcc, sun4v_nonres_mondo_queue_empty
  200. nop
  201. /* Get &trap_block[smp_processor_id()] into %g3. */
  202. ldxa [%g0] ASI_SCRATCHPAD, %g3
  203. sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3
  204. /* Get RES mondo queue base phys address into %g5. */
  205. ldx [%g3 + TRAP_PER_CPU_NONRESUM_MONDO_PA], %g5
  206. /* Get RES kernel buffer base phys address into %g7. */
  207. ldx [%g3 + TRAP_PER_CPU_NONRESUM_KBUF_PA], %g7
  208. /* If the first word is non-zero, queue is full. */
  209. ldxa [%g7 + %g2] ASI_PHYS_USE_EC, %g1
  210. brnz,pn %g1, sun4v_nonres_mondo_queue_full
  211. nop
  212. lduw [%g3 + TRAP_PER_CPU_NONRESUM_QMASK], %g4
  213. /* Remember this entry's offset in %g1. */
  214. mov %g2, %g1
  215. /* Copy 64-byte queue entry into kernel buffer. */
  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. ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
  238. stxa %g3, [%g7 + %g2] ASI_PHYS_USE_EC
  239. add %g2, 0x08, %g2
  240. /* Update queue head pointer. */
  241. and %g2, %g4, %g2
  242. mov INTRQ_NONRESUM_MONDO_HEAD, %g4
  243. stxa %g2, [%g4] ASI_QUEUE
  244. membar #Sync
  245. /* Disable interrupts and save register state so we can call
  246. * C code. The etrap handling will leave %g4 in %l4 for us
  247. * when it's done.
  248. */
  249. rdpr %pil, %g2
  250. wrpr %g0, PIL_NORMAL_MAX, %pil
  251. mov %g1, %g4
  252. ba,pt %xcc, etrap_irq
  253. rd %pc, %g7
  254. #ifdef CONFIG_TRACE_IRQFLAGS
  255. call trace_hardirqs_off
  256. nop
  257. #endif
  258. /* Log the event. */
  259. add %sp, PTREGS_OFF, %o0
  260. call sun4v_nonresum_error
  261. mov %l4, %o1
  262. /* Return from trap. */
  263. ba,pt %xcc, rtrap_irq
  264. nop
  265. sun4v_nonres_mondo_queue_empty:
  266. retry
  267. sun4v_nonres_mondo_queue_full:
  268. /* The queue is full, consolidate our damage by setting
  269. * the head equal to the tail. We'll just trap again otherwise.
  270. * Call C code to log the event.
  271. */
  272. mov INTRQ_NONRESUM_MONDO_HEAD, %g2
  273. stxa %g4, [%g2] ASI_QUEUE
  274. membar #Sync
  275. rdpr %pil, %g2
  276. wrpr %g0, PIL_NORMAL_MAX, %pil
  277. ba,pt %xcc, etrap_irq
  278. rd %pc, %g7
  279. #ifdef CONFIG_TRACE_IRQFLAGS
  280. call trace_hardirqs_off
  281. nop
  282. #endif
  283. call sun4v_nonresum_overflow
  284. add %sp, PTREGS_OFF, %o0
  285. ba,pt %xcc, rtrap_irq
  286. nop