gruhandles.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * SN Platform GRU Driver
  3. *
  4. * GRU HANDLE DEFINITION
  5. *
  6. * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef __GRUHANDLES_H__
  23. #define __GRUHANDLES_H__
  24. #include "gru_instructions.h"
  25. /*
  26. * Manifest constants for GRU Memory Map
  27. */
  28. #define GRU_GSEG0_BASE 0
  29. #define GRU_MCS_BASE (64 * 1024 * 1024)
  30. #define GRU_SIZE (128UL * 1024 * 1024)
  31. /* Handle & resource counts */
  32. #define GRU_NUM_CB 128
  33. #define GRU_NUM_DSR_BYTES (32 * 1024)
  34. #define GRU_NUM_TFM 16
  35. #define GRU_NUM_TGH 24
  36. #define GRU_NUM_CBE 128
  37. #define GRU_NUM_TFH 128
  38. #define GRU_NUM_CCH 16
  39. #define GRU_NUM_GSH 1
  40. /* Maximum resource counts that can be reserved by user programs */
  41. #define GRU_NUM_USER_CBR GRU_NUM_CBE
  42. #define GRU_NUM_USER_DSR_BYTES GRU_NUM_DSR_BYTES
  43. /* Bytes per handle & handle stride. Code assumes all cb, tfh, cbe handles
  44. * are the same */
  45. #define GRU_HANDLE_BYTES 64
  46. #define GRU_HANDLE_STRIDE 256
  47. /* Base addresses of handles */
  48. #define GRU_TFM_BASE (GRU_MCS_BASE + 0x00000)
  49. #define GRU_TGH_BASE (GRU_MCS_BASE + 0x08000)
  50. #define GRU_CBE_BASE (GRU_MCS_BASE + 0x10000)
  51. #define GRU_TFH_BASE (GRU_MCS_BASE + 0x18000)
  52. #define GRU_CCH_BASE (GRU_MCS_BASE + 0x20000)
  53. #define GRU_GSH_BASE (GRU_MCS_BASE + 0x30000)
  54. /* User gseg constants */
  55. #define GRU_GSEG_STRIDE (4 * 1024 * 1024)
  56. #define GSEG_BASE(a) ((a) & ~(GRU_GSEG_PAGESIZE - 1))
  57. /* Data segment constants */
  58. #define GRU_DSR_AU_BYTES 1024
  59. #define GRU_DSR_CL (GRU_NUM_DSR_BYTES / GRU_CACHE_LINE_BYTES)
  60. #define GRU_DSR_AU_CL (GRU_DSR_AU_BYTES / GRU_CACHE_LINE_BYTES)
  61. #define GRU_DSR_AU (GRU_NUM_DSR_BYTES / GRU_DSR_AU_BYTES)
  62. /* Control block constants */
  63. #define GRU_CBR_AU_SIZE 2
  64. #define GRU_CBR_AU (GRU_NUM_CBE / GRU_CBR_AU_SIZE)
  65. /* Convert resource counts to the number of AU */
  66. #define GRU_DS_BYTES_TO_AU(n) DIV_ROUND_UP(n, GRU_DSR_AU_BYTES)
  67. #define GRU_CB_COUNT_TO_AU(n) DIV_ROUND_UP(n, GRU_CBR_AU_SIZE)
  68. /* UV limits */
  69. #define GRU_CHIPLETS_PER_HUB 2
  70. #define GRU_HUBS_PER_BLADE 1
  71. #define GRU_CHIPLETS_PER_BLADE (GRU_HUBS_PER_BLADE * GRU_CHIPLETS_PER_HUB)
  72. /* User GRU Gseg offsets */
  73. #define GRU_CB_BASE 0
  74. #define GRU_CB_LIMIT (GRU_CB_BASE + GRU_HANDLE_STRIDE * GRU_NUM_CBE)
  75. #define GRU_DS_BASE 0x20000
  76. #define GRU_DS_LIMIT (GRU_DS_BASE + GRU_NUM_DSR_BYTES)
  77. /* Convert a GRU physical address to the chiplet offset */
  78. #define GSEGPOFF(h) ((h) & (GRU_SIZE - 1))
  79. /* Convert an arbitrary handle address to the beginning of the GRU segment */
  80. #ifndef __PLUGIN__
  81. #define GRUBASE(h) ((void *)((unsigned long)(h) & ~(GRU_SIZE - 1)))
  82. #else
  83. extern void *gmu_grubase(void *h);
  84. #define GRUBASE(h) gmu_grubase(h)
  85. #endif
  86. /* General addressing macros. */
  87. static inline void *get_gseg_base_address(void *base, int ctxnum)
  88. {
  89. return (void *)(base + GRU_GSEG0_BASE + GRU_GSEG_STRIDE * ctxnum);
  90. }
  91. static inline void *get_gseg_base_address_cb(void *base, int ctxnum, int line)
  92. {
  93. return (void *)(get_gseg_base_address(base, ctxnum) +
  94. GRU_CB_BASE + GRU_HANDLE_STRIDE * line);
  95. }
  96. static inline void *get_gseg_base_address_ds(void *base, int ctxnum, int line)
  97. {
  98. return (void *)(get_gseg_base_address(base, ctxnum) + GRU_DS_BASE +
  99. GRU_CACHE_LINE_BYTES * line);
  100. }
  101. static inline struct gru_tlb_fault_map *get_tfm(void *base, int ctxnum)
  102. {
  103. return (struct gru_tlb_fault_map *)(base + GRU_TFM_BASE +
  104. ctxnum * GRU_HANDLE_STRIDE);
  105. }
  106. static inline struct gru_tlb_global_handle *get_tgh(void *base, int ctxnum)
  107. {
  108. return (struct gru_tlb_global_handle *)(base + GRU_TGH_BASE +
  109. ctxnum * GRU_HANDLE_STRIDE);
  110. }
  111. static inline struct gru_control_block_extended *get_cbe(void *base, int ctxnum)
  112. {
  113. return (struct gru_control_block_extended *)(base + GRU_CBE_BASE +
  114. ctxnum * GRU_HANDLE_STRIDE);
  115. }
  116. static inline struct gru_tlb_fault_handle *get_tfh(void *base, int ctxnum)
  117. {
  118. return (struct gru_tlb_fault_handle *)(base + GRU_TFH_BASE +
  119. ctxnum * GRU_HANDLE_STRIDE);
  120. }
  121. static inline struct gru_context_configuration_handle *get_cch(void *base,
  122. int ctxnum)
  123. {
  124. return (struct gru_context_configuration_handle *)(base +
  125. GRU_CCH_BASE + ctxnum * GRU_HANDLE_STRIDE);
  126. }
  127. static inline unsigned long get_cb_number(void *cb)
  128. {
  129. return (((unsigned long)cb - GRU_CB_BASE) % GRU_GSEG_PAGESIZE) /
  130. GRU_HANDLE_STRIDE;
  131. }
  132. /* byte offset to a specific GRU chiplet. (p=pnode, c=chiplet (0 or 1)*/
  133. static inline unsigned long gru_chiplet_paddr(unsigned long paddr, int pnode,
  134. int chiplet)
  135. {
  136. return paddr + GRU_SIZE * (2 * pnode + chiplet);
  137. }
  138. static inline void *gru_chiplet_vaddr(void *vaddr, int pnode, int chiplet)
  139. {
  140. return vaddr + GRU_SIZE * (2 * pnode + chiplet);
  141. }
  142. /*
  143. * Global TLB Fault Map
  144. * Bitmap of outstanding TLB misses needing interrupt/polling service.
  145. *
  146. */
  147. struct gru_tlb_fault_map {
  148. unsigned long fault_bits[BITS_TO_LONGS(GRU_NUM_CBE)];
  149. unsigned long fill0[2];
  150. unsigned long done_bits[BITS_TO_LONGS(GRU_NUM_CBE)];
  151. unsigned long fill1[2];
  152. };
  153. /*
  154. * TGH - TLB Global Handle
  155. * Used for TLB flushing.
  156. *
  157. */
  158. struct gru_tlb_global_handle {
  159. unsigned int cmd:1; /* DW 0 */
  160. unsigned int delresp:1;
  161. unsigned int opc:1;
  162. unsigned int fill1:5;
  163. unsigned int fill2:8;
  164. unsigned int status:2;
  165. unsigned long fill3:2;
  166. unsigned int state:3;
  167. unsigned long fill4:1;
  168. unsigned int cause:3;
  169. unsigned long fill5:37;
  170. unsigned long vaddr:64; /* DW 1 */
  171. unsigned int asid:24; /* DW 2 */
  172. unsigned int fill6:8;
  173. unsigned int pagesize:5;
  174. unsigned int fill7:11;
  175. unsigned int global:1;
  176. unsigned int fill8:15;
  177. unsigned long vaddrmask:39; /* DW 3 */
  178. unsigned int fill9:9;
  179. unsigned int n:10;
  180. unsigned int fill10:6;
  181. unsigned int ctxbitmap:16; /* DW4 */
  182. unsigned long fill11[3];
  183. };
  184. enum gru_tgh_cmd {
  185. TGHCMD_START
  186. };
  187. enum gru_tgh_opc {
  188. TGHOP_TLBNOP,
  189. TGHOP_TLBINV
  190. };
  191. enum gru_tgh_status {
  192. TGHSTATUS_IDLE,
  193. TGHSTATUS_EXCEPTION,
  194. TGHSTATUS_ACTIVE
  195. };
  196. enum gru_tgh_state {
  197. TGHSTATE_IDLE,
  198. TGHSTATE_PE_INVAL,
  199. TGHSTATE_INTERRUPT_INVAL,
  200. TGHSTATE_WAITDONE,
  201. TGHSTATE_RESTART_CTX,
  202. };
  203. /*
  204. * TFH - TLB Global Handle
  205. * Used for TLB dropins into the GRU TLB.
  206. *
  207. */
  208. struct gru_tlb_fault_handle {
  209. unsigned int cmd:1; /* DW 0 - low 32*/
  210. unsigned int delresp:1;
  211. unsigned int fill0:2;
  212. unsigned int opc:3;
  213. unsigned int fill1:9;
  214. unsigned int status:2;
  215. unsigned int fill2:1;
  216. unsigned int color:1;
  217. unsigned int state:3;
  218. unsigned int fill3:1;
  219. unsigned int cause:7; /* DW 0 - high 32 */
  220. unsigned int fill4:1;
  221. unsigned int indexway:12;
  222. unsigned int fill5:4;
  223. unsigned int ctxnum:4;
  224. unsigned int fill6:12;
  225. unsigned long missvaddr:64; /* DW 1 */
  226. unsigned int missasid:24; /* DW 2 */
  227. unsigned int fill7:8;
  228. unsigned int fillasid:24;
  229. unsigned int dirty:1;
  230. unsigned int gaa:2;
  231. unsigned long fill8:5;
  232. unsigned long pfn:41; /* DW 3 */
  233. unsigned int fill9:7;
  234. unsigned int pagesize:5;
  235. unsigned int fill10:11;
  236. unsigned long fillvaddr:64; /* DW 4 */
  237. unsigned long fill11[3];
  238. };
  239. enum gru_tfh_opc {
  240. TFHOP_NOOP,
  241. TFHOP_RESTART,
  242. TFHOP_WRITE_ONLY,
  243. TFHOP_WRITE_RESTART,
  244. TFHOP_EXCEPTION,
  245. TFHOP_USER_POLLING_MODE = 7,
  246. };
  247. enum tfh_status {
  248. TFHSTATUS_IDLE,
  249. TFHSTATUS_EXCEPTION,
  250. TFHSTATUS_ACTIVE,
  251. };
  252. enum tfh_state {
  253. TFHSTATE_INACTIVE,
  254. TFHSTATE_IDLE,
  255. TFHSTATE_MISS_UPM,
  256. TFHSTATE_MISS_FMM,
  257. TFHSTATE_HW_ERR,
  258. TFHSTATE_WRITE_TLB,
  259. TFHSTATE_RESTART_CBR,
  260. };
  261. /* TFH cause bits */
  262. enum tfh_cause {
  263. TFHCAUSE_NONE,
  264. TFHCAUSE_TLB_MISS,
  265. TFHCAUSE_TLB_MOD,
  266. TFHCAUSE_HW_ERROR_RR,
  267. TFHCAUSE_HW_ERROR_MAIN_ARRAY,
  268. TFHCAUSE_HW_ERROR_VALID,
  269. TFHCAUSE_HW_ERROR_PAGESIZE,
  270. TFHCAUSE_INSTRUCTION_EXCEPTION,
  271. TFHCAUSE_UNCORRECTIBLE_ERROR,
  272. };
  273. /* GAA values */
  274. #define GAA_RAM 0x0
  275. #define GAA_NCRAM 0x2
  276. #define GAA_MMIO 0x1
  277. #define GAA_REGISTER 0x3
  278. /* GRU paddr shift for pfn. (NOTE: shift is NOT by actual pagesize) */
  279. #define GRU_PADDR_SHIFT 12
  280. /*
  281. * Context Configuration handle
  282. * Used to allocate resources to a GSEG context.
  283. *
  284. */
  285. struct gru_context_configuration_handle {
  286. unsigned int cmd:1; /* DW0 */
  287. unsigned int delresp:1;
  288. unsigned int opc:3;
  289. unsigned int unmap_enable:1;
  290. unsigned int req_slice_set_enable:1;
  291. unsigned int req_slice:2;
  292. unsigned int cb_int_enable:1;
  293. unsigned int tlb_int_enable:1;
  294. unsigned int tfm_fault_bit_enable:1;
  295. unsigned int tlb_int_select:4;
  296. unsigned int status:2;
  297. unsigned int state:2;
  298. unsigned int reserved2:4;
  299. unsigned int cause:4;
  300. unsigned int tfm_done_bit_enable:1;
  301. unsigned int unused:3;
  302. unsigned int dsr_allocation_map;
  303. unsigned long cbr_allocation_map; /* DW1 */
  304. unsigned int asid[8]; /* DW 2 - 5 */
  305. unsigned short sizeavail[8]; /* DW 6 - 7 */
  306. } __attribute__ ((packed));
  307. enum gru_cch_opc {
  308. CCHOP_START = 1,
  309. CCHOP_ALLOCATE,
  310. CCHOP_INTERRUPT,
  311. CCHOP_DEALLOCATE,
  312. CCHOP_INTERRUPT_SYNC,
  313. };
  314. enum gru_cch_status {
  315. CCHSTATUS_IDLE,
  316. CCHSTATUS_EXCEPTION,
  317. CCHSTATUS_ACTIVE,
  318. };
  319. enum gru_cch_state {
  320. CCHSTATE_INACTIVE,
  321. CCHSTATE_MAPPED,
  322. CCHSTATE_ACTIVE,
  323. CCHSTATE_INTERRUPTED,
  324. };
  325. /* CCH Exception cause */
  326. enum gru_cch_cause {
  327. CCHCAUSE_REGION_REGISTER_WRITE_ERROR = 1,
  328. CCHCAUSE_ILLEGAL_OPCODE = 2,
  329. CCHCAUSE_INVALID_START_REQUEST = 3,
  330. CCHCAUSE_INVALID_ALLOCATION_REQUEST = 4,
  331. CCHCAUSE_INVALID_DEALLOCATION_REQUEST = 5,
  332. CCHCAUSE_INVALID_INTERRUPT_REQUEST = 6,
  333. CCHCAUSE_CCH_BUSY = 7,
  334. CCHCAUSE_NO_CBRS_TO_ALLOCATE = 8,
  335. CCHCAUSE_BAD_TFM_CONFIG = 9,
  336. CCHCAUSE_CBR_RESOURCES_OVERSUBSCRIPED = 10,
  337. CCHCAUSE_DSR_RESOURCES_OVERSUBSCRIPED = 11,
  338. CCHCAUSE_CBR_DEALLOCATION_ERROR = 12,
  339. };
  340. /*
  341. * CBE - Control Block Extended
  342. * Maintains internal GRU state for active CBs.
  343. *
  344. */
  345. struct gru_control_block_extended {
  346. unsigned int reserved0:1; /* DW 0 - low */
  347. unsigned int imacpy:3;
  348. unsigned int reserved1:4;
  349. unsigned int xtypecpy:3;
  350. unsigned int iaa0cpy:2;
  351. unsigned int iaa1cpy:2;
  352. unsigned int reserved2:1;
  353. unsigned int opccpy:8;
  354. unsigned int exopccpy:8;
  355. unsigned int idef2cpy:22; /* DW 0 - high */
  356. unsigned int reserved3:10;
  357. unsigned int idef4cpy:22; /* DW 1 */
  358. unsigned int reserved4:10;
  359. unsigned int idef4upd:22;
  360. unsigned int reserved5:10;
  361. unsigned long idef1upd:64; /* DW 2 */
  362. unsigned long idef5cpy:64; /* DW 3 */
  363. unsigned long idef6cpy:64; /* DW 4 */
  364. unsigned long idef3upd:64; /* DW 5 */
  365. unsigned long idef5upd:64; /* DW 6 */
  366. unsigned int idef2upd:22; /* DW 7 */
  367. unsigned int reserved6:10;
  368. unsigned int ecause:20;
  369. unsigned int cbrstate:4;
  370. unsigned int cbrexecstatus:8;
  371. };
  372. enum gru_cbr_state {
  373. CBRSTATE_INACTIVE,
  374. CBRSTATE_IDLE,
  375. CBRSTATE_PE_CHECK,
  376. CBRSTATE_QUEUED,
  377. CBRSTATE_WAIT_RESPONSE,
  378. CBRSTATE_INTERRUPTED,
  379. CBRSTATE_INTERRUPTED_MISS_FMM,
  380. CBRSTATE_BUSY_INTERRUPT_MISS_FMM,
  381. CBRSTATE_INTERRUPTED_MISS_UPM,
  382. CBRSTATE_BUSY_INTERRUPTED_MISS_UPM,
  383. CBRSTATE_REQUEST_ISSUE,
  384. CBRSTATE_BUSY_INTERRUPT,
  385. };
  386. /* CBE cbrexecstatus bits */
  387. #define CBR_EXS_ABORT_OCC_BIT 0
  388. #define CBR_EXS_INT_OCC_BIT 1
  389. #define CBR_EXS_PENDING_BIT 2
  390. #define CBR_EXS_QUEUED_BIT 3
  391. #define CBR_EXS_TLBHW_BIT 4
  392. #define CBR_EXS_EXCEPTION_BIT 5
  393. #define CBR_EXS_ABORT_OCC (1 << CBR_EXS_ABORT_OCC_BIT)
  394. #define CBR_EXS_INT_OCC (1 << CBR_EXS_INT_OCC_BIT)
  395. #define CBR_EXS_PENDING (1 << CBR_EXS_PENDING_BIT)
  396. #define CBR_EXS_QUEUED (1 << CBR_EXS_QUEUED_BIT)
  397. #define CBR_EXS_TLBHW (1 << CBR_EXS_TLBHW_BIT)
  398. #define CBR_EXS_EXCEPTION (1 << CBR_EXS_EXCEPTION_BIT)
  399. /* CBE ecause bits - defined in gru_instructions.h */
  400. /*
  401. * Convert a processor pagesize into the strange encoded pagesize used by the
  402. * GRU. Processor pagesize is encoded as log of bytes per page. (or PAGE_SHIFT)
  403. * pagesize log pagesize grupagesize
  404. * 4k 12 0
  405. * 16k 14 1
  406. * 64k 16 2
  407. * 256k 18 3
  408. * 1m 20 4
  409. * 2m 21 5
  410. * 4m 22 6
  411. * 16m 24 7
  412. * 64m 26 8
  413. * ...
  414. */
  415. #define GRU_PAGESIZE(sh) ((((sh) > 20 ? (sh) + 2: (sh)) >> 1) - 6)
  416. #define GRU_SIZEAVAIL(sh) (1UL << GRU_PAGESIZE(sh))
  417. /* minimum TLB purge count to ensure a full purge */
  418. #define GRUMAXINVAL 1024UL
  419. /* Extract the status field from a kernel handle */
  420. #define GET_MSEG_HANDLE_STATUS(h) (((*(unsigned long *)(h)) >> 16) & 3)
  421. static inline void start_instruction(void *h)
  422. {
  423. unsigned long *w0 = h;
  424. wmb(); /* setting CMD bit must be last */
  425. *w0 = *w0 | 1;
  426. gru_flush_cache(h);
  427. }
  428. static inline int wait_instruction_complete(void *h)
  429. {
  430. int status;
  431. do {
  432. cpu_relax();
  433. barrier();
  434. status = GET_MSEG_HANDLE_STATUS(h);
  435. } while (status == CCHSTATUS_ACTIVE);
  436. return status;
  437. }
  438. #if defined CONFIG_IA64
  439. static inline void cch_allocate_set_asids(
  440. struct gru_context_configuration_handle *cch, int asidval)
  441. {
  442. int i;
  443. for (i = 0; i <= RGN_HPAGE; i++) { /* assume HPAGE is last region */
  444. cch->asid[i] = (asidval++);
  445. #if 0
  446. /* ZZZ hugepages not supported yet */
  447. if (i == RGN_HPAGE)
  448. cch->sizeavail[i] = GRU_SIZEAVAIL(hpage_shift);
  449. else
  450. #endif
  451. cch->sizeavail[i] = GRU_SIZEAVAIL(PAGE_SHIFT);
  452. }
  453. }
  454. #elif defined CONFIG_X86_64
  455. static inline void cch_allocate_set_asids(
  456. struct gru_context_configuration_handle *cch, int asidval)
  457. {
  458. int i;
  459. for (i = 0; i < 8; i++) {
  460. cch->asid[i] = asidval++;
  461. cch->sizeavail[i] = GRU_SIZEAVAIL(PAGE_SHIFT) |
  462. GRU_SIZEAVAIL(21);
  463. }
  464. }
  465. #endif
  466. static inline int cch_allocate(struct gru_context_configuration_handle *cch,
  467. int asidval, unsigned long cbrmap,
  468. unsigned long dsrmap)
  469. {
  470. cch_allocate_set_asids(cch, asidval);
  471. cch->dsr_allocation_map = dsrmap;
  472. cch->cbr_allocation_map = cbrmap;
  473. cch->opc = CCHOP_ALLOCATE;
  474. start_instruction(cch);
  475. return wait_instruction_complete(cch);
  476. }
  477. static inline int cch_start(struct gru_context_configuration_handle *cch)
  478. {
  479. cch->opc = CCHOP_START;
  480. start_instruction(cch);
  481. return wait_instruction_complete(cch);
  482. }
  483. static inline int cch_interrupt(struct gru_context_configuration_handle *cch)
  484. {
  485. cch->opc = CCHOP_INTERRUPT;
  486. start_instruction(cch);
  487. return wait_instruction_complete(cch);
  488. }
  489. static inline int cch_deallocate(struct gru_context_configuration_handle *cch)
  490. {
  491. cch->opc = CCHOP_DEALLOCATE;
  492. start_instruction(cch);
  493. return wait_instruction_complete(cch);
  494. }
  495. static inline int cch_interrupt_sync(struct gru_context_configuration_handle
  496. *cch)
  497. {
  498. cch->opc = CCHOP_INTERRUPT_SYNC;
  499. start_instruction(cch);
  500. return wait_instruction_complete(cch);
  501. }
  502. static inline int tgh_invalidate(struct gru_tlb_global_handle *tgh,
  503. unsigned long vaddr, unsigned long vaddrmask,
  504. int asid, int pagesize, int global, int n,
  505. unsigned short ctxbitmap)
  506. {
  507. tgh->vaddr = vaddr;
  508. tgh->asid = asid;
  509. tgh->pagesize = pagesize;
  510. tgh->n = n;
  511. tgh->global = global;
  512. tgh->vaddrmask = vaddrmask;
  513. tgh->ctxbitmap = ctxbitmap;
  514. tgh->opc = TGHOP_TLBINV;
  515. start_instruction(tgh);
  516. return wait_instruction_complete(tgh);
  517. }
  518. static inline void tfh_write_only(struct gru_tlb_fault_handle *tfh,
  519. unsigned long pfn, unsigned long vaddr,
  520. int asid, int dirty, int pagesize)
  521. {
  522. tfh->fillasid = asid;
  523. tfh->fillvaddr = vaddr;
  524. tfh->pfn = pfn;
  525. tfh->dirty = dirty;
  526. tfh->pagesize = pagesize;
  527. tfh->opc = TFHOP_WRITE_ONLY;
  528. start_instruction(tfh);
  529. }
  530. static inline void tfh_write_restart(struct gru_tlb_fault_handle *tfh,
  531. unsigned long paddr, int gaa,
  532. unsigned long vaddr, int asid, int dirty,
  533. int pagesize)
  534. {
  535. tfh->fillasid = asid;
  536. tfh->fillvaddr = vaddr;
  537. tfh->pfn = paddr >> GRU_PADDR_SHIFT;
  538. tfh->gaa = gaa;
  539. tfh->dirty = dirty;
  540. tfh->pagesize = pagesize;
  541. tfh->opc = TFHOP_WRITE_RESTART;
  542. start_instruction(tfh);
  543. }
  544. static inline void tfh_restart(struct gru_tlb_fault_handle *tfh)
  545. {
  546. tfh->opc = TFHOP_RESTART;
  547. start_instruction(tfh);
  548. }
  549. static inline void tfh_user_polling_mode(struct gru_tlb_fault_handle *tfh)
  550. {
  551. tfh->opc = TFHOP_USER_POLLING_MODE;
  552. start_instruction(tfh);
  553. }
  554. static inline void tfh_exception(struct gru_tlb_fault_handle *tfh)
  555. {
  556. tfh->opc = TFHOP_EXCEPTION;
  557. start_instruction(tfh);
  558. }
  559. #endif /* __GRUHANDLES_H__ */