spu_csa.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * spu_csa.h: Definitions for SPU context save area (CSA).
  4. *
  5. * (C) Copyright IBM 2005
  6. *
  7. * Author: Mark Nutter <[email protected]>
  8. */
  9. #ifndef _SPU_CSA_H_
  10. #define _SPU_CSA_H_
  11. #ifdef __KERNEL__
  12. /*
  13. * Total number of 128-bit registers.
  14. */
  15. #define NR_SPU_GPRS 128
  16. #define NR_SPU_SPRS 9
  17. #define NR_SPU_REGS_PAD 7
  18. #define NR_SPU_SPILL_REGS 144 /* GPRS + SPRS + PAD */
  19. #define SIZEOF_SPU_SPILL_REGS NR_SPU_SPILL_REGS * 16
  20. #define SPU_SAVE_COMPLETE 0x3FFB
  21. #define SPU_RESTORE_COMPLETE 0x3FFC
  22. /*
  23. * Definitions for various 'stopped' status conditions,
  24. * to be recreated during context restore.
  25. */
  26. #define SPU_STOPPED_STATUS_P 1
  27. #define SPU_STOPPED_STATUS_I 2
  28. #define SPU_STOPPED_STATUS_H 3
  29. #define SPU_STOPPED_STATUS_S 4
  30. #define SPU_STOPPED_STATUS_S_I 5
  31. #define SPU_STOPPED_STATUS_S_P 6
  32. #define SPU_STOPPED_STATUS_P_H 7
  33. #define SPU_STOPPED_STATUS_P_I 8
  34. #define SPU_STOPPED_STATUS_R 9
  35. /*
  36. * Definitions for software decrementer status flag.
  37. */
  38. #define SPU_DECR_STATUS_RUNNING 0x1
  39. #define SPU_DECR_STATUS_WRAPPED 0x2
  40. #ifndef __ASSEMBLY__
  41. /**
  42. * spu_reg128 - generic 128-bit register definition.
  43. */
  44. struct spu_reg128 {
  45. u32 slot[4];
  46. };
  47. /**
  48. * struct spu_lscsa - Local Store Context Save Area.
  49. * @gprs: Array of saved registers.
  50. * @fpcr: Saved floating point status control register.
  51. * @decr: Saved decrementer value.
  52. * @decr_status: Indicates software decrementer status flags.
  53. * @ppu_mb: Saved PPU mailbox data.
  54. * @ppuint_mb: Saved PPU interrupting mailbox data.
  55. * @tag_mask: Saved tag group mask.
  56. * @event_mask: Saved event mask.
  57. * @srr0: Saved SRR0.
  58. * @stopped_status: Conditions to be recreated by restore.
  59. * @ls: Saved contents of Local Storage Area.
  60. *
  61. * The LSCSA represents state that is primarily saved and
  62. * restored by SPU-side code.
  63. */
  64. struct spu_lscsa {
  65. struct spu_reg128 gprs[128];
  66. struct spu_reg128 fpcr;
  67. struct spu_reg128 decr;
  68. struct spu_reg128 decr_status;
  69. struct spu_reg128 ppu_mb;
  70. struct spu_reg128 ppuint_mb;
  71. struct spu_reg128 tag_mask;
  72. struct spu_reg128 event_mask;
  73. struct spu_reg128 srr0;
  74. struct spu_reg128 stopped_status;
  75. /*
  76. * 'ls' must be page-aligned on all configurations.
  77. * Since we don't want to rely on having the spu-gcc
  78. * installed to build the kernel and this structure
  79. * is used in the SPU-side code, make it 64k-page
  80. * aligned for now.
  81. */
  82. unsigned char ls[LS_SIZE] __attribute__((aligned(65536)));
  83. };
  84. #ifndef __SPU__
  85. /*
  86. * struct spu_problem_collapsed - condensed problem state area, w/o pads.
  87. */
  88. struct spu_problem_collapsed {
  89. u64 spc_mssync_RW;
  90. u32 mfc_lsa_W;
  91. u32 unused_pad0;
  92. u64 mfc_ea_W;
  93. union mfc_tag_size_class_cmd mfc_union_W;
  94. u32 dma_qstatus_R;
  95. u32 dma_querytype_RW;
  96. u32 dma_querymask_RW;
  97. u32 dma_tagstatus_R;
  98. u32 pu_mb_R;
  99. u32 spu_mb_W;
  100. u32 mb_stat_R;
  101. u32 spu_runcntl_RW;
  102. u32 spu_status_R;
  103. u32 spu_spc_R;
  104. u32 spu_npc_RW;
  105. u32 signal_notify1;
  106. u32 signal_notify2;
  107. u32 unused_pad1;
  108. };
  109. /*
  110. * struct spu_priv1_collapsed - condensed privileged 1 area, w/o pads.
  111. */
  112. struct spu_priv1_collapsed {
  113. u64 mfc_sr1_RW;
  114. u64 mfc_lpid_RW;
  115. u64 spu_idr_RW;
  116. u64 mfc_vr_RO;
  117. u64 spu_vr_RO;
  118. u64 int_mask_class0_RW;
  119. u64 int_mask_class1_RW;
  120. u64 int_mask_class2_RW;
  121. u64 int_stat_class0_RW;
  122. u64 int_stat_class1_RW;
  123. u64 int_stat_class2_RW;
  124. u64 int_route_RW;
  125. u64 mfc_atomic_flush_RW;
  126. u64 resource_allocation_groupID_RW;
  127. u64 resource_allocation_enable_RW;
  128. u64 mfc_fir_R;
  129. u64 mfc_fir_status_or_W;
  130. u64 mfc_fir_status_and_W;
  131. u64 mfc_fir_mask_R;
  132. u64 mfc_fir_mask_or_W;
  133. u64 mfc_fir_mask_and_W;
  134. u64 mfc_fir_chkstp_enable_RW;
  135. u64 smf_sbi_signal_sel;
  136. u64 smf_ato_signal_sel;
  137. u64 tlb_index_hint_RO;
  138. u64 tlb_index_W;
  139. u64 tlb_vpn_RW;
  140. u64 tlb_rpn_RW;
  141. u64 tlb_invalidate_entry_W;
  142. u64 tlb_invalidate_all_W;
  143. u64 smm_hid;
  144. u64 mfc_accr_RW;
  145. u64 mfc_dsisr_RW;
  146. u64 mfc_dar_RW;
  147. u64 rmt_index_RW;
  148. u64 rmt_data1_RW;
  149. u64 mfc_dsir_R;
  150. u64 mfc_lsacr_RW;
  151. u64 mfc_lscrr_R;
  152. u64 mfc_tclass_id_RW;
  153. u64 mfc_rm_boundary;
  154. u64 smf_dma_signal_sel;
  155. u64 smm_signal_sel;
  156. u64 mfc_cer_R;
  157. u64 pu_ecc_cntl_RW;
  158. u64 pu_ecc_stat_RW;
  159. u64 spu_ecc_addr_RW;
  160. u64 spu_err_mask_RW;
  161. u64 spu_trig0_sel;
  162. u64 spu_trig1_sel;
  163. u64 spu_trig2_sel;
  164. u64 spu_trig3_sel;
  165. u64 spu_trace_sel;
  166. u64 spu_event0_sel;
  167. u64 spu_event1_sel;
  168. u64 spu_event2_sel;
  169. u64 spu_event3_sel;
  170. u64 spu_trace_cntl;
  171. };
  172. /*
  173. * struct spu_priv2_collapsed - condensed privileged 2 area, w/o pads.
  174. */
  175. struct spu_priv2_collapsed {
  176. u64 slb_index_W;
  177. u64 slb_esid_RW;
  178. u64 slb_vsid_RW;
  179. u64 slb_invalidate_entry_W;
  180. u64 slb_invalidate_all_W;
  181. struct mfc_cq_sr spuq[16];
  182. struct mfc_cq_sr puq[8];
  183. u64 mfc_control_RW;
  184. u64 puint_mb_R;
  185. u64 spu_privcntl_RW;
  186. u64 spu_lslr_RW;
  187. u64 spu_chnlcntptr_RW;
  188. u64 spu_chnlcnt_RW;
  189. u64 spu_chnldata_RW;
  190. u64 spu_cfg_RW;
  191. u64 spu_tag_status_query_RW;
  192. u64 spu_cmd_buf1_RW;
  193. u64 spu_cmd_buf2_RW;
  194. u64 spu_atomic_status_RW;
  195. };
  196. /**
  197. * struct spu_state
  198. * @lscsa: Local Store Context Save Area.
  199. * @prob: Collapsed Problem State Area, w/o pads.
  200. * @priv1: Collapsed Privileged 1 Area, w/o pads.
  201. * @priv2: Collapsed Privileged 2 Area, w/o pads.
  202. * @spu_chnlcnt_RW: Array of saved channel counts.
  203. * @spu_chnldata_RW: Array of saved channel data.
  204. * @suspend_time: Time stamp when decrementer disabled.
  205. *
  206. * Structure representing the whole of the SPU
  207. * context save area (CSA). This struct contains
  208. * all of the state necessary to suspend and then
  209. * later optionally resume execution of an SPU
  210. * context.
  211. *
  212. * The @lscsa region is by far the largest, and is
  213. * allocated separately so that it may either be
  214. * pinned or mapped to/from application memory, as
  215. * appropriate for the OS environment.
  216. */
  217. struct spu_state {
  218. struct spu_lscsa *lscsa;
  219. struct spu_problem_collapsed prob;
  220. struct spu_priv1_collapsed priv1;
  221. struct spu_priv2_collapsed priv2;
  222. u64 spu_chnlcnt_RW[32];
  223. u64 spu_chnldata_RW[32];
  224. u32 spu_mailbox_data[4];
  225. u32 pu_mailbox_data[1];
  226. u64 class_0_dar, class_0_pending;
  227. u64 class_1_dar, class_1_dsisr;
  228. unsigned long suspend_time;
  229. spinlock_t register_lock;
  230. };
  231. #endif /* !__SPU__ */
  232. #endif /* __KERNEL__ */
  233. #endif /* !__ASSEMBLY__ */
  234. #endif /* _SPU_CSA_H_ */