evergreen_cs.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469
  1. /*
  2. * Copyright 2010 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #include "drmP.h"
  29. #include "radeon.h"
  30. #include "evergreend.h"
  31. #include "evergreen_reg_safe.h"
  32. #include "cayman_reg_safe.h"
  33. static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p,
  34. struct radeon_cs_reloc **cs_reloc);
  35. struct evergreen_cs_track {
  36. u32 group_size;
  37. u32 nbanks;
  38. u32 npipes;
  39. /* value we track */
  40. u32 nsamples;
  41. u32 cb_color_base_last[12];
  42. struct radeon_bo *cb_color_bo[12];
  43. u32 cb_color_bo_offset[12];
  44. struct radeon_bo *cb_color_fmask_bo[8];
  45. struct radeon_bo *cb_color_cmask_bo[8];
  46. u32 cb_color_info[12];
  47. u32 cb_color_view[12];
  48. u32 cb_color_pitch_idx[12];
  49. u32 cb_color_slice_idx[12];
  50. u32 cb_color_dim_idx[12];
  51. u32 cb_color_dim[12];
  52. u32 cb_color_pitch[12];
  53. u32 cb_color_slice[12];
  54. u32 cb_color_cmask_slice[8];
  55. u32 cb_color_fmask_slice[8];
  56. u32 cb_target_mask;
  57. u32 cb_shader_mask;
  58. u32 vgt_strmout_config;
  59. u32 vgt_strmout_buffer_config;
  60. u32 db_depth_control;
  61. u32 db_depth_view;
  62. u32 db_depth_size;
  63. u32 db_depth_size_idx;
  64. u32 db_z_info;
  65. u32 db_z_idx;
  66. u32 db_z_read_offset;
  67. u32 db_z_write_offset;
  68. struct radeon_bo *db_z_read_bo;
  69. struct radeon_bo *db_z_write_bo;
  70. u32 db_s_info;
  71. u32 db_s_idx;
  72. u32 db_s_read_offset;
  73. u32 db_s_write_offset;
  74. struct radeon_bo *db_s_read_bo;
  75. struct radeon_bo *db_s_write_bo;
  76. };
  77. static void evergreen_cs_track_init(struct evergreen_cs_track *track)
  78. {
  79. int i;
  80. for (i = 0; i < 8; i++) {
  81. track->cb_color_fmask_bo[i] = NULL;
  82. track->cb_color_cmask_bo[i] = NULL;
  83. track->cb_color_cmask_slice[i] = 0;
  84. track->cb_color_fmask_slice[i] = 0;
  85. }
  86. for (i = 0; i < 12; i++) {
  87. track->cb_color_base_last[i] = 0;
  88. track->cb_color_bo[i] = NULL;
  89. track->cb_color_bo_offset[i] = 0xFFFFFFFF;
  90. track->cb_color_info[i] = 0;
  91. track->cb_color_view[i] = 0;
  92. track->cb_color_pitch_idx[i] = 0;
  93. track->cb_color_slice_idx[i] = 0;
  94. track->cb_color_dim[i] = 0;
  95. track->cb_color_pitch[i] = 0;
  96. track->cb_color_slice[i] = 0;
  97. track->cb_color_dim[i] = 0;
  98. }
  99. track->cb_target_mask = 0xFFFFFFFF;
  100. track->cb_shader_mask = 0xFFFFFFFF;
  101. track->db_depth_view = 0xFFFFC000;
  102. track->db_depth_size = 0xFFFFFFFF;
  103. track->db_depth_size_idx = 0;
  104. track->db_depth_control = 0xFFFFFFFF;
  105. track->db_z_info = 0xFFFFFFFF;
  106. track->db_z_idx = 0xFFFFFFFF;
  107. track->db_z_read_offset = 0xFFFFFFFF;
  108. track->db_z_write_offset = 0xFFFFFFFF;
  109. track->db_z_read_bo = NULL;
  110. track->db_z_write_bo = NULL;
  111. track->db_s_info = 0xFFFFFFFF;
  112. track->db_s_idx = 0xFFFFFFFF;
  113. track->db_s_read_offset = 0xFFFFFFFF;
  114. track->db_s_write_offset = 0xFFFFFFFF;
  115. track->db_s_read_bo = NULL;
  116. track->db_s_write_bo = NULL;
  117. }
  118. static int evergreen_cs_track_check(struct radeon_cs_parser *p)
  119. {
  120. struct evergreen_cs_track *track = p->track;
  121. /* we don't support stream out buffer yet */
  122. if (track->vgt_strmout_config || track->vgt_strmout_buffer_config) {
  123. dev_warn(p->dev, "this kernel doesn't support SMX output buffer\n");
  124. return -EINVAL;
  125. }
  126. /* XXX fill in */
  127. return 0;
  128. }
  129. /**
  130. * evergreen_cs_packet_parse() - parse cp packet and point ib index to next packet
  131. * @parser: parser structure holding parsing context.
  132. * @pkt: where to store packet informations
  133. *
  134. * Assume that chunk_ib_index is properly set. Will return -EINVAL
  135. * if packet is bigger than remaining ib size. or if packets is unknown.
  136. **/
  137. int evergreen_cs_packet_parse(struct radeon_cs_parser *p,
  138. struct radeon_cs_packet *pkt,
  139. unsigned idx)
  140. {
  141. struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
  142. uint32_t header;
  143. if (idx >= ib_chunk->length_dw) {
  144. DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
  145. idx, ib_chunk->length_dw);
  146. return -EINVAL;
  147. }
  148. header = radeon_get_ib_value(p, idx);
  149. pkt->idx = idx;
  150. pkt->type = CP_PACKET_GET_TYPE(header);
  151. pkt->count = CP_PACKET_GET_COUNT(header);
  152. pkt->one_reg_wr = 0;
  153. switch (pkt->type) {
  154. case PACKET_TYPE0:
  155. pkt->reg = CP_PACKET0_GET_REG(header);
  156. break;
  157. case PACKET_TYPE3:
  158. pkt->opcode = CP_PACKET3_GET_OPCODE(header);
  159. break;
  160. case PACKET_TYPE2:
  161. pkt->count = -1;
  162. break;
  163. default:
  164. DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx);
  165. return -EINVAL;
  166. }
  167. if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) {
  168. DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n",
  169. pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw);
  170. return -EINVAL;
  171. }
  172. return 0;
  173. }
  174. /**
  175. * evergreen_cs_packet_next_reloc() - parse next packet which should be reloc packet3
  176. * @parser: parser structure holding parsing context.
  177. * @data: pointer to relocation data
  178. * @offset_start: starting offset
  179. * @offset_mask: offset mask (to align start offset on)
  180. * @reloc: reloc informations
  181. *
  182. * Check next packet is relocation packet3, do bo validation and compute
  183. * GPU offset using the provided start.
  184. **/
  185. static int evergreen_cs_packet_next_reloc(struct radeon_cs_parser *p,
  186. struct radeon_cs_reloc **cs_reloc)
  187. {
  188. struct radeon_cs_chunk *relocs_chunk;
  189. struct radeon_cs_packet p3reloc;
  190. unsigned idx;
  191. int r;
  192. if (p->chunk_relocs_idx == -1) {
  193. DRM_ERROR("No relocation chunk !\n");
  194. return -EINVAL;
  195. }
  196. *cs_reloc = NULL;
  197. relocs_chunk = &p->chunks[p->chunk_relocs_idx];
  198. r = evergreen_cs_packet_parse(p, &p3reloc, p->idx);
  199. if (r) {
  200. return r;
  201. }
  202. p->idx += p3reloc.count + 2;
  203. if (p3reloc.type != PACKET_TYPE3 || p3reloc.opcode != PACKET3_NOP) {
  204. DRM_ERROR("No packet3 for relocation for packet at %d.\n",
  205. p3reloc.idx);
  206. return -EINVAL;
  207. }
  208. idx = radeon_get_ib_value(p, p3reloc.idx + 1);
  209. if (idx >= relocs_chunk->length_dw) {
  210. DRM_ERROR("Relocs at %d after relocations chunk end %d !\n",
  211. idx, relocs_chunk->length_dw);
  212. return -EINVAL;
  213. }
  214. /* FIXME: we assume reloc size is 4 dwords */
  215. *cs_reloc = p->relocs_ptr[(idx / 4)];
  216. return 0;
  217. }
  218. /**
  219. * evergreen_cs_packet_next_vline() - parse userspace VLINE packet
  220. * @parser: parser structure holding parsing context.
  221. *
  222. * Userspace sends a special sequence for VLINE waits.
  223. * PACKET0 - VLINE_START_END + value
  224. * PACKET3 - WAIT_REG_MEM poll vline status reg
  225. * RELOC (P3) - crtc_id in reloc.
  226. *
  227. * This function parses this and relocates the VLINE START END
  228. * and WAIT_REG_MEM packets to the correct crtc.
  229. * It also detects a switched off crtc and nulls out the
  230. * wait in that case.
  231. */
  232. static int evergreen_cs_packet_parse_vline(struct radeon_cs_parser *p)
  233. {
  234. struct drm_mode_object *obj;
  235. struct drm_crtc *crtc;
  236. struct radeon_crtc *radeon_crtc;
  237. struct radeon_cs_packet p3reloc, wait_reg_mem;
  238. int crtc_id;
  239. int r;
  240. uint32_t header, h_idx, reg, wait_reg_mem_info;
  241. volatile uint32_t *ib;
  242. ib = p->ib->ptr;
  243. /* parse the WAIT_REG_MEM */
  244. r = evergreen_cs_packet_parse(p, &wait_reg_mem, p->idx);
  245. if (r)
  246. return r;
  247. /* check its a WAIT_REG_MEM */
  248. if (wait_reg_mem.type != PACKET_TYPE3 ||
  249. wait_reg_mem.opcode != PACKET3_WAIT_REG_MEM) {
  250. DRM_ERROR("vline wait missing WAIT_REG_MEM segment\n");
  251. return -EINVAL;
  252. }
  253. wait_reg_mem_info = radeon_get_ib_value(p, wait_reg_mem.idx + 1);
  254. /* bit 4 is reg (0) or mem (1) */
  255. if (wait_reg_mem_info & 0x10) {
  256. DRM_ERROR("vline WAIT_REG_MEM waiting on MEM rather than REG\n");
  257. return -EINVAL;
  258. }
  259. /* waiting for value to be equal */
  260. if ((wait_reg_mem_info & 0x7) != 0x3) {
  261. DRM_ERROR("vline WAIT_REG_MEM function not equal\n");
  262. return -EINVAL;
  263. }
  264. if ((radeon_get_ib_value(p, wait_reg_mem.idx + 2) << 2) != EVERGREEN_VLINE_STATUS) {
  265. DRM_ERROR("vline WAIT_REG_MEM bad reg\n");
  266. return -EINVAL;
  267. }
  268. if (radeon_get_ib_value(p, wait_reg_mem.idx + 5) != EVERGREEN_VLINE_STAT) {
  269. DRM_ERROR("vline WAIT_REG_MEM bad bit mask\n");
  270. return -EINVAL;
  271. }
  272. /* jump over the NOP */
  273. r = evergreen_cs_packet_parse(p, &p3reloc, p->idx + wait_reg_mem.count + 2);
  274. if (r)
  275. return r;
  276. h_idx = p->idx - 2;
  277. p->idx += wait_reg_mem.count + 2;
  278. p->idx += p3reloc.count + 2;
  279. header = radeon_get_ib_value(p, h_idx);
  280. crtc_id = radeon_get_ib_value(p, h_idx + 2 + 7 + 1);
  281. reg = CP_PACKET0_GET_REG(header);
  282. obj = drm_mode_object_find(p->rdev->ddev, crtc_id, DRM_MODE_OBJECT_CRTC);
  283. if (!obj) {
  284. DRM_ERROR("cannot find crtc %d\n", crtc_id);
  285. return -EINVAL;
  286. }
  287. crtc = obj_to_crtc(obj);
  288. radeon_crtc = to_radeon_crtc(crtc);
  289. crtc_id = radeon_crtc->crtc_id;
  290. if (!crtc->enabled) {
  291. /* if the CRTC isn't enabled - we need to nop out the WAIT_REG_MEM */
  292. ib[h_idx + 2] = PACKET2(0);
  293. ib[h_idx + 3] = PACKET2(0);
  294. ib[h_idx + 4] = PACKET2(0);
  295. ib[h_idx + 5] = PACKET2(0);
  296. ib[h_idx + 6] = PACKET2(0);
  297. ib[h_idx + 7] = PACKET2(0);
  298. ib[h_idx + 8] = PACKET2(0);
  299. } else {
  300. switch (reg) {
  301. case EVERGREEN_VLINE_START_END:
  302. header &= ~R600_CP_PACKET0_REG_MASK;
  303. header |= (EVERGREEN_VLINE_START_END + radeon_crtc->crtc_offset) >> 2;
  304. ib[h_idx] = header;
  305. ib[h_idx + 4] = (EVERGREEN_VLINE_STATUS + radeon_crtc->crtc_offset) >> 2;
  306. break;
  307. default:
  308. DRM_ERROR("unknown crtc reloc\n");
  309. return -EINVAL;
  310. }
  311. }
  312. return 0;
  313. }
  314. static int evergreen_packet0_check(struct radeon_cs_parser *p,
  315. struct radeon_cs_packet *pkt,
  316. unsigned idx, unsigned reg)
  317. {
  318. int r;
  319. switch (reg) {
  320. case EVERGREEN_VLINE_START_END:
  321. r = evergreen_cs_packet_parse_vline(p);
  322. if (r) {
  323. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  324. idx, reg);
  325. return r;
  326. }
  327. break;
  328. default:
  329. printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n",
  330. reg, idx);
  331. return -EINVAL;
  332. }
  333. return 0;
  334. }
  335. static int evergreen_cs_parse_packet0(struct radeon_cs_parser *p,
  336. struct radeon_cs_packet *pkt)
  337. {
  338. unsigned reg, i;
  339. unsigned idx;
  340. int r;
  341. idx = pkt->idx + 1;
  342. reg = pkt->reg;
  343. for (i = 0; i <= pkt->count; i++, idx++, reg += 4) {
  344. r = evergreen_packet0_check(p, pkt, idx, reg);
  345. if (r) {
  346. return r;
  347. }
  348. }
  349. return 0;
  350. }
  351. /**
  352. * evergreen_cs_check_reg() - check if register is authorized or not
  353. * @parser: parser structure holding parsing context
  354. * @reg: register we are testing
  355. * @idx: index into the cs buffer
  356. *
  357. * This function will test against evergreen_reg_safe_bm and return 0
  358. * if register is safe. If register is not flag as safe this function
  359. * will test it against a list of register needind special handling.
  360. */
  361. static int evergreen_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx)
  362. {
  363. struct evergreen_cs_track *track = (struct evergreen_cs_track *)p->track;
  364. struct radeon_cs_reloc *reloc;
  365. u32 last_reg;
  366. u32 m, i, tmp, *ib;
  367. int r;
  368. if (p->rdev->family >= CHIP_CAYMAN)
  369. last_reg = ARRAY_SIZE(cayman_reg_safe_bm);
  370. else
  371. last_reg = ARRAY_SIZE(evergreen_reg_safe_bm);
  372. i = (reg >> 7);
  373. if (i >= last_reg) {
  374. dev_warn(p->dev, "forbidden register 0x%08x at %d\n", reg, idx);
  375. return -EINVAL;
  376. }
  377. m = 1 << ((reg >> 2) & 31);
  378. if (p->rdev->family >= CHIP_CAYMAN) {
  379. if (!(cayman_reg_safe_bm[i] & m))
  380. return 0;
  381. } else {
  382. if (!(evergreen_reg_safe_bm[i] & m))
  383. return 0;
  384. }
  385. ib = p->ib->ptr;
  386. switch (reg) {
  387. /* force following reg to 0 in an attempt to disable out buffer
  388. * which will need us to better understand how it works to perform
  389. * security check on it (Jerome)
  390. */
  391. case SQ_ESGS_RING_SIZE:
  392. case SQ_GSVS_RING_SIZE:
  393. case SQ_ESTMP_RING_SIZE:
  394. case SQ_GSTMP_RING_SIZE:
  395. case SQ_HSTMP_RING_SIZE:
  396. case SQ_LSTMP_RING_SIZE:
  397. case SQ_PSTMP_RING_SIZE:
  398. case SQ_VSTMP_RING_SIZE:
  399. case SQ_ESGS_RING_ITEMSIZE:
  400. case SQ_ESTMP_RING_ITEMSIZE:
  401. case SQ_GSTMP_RING_ITEMSIZE:
  402. case SQ_GSVS_RING_ITEMSIZE:
  403. case SQ_GS_VERT_ITEMSIZE:
  404. case SQ_GS_VERT_ITEMSIZE_1:
  405. case SQ_GS_VERT_ITEMSIZE_2:
  406. case SQ_GS_VERT_ITEMSIZE_3:
  407. case SQ_GSVS_RING_OFFSET_1:
  408. case SQ_GSVS_RING_OFFSET_2:
  409. case SQ_GSVS_RING_OFFSET_3:
  410. case SQ_HSTMP_RING_ITEMSIZE:
  411. case SQ_LSTMP_RING_ITEMSIZE:
  412. case SQ_PSTMP_RING_ITEMSIZE:
  413. case SQ_VSTMP_RING_ITEMSIZE:
  414. case VGT_TF_RING_SIZE:
  415. /* get value to populate the IB don't remove */
  416. /*tmp =radeon_get_ib_value(p, idx);
  417. ib[idx] = 0;*/
  418. break;
  419. case SQ_ESGS_RING_BASE:
  420. case SQ_GSVS_RING_BASE:
  421. case SQ_ESTMP_RING_BASE:
  422. case SQ_GSTMP_RING_BASE:
  423. case SQ_HSTMP_RING_BASE:
  424. case SQ_LSTMP_RING_BASE:
  425. case SQ_PSTMP_RING_BASE:
  426. case SQ_VSTMP_RING_BASE:
  427. r = evergreen_cs_packet_next_reloc(p, &reloc);
  428. if (r) {
  429. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  430. "0x%04X\n", reg);
  431. return -EINVAL;
  432. }
  433. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  434. break;
  435. case DB_DEPTH_CONTROL:
  436. track->db_depth_control = radeon_get_ib_value(p, idx);
  437. break;
  438. case CAYMAN_DB_EQAA:
  439. if (p->rdev->family < CHIP_CAYMAN) {
  440. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  441. "0x%04X\n", reg);
  442. return -EINVAL;
  443. }
  444. break;
  445. case CAYMAN_DB_DEPTH_INFO:
  446. if (p->rdev->family < CHIP_CAYMAN) {
  447. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  448. "0x%04X\n", reg);
  449. return -EINVAL;
  450. }
  451. break;
  452. case DB_Z_INFO:
  453. r = evergreen_cs_packet_next_reloc(p, &reloc);
  454. if (r) {
  455. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  456. "0x%04X\n", reg);
  457. return -EINVAL;
  458. }
  459. track->db_z_info = radeon_get_ib_value(p, idx);
  460. ib[idx] &= ~Z_ARRAY_MODE(0xf);
  461. track->db_z_info &= ~Z_ARRAY_MODE(0xf);
  462. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) {
  463. ib[idx] |= Z_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  464. track->db_z_info |= Z_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  465. } else {
  466. ib[idx] |= Z_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  467. track->db_z_info |= Z_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  468. }
  469. break;
  470. case DB_STENCIL_INFO:
  471. track->db_s_info = radeon_get_ib_value(p, idx);
  472. break;
  473. case DB_DEPTH_VIEW:
  474. track->db_depth_view = radeon_get_ib_value(p, idx);
  475. break;
  476. case DB_DEPTH_SIZE:
  477. track->db_depth_size = radeon_get_ib_value(p, idx);
  478. track->db_depth_size_idx = idx;
  479. break;
  480. case DB_Z_READ_BASE:
  481. r = evergreen_cs_packet_next_reloc(p, &reloc);
  482. if (r) {
  483. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  484. "0x%04X\n", reg);
  485. return -EINVAL;
  486. }
  487. track->db_z_read_offset = radeon_get_ib_value(p, idx);
  488. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  489. track->db_z_read_bo = reloc->robj;
  490. break;
  491. case DB_Z_WRITE_BASE:
  492. r = evergreen_cs_packet_next_reloc(p, &reloc);
  493. if (r) {
  494. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  495. "0x%04X\n", reg);
  496. return -EINVAL;
  497. }
  498. track->db_z_write_offset = radeon_get_ib_value(p, idx);
  499. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  500. track->db_z_write_bo = reloc->robj;
  501. break;
  502. case DB_STENCIL_READ_BASE:
  503. r = evergreen_cs_packet_next_reloc(p, &reloc);
  504. if (r) {
  505. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  506. "0x%04X\n", reg);
  507. return -EINVAL;
  508. }
  509. track->db_s_read_offset = radeon_get_ib_value(p, idx);
  510. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  511. track->db_s_read_bo = reloc->robj;
  512. break;
  513. case DB_STENCIL_WRITE_BASE:
  514. r = evergreen_cs_packet_next_reloc(p, &reloc);
  515. if (r) {
  516. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  517. "0x%04X\n", reg);
  518. return -EINVAL;
  519. }
  520. track->db_s_write_offset = radeon_get_ib_value(p, idx);
  521. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  522. track->db_s_write_bo = reloc->robj;
  523. break;
  524. case VGT_STRMOUT_CONFIG:
  525. track->vgt_strmout_config = radeon_get_ib_value(p, idx);
  526. break;
  527. case VGT_STRMOUT_BUFFER_CONFIG:
  528. track->vgt_strmout_buffer_config = radeon_get_ib_value(p, idx);
  529. break;
  530. case CB_TARGET_MASK:
  531. track->cb_target_mask = radeon_get_ib_value(p, idx);
  532. break;
  533. case CB_SHADER_MASK:
  534. track->cb_shader_mask = radeon_get_ib_value(p, idx);
  535. break;
  536. case PA_SC_AA_CONFIG:
  537. if (p->rdev->family >= CHIP_CAYMAN) {
  538. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  539. "0x%04X\n", reg);
  540. return -EINVAL;
  541. }
  542. tmp = radeon_get_ib_value(p, idx) & MSAA_NUM_SAMPLES_MASK;
  543. track->nsamples = 1 << tmp;
  544. break;
  545. case CAYMAN_PA_SC_AA_CONFIG:
  546. if (p->rdev->family < CHIP_CAYMAN) {
  547. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  548. "0x%04X\n", reg);
  549. return -EINVAL;
  550. }
  551. tmp = radeon_get_ib_value(p, idx) & CAYMAN_MSAA_NUM_SAMPLES_MASK;
  552. track->nsamples = 1 << tmp;
  553. break;
  554. case CB_COLOR0_VIEW:
  555. case CB_COLOR1_VIEW:
  556. case CB_COLOR2_VIEW:
  557. case CB_COLOR3_VIEW:
  558. case CB_COLOR4_VIEW:
  559. case CB_COLOR5_VIEW:
  560. case CB_COLOR6_VIEW:
  561. case CB_COLOR7_VIEW:
  562. tmp = (reg - CB_COLOR0_VIEW) / 0x3c;
  563. track->cb_color_view[tmp] = radeon_get_ib_value(p, idx);
  564. break;
  565. case CB_COLOR8_VIEW:
  566. case CB_COLOR9_VIEW:
  567. case CB_COLOR10_VIEW:
  568. case CB_COLOR11_VIEW:
  569. tmp = ((reg - CB_COLOR8_VIEW) / 0x1c) + 8;
  570. track->cb_color_view[tmp] = radeon_get_ib_value(p, idx);
  571. break;
  572. case CB_COLOR0_INFO:
  573. case CB_COLOR1_INFO:
  574. case CB_COLOR2_INFO:
  575. case CB_COLOR3_INFO:
  576. case CB_COLOR4_INFO:
  577. case CB_COLOR5_INFO:
  578. case CB_COLOR6_INFO:
  579. case CB_COLOR7_INFO:
  580. r = evergreen_cs_packet_next_reloc(p, &reloc);
  581. if (r) {
  582. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  583. "0x%04X\n", reg);
  584. return -EINVAL;
  585. }
  586. tmp = (reg - CB_COLOR0_INFO) / 0x3c;
  587. track->cb_color_info[tmp] = radeon_get_ib_value(p, idx);
  588. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) {
  589. ib[idx] |= CB_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  590. track->cb_color_info[tmp] |= CB_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  591. } else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) {
  592. ib[idx] |= CB_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  593. track->cb_color_info[tmp] |= CB_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  594. }
  595. break;
  596. case CB_COLOR8_INFO:
  597. case CB_COLOR9_INFO:
  598. case CB_COLOR10_INFO:
  599. case CB_COLOR11_INFO:
  600. r = evergreen_cs_packet_next_reloc(p, &reloc);
  601. if (r) {
  602. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  603. "0x%04X\n", reg);
  604. return -EINVAL;
  605. }
  606. tmp = ((reg - CB_COLOR8_INFO) / 0x1c) + 8;
  607. track->cb_color_info[tmp] = radeon_get_ib_value(p, idx);
  608. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO) {
  609. ib[idx] |= CB_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  610. track->cb_color_info[tmp] |= CB_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  611. } else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) {
  612. ib[idx] |= CB_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  613. track->cb_color_info[tmp] |= CB_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  614. }
  615. break;
  616. case CB_COLOR0_PITCH:
  617. case CB_COLOR1_PITCH:
  618. case CB_COLOR2_PITCH:
  619. case CB_COLOR3_PITCH:
  620. case CB_COLOR4_PITCH:
  621. case CB_COLOR5_PITCH:
  622. case CB_COLOR6_PITCH:
  623. case CB_COLOR7_PITCH:
  624. tmp = (reg - CB_COLOR0_PITCH) / 0x3c;
  625. track->cb_color_pitch[tmp] = radeon_get_ib_value(p, idx);
  626. track->cb_color_pitch_idx[tmp] = idx;
  627. break;
  628. case CB_COLOR8_PITCH:
  629. case CB_COLOR9_PITCH:
  630. case CB_COLOR10_PITCH:
  631. case CB_COLOR11_PITCH:
  632. tmp = ((reg - CB_COLOR8_PITCH) / 0x1c) + 8;
  633. track->cb_color_pitch[tmp] = radeon_get_ib_value(p, idx);
  634. track->cb_color_pitch_idx[tmp] = idx;
  635. break;
  636. case CB_COLOR0_SLICE:
  637. case CB_COLOR1_SLICE:
  638. case CB_COLOR2_SLICE:
  639. case CB_COLOR3_SLICE:
  640. case CB_COLOR4_SLICE:
  641. case CB_COLOR5_SLICE:
  642. case CB_COLOR6_SLICE:
  643. case CB_COLOR7_SLICE:
  644. tmp = (reg - CB_COLOR0_SLICE) / 0x3c;
  645. track->cb_color_slice[tmp] = radeon_get_ib_value(p, idx);
  646. track->cb_color_slice_idx[tmp] = idx;
  647. break;
  648. case CB_COLOR8_SLICE:
  649. case CB_COLOR9_SLICE:
  650. case CB_COLOR10_SLICE:
  651. case CB_COLOR11_SLICE:
  652. tmp = ((reg - CB_COLOR8_SLICE) / 0x1c) + 8;
  653. track->cb_color_slice[tmp] = radeon_get_ib_value(p, idx);
  654. track->cb_color_slice_idx[tmp] = idx;
  655. break;
  656. case CB_COLOR0_ATTRIB:
  657. case CB_COLOR1_ATTRIB:
  658. case CB_COLOR2_ATTRIB:
  659. case CB_COLOR3_ATTRIB:
  660. case CB_COLOR4_ATTRIB:
  661. case CB_COLOR5_ATTRIB:
  662. case CB_COLOR6_ATTRIB:
  663. case CB_COLOR7_ATTRIB:
  664. case CB_COLOR8_ATTRIB:
  665. case CB_COLOR9_ATTRIB:
  666. case CB_COLOR10_ATTRIB:
  667. case CB_COLOR11_ATTRIB:
  668. break;
  669. case CB_COLOR0_DIM:
  670. case CB_COLOR1_DIM:
  671. case CB_COLOR2_DIM:
  672. case CB_COLOR3_DIM:
  673. case CB_COLOR4_DIM:
  674. case CB_COLOR5_DIM:
  675. case CB_COLOR6_DIM:
  676. case CB_COLOR7_DIM:
  677. tmp = (reg - CB_COLOR0_DIM) / 0x3c;
  678. track->cb_color_dim[tmp] = radeon_get_ib_value(p, idx);
  679. track->cb_color_dim_idx[tmp] = idx;
  680. break;
  681. case CB_COLOR8_DIM:
  682. case CB_COLOR9_DIM:
  683. case CB_COLOR10_DIM:
  684. case CB_COLOR11_DIM:
  685. tmp = ((reg - CB_COLOR8_DIM) / 0x1c) + 8;
  686. track->cb_color_dim[tmp] = radeon_get_ib_value(p, idx);
  687. track->cb_color_dim_idx[tmp] = idx;
  688. break;
  689. case CB_COLOR0_FMASK:
  690. case CB_COLOR1_FMASK:
  691. case CB_COLOR2_FMASK:
  692. case CB_COLOR3_FMASK:
  693. case CB_COLOR4_FMASK:
  694. case CB_COLOR5_FMASK:
  695. case CB_COLOR6_FMASK:
  696. case CB_COLOR7_FMASK:
  697. tmp = (reg - CB_COLOR0_FMASK) / 0x3c;
  698. r = evergreen_cs_packet_next_reloc(p, &reloc);
  699. if (r) {
  700. dev_err(p->dev, "bad SET_CONTEXT_REG 0x%04X\n", reg);
  701. return -EINVAL;
  702. }
  703. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  704. track->cb_color_fmask_bo[tmp] = reloc->robj;
  705. break;
  706. case CB_COLOR0_CMASK:
  707. case CB_COLOR1_CMASK:
  708. case CB_COLOR2_CMASK:
  709. case CB_COLOR3_CMASK:
  710. case CB_COLOR4_CMASK:
  711. case CB_COLOR5_CMASK:
  712. case CB_COLOR6_CMASK:
  713. case CB_COLOR7_CMASK:
  714. tmp = (reg - CB_COLOR0_CMASK) / 0x3c;
  715. r = evergreen_cs_packet_next_reloc(p, &reloc);
  716. if (r) {
  717. dev_err(p->dev, "bad SET_CONTEXT_REG 0x%04X\n", reg);
  718. return -EINVAL;
  719. }
  720. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  721. track->cb_color_cmask_bo[tmp] = reloc->robj;
  722. break;
  723. case CB_COLOR0_FMASK_SLICE:
  724. case CB_COLOR1_FMASK_SLICE:
  725. case CB_COLOR2_FMASK_SLICE:
  726. case CB_COLOR3_FMASK_SLICE:
  727. case CB_COLOR4_FMASK_SLICE:
  728. case CB_COLOR5_FMASK_SLICE:
  729. case CB_COLOR6_FMASK_SLICE:
  730. case CB_COLOR7_FMASK_SLICE:
  731. tmp = (reg - CB_COLOR0_FMASK_SLICE) / 0x3c;
  732. track->cb_color_fmask_slice[tmp] = radeon_get_ib_value(p, idx);
  733. break;
  734. case CB_COLOR0_CMASK_SLICE:
  735. case CB_COLOR1_CMASK_SLICE:
  736. case CB_COLOR2_CMASK_SLICE:
  737. case CB_COLOR3_CMASK_SLICE:
  738. case CB_COLOR4_CMASK_SLICE:
  739. case CB_COLOR5_CMASK_SLICE:
  740. case CB_COLOR6_CMASK_SLICE:
  741. case CB_COLOR7_CMASK_SLICE:
  742. tmp = (reg - CB_COLOR0_CMASK_SLICE) / 0x3c;
  743. track->cb_color_cmask_slice[tmp] = radeon_get_ib_value(p, idx);
  744. break;
  745. case CB_COLOR0_BASE:
  746. case CB_COLOR1_BASE:
  747. case CB_COLOR2_BASE:
  748. case CB_COLOR3_BASE:
  749. case CB_COLOR4_BASE:
  750. case CB_COLOR5_BASE:
  751. case CB_COLOR6_BASE:
  752. case CB_COLOR7_BASE:
  753. r = evergreen_cs_packet_next_reloc(p, &reloc);
  754. if (r) {
  755. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  756. "0x%04X\n", reg);
  757. return -EINVAL;
  758. }
  759. tmp = (reg - CB_COLOR0_BASE) / 0x3c;
  760. track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx);
  761. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  762. track->cb_color_base_last[tmp] = ib[idx];
  763. track->cb_color_bo[tmp] = reloc->robj;
  764. break;
  765. case CB_COLOR8_BASE:
  766. case CB_COLOR9_BASE:
  767. case CB_COLOR10_BASE:
  768. case CB_COLOR11_BASE:
  769. r = evergreen_cs_packet_next_reloc(p, &reloc);
  770. if (r) {
  771. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  772. "0x%04X\n", reg);
  773. return -EINVAL;
  774. }
  775. tmp = ((reg - CB_COLOR8_BASE) / 0x1c) + 8;
  776. track->cb_color_bo_offset[tmp] = radeon_get_ib_value(p, idx);
  777. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  778. track->cb_color_base_last[tmp] = ib[idx];
  779. track->cb_color_bo[tmp] = reloc->robj;
  780. break;
  781. case CB_IMMED0_BASE:
  782. case CB_IMMED1_BASE:
  783. case CB_IMMED2_BASE:
  784. case CB_IMMED3_BASE:
  785. case CB_IMMED4_BASE:
  786. case CB_IMMED5_BASE:
  787. case CB_IMMED6_BASE:
  788. case CB_IMMED7_BASE:
  789. case CB_IMMED8_BASE:
  790. case CB_IMMED9_BASE:
  791. case CB_IMMED10_BASE:
  792. case CB_IMMED11_BASE:
  793. case DB_HTILE_DATA_BASE:
  794. case SQ_PGM_START_FS:
  795. case SQ_PGM_START_ES:
  796. case SQ_PGM_START_VS:
  797. case SQ_PGM_START_GS:
  798. case SQ_PGM_START_PS:
  799. case SQ_PGM_START_HS:
  800. case SQ_PGM_START_LS:
  801. case SQ_CONST_MEM_BASE:
  802. case SQ_ALU_CONST_CACHE_GS_0:
  803. case SQ_ALU_CONST_CACHE_GS_1:
  804. case SQ_ALU_CONST_CACHE_GS_2:
  805. case SQ_ALU_CONST_CACHE_GS_3:
  806. case SQ_ALU_CONST_CACHE_GS_4:
  807. case SQ_ALU_CONST_CACHE_GS_5:
  808. case SQ_ALU_CONST_CACHE_GS_6:
  809. case SQ_ALU_CONST_CACHE_GS_7:
  810. case SQ_ALU_CONST_CACHE_GS_8:
  811. case SQ_ALU_CONST_CACHE_GS_9:
  812. case SQ_ALU_CONST_CACHE_GS_10:
  813. case SQ_ALU_CONST_CACHE_GS_11:
  814. case SQ_ALU_CONST_CACHE_GS_12:
  815. case SQ_ALU_CONST_CACHE_GS_13:
  816. case SQ_ALU_CONST_CACHE_GS_14:
  817. case SQ_ALU_CONST_CACHE_GS_15:
  818. case SQ_ALU_CONST_CACHE_PS_0:
  819. case SQ_ALU_CONST_CACHE_PS_1:
  820. case SQ_ALU_CONST_CACHE_PS_2:
  821. case SQ_ALU_CONST_CACHE_PS_3:
  822. case SQ_ALU_CONST_CACHE_PS_4:
  823. case SQ_ALU_CONST_CACHE_PS_5:
  824. case SQ_ALU_CONST_CACHE_PS_6:
  825. case SQ_ALU_CONST_CACHE_PS_7:
  826. case SQ_ALU_CONST_CACHE_PS_8:
  827. case SQ_ALU_CONST_CACHE_PS_9:
  828. case SQ_ALU_CONST_CACHE_PS_10:
  829. case SQ_ALU_CONST_CACHE_PS_11:
  830. case SQ_ALU_CONST_CACHE_PS_12:
  831. case SQ_ALU_CONST_CACHE_PS_13:
  832. case SQ_ALU_CONST_CACHE_PS_14:
  833. case SQ_ALU_CONST_CACHE_PS_15:
  834. case SQ_ALU_CONST_CACHE_VS_0:
  835. case SQ_ALU_CONST_CACHE_VS_1:
  836. case SQ_ALU_CONST_CACHE_VS_2:
  837. case SQ_ALU_CONST_CACHE_VS_3:
  838. case SQ_ALU_CONST_CACHE_VS_4:
  839. case SQ_ALU_CONST_CACHE_VS_5:
  840. case SQ_ALU_CONST_CACHE_VS_6:
  841. case SQ_ALU_CONST_CACHE_VS_7:
  842. case SQ_ALU_CONST_CACHE_VS_8:
  843. case SQ_ALU_CONST_CACHE_VS_9:
  844. case SQ_ALU_CONST_CACHE_VS_10:
  845. case SQ_ALU_CONST_CACHE_VS_11:
  846. case SQ_ALU_CONST_CACHE_VS_12:
  847. case SQ_ALU_CONST_CACHE_VS_13:
  848. case SQ_ALU_CONST_CACHE_VS_14:
  849. case SQ_ALU_CONST_CACHE_VS_15:
  850. case SQ_ALU_CONST_CACHE_HS_0:
  851. case SQ_ALU_CONST_CACHE_HS_1:
  852. case SQ_ALU_CONST_CACHE_HS_2:
  853. case SQ_ALU_CONST_CACHE_HS_3:
  854. case SQ_ALU_CONST_CACHE_HS_4:
  855. case SQ_ALU_CONST_CACHE_HS_5:
  856. case SQ_ALU_CONST_CACHE_HS_6:
  857. case SQ_ALU_CONST_CACHE_HS_7:
  858. case SQ_ALU_CONST_CACHE_HS_8:
  859. case SQ_ALU_CONST_CACHE_HS_9:
  860. case SQ_ALU_CONST_CACHE_HS_10:
  861. case SQ_ALU_CONST_CACHE_HS_11:
  862. case SQ_ALU_CONST_CACHE_HS_12:
  863. case SQ_ALU_CONST_CACHE_HS_13:
  864. case SQ_ALU_CONST_CACHE_HS_14:
  865. case SQ_ALU_CONST_CACHE_HS_15:
  866. case SQ_ALU_CONST_CACHE_LS_0:
  867. case SQ_ALU_CONST_CACHE_LS_1:
  868. case SQ_ALU_CONST_CACHE_LS_2:
  869. case SQ_ALU_CONST_CACHE_LS_3:
  870. case SQ_ALU_CONST_CACHE_LS_4:
  871. case SQ_ALU_CONST_CACHE_LS_5:
  872. case SQ_ALU_CONST_CACHE_LS_6:
  873. case SQ_ALU_CONST_CACHE_LS_7:
  874. case SQ_ALU_CONST_CACHE_LS_8:
  875. case SQ_ALU_CONST_CACHE_LS_9:
  876. case SQ_ALU_CONST_CACHE_LS_10:
  877. case SQ_ALU_CONST_CACHE_LS_11:
  878. case SQ_ALU_CONST_CACHE_LS_12:
  879. case SQ_ALU_CONST_CACHE_LS_13:
  880. case SQ_ALU_CONST_CACHE_LS_14:
  881. case SQ_ALU_CONST_CACHE_LS_15:
  882. r = evergreen_cs_packet_next_reloc(p, &reloc);
  883. if (r) {
  884. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  885. "0x%04X\n", reg);
  886. return -EINVAL;
  887. }
  888. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  889. break;
  890. case SX_MEMORY_EXPORT_BASE:
  891. if (p->rdev->family >= CHIP_CAYMAN) {
  892. dev_warn(p->dev, "bad SET_CONFIG_REG "
  893. "0x%04X\n", reg);
  894. return -EINVAL;
  895. }
  896. r = evergreen_cs_packet_next_reloc(p, &reloc);
  897. if (r) {
  898. dev_warn(p->dev, "bad SET_CONFIG_REG "
  899. "0x%04X\n", reg);
  900. return -EINVAL;
  901. }
  902. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  903. break;
  904. case CAYMAN_SX_SCATTER_EXPORT_BASE:
  905. if (p->rdev->family < CHIP_CAYMAN) {
  906. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  907. "0x%04X\n", reg);
  908. return -EINVAL;
  909. }
  910. r = evergreen_cs_packet_next_reloc(p, &reloc);
  911. if (r) {
  912. dev_warn(p->dev, "bad SET_CONTEXT_REG "
  913. "0x%04X\n", reg);
  914. return -EINVAL;
  915. }
  916. ib[idx] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  917. break;
  918. default:
  919. dev_warn(p->dev, "forbidden register 0x%08x at %d\n", reg, idx);
  920. return -EINVAL;
  921. }
  922. return 0;
  923. }
  924. /**
  925. * evergreen_check_texture_resource() - check if register is authorized or not
  926. * @p: parser structure holding parsing context
  927. * @idx: index into the cs buffer
  928. * @texture: texture's bo structure
  929. * @mipmap: mipmap's bo structure
  930. *
  931. * This function will check that the resource has valid field and that
  932. * the texture and mipmap bo object are big enough to cover this resource.
  933. */
  934. static int evergreen_check_texture_resource(struct radeon_cs_parser *p, u32 idx,
  935. struct radeon_bo *texture,
  936. struct radeon_bo *mipmap)
  937. {
  938. /* XXX fill in */
  939. return 0;
  940. }
  941. static int evergreen_packet3_check(struct radeon_cs_parser *p,
  942. struct radeon_cs_packet *pkt)
  943. {
  944. struct radeon_cs_reloc *reloc;
  945. struct evergreen_cs_track *track;
  946. volatile u32 *ib;
  947. unsigned idx;
  948. unsigned i;
  949. unsigned start_reg, end_reg, reg;
  950. int r;
  951. u32 idx_value;
  952. track = (struct evergreen_cs_track *)p->track;
  953. ib = p->ib->ptr;
  954. idx = pkt->idx + 1;
  955. idx_value = radeon_get_ib_value(p, idx);
  956. switch (pkt->opcode) {
  957. case PACKET3_SET_PREDICATION:
  958. {
  959. int pred_op;
  960. int tmp;
  961. if (pkt->count != 1) {
  962. DRM_ERROR("bad SET PREDICATION\n");
  963. return -EINVAL;
  964. }
  965. tmp = radeon_get_ib_value(p, idx + 1);
  966. pred_op = (tmp >> 16) & 0x7;
  967. /* for the clear predicate operation */
  968. if (pred_op == 0)
  969. return 0;
  970. if (pred_op > 2) {
  971. DRM_ERROR("bad SET PREDICATION operation %d\n", pred_op);
  972. return -EINVAL;
  973. }
  974. r = evergreen_cs_packet_next_reloc(p, &reloc);
  975. if (r) {
  976. DRM_ERROR("bad SET PREDICATION\n");
  977. return -EINVAL;
  978. }
  979. ib[idx + 0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  980. ib[idx + 1] = tmp + (upper_32_bits(reloc->lobj.gpu_offset) & 0xff);
  981. }
  982. break;
  983. case PACKET3_CONTEXT_CONTROL:
  984. if (pkt->count != 1) {
  985. DRM_ERROR("bad CONTEXT_CONTROL\n");
  986. return -EINVAL;
  987. }
  988. break;
  989. case PACKET3_INDEX_TYPE:
  990. case PACKET3_NUM_INSTANCES:
  991. case PACKET3_CLEAR_STATE:
  992. if (pkt->count) {
  993. DRM_ERROR("bad INDEX_TYPE/NUM_INSTANCES/CLEAR_STATE\n");
  994. return -EINVAL;
  995. }
  996. break;
  997. case CAYMAN_PACKET3_DEALLOC_STATE:
  998. if (p->rdev->family < CHIP_CAYMAN) {
  999. DRM_ERROR("bad PACKET3_DEALLOC_STATE\n");
  1000. return -EINVAL;
  1001. }
  1002. if (pkt->count) {
  1003. DRM_ERROR("bad INDEX_TYPE/NUM_INSTANCES/CLEAR_STATE\n");
  1004. return -EINVAL;
  1005. }
  1006. break;
  1007. case PACKET3_INDEX_BASE:
  1008. if (pkt->count != 1) {
  1009. DRM_ERROR("bad INDEX_BASE\n");
  1010. return -EINVAL;
  1011. }
  1012. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1013. if (r) {
  1014. DRM_ERROR("bad INDEX_BASE\n");
  1015. return -EINVAL;
  1016. }
  1017. ib[idx+0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1018. ib[idx+1] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1019. r = evergreen_cs_track_check(p);
  1020. if (r) {
  1021. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1022. return r;
  1023. }
  1024. break;
  1025. case PACKET3_DRAW_INDEX:
  1026. if (pkt->count != 3) {
  1027. DRM_ERROR("bad DRAW_INDEX\n");
  1028. return -EINVAL;
  1029. }
  1030. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1031. if (r) {
  1032. DRM_ERROR("bad DRAW_INDEX\n");
  1033. return -EINVAL;
  1034. }
  1035. ib[idx+0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1036. ib[idx+1] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1037. r = evergreen_cs_track_check(p);
  1038. if (r) {
  1039. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1040. return r;
  1041. }
  1042. break;
  1043. case PACKET3_DRAW_INDEX_2:
  1044. if (pkt->count != 4) {
  1045. DRM_ERROR("bad DRAW_INDEX_2\n");
  1046. return -EINVAL;
  1047. }
  1048. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1049. if (r) {
  1050. DRM_ERROR("bad DRAW_INDEX_2\n");
  1051. return -EINVAL;
  1052. }
  1053. ib[idx+1] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1054. ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1055. r = evergreen_cs_track_check(p);
  1056. if (r) {
  1057. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1058. return r;
  1059. }
  1060. break;
  1061. case PACKET3_DRAW_INDEX_AUTO:
  1062. if (pkt->count != 1) {
  1063. DRM_ERROR("bad DRAW_INDEX_AUTO\n");
  1064. return -EINVAL;
  1065. }
  1066. r = evergreen_cs_track_check(p);
  1067. if (r) {
  1068. dev_warn(p->dev, "%s:%d invalid cmd stream %d\n", __func__, __LINE__, idx);
  1069. return r;
  1070. }
  1071. break;
  1072. case PACKET3_DRAW_INDEX_MULTI_AUTO:
  1073. if (pkt->count != 2) {
  1074. DRM_ERROR("bad DRAW_INDEX_MULTI_AUTO\n");
  1075. return -EINVAL;
  1076. }
  1077. r = evergreen_cs_track_check(p);
  1078. if (r) {
  1079. dev_warn(p->dev, "%s:%d invalid cmd stream %d\n", __func__, __LINE__, idx);
  1080. return r;
  1081. }
  1082. break;
  1083. case PACKET3_DRAW_INDEX_IMMD:
  1084. if (pkt->count < 2) {
  1085. DRM_ERROR("bad DRAW_INDEX_IMMD\n");
  1086. return -EINVAL;
  1087. }
  1088. r = evergreen_cs_track_check(p);
  1089. if (r) {
  1090. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1091. return r;
  1092. }
  1093. break;
  1094. case PACKET3_DRAW_INDEX_OFFSET:
  1095. if (pkt->count != 2) {
  1096. DRM_ERROR("bad DRAW_INDEX_OFFSET\n");
  1097. return -EINVAL;
  1098. }
  1099. r = evergreen_cs_track_check(p);
  1100. if (r) {
  1101. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1102. return r;
  1103. }
  1104. break;
  1105. case PACKET3_DRAW_INDEX_OFFSET_2:
  1106. if (pkt->count != 3) {
  1107. DRM_ERROR("bad DRAW_INDEX_OFFSET_2\n");
  1108. return -EINVAL;
  1109. }
  1110. r = evergreen_cs_track_check(p);
  1111. if (r) {
  1112. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1113. return r;
  1114. }
  1115. break;
  1116. case PACKET3_DISPATCH_DIRECT:
  1117. if (pkt->count != 3) {
  1118. DRM_ERROR("bad DISPATCH_DIRECT\n");
  1119. return -EINVAL;
  1120. }
  1121. r = evergreen_cs_track_check(p);
  1122. if (r) {
  1123. dev_warn(p->dev, "%s:%d invalid cmd stream %d\n", __func__, __LINE__, idx);
  1124. return r;
  1125. }
  1126. break;
  1127. case PACKET3_DISPATCH_INDIRECT:
  1128. if (pkt->count != 1) {
  1129. DRM_ERROR("bad DISPATCH_INDIRECT\n");
  1130. return -EINVAL;
  1131. }
  1132. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1133. if (r) {
  1134. DRM_ERROR("bad DISPATCH_INDIRECT\n");
  1135. return -EINVAL;
  1136. }
  1137. ib[idx+0] = idx_value + (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1138. r = evergreen_cs_track_check(p);
  1139. if (r) {
  1140. dev_warn(p->dev, "%s:%d invalid cmd stream\n", __func__, __LINE__);
  1141. return r;
  1142. }
  1143. break;
  1144. case PACKET3_WAIT_REG_MEM:
  1145. if (pkt->count != 5) {
  1146. DRM_ERROR("bad WAIT_REG_MEM\n");
  1147. return -EINVAL;
  1148. }
  1149. /* bit 4 is reg (0) or mem (1) */
  1150. if (idx_value & 0x10) {
  1151. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1152. if (r) {
  1153. DRM_ERROR("bad WAIT_REG_MEM\n");
  1154. return -EINVAL;
  1155. }
  1156. ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1157. ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1158. }
  1159. break;
  1160. case PACKET3_SURFACE_SYNC:
  1161. if (pkt->count != 3) {
  1162. DRM_ERROR("bad SURFACE_SYNC\n");
  1163. return -EINVAL;
  1164. }
  1165. /* 0xffffffff/0x0 is flush all cache flag */
  1166. if (radeon_get_ib_value(p, idx + 1) != 0xffffffff ||
  1167. radeon_get_ib_value(p, idx + 2) != 0) {
  1168. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1169. if (r) {
  1170. DRM_ERROR("bad SURFACE_SYNC\n");
  1171. return -EINVAL;
  1172. }
  1173. ib[idx+2] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  1174. }
  1175. break;
  1176. case PACKET3_EVENT_WRITE:
  1177. if (pkt->count != 2 && pkt->count != 0) {
  1178. DRM_ERROR("bad EVENT_WRITE\n");
  1179. return -EINVAL;
  1180. }
  1181. if (pkt->count) {
  1182. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1183. if (r) {
  1184. DRM_ERROR("bad EVENT_WRITE\n");
  1185. return -EINVAL;
  1186. }
  1187. ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1188. ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1189. }
  1190. break;
  1191. case PACKET3_EVENT_WRITE_EOP:
  1192. if (pkt->count != 4) {
  1193. DRM_ERROR("bad EVENT_WRITE_EOP\n");
  1194. return -EINVAL;
  1195. }
  1196. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1197. if (r) {
  1198. DRM_ERROR("bad EVENT_WRITE_EOP\n");
  1199. return -EINVAL;
  1200. }
  1201. ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1202. ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1203. break;
  1204. case PACKET3_EVENT_WRITE_EOS:
  1205. if (pkt->count != 3) {
  1206. DRM_ERROR("bad EVENT_WRITE_EOS\n");
  1207. return -EINVAL;
  1208. }
  1209. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1210. if (r) {
  1211. DRM_ERROR("bad EVENT_WRITE_EOS\n");
  1212. return -EINVAL;
  1213. }
  1214. ib[idx+1] += (u32)(reloc->lobj.gpu_offset & 0xffffffff);
  1215. ib[idx+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1216. break;
  1217. case PACKET3_SET_CONFIG_REG:
  1218. start_reg = (idx_value << 2) + PACKET3_SET_CONFIG_REG_START;
  1219. end_reg = 4 * pkt->count + start_reg - 4;
  1220. if ((start_reg < PACKET3_SET_CONFIG_REG_START) ||
  1221. (start_reg >= PACKET3_SET_CONFIG_REG_END) ||
  1222. (end_reg >= PACKET3_SET_CONFIG_REG_END)) {
  1223. DRM_ERROR("bad PACKET3_SET_CONFIG_REG\n");
  1224. return -EINVAL;
  1225. }
  1226. for (i = 0; i < pkt->count; i++) {
  1227. reg = start_reg + (4 * i);
  1228. r = evergreen_cs_check_reg(p, reg, idx+1+i);
  1229. if (r)
  1230. return r;
  1231. }
  1232. break;
  1233. case PACKET3_SET_CONTEXT_REG:
  1234. start_reg = (idx_value << 2) + PACKET3_SET_CONTEXT_REG_START;
  1235. end_reg = 4 * pkt->count + start_reg - 4;
  1236. if ((start_reg < PACKET3_SET_CONTEXT_REG_START) ||
  1237. (start_reg >= PACKET3_SET_CONTEXT_REG_END) ||
  1238. (end_reg >= PACKET3_SET_CONTEXT_REG_END)) {
  1239. DRM_ERROR("bad PACKET3_SET_CONTEXT_REG\n");
  1240. return -EINVAL;
  1241. }
  1242. for (i = 0; i < pkt->count; i++) {
  1243. reg = start_reg + (4 * i);
  1244. r = evergreen_cs_check_reg(p, reg, idx+1+i);
  1245. if (r)
  1246. return r;
  1247. }
  1248. break;
  1249. case PACKET3_SET_RESOURCE:
  1250. if (pkt->count % 8) {
  1251. DRM_ERROR("bad SET_RESOURCE\n");
  1252. return -EINVAL;
  1253. }
  1254. start_reg = (idx_value << 2) + PACKET3_SET_RESOURCE_START;
  1255. end_reg = 4 * pkt->count + start_reg - 4;
  1256. if ((start_reg < PACKET3_SET_RESOURCE_START) ||
  1257. (start_reg >= PACKET3_SET_RESOURCE_END) ||
  1258. (end_reg >= PACKET3_SET_RESOURCE_END)) {
  1259. DRM_ERROR("bad SET_RESOURCE\n");
  1260. return -EINVAL;
  1261. }
  1262. for (i = 0; i < (pkt->count / 8); i++) {
  1263. struct radeon_bo *texture, *mipmap;
  1264. u32 size, offset;
  1265. switch (G__SQ_CONSTANT_TYPE(radeon_get_ib_value(p, idx+1+(i*8)+7))) {
  1266. case SQ_TEX_VTX_VALID_TEXTURE:
  1267. /* tex base */
  1268. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1269. if (r) {
  1270. DRM_ERROR("bad SET_RESOURCE (tex)\n");
  1271. return -EINVAL;
  1272. }
  1273. ib[idx+1+(i*8)+2] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  1274. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
  1275. ib[idx+1+(i*8)+1] |= TEX_ARRAY_MODE(ARRAY_2D_TILED_THIN1);
  1276. else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
  1277. ib[idx+1+(i*8)+1] |= TEX_ARRAY_MODE(ARRAY_1D_TILED_THIN1);
  1278. texture = reloc->robj;
  1279. /* tex mip base */
  1280. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1281. if (r) {
  1282. DRM_ERROR("bad SET_RESOURCE (tex)\n");
  1283. return -EINVAL;
  1284. }
  1285. ib[idx+1+(i*8)+3] += (u32)((reloc->lobj.gpu_offset >> 8) & 0xffffffff);
  1286. mipmap = reloc->robj;
  1287. r = evergreen_check_texture_resource(p, idx+1+(i*8),
  1288. texture, mipmap);
  1289. if (r)
  1290. return r;
  1291. break;
  1292. case SQ_TEX_VTX_VALID_BUFFER:
  1293. /* vtx base */
  1294. r = evergreen_cs_packet_next_reloc(p, &reloc);
  1295. if (r) {
  1296. DRM_ERROR("bad SET_RESOURCE (vtx)\n");
  1297. return -EINVAL;
  1298. }
  1299. offset = radeon_get_ib_value(p, idx+1+(i*8)+0);
  1300. size = radeon_get_ib_value(p, idx+1+(i*8)+1);
  1301. if (p->rdev && (size + offset) > radeon_bo_size(reloc->robj)) {
  1302. /* force size to size of the buffer */
  1303. dev_warn(p->dev, "vbo resource seems too big for the bo\n");
  1304. ib[idx+1+(i*8)+1] = radeon_bo_size(reloc->robj);
  1305. }
  1306. ib[idx+1+(i*8)+0] += (u32)((reloc->lobj.gpu_offset) & 0xffffffff);
  1307. ib[idx+1+(i*8)+2] += upper_32_bits(reloc->lobj.gpu_offset) & 0xff;
  1308. break;
  1309. case SQ_TEX_VTX_INVALID_TEXTURE:
  1310. case SQ_TEX_VTX_INVALID_BUFFER:
  1311. default:
  1312. DRM_ERROR("bad SET_RESOURCE\n");
  1313. return -EINVAL;
  1314. }
  1315. }
  1316. break;
  1317. case PACKET3_SET_ALU_CONST:
  1318. /* XXX fix me ALU const buffers only */
  1319. break;
  1320. case PACKET3_SET_BOOL_CONST:
  1321. start_reg = (idx_value << 2) + PACKET3_SET_BOOL_CONST_START;
  1322. end_reg = 4 * pkt->count + start_reg - 4;
  1323. if ((start_reg < PACKET3_SET_BOOL_CONST_START) ||
  1324. (start_reg >= PACKET3_SET_BOOL_CONST_END) ||
  1325. (end_reg >= PACKET3_SET_BOOL_CONST_END)) {
  1326. DRM_ERROR("bad SET_BOOL_CONST\n");
  1327. return -EINVAL;
  1328. }
  1329. break;
  1330. case PACKET3_SET_LOOP_CONST:
  1331. start_reg = (idx_value << 2) + PACKET3_SET_LOOP_CONST_START;
  1332. end_reg = 4 * pkt->count + start_reg - 4;
  1333. if ((start_reg < PACKET3_SET_LOOP_CONST_START) ||
  1334. (start_reg >= PACKET3_SET_LOOP_CONST_END) ||
  1335. (end_reg >= PACKET3_SET_LOOP_CONST_END)) {
  1336. DRM_ERROR("bad SET_LOOP_CONST\n");
  1337. return -EINVAL;
  1338. }
  1339. break;
  1340. case PACKET3_SET_CTL_CONST:
  1341. start_reg = (idx_value << 2) + PACKET3_SET_CTL_CONST_START;
  1342. end_reg = 4 * pkt->count + start_reg - 4;
  1343. if ((start_reg < PACKET3_SET_CTL_CONST_START) ||
  1344. (start_reg >= PACKET3_SET_CTL_CONST_END) ||
  1345. (end_reg >= PACKET3_SET_CTL_CONST_END)) {
  1346. DRM_ERROR("bad SET_CTL_CONST\n");
  1347. return -EINVAL;
  1348. }
  1349. break;
  1350. case PACKET3_SET_SAMPLER:
  1351. if (pkt->count % 3) {
  1352. DRM_ERROR("bad SET_SAMPLER\n");
  1353. return -EINVAL;
  1354. }
  1355. start_reg = (idx_value << 2) + PACKET3_SET_SAMPLER_START;
  1356. end_reg = 4 * pkt->count + start_reg - 4;
  1357. if ((start_reg < PACKET3_SET_SAMPLER_START) ||
  1358. (start_reg >= PACKET3_SET_SAMPLER_END) ||
  1359. (end_reg >= PACKET3_SET_SAMPLER_END)) {
  1360. DRM_ERROR("bad SET_SAMPLER\n");
  1361. return -EINVAL;
  1362. }
  1363. break;
  1364. case PACKET3_NOP:
  1365. break;
  1366. default:
  1367. DRM_ERROR("Packet3 opcode %x not supported\n", pkt->opcode);
  1368. return -EINVAL;
  1369. }
  1370. return 0;
  1371. }
  1372. int evergreen_cs_parse(struct radeon_cs_parser *p)
  1373. {
  1374. struct radeon_cs_packet pkt;
  1375. struct evergreen_cs_track *track;
  1376. int r;
  1377. if (p->track == NULL) {
  1378. /* initialize tracker, we are in kms */
  1379. track = kzalloc(sizeof(*track), GFP_KERNEL);
  1380. if (track == NULL)
  1381. return -ENOMEM;
  1382. evergreen_cs_track_init(track);
  1383. track->npipes = p->rdev->config.evergreen.tiling_npipes;
  1384. track->nbanks = p->rdev->config.evergreen.tiling_nbanks;
  1385. track->group_size = p->rdev->config.evergreen.tiling_group_size;
  1386. p->track = track;
  1387. }
  1388. do {
  1389. r = evergreen_cs_packet_parse(p, &pkt, p->idx);
  1390. if (r) {
  1391. kfree(p->track);
  1392. p->track = NULL;
  1393. return r;
  1394. }
  1395. p->idx += pkt.count + 2;
  1396. switch (pkt.type) {
  1397. case PACKET_TYPE0:
  1398. r = evergreen_cs_parse_packet0(p, &pkt);
  1399. break;
  1400. case PACKET_TYPE2:
  1401. break;
  1402. case PACKET_TYPE3:
  1403. r = evergreen_packet3_check(p, &pkt);
  1404. break;
  1405. default:
  1406. DRM_ERROR("Unknown packet type %d !\n", pkt.type);
  1407. kfree(p->track);
  1408. p->track = NULL;
  1409. return -EINVAL;
  1410. }
  1411. if (r) {
  1412. kfree(p->track);
  1413. p->track = NULL;
  1414. return r;
  1415. }
  1416. } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
  1417. #if 0
  1418. for (r = 0; r < p->ib->length_dw; r++) {
  1419. printk(KERN_INFO "%05d 0x%08X\n", r, p->ib->ptr[r]);
  1420. mdelay(1);
  1421. }
  1422. #endif
  1423. kfree(p->track);
  1424. p->track = NULL;
  1425. return 0;
  1426. }