r300.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  1. /*
  2. * Copyright 2008 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 <linux/seq_file.h>
  29. #include <linux/slab.h>
  30. #include <drm/drmP.h>
  31. #include <drm/drm.h>
  32. #include <drm/drm_crtc_helper.h>
  33. #include "radeon_reg.h"
  34. #include "radeon.h"
  35. #include "radeon_asic.h"
  36. #include "radeon_drm.h"
  37. #include "r100_track.h"
  38. #include "r300d.h"
  39. #include "rv350d.h"
  40. #include "r300_reg_safe.h"
  41. /* This files gather functions specifics to: r300,r350,rv350,rv370,rv380
  42. *
  43. * GPU Errata:
  44. * - HOST_PATH_CNTL: r300 family seems to dislike write to HOST_PATH_CNTL
  45. * using MMIO to flush host path read cache, this lead to HARDLOCKUP.
  46. * However, scheduling such write to the ring seems harmless, i suspect
  47. * the CP read collide with the flush somehow, or maybe the MC, hard to
  48. * tell. (Jerome Glisse)
  49. */
  50. /*
  51. * rv370,rv380 PCIE GART
  52. */
  53. static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev);
  54. void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
  55. {
  56. uint32_t tmp;
  57. int i;
  58. /* Workaround HW bug do flush 2 times */
  59. for (i = 0; i < 2; i++) {
  60. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
  61. WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB);
  62. (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
  63. WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
  64. }
  65. mb();
  66. }
  67. #define R300_PTE_WRITEABLE (1 << 2)
  68. #define R300_PTE_READABLE (1 << 3)
  69. int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
  70. {
  71. void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
  72. if (i < 0 || i > rdev->gart.num_gpu_pages) {
  73. return -EINVAL;
  74. }
  75. addr = (lower_32_bits(addr) >> 8) |
  76. ((upper_32_bits(addr) & 0xff) << 24) |
  77. R300_PTE_WRITEABLE | R300_PTE_READABLE;
  78. /* on x86 we want this to be CPU endian, on powerpc
  79. * on powerpc without HW swappers, it'll get swapped on way
  80. * into VRAM - so no need for cpu_to_le32 on VRAM tables */
  81. writel(addr, ((void __iomem *)ptr) + (i * 4));
  82. return 0;
  83. }
  84. int rv370_pcie_gart_init(struct radeon_device *rdev)
  85. {
  86. int r;
  87. if (rdev->gart.table.vram.robj) {
  88. WARN(1, "RV370 PCIE GART already initialized\n");
  89. return 0;
  90. }
  91. /* Initialize common gart structure */
  92. r = radeon_gart_init(rdev);
  93. if (r)
  94. return r;
  95. r = rv370_debugfs_pcie_gart_info_init(rdev);
  96. if (r)
  97. DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
  98. rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
  99. rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
  100. rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
  101. return radeon_gart_table_vram_alloc(rdev);
  102. }
  103. int rv370_pcie_gart_enable(struct radeon_device *rdev)
  104. {
  105. uint32_t table_addr;
  106. uint32_t tmp;
  107. int r;
  108. if (rdev->gart.table.vram.robj == NULL) {
  109. dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
  110. return -EINVAL;
  111. }
  112. r = radeon_gart_table_vram_pin(rdev);
  113. if (r)
  114. return r;
  115. radeon_gart_restore(rdev);
  116. /* discard memory request outside of configured range */
  117. tmp = RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
  118. WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
  119. WREG32_PCIE(RADEON_PCIE_TX_GART_START_LO, rdev->mc.gtt_start);
  120. tmp = rdev->mc.gtt_end & ~RADEON_GPU_PAGE_MASK;
  121. WREG32_PCIE(RADEON_PCIE_TX_GART_END_LO, tmp);
  122. WREG32_PCIE(RADEON_PCIE_TX_GART_START_HI, 0);
  123. WREG32_PCIE(RADEON_PCIE_TX_GART_END_HI, 0);
  124. table_addr = rdev->gart.table_addr;
  125. WREG32_PCIE(RADEON_PCIE_TX_GART_BASE, table_addr);
  126. /* FIXME: setup default page */
  127. WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, rdev->mc.vram_start);
  128. WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI, 0);
  129. /* Clear error */
  130. WREG32_PCIE(RADEON_PCIE_TX_GART_ERROR, 0);
  131. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
  132. tmp |= RADEON_PCIE_TX_GART_EN;
  133. tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
  134. WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
  135. rv370_pcie_gart_tlb_flush(rdev);
  136. DRM_INFO("PCIE GART of %uM enabled (table at 0x%08X).\n",
  137. (unsigned)(rdev->mc.gtt_size >> 20), table_addr);
  138. rdev->gart.ready = true;
  139. return 0;
  140. }
  141. void rv370_pcie_gart_disable(struct radeon_device *rdev)
  142. {
  143. u32 tmp;
  144. int r;
  145. WREG32_PCIE(RADEON_PCIE_TX_GART_START_LO, 0);
  146. WREG32_PCIE(RADEON_PCIE_TX_GART_END_LO, 0);
  147. WREG32_PCIE(RADEON_PCIE_TX_GART_START_HI, 0);
  148. WREG32_PCIE(RADEON_PCIE_TX_GART_END_HI, 0);
  149. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
  150. tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
  151. WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp & ~RADEON_PCIE_TX_GART_EN);
  152. if (rdev->gart.table.vram.robj) {
  153. r = radeon_bo_reserve(rdev->gart.table.vram.robj, false);
  154. if (likely(r == 0)) {
  155. radeon_bo_kunmap(rdev->gart.table.vram.robj);
  156. radeon_bo_unpin(rdev->gart.table.vram.robj);
  157. radeon_bo_unreserve(rdev->gart.table.vram.robj);
  158. }
  159. }
  160. }
  161. void rv370_pcie_gart_fini(struct radeon_device *rdev)
  162. {
  163. radeon_gart_fini(rdev);
  164. rv370_pcie_gart_disable(rdev);
  165. radeon_gart_table_vram_free(rdev);
  166. }
  167. void r300_fence_ring_emit(struct radeon_device *rdev,
  168. struct radeon_fence *fence)
  169. {
  170. /* Who ever call radeon_fence_emit should call ring_lock and ask
  171. * for enough space (today caller are ib schedule and buffer move) */
  172. /* Write SC register so SC & US assert idle */
  173. radeon_ring_write(rdev, PACKET0(R300_RE_SCISSORS_TL, 0));
  174. radeon_ring_write(rdev, 0);
  175. radeon_ring_write(rdev, PACKET0(R300_RE_SCISSORS_BR, 0));
  176. radeon_ring_write(rdev, 0);
  177. /* Flush 3D cache */
  178. radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
  179. radeon_ring_write(rdev, R300_RB3D_DC_FLUSH);
  180. radeon_ring_write(rdev, PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0));
  181. radeon_ring_write(rdev, R300_ZC_FLUSH);
  182. /* Wait until IDLE & CLEAN */
  183. radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
  184. radeon_ring_write(rdev, (RADEON_WAIT_3D_IDLECLEAN |
  185. RADEON_WAIT_2D_IDLECLEAN |
  186. RADEON_WAIT_DMA_GUI_IDLE));
  187. radeon_ring_write(rdev, PACKET0(RADEON_HOST_PATH_CNTL, 0));
  188. radeon_ring_write(rdev, rdev->config.r300.hdp_cntl |
  189. RADEON_HDP_READ_BUFFER_INVALIDATE);
  190. radeon_ring_write(rdev, PACKET0(RADEON_HOST_PATH_CNTL, 0));
  191. radeon_ring_write(rdev, rdev->config.r300.hdp_cntl);
  192. /* Emit fence sequence & fire IRQ */
  193. radeon_ring_write(rdev, PACKET0(rdev->fence_drv.scratch_reg, 0));
  194. radeon_ring_write(rdev, fence->seq);
  195. radeon_ring_write(rdev, PACKET0(RADEON_GEN_INT_STATUS, 0));
  196. radeon_ring_write(rdev, RADEON_SW_INT_FIRE);
  197. }
  198. void r300_ring_start(struct radeon_device *rdev)
  199. {
  200. unsigned gb_tile_config;
  201. int r;
  202. /* Sub pixel 1/12 so we can have 4K rendering according to doc */
  203. gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16);
  204. switch(rdev->num_gb_pipes) {
  205. case 2:
  206. gb_tile_config |= R300_PIPE_COUNT_R300;
  207. break;
  208. case 3:
  209. gb_tile_config |= R300_PIPE_COUNT_R420_3P;
  210. break;
  211. case 4:
  212. gb_tile_config |= R300_PIPE_COUNT_R420;
  213. break;
  214. case 1:
  215. default:
  216. gb_tile_config |= R300_PIPE_COUNT_RV350;
  217. break;
  218. }
  219. r = radeon_ring_lock(rdev, 64);
  220. if (r) {
  221. return;
  222. }
  223. radeon_ring_write(rdev, PACKET0(RADEON_ISYNC_CNTL, 0));
  224. radeon_ring_write(rdev,
  225. RADEON_ISYNC_ANY2D_IDLE3D |
  226. RADEON_ISYNC_ANY3D_IDLE2D |
  227. RADEON_ISYNC_WAIT_IDLEGUI |
  228. RADEON_ISYNC_CPSCRATCH_IDLEGUI);
  229. radeon_ring_write(rdev, PACKET0(R300_GB_TILE_CONFIG, 0));
  230. radeon_ring_write(rdev, gb_tile_config);
  231. radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
  232. radeon_ring_write(rdev,
  233. RADEON_WAIT_2D_IDLECLEAN |
  234. RADEON_WAIT_3D_IDLECLEAN);
  235. radeon_ring_write(rdev, PACKET0(R300_DST_PIPE_CONFIG, 0));
  236. radeon_ring_write(rdev, R300_PIPE_AUTO_CONFIG);
  237. radeon_ring_write(rdev, PACKET0(R300_GB_SELECT, 0));
  238. radeon_ring_write(rdev, 0);
  239. radeon_ring_write(rdev, PACKET0(R300_GB_ENABLE, 0));
  240. radeon_ring_write(rdev, 0);
  241. radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
  242. radeon_ring_write(rdev, R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);
  243. radeon_ring_write(rdev, PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0));
  244. radeon_ring_write(rdev, R300_ZC_FLUSH | R300_ZC_FREE);
  245. radeon_ring_write(rdev, PACKET0(RADEON_WAIT_UNTIL, 0));
  246. radeon_ring_write(rdev,
  247. RADEON_WAIT_2D_IDLECLEAN |
  248. RADEON_WAIT_3D_IDLECLEAN);
  249. radeon_ring_write(rdev, PACKET0(R300_GB_AA_CONFIG, 0));
  250. radeon_ring_write(rdev, 0);
  251. radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
  252. radeon_ring_write(rdev, R300_RB3D_DC_FLUSH | R300_RB3D_DC_FREE);
  253. radeon_ring_write(rdev, PACKET0(R300_RB3D_ZCACHE_CTLSTAT, 0));
  254. radeon_ring_write(rdev, R300_ZC_FLUSH | R300_ZC_FREE);
  255. radeon_ring_write(rdev, PACKET0(R300_GB_MSPOS0, 0));
  256. radeon_ring_write(rdev,
  257. ((6 << R300_MS_X0_SHIFT) |
  258. (6 << R300_MS_Y0_SHIFT) |
  259. (6 << R300_MS_X1_SHIFT) |
  260. (6 << R300_MS_Y1_SHIFT) |
  261. (6 << R300_MS_X2_SHIFT) |
  262. (6 << R300_MS_Y2_SHIFT) |
  263. (6 << R300_MSBD0_Y_SHIFT) |
  264. (6 << R300_MSBD0_X_SHIFT)));
  265. radeon_ring_write(rdev, PACKET0(R300_GB_MSPOS1, 0));
  266. radeon_ring_write(rdev,
  267. ((6 << R300_MS_X3_SHIFT) |
  268. (6 << R300_MS_Y3_SHIFT) |
  269. (6 << R300_MS_X4_SHIFT) |
  270. (6 << R300_MS_Y4_SHIFT) |
  271. (6 << R300_MS_X5_SHIFT) |
  272. (6 << R300_MS_Y5_SHIFT) |
  273. (6 << R300_MSBD1_SHIFT)));
  274. radeon_ring_write(rdev, PACKET0(R300_GA_ENHANCE, 0));
  275. radeon_ring_write(rdev, R300_GA_DEADLOCK_CNTL | R300_GA_FASTSYNC_CNTL);
  276. radeon_ring_write(rdev, PACKET0(R300_GA_POLY_MODE, 0));
  277. radeon_ring_write(rdev,
  278. R300_FRONT_PTYPE_TRIANGE | R300_BACK_PTYPE_TRIANGE);
  279. radeon_ring_write(rdev, PACKET0(R300_GA_ROUND_MODE, 0));
  280. radeon_ring_write(rdev,
  281. R300_GEOMETRY_ROUND_NEAREST |
  282. R300_COLOR_ROUND_NEAREST);
  283. radeon_ring_unlock_commit(rdev);
  284. }
  285. void r300_errata(struct radeon_device *rdev)
  286. {
  287. rdev->pll_errata = 0;
  288. if (rdev->family == CHIP_R300 &&
  289. (RREG32(RADEON_CONFIG_CNTL) & RADEON_CFG_ATI_REV_ID_MASK) == RADEON_CFG_ATI_REV_A11) {
  290. rdev->pll_errata |= CHIP_ERRATA_R300_CG;
  291. }
  292. }
  293. int r300_mc_wait_for_idle(struct radeon_device *rdev)
  294. {
  295. unsigned i;
  296. uint32_t tmp;
  297. for (i = 0; i < rdev->usec_timeout; i++) {
  298. /* read MC_STATUS */
  299. tmp = RREG32(RADEON_MC_STATUS);
  300. if (tmp & R300_MC_IDLE) {
  301. return 0;
  302. }
  303. DRM_UDELAY(1);
  304. }
  305. return -1;
  306. }
  307. void r300_gpu_init(struct radeon_device *rdev)
  308. {
  309. uint32_t gb_tile_config, tmp;
  310. if ((rdev->family == CHIP_R300 && rdev->pdev->device != 0x4144) ||
  311. (rdev->family == CHIP_R350 && rdev->pdev->device != 0x4148)) {
  312. /* r300,r350 */
  313. rdev->num_gb_pipes = 2;
  314. } else {
  315. /* rv350,rv370,rv380,r300 AD, r350 AH */
  316. rdev->num_gb_pipes = 1;
  317. }
  318. rdev->num_z_pipes = 1;
  319. gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16);
  320. switch (rdev->num_gb_pipes) {
  321. case 2:
  322. gb_tile_config |= R300_PIPE_COUNT_R300;
  323. break;
  324. case 3:
  325. gb_tile_config |= R300_PIPE_COUNT_R420_3P;
  326. break;
  327. case 4:
  328. gb_tile_config |= R300_PIPE_COUNT_R420;
  329. break;
  330. default:
  331. case 1:
  332. gb_tile_config |= R300_PIPE_COUNT_RV350;
  333. break;
  334. }
  335. WREG32(R300_GB_TILE_CONFIG, gb_tile_config);
  336. if (r100_gui_wait_for_idle(rdev)) {
  337. printk(KERN_WARNING "Failed to wait GUI idle while "
  338. "programming pipes. Bad things might happen.\n");
  339. }
  340. tmp = RREG32(R300_DST_PIPE_CONFIG);
  341. WREG32(R300_DST_PIPE_CONFIG, tmp | R300_PIPE_AUTO_CONFIG);
  342. WREG32(R300_RB2D_DSTCACHE_MODE,
  343. R300_DC_AUTOFLUSH_ENABLE |
  344. R300_DC_DC_DISABLE_IGNORE_PE);
  345. if (r100_gui_wait_for_idle(rdev)) {
  346. printk(KERN_WARNING "Failed to wait GUI idle while "
  347. "programming pipes. Bad things might happen.\n");
  348. }
  349. if (r300_mc_wait_for_idle(rdev)) {
  350. printk(KERN_WARNING "Failed to wait MC idle while "
  351. "programming pipes. Bad things might happen.\n");
  352. }
  353. DRM_INFO("radeon: %d quad pipes, %d Z pipes initialized.\n",
  354. rdev->num_gb_pipes, rdev->num_z_pipes);
  355. }
  356. bool r300_gpu_is_lockup(struct radeon_device *rdev)
  357. {
  358. u32 rbbm_status;
  359. int r;
  360. rbbm_status = RREG32(R_000E40_RBBM_STATUS);
  361. if (!G_000E40_GUI_ACTIVE(rbbm_status)) {
  362. r100_gpu_lockup_update(&rdev->config.r300.lockup, &rdev->cp);
  363. return false;
  364. }
  365. /* force CP activities */
  366. r = radeon_ring_lock(rdev, 2);
  367. if (!r) {
  368. /* PACKET2 NOP */
  369. radeon_ring_write(rdev, 0x80000000);
  370. radeon_ring_write(rdev, 0x80000000);
  371. radeon_ring_unlock_commit(rdev);
  372. }
  373. rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
  374. return r100_gpu_cp_is_lockup(rdev, &rdev->config.r300.lockup, &rdev->cp);
  375. }
  376. int r300_asic_reset(struct radeon_device *rdev)
  377. {
  378. struct r100_mc_save save;
  379. u32 status, tmp;
  380. int ret = 0;
  381. status = RREG32(R_000E40_RBBM_STATUS);
  382. if (!G_000E40_GUI_ACTIVE(status)) {
  383. return 0;
  384. }
  385. r100_mc_stop(rdev, &save);
  386. status = RREG32(R_000E40_RBBM_STATUS);
  387. dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
  388. /* stop CP */
  389. WREG32(RADEON_CP_CSQ_CNTL, 0);
  390. tmp = RREG32(RADEON_CP_RB_CNTL);
  391. WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA);
  392. WREG32(RADEON_CP_RB_RPTR_WR, 0);
  393. WREG32(RADEON_CP_RB_WPTR, 0);
  394. WREG32(RADEON_CP_RB_CNTL, tmp);
  395. /* save PCI state */
  396. pci_save_state(rdev->pdev);
  397. /* disable bus mastering */
  398. r100_bm_disable(rdev);
  399. WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) |
  400. S_0000F0_SOFT_RESET_GA(1));
  401. RREG32(R_0000F0_RBBM_SOFT_RESET);
  402. mdelay(500);
  403. WREG32(R_0000F0_RBBM_SOFT_RESET, 0);
  404. mdelay(1);
  405. status = RREG32(R_000E40_RBBM_STATUS);
  406. dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
  407. /* resetting the CP seems to be problematic sometimes it end up
  408. * hard locking the computer, but it's necessary for successful
  409. * reset more test & playing is needed on R3XX/R4XX to find a
  410. * reliable (if any solution)
  411. */
  412. WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_CP(1));
  413. RREG32(R_0000F0_RBBM_SOFT_RESET);
  414. mdelay(500);
  415. WREG32(R_0000F0_RBBM_SOFT_RESET, 0);
  416. mdelay(1);
  417. status = RREG32(R_000E40_RBBM_STATUS);
  418. dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
  419. /* restore PCI & busmastering */
  420. pci_restore_state(rdev->pdev);
  421. r100_enable_bm(rdev);
  422. /* Check if GPU is idle */
  423. if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) {
  424. dev_err(rdev->dev, "failed to reset GPU\n");
  425. rdev->gpu_lockup = true;
  426. ret = -1;
  427. } else
  428. dev_info(rdev->dev, "GPU reset succeed\n");
  429. r100_mc_resume(rdev, &save);
  430. return ret;
  431. }
  432. /*
  433. * r300,r350,rv350,rv380 VRAM info
  434. */
  435. void r300_mc_init(struct radeon_device *rdev)
  436. {
  437. u64 base;
  438. u32 tmp;
  439. /* DDR for all card after R300 & IGP */
  440. rdev->mc.vram_is_ddr = true;
  441. tmp = RREG32(RADEON_MEM_CNTL);
  442. tmp &= R300_MEM_NUM_CHANNELS_MASK;
  443. switch (tmp) {
  444. case 0: rdev->mc.vram_width = 64; break;
  445. case 1: rdev->mc.vram_width = 128; break;
  446. case 2: rdev->mc.vram_width = 256; break;
  447. default: rdev->mc.vram_width = 128; break;
  448. }
  449. r100_vram_init_sizes(rdev);
  450. base = rdev->mc.aper_base;
  451. if (rdev->flags & RADEON_IS_IGP)
  452. base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
  453. radeon_vram_location(rdev, &rdev->mc, base);
  454. rdev->mc.gtt_base_align = 0;
  455. if (!(rdev->flags & RADEON_IS_AGP))
  456. radeon_gtt_location(rdev, &rdev->mc);
  457. radeon_update_bandwidth_info(rdev);
  458. }
  459. void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes)
  460. {
  461. uint32_t link_width_cntl, mask;
  462. if (rdev->flags & RADEON_IS_IGP)
  463. return;
  464. if (!(rdev->flags & RADEON_IS_PCIE))
  465. return;
  466. /* FIXME wait for idle */
  467. switch (lanes) {
  468. case 0:
  469. mask = RADEON_PCIE_LC_LINK_WIDTH_X0;
  470. break;
  471. case 1:
  472. mask = RADEON_PCIE_LC_LINK_WIDTH_X1;
  473. break;
  474. case 2:
  475. mask = RADEON_PCIE_LC_LINK_WIDTH_X2;
  476. break;
  477. case 4:
  478. mask = RADEON_PCIE_LC_LINK_WIDTH_X4;
  479. break;
  480. case 8:
  481. mask = RADEON_PCIE_LC_LINK_WIDTH_X8;
  482. break;
  483. case 12:
  484. mask = RADEON_PCIE_LC_LINK_WIDTH_X12;
  485. break;
  486. case 16:
  487. default:
  488. mask = RADEON_PCIE_LC_LINK_WIDTH_X16;
  489. break;
  490. }
  491. link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
  492. if ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) ==
  493. (mask << RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT))
  494. return;
  495. link_width_cntl &= ~(RADEON_PCIE_LC_LINK_WIDTH_MASK |
  496. RADEON_PCIE_LC_RECONFIG_NOW |
  497. RADEON_PCIE_LC_RECONFIG_LATER |
  498. RADEON_PCIE_LC_SHORT_RECONFIG_EN);
  499. link_width_cntl |= mask;
  500. WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL, link_width_cntl);
  501. WREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL, (link_width_cntl |
  502. RADEON_PCIE_LC_RECONFIG_NOW));
  503. /* wait for lane set to complete */
  504. link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
  505. while (link_width_cntl == 0xffffffff)
  506. link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
  507. }
  508. int rv370_get_pcie_lanes(struct radeon_device *rdev)
  509. {
  510. u32 link_width_cntl;
  511. if (rdev->flags & RADEON_IS_IGP)
  512. return 0;
  513. if (!(rdev->flags & RADEON_IS_PCIE))
  514. return 0;
  515. /* FIXME wait for idle */
  516. link_width_cntl = RREG32_PCIE(RADEON_PCIE_LC_LINK_WIDTH_CNTL);
  517. switch ((link_width_cntl & RADEON_PCIE_LC_LINK_WIDTH_RD_MASK) >> RADEON_PCIE_LC_LINK_WIDTH_RD_SHIFT) {
  518. case RADEON_PCIE_LC_LINK_WIDTH_X0:
  519. return 0;
  520. case RADEON_PCIE_LC_LINK_WIDTH_X1:
  521. return 1;
  522. case RADEON_PCIE_LC_LINK_WIDTH_X2:
  523. return 2;
  524. case RADEON_PCIE_LC_LINK_WIDTH_X4:
  525. return 4;
  526. case RADEON_PCIE_LC_LINK_WIDTH_X8:
  527. return 8;
  528. case RADEON_PCIE_LC_LINK_WIDTH_X16:
  529. default:
  530. return 16;
  531. }
  532. }
  533. #if defined(CONFIG_DEBUG_FS)
  534. static int rv370_debugfs_pcie_gart_info(struct seq_file *m, void *data)
  535. {
  536. struct drm_info_node *node = (struct drm_info_node *) m->private;
  537. struct drm_device *dev = node->minor->dev;
  538. struct radeon_device *rdev = dev->dev_private;
  539. uint32_t tmp;
  540. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
  541. seq_printf(m, "PCIE_TX_GART_CNTL 0x%08x\n", tmp);
  542. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_BASE);
  543. seq_printf(m, "PCIE_TX_GART_BASE 0x%08x\n", tmp);
  544. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_START_LO);
  545. seq_printf(m, "PCIE_TX_GART_START_LO 0x%08x\n", tmp);
  546. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_START_HI);
  547. seq_printf(m, "PCIE_TX_GART_START_HI 0x%08x\n", tmp);
  548. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_END_LO);
  549. seq_printf(m, "PCIE_TX_GART_END_LO 0x%08x\n", tmp);
  550. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_END_HI);
  551. seq_printf(m, "PCIE_TX_GART_END_HI 0x%08x\n", tmp);
  552. tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_ERROR);
  553. seq_printf(m, "PCIE_TX_GART_ERROR 0x%08x\n", tmp);
  554. return 0;
  555. }
  556. static struct drm_info_list rv370_pcie_gart_info_list[] = {
  557. {"rv370_pcie_gart_info", rv370_debugfs_pcie_gart_info, 0, NULL},
  558. };
  559. #endif
  560. static int rv370_debugfs_pcie_gart_info_init(struct radeon_device *rdev)
  561. {
  562. #if defined(CONFIG_DEBUG_FS)
  563. return radeon_debugfs_add_files(rdev, rv370_pcie_gart_info_list, 1);
  564. #else
  565. return 0;
  566. #endif
  567. }
  568. static int r300_packet0_check(struct radeon_cs_parser *p,
  569. struct radeon_cs_packet *pkt,
  570. unsigned idx, unsigned reg)
  571. {
  572. struct radeon_cs_reloc *reloc;
  573. struct r100_cs_track *track;
  574. volatile uint32_t *ib;
  575. uint32_t tmp, tile_flags = 0;
  576. unsigned i;
  577. int r;
  578. u32 idx_value;
  579. ib = p->ib->ptr;
  580. track = (struct r100_cs_track *)p->track;
  581. idx_value = radeon_get_ib_value(p, idx);
  582. switch(reg) {
  583. case AVIVO_D1MODE_VLINE_START_END:
  584. case RADEON_CRTC_GUI_TRIG_VLINE:
  585. r = r100_cs_packet_parse_vline(p);
  586. if (r) {
  587. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  588. idx, reg);
  589. r100_cs_dump_packet(p, pkt);
  590. return r;
  591. }
  592. break;
  593. case RADEON_DST_PITCH_OFFSET:
  594. case RADEON_SRC_PITCH_OFFSET:
  595. r = r100_reloc_pitch_offset(p, pkt, idx, reg);
  596. if (r)
  597. return r;
  598. break;
  599. case R300_RB3D_COLOROFFSET0:
  600. case R300_RB3D_COLOROFFSET1:
  601. case R300_RB3D_COLOROFFSET2:
  602. case R300_RB3D_COLOROFFSET3:
  603. i = (reg - R300_RB3D_COLOROFFSET0) >> 2;
  604. r = r100_cs_packet_next_reloc(p, &reloc);
  605. if (r) {
  606. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  607. idx, reg);
  608. r100_cs_dump_packet(p, pkt);
  609. return r;
  610. }
  611. track->cb[i].robj = reloc->robj;
  612. track->cb[i].offset = idx_value;
  613. track->cb_dirty = true;
  614. ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
  615. break;
  616. case R300_ZB_DEPTHOFFSET:
  617. r = r100_cs_packet_next_reloc(p, &reloc);
  618. if (r) {
  619. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  620. idx, reg);
  621. r100_cs_dump_packet(p, pkt);
  622. return r;
  623. }
  624. track->zb.robj = reloc->robj;
  625. track->zb.offset = idx_value;
  626. track->zb_dirty = true;
  627. ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
  628. break;
  629. case R300_TX_OFFSET_0:
  630. case R300_TX_OFFSET_0+4:
  631. case R300_TX_OFFSET_0+8:
  632. case R300_TX_OFFSET_0+12:
  633. case R300_TX_OFFSET_0+16:
  634. case R300_TX_OFFSET_0+20:
  635. case R300_TX_OFFSET_0+24:
  636. case R300_TX_OFFSET_0+28:
  637. case R300_TX_OFFSET_0+32:
  638. case R300_TX_OFFSET_0+36:
  639. case R300_TX_OFFSET_0+40:
  640. case R300_TX_OFFSET_0+44:
  641. case R300_TX_OFFSET_0+48:
  642. case R300_TX_OFFSET_0+52:
  643. case R300_TX_OFFSET_0+56:
  644. case R300_TX_OFFSET_0+60:
  645. i = (reg - R300_TX_OFFSET_0) >> 2;
  646. r = r100_cs_packet_next_reloc(p, &reloc);
  647. if (r) {
  648. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  649. idx, reg);
  650. r100_cs_dump_packet(p, pkt);
  651. return r;
  652. }
  653. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
  654. tile_flags |= R300_TXO_MACRO_TILE;
  655. if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
  656. tile_flags |= R300_TXO_MICRO_TILE;
  657. else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO_SQUARE)
  658. tile_flags |= R300_TXO_MICRO_TILE_SQUARE;
  659. tmp = idx_value + ((u32)reloc->lobj.gpu_offset);
  660. tmp |= tile_flags;
  661. ib[idx] = tmp;
  662. track->textures[i].robj = reloc->robj;
  663. track->tex_dirty = true;
  664. break;
  665. /* Tracked registers */
  666. case 0x2084:
  667. /* VAP_VF_CNTL */
  668. track->vap_vf_cntl = idx_value;
  669. break;
  670. case 0x20B4:
  671. /* VAP_VTX_SIZE */
  672. track->vtx_size = idx_value & 0x7F;
  673. break;
  674. case 0x2134:
  675. /* VAP_VF_MAX_VTX_INDX */
  676. track->max_indx = idx_value & 0x00FFFFFFUL;
  677. break;
  678. case 0x2088:
  679. /* VAP_ALT_NUM_VERTICES - only valid on r500 */
  680. if (p->rdev->family < CHIP_RV515)
  681. goto fail;
  682. track->vap_alt_nverts = idx_value & 0xFFFFFF;
  683. break;
  684. case 0x43E4:
  685. /* SC_SCISSOR1 */
  686. track->maxy = ((idx_value >> 13) & 0x1FFF) + 1;
  687. if (p->rdev->family < CHIP_RV515) {
  688. track->maxy -= 1440;
  689. }
  690. track->cb_dirty = true;
  691. track->zb_dirty = true;
  692. break;
  693. case 0x4E00:
  694. /* RB3D_CCTL */
  695. if ((idx_value & (1 << 10)) && /* CMASK_ENABLE */
  696. p->rdev->cmask_filp != p->filp) {
  697. DRM_ERROR("Invalid RB3D_CCTL: Cannot enable CMASK.\n");
  698. return -EINVAL;
  699. }
  700. track->num_cb = ((idx_value >> 5) & 0x3) + 1;
  701. track->cb_dirty = true;
  702. break;
  703. case 0x4E38:
  704. case 0x4E3C:
  705. case 0x4E40:
  706. case 0x4E44:
  707. /* RB3D_COLORPITCH0 */
  708. /* RB3D_COLORPITCH1 */
  709. /* RB3D_COLORPITCH2 */
  710. /* RB3D_COLORPITCH3 */
  711. r = r100_cs_packet_next_reloc(p, &reloc);
  712. if (r) {
  713. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  714. idx, reg);
  715. r100_cs_dump_packet(p, pkt);
  716. return r;
  717. }
  718. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
  719. tile_flags |= R300_COLOR_TILE_ENABLE;
  720. if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
  721. tile_flags |= R300_COLOR_MICROTILE_ENABLE;
  722. else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO_SQUARE)
  723. tile_flags |= R300_COLOR_MICROTILE_SQUARE_ENABLE;
  724. tmp = idx_value & ~(0x7 << 16);
  725. tmp |= tile_flags;
  726. ib[idx] = tmp;
  727. i = (reg - 0x4E38) >> 2;
  728. track->cb[i].pitch = idx_value & 0x3FFE;
  729. switch (((idx_value >> 21) & 0xF)) {
  730. case 9:
  731. case 11:
  732. case 12:
  733. track->cb[i].cpp = 1;
  734. break;
  735. case 3:
  736. case 4:
  737. case 13:
  738. case 15:
  739. track->cb[i].cpp = 2;
  740. break;
  741. case 5:
  742. if (p->rdev->family < CHIP_RV515) {
  743. DRM_ERROR("Invalid color buffer format (%d)!\n",
  744. ((idx_value >> 21) & 0xF));
  745. return -EINVAL;
  746. }
  747. /* Pass through. */
  748. case 6:
  749. track->cb[i].cpp = 4;
  750. break;
  751. case 10:
  752. track->cb[i].cpp = 8;
  753. break;
  754. case 7:
  755. track->cb[i].cpp = 16;
  756. break;
  757. default:
  758. DRM_ERROR("Invalid color buffer format (%d) !\n",
  759. ((idx_value >> 21) & 0xF));
  760. return -EINVAL;
  761. }
  762. track->cb_dirty = true;
  763. break;
  764. case 0x4F00:
  765. /* ZB_CNTL */
  766. if (idx_value & 2) {
  767. track->z_enabled = true;
  768. } else {
  769. track->z_enabled = false;
  770. }
  771. track->zb_dirty = true;
  772. break;
  773. case 0x4F10:
  774. /* ZB_FORMAT */
  775. switch ((idx_value & 0xF)) {
  776. case 0:
  777. case 1:
  778. track->zb.cpp = 2;
  779. break;
  780. case 2:
  781. track->zb.cpp = 4;
  782. break;
  783. default:
  784. DRM_ERROR("Invalid z buffer format (%d) !\n",
  785. (idx_value & 0xF));
  786. return -EINVAL;
  787. }
  788. track->zb_dirty = true;
  789. break;
  790. case 0x4F24:
  791. /* ZB_DEPTHPITCH */
  792. r = r100_cs_packet_next_reloc(p, &reloc);
  793. if (r) {
  794. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  795. idx, reg);
  796. r100_cs_dump_packet(p, pkt);
  797. return r;
  798. }
  799. if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
  800. tile_flags |= R300_DEPTHMACROTILE_ENABLE;
  801. if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
  802. tile_flags |= R300_DEPTHMICROTILE_TILED;
  803. else if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO_SQUARE)
  804. tile_flags |= R300_DEPTHMICROTILE_TILED_SQUARE;
  805. tmp = idx_value & ~(0x7 << 16);
  806. tmp |= tile_flags;
  807. ib[idx] = tmp;
  808. track->zb.pitch = idx_value & 0x3FFC;
  809. track->zb_dirty = true;
  810. break;
  811. case 0x4104:
  812. /* TX_ENABLE */
  813. for (i = 0; i < 16; i++) {
  814. bool enabled;
  815. enabled = !!(idx_value & (1 << i));
  816. track->textures[i].enabled = enabled;
  817. }
  818. track->tex_dirty = true;
  819. break;
  820. case 0x44C0:
  821. case 0x44C4:
  822. case 0x44C8:
  823. case 0x44CC:
  824. case 0x44D0:
  825. case 0x44D4:
  826. case 0x44D8:
  827. case 0x44DC:
  828. case 0x44E0:
  829. case 0x44E4:
  830. case 0x44E8:
  831. case 0x44EC:
  832. case 0x44F0:
  833. case 0x44F4:
  834. case 0x44F8:
  835. case 0x44FC:
  836. /* TX_FORMAT1_[0-15] */
  837. i = (reg - 0x44C0) >> 2;
  838. tmp = (idx_value >> 25) & 0x3;
  839. track->textures[i].tex_coord_type = tmp;
  840. switch ((idx_value & 0x1F)) {
  841. case R300_TX_FORMAT_X8:
  842. case R300_TX_FORMAT_Y4X4:
  843. case R300_TX_FORMAT_Z3Y3X2:
  844. track->textures[i].cpp = 1;
  845. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  846. break;
  847. case R300_TX_FORMAT_X16:
  848. case R300_TX_FORMAT_FL_I16:
  849. case R300_TX_FORMAT_Y8X8:
  850. case R300_TX_FORMAT_Z5Y6X5:
  851. case R300_TX_FORMAT_Z6Y5X5:
  852. case R300_TX_FORMAT_W4Z4Y4X4:
  853. case R300_TX_FORMAT_W1Z5Y5X5:
  854. case R300_TX_FORMAT_D3DMFT_CxV8U8:
  855. case R300_TX_FORMAT_B8G8_B8G8:
  856. case R300_TX_FORMAT_G8R8_G8B8:
  857. track->textures[i].cpp = 2;
  858. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  859. break;
  860. case R300_TX_FORMAT_Y16X16:
  861. case R300_TX_FORMAT_FL_I16A16:
  862. case R300_TX_FORMAT_Z11Y11X10:
  863. case R300_TX_FORMAT_Z10Y11X11:
  864. case R300_TX_FORMAT_W8Z8Y8X8:
  865. case R300_TX_FORMAT_W2Z10Y10X10:
  866. case 0x17:
  867. case R300_TX_FORMAT_FL_I32:
  868. case 0x1e:
  869. track->textures[i].cpp = 4;
  870. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  871. break;
  872. case R300_TX_FORMAT_W16Z16Y16X16:
  873. case R300_TX_FORMAT_FL_R16G16B16A16:
  874. case R300_TX_FORMAT_FL_I32A32:
  875. track->textures[i].cpp = 8;
  876. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  877. break;
  878. case R300_TX_FORMAT_FL_R32G32B32A32:
  879. track->textures[i].cpp = 16;
  880. track->textures[i].compress_format = R100_TRACK_COMP_NONE;
  881. break;
  882. case R300_TX_FORMAT_DXT1:
  883. track->textures[i].cpp = 1;
  884. track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
  885. break;
  886. case R300_TX_FORMAT_ATI2N:
  887. if (p->rdev->family < CHIP_R420) {
  888. DRM_ERROR("Invalid texture format %u\n",
  889. (idx_value & 0x1F));
  890. return -EINVAL;
  891. }
  892. /* The same rules apply as for DXT3/5. */
  893. /* Pass through. */
  894. case R300_TX_FORMAT_DXT3:
  895. case R300_TX_FORMAT_DXT5:
  896. track->textures[i].cpp = 1;
  897. track->textures[i].compress_format = R100_TRACK_COMP_DXT35;
  898. break;
  899. default:
  900. DRM_ERROR("Invalid texture format %u\n",
  901. (idx_value & 0x1F));
  902. return -EINVAL;
  903. }
  904. track->tex_dirty = true;
  905. break;
  906. case 0x4400:
  907. case 0x4404:
  908. case 0x4408:
  909. case 0x440C:
  910. case 0x4410:
  911. case 0x4414:
  912. case 0x4418:
  913. case 0x441C:
  914. case 0x4420:
  915. case 0x4424:
  916. case 0x4428:
  917. case 0x442C:
  918. case 0x4430:
  919. case 0x4434:
  920. case 0x4438:
  921. case 0x443C:
  922. /* TX_FILTER0_[0-15] */
  923. i = (reg - 0x4400) >> 2;
  924. tmp = idx_value & 0x7;
  925. if (tmp == 2 || tmp == 4 || tmp == 6) {
  926. track->textures[i].roundup_w = false;
  927. }
  928. tmp = (idx_value >> 3) & 0x7;
  929. if (tmp == 2 || tmp == 4 || tmp == 6) {
  930. track->textures[i].roundup_h = false;
  931. }
  932. track->tex_dirty = true;
  933. break;
  934. case 0x4500:
  935. case 0x4504:
  936. case 0x4508:
  937. case 0x450C:
  938. case 0x4510:
  939. case 0x4514:
  940. case 0x4518:
  941. case 0x451C:
  942. case 0x4520:
  943. case 0x4524:
  944. case 0x4528:
  945. case 0x452C:
  946. case 0x4530:
  947. case 0x4534:
  948. case 0x4538:
  949. case 0x453C:
  950. /* TX_FORMAT2_[0-15] */
  951. i = (reg - 0x4500) >> 2;
  952. tmp = idx_value & 0x3FFF;
  953. track->textures[i].pitch = tmp + 1;
  954. if (p->rdev->family >= CHIP_RV515) {
  955. tmp = ((idx_value >> 15) & 1) << 11;
  956. track->textures[i].width_11 = tmp;
  957. tmp = ((idx_value >> 16) & 1) << 11;
  958. track->textures[i].height_11 = tmp;
  959. /* ATI1N */
  960. if (idx_value & (1 << 14)) {
  961. /* The same rules apply as for DXT1. */
  962. track->textures[i].compress_format =
  963. R100_TRACK_COMP_DXT1;
  964. }
  965. } else if (idx_value & (1 << 14)) {
  966. DRM_ERROR("Forbidden bit TXFORMAT_MSB\n");
  967. return -EINVAL;
  968. }
  969. track->tex_dirty = true;
  970. break;
  971. case 0x4480:
  972. case 0x4484:
  973. case 0x4488:
  974. case 0x448C:
  975. case 0x4490:
  976. case 0x4494:
  977. case 0x4498:
  978. case 0x449C:
  979. case 0x44A0:
  980. case 0x44A4:
  981. case 0x44A8:
  982. case 0x44AC:
  983. case 0x44B0:
  984. case 0x44B4:
  985. case 0x44B8:
  986. case 0x44BC:
  987. /* TX_FORMAT0_[0-15] */
  988. i = (reg - 0x4480) >> 2;
  989. tmp = idx_value & 0x7FF;
  990. track->textures[i].width = tmp + 1;
  991. tmp = (idx_value >> 11) & 0x7FF;
  992. track->textures[i].height = tmp + 1;
  993. tmp = (idx_value >> 26) & 0xF;
  994. track->textures[i].num_levels = tmp;
  995. tmp = idx_value & (1 << 31);
  996. track->textures[i].use_pitch = !!tmp;
  997. tmp = (idx_value >> 22) & 0xF;
  998. track->textures[i].txdepth = tmp;
  999. track->tex_dirty = true;
  1000. break;
  1001. case R300_ZB_ZPASS_ADDR:
  1002. r = r100_cs_packet_next_reloc(p, &reloc);
  1003. if (r) {
  1004. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  1005. idx, reg);
  1006. r100_cs_dump_packet(p, pkt);
  1007. return r;
  1008. }
  1009. ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
  1010. break;
  1011. case 0x4e0c:
  1012. /* RB3D_COLOR_CHANNEL_MASK */
  1013. track->color_channel_mask = idx_value;
  1014. track->cb_dirty = true;
  1015. break;
  1016. case 0x43a4:
  1017. /* SC_HYPERZ_EN */
  1018. /* r300c emits this register - we need to disable hyperz for it
  1019. * without complaining */
  1020. if (p->rdev->hyperz_filp != p->filp) {
  1021. if (idx_value & 0x1)
  1022. ib[idx] = idx_value & ~1;
  1023. }
  1024. break;
  1025. case 0x4f1c:
  1026. /* ZB_BW_CNTL */
  1027. track->zb_cb_clear = !!(idx_value & (1 << 5));
  1028. track->cb_dirty = true;
  1029. track->zb_dirty = true;
  1030. if (p->rdev->hyperz_filp != p->filp) {
  1031. if (idx_value & (R300_HIZ_ENABLE |
  1032. R300_RD_COMP_ENABLE |
  1033. R300_WR_COMP_ENABLE |
  1034. R300_FAST_FILL_ENABLE))
  1035. goto fail;
  1036. }
  1037. break;
  1038. case 0x4e04:
  1039. /* RB3D_BLENDCNTL */
  1040. track->blend_read_enable = !!(idx_value & (1 << 2));
  1041. track->cb_dirty = true;
  1042. break;
  1043. case R300_RB3D_AARESOLVE_OFFSET:
  1044. r = r100_cs_packet_next_reloc(p, &reloc);
  1045. if (r) {
  1046. DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
  1047. idx, reg);
  1048. r100_cs_dump_packet(p, pkt);
  1049. return r;
  1050. }
  1051. track->aa.robj = reloc->robj;
  1052. track->aa.offset = idx_value;
  1053. track->aa_dirty = true;
  1054. ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
  1055. break;
  1056. case R300_RB3D_AARESOLVE_PITCH:
  1057. track->aa.pitch = idx_value & 0x3FFE;
  1058. track->aa_dirty = true;
  1059. break;
  1060. case R300_RB3D_AARESOLVE_CTL:
  1061. track->aaresolve = idx_value & 0x1;
  1062. track->aa_dirty = true;
  1063. break;
  1064. case 0x4f30: /* ZB_MASK_OFFSET */
  1065. case 0x4f34: /* ZB_ZMASK_PITCH */
  1066. case 0x4f44: /* ZB_HIZ_OFFSET */
  1067. case 0x4f54: /* ZB_HIZ_PITCH */
  1068. if (idx_value && (p->rdev->hyperz_filp != p->filp))
  1069. goto fail;
  1070. break;
  1071. case 0x4028:
  1072. if (idx_value && (p->rdev->hyperz_filp != p->filp))
  1073. goto fail;
  1074. /* GB_Z_PEQ_CONFIG */
  1075. if (p->rdev->family >= CHIP_RV350)
  1076. break;
  1077. goto fail;
  1078. break;
  1079. case 0x4be8:
  1080. /* valid register only on RV530 */
  1081. if (p->rdev->family == CHIP_RV530)
  1082. break;
  1083. /* fallthrough do not move */
  1084. default:
  1085. goto fail;
  1086. }
  1087. return 0;
  1088. fail:
  1089. printk(KERN_ERR "Forbidden register 0x%04X in cs at %d (val=%08x)\n",
  1090. reg, idx, idx_value);
  1091. return -EINVAL;
  1092. }
  1093. static int r300_packet3_check(struct radeon_cs_parser *p,
  1094. struct radeon_cs_packet *pkt)
  1095. {
  1096. struct radeon_cs_reloc *reloc;
  1097. struct r100_cs_track *track;
  1098. volatile uint32_t *ib;
  1099. unsigned idx;
  1100. int r;
  1101. ib = p->ib->ptr;
  1102. idx = pkt->idx + 1;
  1103. track = (struct r100_cs_track *)p->track;
  1104. switch(pkt->opcode) {
  1105. case PACKET3_3D_LOAD_VBPNTR:
  1106. r = r100_packet3_load_vbpntr(p, pkt, idx);
  1107. if (r)
  1108. return r;
  1109. break;
  1110. case PACKET3_INDX_BUFFER:
  1111. r = r100_cs_packet_next_reloc(p, &reloc);
  1112. if (r) {
  1113. DRM_ERROR("No reloc for packet3 %d\n", pkt->opcode);
  1114. r100_cs_dump_packet(p, pkt);
  1115. return r;
  1116. }
  1117. ib[idx+1] = radeon_get_ib_value(p, idx + 1) + ((u32)reloc->lobj.gpu_offset);
  1118. r = r100_cs_track_check_pkt3_indx_buffer(p, pkt, reloc->robj);
  1119. if (r) {
  1120. return r;
  1121. }
  1122. break;
  1123. /* Draw packet */
  1124. case PACKET3_3D_DRAW_IMMD:
  1125. /* Number of dwords is vtx_size * (num_vertices - 1)
  1126. * PRIM_WALK must be equal to 3 vertex data in embedded
  1127. * in cmd stream */
  1128. if (((radeon_get_ib_value(p, idx + 1) >> 4) & 0x3) != 3) {
  1129. DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
  1130. return -EINVAL;
  1131. }
  1132. track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
  1133. track->immd_dwords = pkt->count - 1;
  1134. r = r100_cs_track_check(p->rdev, track);
  1135. if (r) {
  1136. return r;
  1137. }
  1138. break;
  1139. case PACKET3_3D_DRAW_IMMD_2:
  1140. /* Number of dwords is vtx_size * (num_vertices - 1)
  1141. * PRIM_WALK must be equal to 3 vertex data in embedded
  1142. * in cmd stream */
  1143. if (((radeon_get_ib_value(p, idx) >> 4) & 0x3) != 3) {
  1144. DRM_ERROR("PRIM_WALK must be 3 for IMMD draw\n");
  1145. return -EINVAL;
  1146. }
  1147. track->vap_vf_cntl = radeon_get_ib_value(p, idx);
  1148. track->immd_dwords = pkt->count;
  1149. r = r100_cs_track_check(p->rdev, track);
  1150. if (r) {
  1151. return r;
  1152. }
  1153. break;
  1154. case PACKET3_3D_DRAW_VBUF:
  1155. track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
  1156. r = r100_cs_track_check(p->rdev, track);
  1157. if (r) {
  1158. return r;
  1159. }
  1160. break;
  1161. case PACKET3_3D_DRAW_VBUF_2:
  1162. track->vap_vf_cntl = radeon_get_ib_value(p, idx);
  1163. r = r100_cs_track_check(p->rdev, track);
  1164. if (r) {
  1165. return r;
  1166. }
  1167. break;
  1168. case PACKET3_3D_DRAW_INDX:
  1169. track->vap_vf_cntl = radeon_get_ib_value(p, idx + 1);
  1170. r = r100_cs_track_check(p->rdev, track);
  1171. if (r) {
  1172. return r;
  1173. }
  1174. break;
  1175. case PACKET3_3D_DRAW_INDX_2:
  1176. track->vap_vf_cntl = radeon_get_ib_value(p, idx);
  1177. r = r100_cs_track_check(p->rdev, track);
  1178. if (r) {
  1179. return r;
  1180. }
  1181. break;
  1182. case PACKET3_3D_CLEAR_HIZ:
  1183. case PACKET3_3D_CLEAR_ZMASK:
  1184. if (p->rdev->hyperz_filp != p->filp)
  1185. return -EINVAL;
  1186. break;
  1187. case PACKET3_3D_CLEAR_CMASK:
  1188. if (p->rdev->cmask_filp != p->filp)
  1189. return -EINVAL;
  1190. break;
  1191. case PACKET3_NOP:
  1192. break;
  1193. default:
  1194. DRM_ERROR("Packet3 opcode %x not supported\n", pkt->opcode);
  1195. return -EINVAL;
  1196. }
  1197. return 0;
  1198. }
  1199. int r300_cs_parse(struct radeon_cs_parser *p)
  1200. {
  1201. struct radeon_cs_packet pkt;
  1202. struct r100_cs_track *track;
  1203. int r;
  1204. track = kzalloc(sizeof(*track), GFP_KERNEL);
  1205. if (track == NULL)
  1206. return -ENOMEM;
  1207. r100_cs_track_clear(p->rdev, track);
  1208. p->track = track;
  1209. do {
  1210. r = r100_cs_packet_parse(p, &pkt, p->idx);
  1211. if (r) {
  1212. return r;
  1213. }
  1214. p->idx += pkt.count + 2;
  1215. switch (pkt.type) {
  1216. case PACKET_TYPE0:
  1217. r = r100_cs_parse_packet0(p, &pkt,
  1218. p->rdev->config.r300.reg_safe_bm,
  1219. p->rdev->config.r300.reg_safe_bm_size,
  1220. &r300_packet0_check);
  1221. break;
  1222. case PACKET_TYPE2:
  1223. break;
  1224. case PACKET_TYPE3:
  1225. r = r300_packet3_check(p, &pkt);
  1226. break;
  1227. default:
  1228. DRM_ERROR("Unknown packet type %d !\n", pkt.type);
  1229. return -EINVAL;
  1230. }
  1231. if (r) {
  1232. return r;
  1233. }
  1234. } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
  1235. return 0;
  1236. }
  1237. void r300_set_reg_safe(struct radeon_device *rdev)
  1238. {
  1239. rdev->config.r300.reg_safe_bm = r300_reg_safe_bm;
  1240. rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(r300_reg_safe_bm);
  1241. }
  1242. void r300_mc_program(struct radeon_device *rdev)
  1243. {
  1244. struct r100_mc_save save;
  1245. int r;
  1246. r = r100_debugfs_mc_info_init(rdev);
  1247. if (r) {
  1248. dev_err(rdev->dev, "Failed to create r100_mc debugfs file.\n");
  1249. }
  1250. /* Stops all mc clients */
  1251. r100_mc_stop(rdev, &save);
  1252. if (rdev->flags & RADEON_IS_AGP) {
  1253. WREG32(R_00014C_MC_AGP_LOCATION,
  1254. S_00014C_MC_AGP_START(rdev->mc.gtt_start >> 16) |
  1255. S_00014C_MC_AGP_TOP(rdev->mc.gtt_end >> 16));
  1256. WREG32(R_000170_AGP_BASE, lower_32_bits(rdev->mc.agp_base));
  1257. WREG32(R_00015C_AGP_BASE_2,
  1258. upper_32_bits(rdev->mc.agp_base) & 0xff);
  1259. } else {
  1260. WREG32(R_00014C_MC_AGP_LOCATION, 0x0FFFFFFF);
  1261. WREG32(R_000170_AGP_BASE, 0);
  1262. WREG32(R_00015C_AGP_BASE_2, 0);
  1263. }
  1264. /* Wait for mc idle */
  1265. if (r300_mc_wait_for_idle(rdev))
  1266. DRM_INFO("Failed to wait MC idle before programming MC.\n");
  1267. /* Program MC, should be a 32bits limited address space */
  1268. WREG32(R_000148_MC_FB_LOCATION,
  1269. S_000148_MC_FB_START(rdev->mc.vram_start >> 16) |
  1270. S_000148_MC_FB_TOP(rdev->mc.vram_end >> 16));
  1271. r100_mc_resume(rdev, &save);
  1272. }
  1273. void r300_clock_startup(struct radeon_device *rdev)
  1274. {
  1275. u32 tmp;
  1276. if (radeon_dynclks != -1 && radeon_dynclks)
  1277. radeon_legacy_set_clock_gating(rdev, 1);
  1278. /* We need to force on some of the block */
  1279. tmp = RREG32_PLL(R_00000D_SCLK_CNTL);
  1280. tmp |= S_00000D_FORCE_CP(1) | S_00000D_FORCE_VIP(1);
  1281. if ((rdev->family == CHIP_RV350) || (rdev->family == CHIP_RV380))
  1282. tmp |= S_00000D_FORCE_VAP(1);
  1283. WREG32_PLL(R_00000D_SCLK_CNTL, tmp);
  1284. }
  1285. static int r300_startup(struct radeon_device *rdev)
  1286. {
  1287. int r;
  1288. /* set common regs */
  1289. r100_set_common_regs(rdev);
  1290. /* program mc */
  1291. r300_mc_program(rdev);
  1292. /* Resume clock */
  1293. r300_clock_startup(rdev);
  1294. /* Initialize GPU configuration (# pipes, ...) */
  1295. r300_gpu_init(rdev);
  1296. /* Initialize GART (initialize after TTM so we can allocate
  1297. * memory through TTM but finalize after TTM) */
  1298. if (rdev->flags & RADEON_IS_PCIE) {
  1299. r = rv370_pcie_gart_enable(rdev);
  1300. if (r)
  1301. return r;
  1302. }
  1303. if (rdev->family == CHIP_R300 ||
  1304. rdev->family == CHIP_R350 ||
  1305. rdev->family == CHIP_RV350)
  1306. r100_enable_bm(rdev);
  1307. if (rdev->flags & RADEON_IS_PCI) {
  1308. r = r100_pci_gart_enable(rdev);
  1309. if (r)
  1310. return r;
  1311. }
  1312. /* allocate wb buffer */
  1313. r = radeon_wb_init(rdev);
  1314. if (r)
  1315. return r;
  1316. /* Enable IRQ */
  1317. r100_irq_set(rdev);
  1318. rdev->config.r300.hdp_cntl = RREG32(RADEON_HOST_PATH_CNTL);
  1319. /* 1M ring buffer */
  1320. r = r100_cp_init(rdev, 1024 * 1024);
  1321. if (r) {
  1322. dev_err(rdev->dev, "failed initializing CP (%d).\n", r);
  1323. return r;
  1324. }
  1325. r = r100_ib_init(rdev);
  1326. if (r) {
  1327. dev_err(rdev->dev, "failed initializing IB (%d).\n", r);
  1328. return r;
  1329. }
  1330. return 0;
  1331. }
  1332. int r300_resume(struct radeon_device *rdev)
  1333. {
  1334. /* Make sur GART are not working */
  1335. if (rdev->flags & RADEON_IS_PCIE)
  1336. rv370_pcie_gart_disable(rdev);
  1337. if (rdev->flags & RADEON_IS_PCI)
  1338. r100_pci_gart_disable(rdev);
  1339. /* Resume clock before doing reset */
  1340. r300_clock_startup(rdev);
  1341. /* Reset gpu before posting otherwise ATOM will enter infinite loop */
  1342. if (radeon_asic_reset(rdev)) {
  1343. dev_warn(rdev->dev, "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
  1344. RREG32(R_000E40_RBBM_STATUS),
  1345. RREG32(R_0007C0_CP_STAT));
  1346. }
  1347. /* post */
  1348. radeon_combios_asic_init(rdev->ddev);
  1349. /* Resume clock after posting */
  1350. r300_clock_startup(rdev);
  1351. /* Initialize surface registers */
  1352. radeon_surface_init(rdev);
  1353. return r300_startup(rdev);
  1354. }
  1355. int r300_suspend(struct radeon_device *rdev)
  1356. {
  1357. r100_cp_disable(rdev);
  1358. radeon_wb_disable(rdev);
  1359. r100_irq_disable(rdev);
  1360. if (rdev->flags & RADEON_IS_PCIE)
  1361. rv370_pcie_gart_disable(rdev);
  1362. if (rdev->flags & RADEON_IS_PCI)
  1363. r100_pci_gart_disable(rdev);
  1364. return 0;
  1365. }
  1366. void r300_fini(struct radeon_device *rdev)
  1367. {
  1368. r100_cp_fini(rdev);
  1369. radeon_wb_fini(rdev);
  1370. r100_ib_fini(rdev);
  1371. radeon_gem_fini(rdev);
  1372. if (rdev->flags & RADEON_IS_PCIE)
  1373. rv370_pcie_gart_fini(rdev);
  1374. if (rdev->flags & RADEON_IS_PCI)
  1375. r100_pci_gart_fini(rdev);
  1376. radeon_agp_fini(rdev);
  1377. radeon_irq_kms_fini(rdev);
  1378. radeon_fence_driver_fini(rdev);
  1379. radeon_bo_fini(rdev);
  1380. radeon_atombios_fini(rdev);
  1381. kfree(rdev->bios);
  1382. rdev->bios = NULL;
  1383. }
  1384. int r300_init(struct radeon_device *rdev)
  1385. {
  1386. int r;
  1387. /* Disable VGA */
  1388. r100_vga_render_disable(rdev);
  1389. /* Initialize scratch registers */
  1390. radeon_scratch_init(rdev);
  1391. /* Initialize surface registers */
  1392. radeon_surface_init(rdev);
  1393. /* TODO: disable VGA need to use VGA request */
  1394. /* restore some register to sane defaults */
  1395. r100_restore_sanity(rdev);
  1396. /* BIOS*/
  1397. if (!radeon_get_bios(rdev)) {
  1398. if (ASIC_IS_AVIVO(rdev))
  1399. return -EINVAL;
  1400. }
  1401. if (rdev->is_atom_bios) {
  1402. dev_err(rdev->dev, "Expecting combios for RS400/RS480 GPU\n");
  1403. return -EINVAL;
  1404. } else {
  1405. r = radeon_combios_init(rdev);
  1406. if (r)
  1407. return r;
  1408. }
  1409. /* Reset gpu before posting otherwise ATOM will enter infinite loop */
  1410. if (radeon_asic_reset(rdev)) {
  1411. dev_warn(rdev->dev,
  1412. "GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\n",
  1413. RREG32(R_000E40_RBBM_STATUS),
  1414. RREG32(R_0007C0_CP_STAT));
  1415. }
  1416. /* check if cards are posted or not */
  1417. if (radeon_boot_test_post_card(rdev) == false)
  1418. return -EINVAL;
  1419. /* Set asic errata */
  1420. r300_errata(rdev);
  1421. /* Initialize clocks */
  1422. radeon_get_clock_info(rdev->ddev);
  1423. /* initialize AGP */
  1424. if (rdev->flags & RADEON_IS_AGP) {
  1425. r = radeon_agp_init(rdev);
  1426. if (r) {
  1427. radeon_agp_disable(rdev);
  1428. }
  1429. }
  1430. /* initialize memory controller */
  1431. r300_mc_init(rdev);
  1432. /* Fence driver */
  1433. r = radeon_fence_driver_init(rdev);
  1434. if (r)
  1435. return r;
  1436. r = radeon_irq_kms_init(rdev);
  1437. if (r)
  1438. return r;
  1439. /* Memory manager */
  1440. r = radeon_bo_init(rdev);
  1441. if (r)
  1442. return r;
  1443. if (rdev->flags & RADEON_IS_PCIE) {
  1444. r = rv370_pcie_gart_init(rdev);
  1445. if (r)
  1446. return r;
  1447. }
  1448. if (rdev->flags & RADEON_IS_PCI) {
  1449. r = r100_pci_gart_init(rdev);
  1450. if (r)
  1451. return r;
  1452. }
  1453. r300_set_reg_safe(rdev);
  1454. rdev->accel_working = true;
  1455. r = r300_startup(rdev);
  1456. if (r) {
  1457. /* Somethings want wront with the accel init stop accel */
  1458. dev_err(rdev->dev, "Disabling GPU acceleration\n");
  1459. r100_cp_fini(rdev);
  1460. radeon_wb_fini(rdev);
  1461. r100_ib_fini(rdev);
  1462. radeon_irq_kms_fini(rdev);
  1463. if (rdev->flags & RADEON_IS_PCIE)
  1464. rv370_pcie_gart_fini(rdev);
  1465. if (rdev->flags & RADEON_IS_PCI)
  1466. r100_pci_gart_fini(rdev);
  1467. radeon_agp_fini(rdev);
  1468. rdev->accel_working = false;
  1469. }
  1470. return 0;
  1471. }