gruhandles.h 16 KB

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