rv515.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  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 "drmP.h"
  30. #include "rv515d.h"
  31. #include "radeon.h"
  32. #include "radeon_share.h"
  33. #include "rv515_reg_safe.h"
  34. /* rv515 depends on : */
  35. void r100_hdp_reset(struct radeon_device *rdev);
  36. int r100_cp_reset(struct radeon_device *rdev);
  37. int r100_rb2d_reset(struct radeon_device *rdev);
  38. int r100_gui_wait_for_idle(struct radeon_device *rdev);
  39. int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
  40. int rv370_pcie_gart_enable(struct radeon_device *rdev);
  41. void rv370_pcie_gart_disable(struct radeon_device *rdev);
  42. void r420_pipes_init(struct radeon_device *rdev);
  43. void rs600_mc_disable_clients(struct radeon_device *rdev);
  44. void rs600_disable_vga(struct radeon_device *rdev);
  45. /* This files gather functions specifics to:
  46. * rv515
  47. *
  48. * Some of these functions might be used by newer ASICs.
  49. */
  50. int rv515_debugfs_pipes_info_init(struct radeon_device *rdev);
  51. int rv515_debugfs_ga_info_init(struct radeon_device *rdev);
  52. void rv515_gpu_init(struct radeon_device *rdev);
  53. int rv515_mc_wait_for_idle(struct radeon_device *rdev);
  54. /*
  55. * MC
  56. */
  57. int rv515_mc_init(struct radeon_device *rdev)
  58. {
  59. uint32_t tmp;
  60. int r;
  61. if (r100_debugfs_rbbm_init(rdev)) {
  62. DRM_ERROR("Failed to register debugfs file for RBBM !\n");
  63. }
  64. if (rv515_debugfs_pipes_info_init(rdev)) {
  65. DRM_ERROR("Failed to register debugfs file for pipes !\n");
  66. }
  67. if (rv515_debugfs_ga_info_init(rdev)) {
  68. DRM_ERROR("Failed to register debugfs file for pipes !\n");
  69. }
  70. rv515_gpu_init(rdev);
  71. rv370_pcie_gart_disable(rdev);
  72. /* Setup GPU memory space */
  73. rdev->mc.vram_location = 0xFFFFFFFFUL;
  74. rdev->mc.gtt_location = 0xFFFFFFFFUL;
  75. if (rdev->flags & RADEON_IS_AGP) {
  76. r = radeon_agp_init(rdev);
  77. if (r) {
  78. printk(KERN_WARNING "[drm] Disabling AGP\n");
  79. rdev->flags &= ~RADEON_IS_AGP;
  80. rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
  81. } else {
  82. rdev->mc.gtt_location = rdev->mc.agp_base;
  83. }
  84. }
  85. r = radeon_mc_setup(rdev);
  86. if (r) {
  87. return r;
  88. }
  89. /* Program GPU memory space */
  90. rs600_mc_disable_clients(rdev);
  91. if (rv515_mc_wait_for_idle(rdev)) {
  92. printk(KERN_WARNING "Failed to wait MC idle while "
  93. "programming pipes. Bad things might happen.\n");
  94. }
  95. /* Write VRAM size in case we are limiting it */
  96. WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size);
  97. tmp = REG_SET(MC_FB_START, rdev->mc.vram_location >> 16);
  98. WREG32(0x134, tmp);
  99. tmp = rdev->mc.vram_location + rdev->mc.mc_vram_size - 1;
  100. tmp = REG_SET(MC_FB_TOP, tmp >> 16);
  101. tmp |= REG_SET(MC_FB_START, rdev->mc.vram_location >> 16);
  102. WREG32_MC(MC_FB_LOCATION, tmp);
  103. WREG32(HDP_FB_LOCATION, rdev->mc.vram_location >> 16);
  104. WREG32(0x310, rdev->mc.vram_location);
  105. if (rdev->flags & RADEON_IS_AGP) {
  106. tmp = rdev->mc.gtt_location + rdev->mc.gtt_size - 1;
  107. tmp = REG_SET(MC_AGP_TOP, tmp >> 16);
  108. tmp |= REG_SET(MC_AGP_START, rdev->mc.gtt_location >> 16);
  109. WREG32_MC(MC_AGP_LOCATION, tmp);
  110. WREG32_MC(MC_AGP_BASE, rdev->mc.agp_base);
  111. WREG32_MC(MC_AGP_BASE_2, 0);
  112. } else {
  113. WREG32_MC(MC_AGP_LOCATION, 0x0FFFFFFF);
  114. WREG32_MC(MC_AGP_BASE, 0);
  115. WREG32_MC(MC_AGP_BASE_2, 0);
  116. }
  117. return 0;
  118. }
  119. void rv515_mc_fini(struct radeon_device *rdev)
  120. {
  121. rv370_pcie_gart_disable(rdev);
  122. radeon_gart_table_vram_free(rdev);
  123. radeon_gart_fini(rdev);
  124. }
  125. /*
  126. * Global GPU functions
  127. */
  128. void rv515_ring_start(struct radeon_device *rdev)
  129. {
  130. int r;
  131. r = radeon_ring_lock(rdev, 64);
  132. if (r) {
  133. return;
  134. }
  135. radeon_ring_write(rdev, PACKET0(ISYNC_CNTL, 0));
  136. radeon_ring_write(rdev,
  137. ISYNC_ANY2D_IDLE3D |
  138. ISYNC_ANY3D_IDLE2D |
  139. ISYNC_WAIT_IDLEGUI |
  140. ISYNC_CPSCRATCH_IDLEGUI);
  141. radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0));
  142. radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN);
  143. radeon_ring_write(rdev, PACKET0(0x170C, 0));
  144. radeon_ring_write(rdev, 1 << 31);
  145. radeon_ring_write(rdev, PACKET0(GB_SELECT, 0));
  146. radeon_ring_write(rdev, 0);
  147. radeon_ring_write(rdev, PACKET0(GB_ENABLE, 0));
  148. radeon_ring_write(rdev, 0);
  149. radeon_ring_write(rdev, PACKET0(0x42C8, 0));
  150. radeon_ring_write(rdev, (1 << rdev->num_gb_pipes) - 1);
  151. radeon_ring_write(rdev, PACKET0(VAP_INDEX_OFFSET, 0));
  152. radeon_ring_write(rdev, 0);
  153. radeon_ring_write(rdev, PACKET0(RB3D_DSTCACHE_CTLSTAT, 0));
  154. radeon_ring_write(rdev, RB3D_DC_FLUSH | RB3D_DC_FREE);
  155. radeon_ring_write(rdev, PACKET0(ZB_ZCACHE_CTLSTAT, 0));
  156. radeon_ring_write(rdev, ZC_FLUSH | ZC_FREE);
  157. radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0));
  158. radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN);
  159. radeon_ring_write(rdev, PACKET0(GB_AA_CONFIG, 0));
  160. radeon_ring_write(rdev, 0);
  161. radeon_ring_write(rdev, PACKET0(RB3D_DSTCACHE_CTLSTAT, 0));
  162. radeon_ring_write(rdev, RB3D_DC_FLUSH | RB3D_DC_FREE);
  163. radeon_ring_write(rdev, PACKET0(ZB_ZCACHE_CTLSTAT, 0));
  164. radeon_ring_write(rdev, ZC_FLUSH | ZC_FREE);
  165. radeon_ring_write(rdev, PACKET0(GB_MSPOS0, 0));
  166. radeon_ring_write(rdev,
  167. ((6 << MS_X0_SHIFT) |
  168. (6 << MS_Y0_SHIFT) |
  169. (6 << MS_X1_SHIFT) |
  170. (6 << MS_Y1_SHIFT) |
  171. (6 << MS_X2_SHIFT) |
  172. (6 << MS_Y2_SHIFT) |
  173. (6 << MSBD0_Y_SHIFT) |
  174. (6 << MSBD0_X_SHIFT)));
  175. radeon_ring_write(rdev, PACKET0(GB_MSPOS1, 0));
  176. radeon_ring_write(rdev,
  177. ((6 << MS_X3_SHIFT) |
  178. (6 << MS_Y3_SHIFT) |
  179. (6 << MS_X4_SHIFT) |
  180. (6 << MS_Y4_SHIFT) |
  181. (6 << MS_X5_SHIFT) |
  182. (6 << MS_Y5_SHIFT) |
  183. (6 << MSBD1_SHIFT)));
  184. radeon_ring_write(rdev, PACKET0(GA_ENHANCE, 0));
  185. radeon_ring_write(rdev, GA_DEADLOCK_CNTL | GA_FASTSYNC_CNTL);
  186. radeon_ring_write(rdev, PACKET0(GA_POLY_MODE, 0));
  187. radeon_ring_write(rdev, FRONT_PTYPE_TRIANGE | BACK_PTYPE_TRIANGE);
  188. radeon_ring_write(rdev, PACKET0(GA_ROUND_MODE, 0));
  189. radeon_ring_write(rdev, GEOMETRY_ROUND_NEAREST | COLOR_ROUND_NEAREST);
  190. radeon_ring_write(rdev, PACKET0(0x20C8, 0));
  191. radeon_ring_write(rdev, 0);
  192. radeon_ring_unlock_commit(rdev);
  193. }
  194. void rv515_errata(struct radeon_device *rdev)
  195. {
  196. rdev->pll_errata = 0;
  197. }
  198. int rv515_mc_wait_for_idle(struct radeon_device *rdev)
  199. {
  200. unsigned i;
  201. uint32_t tmp;
  202. for (i = 0; i < rdev->usec_timeout; i++) {
  203. /* read MC_STATUS */
  204. tmp = RREG32_MC(MC_STATUS);
  205. if (tmp & MC_STATUS_IDLE) {
  206. return 0;
  207. }
  208. DRM_UDELAY(1);
  209. }
  210. return -1;
  211. }
  212. void rv515_gpu_init(struct radeon_device *rdev)
  213. {
  214. unsigned pipe_select_current, gb_pipe_select, tmp;
  215. r100_hdp_reset(rdev);
  216. r100_rb2d_reset(rdev);
  217. if (r100_gui_wait_for_idle(rdev)) {
  218. printk(KERN_WARNING "Failed to wait GUI idle while "
  219. "reseting GPU. Bad things might happen.\n");
  220. }
  221. rs600_disable_vga(rdev);
  222. r420_pipes_init(rdev);
  223. gb_pipe_select = RREG32(0x402C);
  224. tmp = RREG32(0x170C);
  225. pipe_select_current = (tmp >> 2) & 3;
  226. tmp = (1 << pipe_select_current) |
  227. (((gb_pipe_select >> 8) & 0xF) << 4);
  228. WREG32_PLL(0x000D, tmp);
  229. if (r100_gui_wait_for_idle(rdev)) {
  230. printk(KERN_WARNING "Failed to wait GUI idle while "
  231. "reseting GPU. Bad things might happen.\n");
  232. }
  233. if (rv515_mc_wait_for_idle(rdev)) {
  234. printk(KERN_WARNING "Failed to wait MC idle while "
  235. "programming pipes. Bad things might happen.\n");
  236. }
  237. }
  238. int rv515_ga_reset(struct radeon_device *rdev)
  239. {
  240. uint32_t tmp;
  241. bool reinit_cp;
  242. int i;
  243. reinit_cp = rdev->cp.ready;
  244. rdev->cp.ready = false;
  245. for (i = 0; i < rdev->usec_timeout; i++) {
  246. WREG32(CP_CSQ_MODE, 0);
  247. WREG32(CP_CSQ_CNTL, 0);
  248. WREG32(RBBM_SOFT_RESET, 0x32005);
  249. (void)RREG32(RBBM_SOFT_RESET);
  250. udelay(200);
  251. WREG32(RBBM_SOFT_RESET, 0);
  252. /* Wait to prevent race in RBBM_STATUS */
  253. mdelay(1);
  254. tmp = RREG32(RBBM_STATUS);
  255. if (tmp & ((1 << 20) | (1 << 26))) {
  256. DRM_ERROR("VAP & CP still busy (RBBM_STATUS=0x%08X)\n", tmp);
  257. /* GA still busy soft reset it */
  258. WREG32(0x429C, 0x200);
  259. WREG32(VAP_PVS_STATE_FLUSH_REG, 0);
  260. WREG32(0x43E0, 0);
  261. WREG32(0x43E4, 0);
  262. WREG32(0x24AC, 0);
  263. }
  264. /* Wait to prevent race in RBBM_STATUS */
  265. mdelay(1);
  266. tmp = RREG32(RBBM_STATUS);
  267. if (!(tmp & ((1 << 20) | (1 << 26)))) {
  268. break;
  269. }
  270. }
  271. for (i = 0; i < rdev->usec_timeout; i++) {
  272. tmp = RREG32(RBBM_STATUS);
  273. if (!(tmp & ((1 << 20) | (1 << 26)))) {
  274. DRM_INFO("GA reset succeed (RBBM_STATUS=0x%08X)\n",
  275. tmp);
  276. DRM_INFO("GA_IDLE=0x%08X\n", RREG32(0x425C));
  277. DRM_INFO("RB3D_RESET_STATUS=0x%08X\n", RREG32(0x46f0));
  278. DRM_INFO("ISYNC_CNTL=0x%08X\n", RREG32(0x1724));
  279. if (reinit_cp) {
  280. return r100_cp_init(rdev, rdev->cp.ring_size);
  281. }
  282. return 0;
  283. }
  284. DRM_UDELAY(1);
  285. }
  286. tmp = RREG32(RBBM_STATUS);
  287. DRM_ERROR("Failed to reset GA ! (RBBM_STATUS=0x%08X)\n", tmp);
  288. return -1;
  289. }
  290. int rv515_gpu_reset(struct radeon_device *rdev)
  291. {
  292. uint32_t status;
  293. /* reset order likely matter */
  294. status = RREG32(RBBM_STATUS);
  295. /* reset HDP */
  296. r100_hdp_reset(rdev);
  297. /* reset rb2d */
  298. if (status & ((1 << 17) | (1 << 18) | (1 << 27))) {
  299. r100_rb2d_reset(rdev);
  300. }
  301. /* reset GA */
  302. if (status & ((1 << 20) | (1 << 26))) {
  303. rv515_ga_reset(rdev);
  304. }
  305. /* reset CP */
  306. status = RREG32(RBBM_STATUS);
  307. if (status & (1 << 16)) {
  308. r100_cp_reset(rdev);
  309. }
  310. /* Check if GPU is idle */
  311. status = RREG32(RBBM_STATUS);
  312. if (status & (1 << 31)) {
  313. DRM_ERROR("Failed to reset GPU (RBBM_STATUS=0x%08X)\n", status);
  314. return -1;
  315. }
  316. DRM_INFO("GPU reset succeed (RBBM_STATUS=0x%08X)\n", status);
  317. return 0;
  318. }
  319. /*
  320. * VRAM info
  321. */
  322. static void rv515_vram_get_type(struct radeon_device *rdev)
  323. {
  324. uint32_t tmp;
  325. rdev->mc.vram_width = 128;
  326. rdev->mc.vram_is_ddr = true;
  327. tmp = RREG32_MC(RV515_MC_CNTL) & MEM_NUM_CHANNELS_MASK;
  328. switch (tmp) {
  329. case 0:
  330. rdev->mc.vram_width = 64;
  331. break;
  332. case 1:
  333. rdev->mc.vram_width = 128;
  334. break;
  335. default:
  336. rdev->mc.vram_width = 128;
  337. break;
  338. }
  339. }
  340. void rv515_vram_info(struct radeon_device *rdev)
  341. {
  342. fixed20_12 a;
  343. rv515_vram_get_type(rdev);
  344. r100_vram_init_sizes(rdev);
  345. /* FIXME: we should enforce default clock in case GPU is not in
  346. * default setup
  347. */
  348. a.full = rfixed_const(100);
  349. rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
  350. rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
  351. }
  352. /*
  353. * Indirect registers accessor
  354. */
  355. uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg)
  356. {
  357. uint32_t r;
  358. WREG32(MC_IND_INDEX, 0x7f0000 | (reg & 0xffff));
  359. r = RREG32(MC_IND_DATA);
  360. WREG32(MC_IND_INDEX, 0);
  361. return r;
  362. }
  363. void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
  364. {
  365. WREG32(MC_IND_INDEX, 0xff0000 | ((reg) & 0xffff));
  366. WREG32(MC_IND_DATA, (v));
  367. WREG32(MC_IND_INDEX, 0);
  368. }
  369. /*
  370. * Debugfs info
  371. */
  372. #if defined(CONFIG_DEBUG_FS)
  373. static int rv515_debugfs_pipes_info(struct seq_file *m, void *data)
  374. {
  375. struct drm_info_node *node = (struct drm_info_node *) m->private;
  376. struct drm_device *dev = node->minor->dev;
  377. struct radeon_device *rdev = dev->dev_private;
  378. uint32_t tmp;
  379. tmp = RREG32(GB_PIPE_SELECT);
  380. seq_printf(m, "GB_PIPE_SELECT 0x%08x\n", tmp);
  381. tmp = RREG32(SU_REG_DEST);
  382. seq_printf(m, "SU_REG_DEST 0x%08x\n", tmp);
  383. tmp = RREG32(GB_TILE_CONFIG);
  384. seq_printf(m, "GB_TILE_CONFIG 0x%08x\n", tmp);
  385. tmp = RREG32(DST_PIPE_CONFIG);
  386. seq_printf(m, "DST_PIPE_CONFIG 0x%08x\n", tmp);
  387. return 0;
  388. }
  389. static int rv515_debugfs_ga_info(struct seq_file *m, void *data)
  390. {
  391. struct drm_info_node *node = (struct drm_info_node *) m->private;
  392. struct drm_device *dev = node->minor->dev;
  393. struct radeon_device *rdev = dev->dev_private;
  394. uint32_t tmp;
  395. tmp = RREG32(0x2140);
  396. seq_printf(m, "VAP_CNTL_STATUS 0x%08x\n", tmp);
  397. radeon_gpu_reset(rdev);
  398. tmp = RREG32(0x425C);
  399. seq_printf(m, "GA_IDLE 0x%08x\n", tmp);
  400. return 0;
  401. }
  402. static struct drm_info_list rv515_pipes_info_list[] = {
  403. {"rv515_pipes_info", rv515_debugfs_pipes_info, 0, NULL},
  404. };
  405. static struct drm_info_list rv515_ga_info_list[] = {
  406. {"rv515_ga_info", rv515_debugfs_ga_info, 0, NULL},
  407. };
  408. #endif
  409. int rv515_debugfs_pipes_info_init(struct radeon_device *rdev)
  410. {
  411. #if defined(CONFIG_DEBUG_FS)
  412. return radeon_debugfs_add_files(rdev, rv515_pipes_info_list, 1);
  413. #else
  414. return 0;
  415. #endif
  416. }
  417. int rv515_debugfs_ga_info_init(struct radeon_device *rdev)
  418. {
  419. #if defined(CONFIG_DEBUG_FS)
  420. return radeon_debugfs_add_files(rdev, rv515_ga_info_list, 1);
  421. #else
  422. return 0;
  423. #endif
  424. }
  425. /*
  426. * Asic initialization
  427. */
  428. int rv515_init(struct radeon_device *rdev)
  429. {
  430. rdev->config.r300.reg_safe_bm = rv515_reg_safe_bm;
  431. rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(rv515_reg_safe_bm);
  432. return 0;
  433. }
  434. void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *crtc)
  435. {
  436. int index_reg = 0x6578 + crtc->crtc_offset;
  437. int data_reg = 0x657c + crtc->crtc_offset;
  438. WREG32(0x659C + crtc->crtc_offset, 0x0);
  439. WREG32(0x6594 + crtc->crtc_offset, 0x705);
  440. WREG32(0x65A4 + crtc->crtc_offset, 0x10001);
  441. WREG32(0x65D8 + crtc->crtc_offset, 0x0);
  442. WREG32(0x65B0 + crtc->crtc_offset, 0x0);
  443. WREG32(0x65C0 + crtc->crtc_offset, 0x0);
  444. WREG32(0x65D4 + crtc->crtc_offset, 0x0);
  445. WREG32(index_reg, 0x0);
  446. WREG32(data_reg, 0x841880A8);
  447. WREG32(index_reg, 0x1);
  448. WREG32(data_reg, 0x84208680);
  449. WREG32(index_reg, 0x2);
  450. WREG32(data_reg, 0xBFF880B0);
  451. WREG32(index_reg, 0x100);
  452. WREG32(data_reg, 0x83D88088);
  453. WREG32(index_reg, 0x101);
  454. WREG32(data_reg, 0x84608680);
  455. WREG32(index_reg, 0x102);
  456. WREG32(data_reg, 0xBFF080D0);
  457. WREG32(index_reg, 0x200);
  458. WREG32(data_reg, 0x83988068);
  459. WREG32(index_reg, 0x201);
  460. WREG32(data_reg, 0x84A08680);
  461. WREG32(index_reg, 0x202);
  462. WREG32(data_reg, 0xBFF080F8);
  463. WREG32(index_reg, 0x300);
  464. WREG32(data_reg, 0x83588058);
  465. WREG32(index_reg, 0x301);
  466. WREG32(data_reg, 0x84E08660);
  467. WREG32(index_reg, 0x302);
  468. WREG32(data_reg, 0xBFF88120);
  469. WREG32(index_reg, 0x400);
  470. WREG32(data_reg, 0x83188040);
  471. WREG32(index_reg, 0x401);
  472. WREG32(data_reg, 0x85008660);
  473. WREG32(index_reg, 0x402);
  474. WREG32(data_reg, 0xBFF88150);
  475. WREG32(index_reg, 0x500);
  476. WREG32(data_reg, 0x82D88030);
  477. WREG32(index_reg, 0x501);
  478. WREG32(data_reg, 0x85408640);
  479. WREG32(index_reg, 0x502);
  480. WREG32(data_reg, 0xBFF88180);
  481. WREG32(index_reg, 0x600);
  482. WREG32(data_reg, 0x82A08018);
  483. WREG32(index_reg, 0x601);
  484. WREG32(data_reg, 0x85808620);
  485. WREG32(index_reg, 0x602);
  486. WREG32(data_reg, 0xBFF081B8);
  487. WREG32(index_reg, 0x700);
  488. WREG32(data_reg, 0x82608010);
  489. WREG32(index_reg, 0x701);
  490. WREG32(data_reg, 0x85A08600);
  491. WREG32(index_reg, 0x702);
  492. WREG32(data_reg, 0x800081F0);
  493. WREG32(index_reg, 0x800);
  494. WREG32(data_reg, 0x8228BFF8);
  495. WREG32(index_reg, 0x801);
  496. WREG32(data_reg, 0x85E085E0);
  497. WREG32(index_reg, 0x802);
  498. WREG32(data_reg, 0xBFF88228);
  499. WREG32(index_reg, 0x10000);
  500. WREG32(data_reg, 0x82A8BF00);
  501. WREG32(index_reg, 0x10001);
  502. WREG32(data_reg, 0x82A08CC0);
  503. WREG32(index_reg, 0x10002);
  504. WREG32(data_reg, 0x8008BEF8);
  505. WREG32(index_reg, 0x10100);
  506. WREG32(data_reg, 0x81F0BF28);
  507. WREG32(index_reg, 0x10101);
  508. WREG32(data_reg, 0x83608CA0);
  509. WREG32(index_reg, 0x10102);
  510. WREG32(data_reg, 0x8018BED0);
  511. WREG32(index_reg, 0x10200);
  512. WREG32(data_reg, 0x8148BF38);
  513. WREG32(index_reg, 0x10201);
  514. WREG32(data_reg, 0x84408C80);
  515. WREG32(index_reg, 0x10202);
  516. WREG32(data_reg, 0x8008BEB8);
  517. WREG32(index_reg, 0x10300);
  518. WREG32(data_reg, 0x80B0BF78);
  519. WREG32(index_reg, 0x10301);
  520. WREG32(data_reg, 0x85008C20);
  521. WREG32(index_reg, 0x10302);
  522. WREG32(data_reg, 0x8020BEA0);
  523. WREG32(index_reg, 0x10400);
  524. WREG32(data_reg, 0x8028BF90);
  525. WREG32(index_reg, 0x10401);
  526. WREG32(data_reg, 0x85E08BC0);
  527. WREG32(index_reg, 0x10402);
  528. WREG32(data_reg, 0x8018BE90);
  529. WREG32(index_reg, 0x10500);
  530. WREG32(data_reg, 0xBFB8BFB0);
  531. WREG32(index_reg, 0x10501);
  532. WREG32(data_reg, 0x86C08B40);
  533. WREG32(index_reg, 0x10502);
  534. WREG32(data_reg, 0x8010BE90);
  535. WREG32(index_reg, 0x10600);
  536. WREG32(data_reg, 0xBF58BFC8);
  537. WREG32(index_reg, 0x10601);
  538. WREG32(data_reg, 0x87A08AA0);
  539. WREG32(index_reg, 0x10602);
  540. WREG32(data_reg, 0x8010BE98);
  541. WREG32(index_reg, 0x10700);
  542. WREG32(data_reg, 0xBF10BFF0);
  543. WREG32(index_reg, 0x10701);
  544. WREG32(data_reg, 0x886089E0);
  545. WREG32(index_reg, 0x10702);
  546. WREG32(data_reg, 0x8018BEB0);
  547. WREG32(index_reg, 0x10800);
  548. WREG32(data_reg, 0xBED8BFE8);
  549. WREG32(index_reg, 0x10801);
  550. WREG32(data_reg, 0x89408940);
  551. WREG32(index_reg, 0x10802);
  552. WREG32(data_reg, 0xBFE8BED8);
  553. WREG32(index_reg, 0x20000);
  554. WREG32(data_reg, 0x80008000);
  555. WREG32(index_reg, 0x20001);
  556. WREG32(data_reg, 0x90008000);
  557. WREG32(index_reg, 0x20002);
  558. WREG32(data_reg, 0x80008000);
  559. WREG32(index_reg, 0x20003);
  560. WREG32(data_reg, 0x80008000);
  561. WREG32(index_reg, 0x20100);
  562. WREG32(data_reg, 0x80108000);
  563. WREG32(index_reg, 0x20101);
  564. WREG32(data_reg, 0x8FE0BF70);
  565. WREG32(index_reg, 0x20102);
  566. WREG32(data_reg, 0xBFE880C0);
  567. WREG32(index_reg, 0x20103);
  568. WREG32(data_reg, 0x80008000);
  569. WREG32(index_reg, 0x20200);
  570. WREG32(data_reg, 0x8018BFF8);
  571. WREG32(index_reg, 0x20201);
  572. WREG32(data_reg, 0x8F80BF08);
  573. WREG32(index_reg, 0x20202);
  574. WREG32(data_reg, 0xBFD081A0);
  575. WREG32(index_reg, 0x20203);
  576. WREG32(data_reg, 0xBFF88000);
  577. WREG32(index_reg, 0x20300);
  578. WREG32(data_reg, 0x80188000);
  579. WREG32(index_reg, 0x20301);
  580. WREG32(data_reg, 0x8EE0BEC0);
  581. WREG32(index_reg, 0x20302);
  582. WREG32(data_reg, 0xBFB082A0);
  583. WREG32(index_reg, 0x20303);
  584. WREG32(data_reg, 0x80008000);
  585. WREG32(index_reg, 0x20400);
  586. WREG32(data_reg, 0x80188000);
  587. WREG32(index_reg, 0x20401);
  588. WREG32(data_reg, 0x8E00BEA0);
  589. WREG32(index_reg, 0x20402);
  590. WREG32(data_reg, 0xBF8883C0);
  591. WREG32(index_reg, 0x20403);
  592. WREG32(data_reg, 0x80008000);
  593. WREG32(index_reg, 0x20500);
  594. WREG32(data_reg, 0x80188000);
  595. WREG32(index_reg, 0x20501);
  596. WREG32(data_reg, 0x8D00BE90);
  597. WREG32(index_reg, 0x20502);
  598. WREG32(data_reg, 0xBF588500);
  599. WREG32(index_reg, 0x20503);
  600. WREG32(data_reg, 0x80008008);
  601. WREG32(index_reg, 0x20600);
  602. WREG32(data_reg, 0x80188000);
  603. WREG32(index_reg, 0x20601);
  604. WREG32(data_reg, 0x8BC0BE98);
  605. WREG32(index_reg, 0x20602);
  606. WREG32(data_reg, 0xBF308660);
  607. WREG32(index_reg, 0x20603);
  608. WREG32(data_reg, 0x80008008);
  609. WREG32(index_reg, 0x20700);
  610. WREG32(data_reg, 0x80108000);
  611. WREG32(index_reg, 0x20701);
  612. WREG32(data_reg, 0x8A80BEB0);
  613. WREG32(index_reg, 0x20702);
  614. WREG32(data_reg, 0xBF0087C0);
  615. WREG32(index_reg, 0x20703);
  616. WREG32(data_reg, 0x80008008);
  617. WREG32(index_reg, 0x20800);
  618. WREG32(data_reg, 0x80108000);
  619. WREG32(index_reg, 0x20801);
  620. WREG32(data_reg, 0x8920BED0);
  621. WREG32(index_reg, 0x20802);
  622. WREG32(data_reg, 0xBED08920);
  623. WREG32(index_reg, 0x20803);
  624. WREG32(data_reg, 0x80008010);
  625. WREG32(index_reg, 0x30000);
  626. WREG32(data_reg, 0x90008000);
  627. WREG32(index_reg, 0x30001);
  628. WREG32(data_reg, 0x80008000);
  629. WREG32(index_reg, 0x30100);
  630. WREG32(data_reg, 0x8FE0BF90);
  631. WREG32(index_reg, 0x30101);
  632. WREG32(data_reg, 0xBFF880A0);
  633. WREG32(index_reg, 0x30200);
  634. WREG32(data_reg, 0x8F60BF40);
  635. WREG32(index_reg, 0x30201);
  636. WREG32(data_reg, 0xBFE88180);
  637. WREG32(index_reg, 0x30300);
  638. WREG32(data_reg, 0x8EC0BF00);
  639. WREG32(index_reg, 0x30301);
  640. WREG32(data_reg, 0xBFC88280);
  641. WREG32(index_reg, 0x30400);
  642. WREG32(data_reg, 0x8DE0BEE0);
  643. WREG32(index_reg, 0x30401);
  644. WREG32(data_reg, 0xBFA083A0);
  645. WREG32(index_reg, 0x30500);
  646. WREG32(data_reg, 0x8CE0BED0);
  647. WREG32(index_reg, 0x30501);
  648. WREG32(data_reg, 0xBF7884E0);
  649. WREG32(index_reg, 0x30600);
  650. WREG32(data_reg, 0x8BA0BED8);
  651. WREG32(index_reg, 0x30601);
  652. WREG32(data_reg, 0xBF508640);
  653. WREG32(index_reg, 0x30700);
  654. WREG32(data_reg, 0x8A60BEE8);
  655. WREG32(index_reg, 0x30701);
  656. WREG32(data_reg, 0xBF2087A0);
  657. WREG32(index_reg, 0x30800);
  658. WREG32(data_reg, 0x8900BF00);
  659. WREG32(index_reg, 0x30801);
  660. WREG32(data_reg, 0xBF008900);
  661. }
  662. struct rv515_watermark {
  663. u32 lb_request_fifo_depth;
  664. fixed20_12 num_line_pair;
  665. fixed20_12 estimated_width;
  666. fixed20_12 worst_case_latency;
  667. fixed20_12 consumption_rate;
  668. fixed20_12 active_time;
  669. fixed20_12 dbpp;
  670. fixed20_12 priority_mark_max;
  671. fixed20_12 priority_mark;
  672. fixed20_12 sclk;
  673. };
  674. void rv515_crtc_bandwidth_compute(struct radeon_device *rdev,
  675. struct radeon_crtc *crtc,
  676. struct rv515_watermark *wm)
  677. {
  678. struct drm_display_mode *mode = &crtc->base.mode;
  679. fixed20_12 a, b, c;
  680. fixed20_12 pclk, request_fifo_depth, tolerable_latency, estimated_width;
  681. fixed20_12 consumption_time, line_time, chunk_time, read_delay_latency;
  682. if (!crtc->base.enabled) {
  683. /* FIXME: wouldn't it better to set priority mark to maximum */
  684. wm->lb_request_fifo_depth = 4;
  685. return;
  686. }
  687. if (crtc->vsc.full > rfixed_const(2))
  688. wm->num_line_pair.full = rfixed_const(2);
  689. else
  690. wm->num_line_pair.full = rfixed_const(1);
  691. b.full = rfixed_const(mode->crtc_hdisplay);
  692. c.full = rfixed_const(256);
  693. a.full = rfixed_mul(wm->num_line_pair, b);
  694. request_fifo_depth.full = rfixed_div(a, c);
  695. if (a.full < rfixed_const(4)) {
  696. wm->lb_request_fifo_depth = 4;
  697. } else {
  698. wm->lb_request_fifo_depth = rfixed_trunc(request_fifo_depth);
  699. }
  700. /* Determine consumption rate
  701. * pclk = pixel clock period(ns) = 1000 / (mode.clock / 1000)
  702. * vtaps = number of vertical taps,
  703. * vsc = vertical scaling ratio, defined as source/destination
  704. * hsc = horizontal scaling ration, defined as source/destination
  705. */
  706. a.full = rfixed_const(mode->clock);
  707. b.full = rfixed_const(1000);
  708. a.full = rfixed_div(a, b);
  709. pclk.full = rfixed_div(b, a);
  710. if (crtc->rmx_type != RMX_OFF) {
  711. b.full = rfixed_const(2);
  712. if (crtc->vsc.full > b.full)
  713. b.full = crtc->vsc.full;
  714. b.full = rfixed_mul(b, crtc->hsc);
  715. c.full = rfixed_const(2);
  716. b.full = rfixed_div(b, c);
  717. consumption_time.full = rfixed_div(pclk, b);
  718. } else {
  719. consumption_time.full = pclk.full;
  720. }
  721. a.full = rfixed_const(1);
  722. wm->consumption_rate.full = rfixed_div(a, consumption_time);
  723. /* Determine line time
  724. * LineTime = total time for one line of displayhtotal
  725. * LineTime = total number of horizontal pixels
  726. * pclk = pixel clock period(ns)
  727. */
  728. a.full = rfixed_const(crtc->base.mode.crtc_htotal);
  729. line_time.full = rfixed_mul(a, pclk);
  730. /* Determine active time
  731. * ActiveTime = time of active region of display within one line,
  732. * hactive = total number of horizontal active pixels
  733. * htotal = total number of horizontal pixels
  734. */
  735. a.full = rfixed_const(crtc->base.mode.crtc_htotal);
  736. b.full = rfixed_const(crtc->base.mode.crtc_hdisplay);
  737. wm->active_time.full = rfixed_mul(line_time, b);
  738. wm->active_time.full = rfixed_div(wm->active_time, a);
  739. /* Determine chunk time
  740. * ChunkTime = the time it takes the DCP to send one chunk of data
  741. * to the LB which consists of pipeline delay and inter chunk gap
  742. * sclk = system clock(Mhz)
  743. */
  744. a.full = rfixed_const(600 * 1000);
  745. chunk_time.full = rfixed_div(a, rdev->pm.sclk);
  746. read_delay_latency.full = rfixed_const(1000);
  747. /* Determine the worst case latency
  748. * NumLinePair = Number of line pairs to request(1=2 lines, 2=4 lines)
  749. * WorstCaseLatency = worst case time from urgent to when the MC starts
  750. * to return data
  751. * READ_DELAY_IDLE_MAX = constant of 1us
  752. * ChunkTime = time it takes the DCP to send one chunk of data to the LB
  753. * which consists of pipeline delay and inter chunk gap
  754. */
  755. if (rfixed_trunc(wm->num_line_pair) > 1) {
  756. a.full = rfixed_const(3);
  757. wm->worst_case_latency.full = rfixed_mul(a, chunk_time);
  758. wm->worst_case_latency.full += read_delay_latency.full;
  759. } else {
  760. wm->worst_case_latency.full = chunk_time.full + read_delay_latency.full;
  761. }
  762. /* Determine the tolerable latency
  763. * TolerableLatency = Any given request has only 1 line time
  764. * for the data to be returned
  765. * LBRequestFifoDepth = Number of chunk requests the LB can
  766. * put into the request FIFO for a display
  767. * LineTime = total time for one line of display
  768. * ChunkTime = the time it takes the DCP to send one chunk
  769. * of data to the LB which consists of
  770. * pipeline delay and inter chunk gap
  771. */
  772. if ((2+wm->lb_request_fifo_depth) >= rfixed_trunc(request_fifo_depth)) {
  773. tolerable_latency.full = line_time.full;
  774. } else {
  775. tolerable_latency.full = rfixed_const(wm->lb_request_fifo_depth - 2);
  776. tolerable_latency.full = request_fifo_depth.full - tolerable_latency.full;
  777. tolerable_latency.full = rfixed_mul(tolerable_latency, chunk_time);
  778. tolerable_latency.full = line_time.full - tolerable_latency.full;
  779. }
  780. /* We assume worst case 32bits (4 bytes) */
  781. wm->dbpp.full = rfixed_const(2 * 16);
  782. /* Determine the maximum priority mark
  783. * width = viewport width in pixels
  784. */
  785. a.full = rfixed_const(16);
  786. wm->priority_mark_max.full = rfixed_const(crtc->base.mode.crtc_hdisplay);
  787. wm->priority_mark_max.full = rfixed_div(wm->priority_mark_max, a);
  788. /* Determine estimated width */
  789. estimated_width.full = tolerable_latency.full - wm->worst_case_latency.full;
  790. estimated_width.full = rfixed_div(estimated_width, consumption_time);
  791. if (rfixed_trunc(estimated_width) > crtc->base.mode.crtc_hdisplay) {
  792. wm->priority_mark.full = rfixed_const(10);
  793. } else {
  794. a.full = rfixed_const(16);
  795. wm->priority_mark.full = rfixed_div(estimated_width, a);
  796. wm->priority_mark.full = wm->priority_mark_max.full - wm->priority_mark.full;
  797. }
  798. }
  799. void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
  800. {
  801. struct drm_display_mode *mode0 = NULL;
  802. struct drm_display_mode *mode1 = NULL;
  803. struct rv515_watermark wm0;
  804. struct rv515_watermark wm1;
  805. u32 tmp;
  806. fixed20_12 priority_mark02, priority_mark12, fill_rate;
  807. fixed20_12 a, b;
  808. if (rdev->mode_info.crtcs[0]->base.enabled)
  809. mode0 = &rdev->mode_info.crtcs[0]->base.mode;
  810. if (rdev->mode_info.crtcs[1]->base.enabled)
  811. mode1 = &rdev->mode_info.crtcs[1]->base.mode;
  812. rs690_line_buffer_adjust(rdev, mode0, mode1);
  813. rv515_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[0], &wm0);
  814. rv515_crtc_bandwidth_compute(rdev, rdev->mode_info.crtcs[1], &wm1);
  815. tmp = wm0.lb_request_fifo_depth;
  816. tmp |= wm1.lb_request_fifo_depth << 16;
  817. WREG32(LB_MAX_REQ_OUTSTANDING, tmp);
  818. if (mode0 && mode1) {
  819. if (rfixed_trunc(wm0.dbpp) > 64)
  820. a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
  821. else
  822. a.full = wm0.num_line_pair.full;
  823. if (rfixed_trunc(wm1.dbpp) > 64)
  824. b.full = rfixed_div(wm1.dbpp, wm1.num_line_pair);
  825. else
  826. b.full = wm1.num_line_pair.full;
  827. a.full += b.full;
  828. fill_rate.full = rfixed_div(wm0.sclk, a);
  829. if (wm0.consumption_rate.full > fill_rate.full) {
  830. b.full = wm0.consumption_rate.full - fill_rate.full;
  831. b.full = rfixed_mul(b, wm0.active_time);
  832. a.full = rfixed_const(16);
  833. b.full = rfixed_div(b, a);
  834. a.full = rfixed_mul(wm0.worst_case_latency,
  835. wm0.consumption_rate);
  836. priority_mark02.full = a.full + b.full;
  837. } else {
  838. a.full = rfixed_mul(wm0.worst_case_latency,
  839. wm0.consumption_rate);
  840. b.full = rfixed_const(16 * 1000);
  841. priority_mark02.full = rfixed_div(a, b);
  842. }
  843. if (wm1.consumption_rate.full > fill_rate.full) {
  844. b.full = wm1.consumption_rate.full - fill_rate.full;
  845. b.full = rfixed_mul(b, wm1.active_time);
  846. a.full = rfixed_const(16);
  847. b.full = rfixed_div(b, a);
  848. a.full = rfixed_mul(wm1.worst_case_latency,
  849. wm1.consumption_rate);
  850. priority_mark12.full = a.full + b.full;
  851. } else {
  852. a.full = rfixed_mul(wm1.worst_case_latency,
  853. wm1.consumption_rate);
  854. b.full = rfixed_const(16 * 1000);
  855. priority_mark12.full = rfixed_div(a, b);
  856. }
  857. if (wm0.priority_mark.full > priority_mark02.full)
  858. priority_mark02.full = wm0.priority_mark.full;
  859. if (rfixed_trunc(priority_mark02) < 0)
  860. priority_mark02.full = 0;
  861. if (wm0.priority_mark_max.full > priority_mark02.full)
  862. priority_mark02.full = wm0.priority_mark_max.full;
  863. if (wm1.priority_mark.full > priority_mark12.full)
  864. priority_mark12.full = wm1.priority_mark.full;
  865. if (rfixed_trunc(priority_mark12) < 0)
  866. priority_mark12.full = 0;
  867. if (wm1.priority_mark_max.full > priority_mark12.full)
  868. priority_mark12.full = wm1.priority_mark_max.full;
  869. WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
  870. WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
  871. WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
  872. WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
  873. } else if (mode0) {
  874. if (rfixed_trunc(wm0.dbpp) > 64)
  875. a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
  876. else
  877. a.full = wm0.num_line_pair.full;
  878. fill_rate.full = rfixed_div(wm0.sclk, a);
  879. if (wm0.consumption_rate.full > fill_rate.full) {
  880. b.full = wm0.consumption_rate.full - fill_rate.full;
  881. b.full = rfixed_mul(b, wm0.active_time);
  882. a.full = rfixed_const(16);
  883. b.full = rfixed_div(b, a);
  884. a.full = rfixed_mul(wm0.worst_case_latency,
  885. wm0.consumption_rate);
  886. priority_mark02.full = a.full + b.full;
  887. } else {
  888. a.full = rfixed_mul(wm0.worst_case_latency,
  889. wm0.consumption_rate);
  890. b.full = rfixed_const(16);
  891. priority_mark02.full = rfixed_div(a, b);
  892. }
  893. if (wm0.priority_mark.full > priority_mark02.full)
  894. priority_mark02.full = wm0.priority_mark.full;
  895. if (rfixed_trunc(priority_mark02) < 0)
  896. priority_mark02.full = 0;
  897. if (wm0.priority_mark_max.full > priority_mark02.full)
  898. priority_mark02.full = wm0.priority_mark_max.full;
  899. WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02));
  900. WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02));
  901. WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
  902. WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
  903. } else {
  904. if (rfixed_trunc(wm1.dbpp) > 64)
  905. a.full = rfixed_div(wm1.dbpp, wm1.num_line_pair);
  906. else
  907. a.full = wm1.num_line_pair.full;
  908. fill_rate.full = rfixed_div(wm1.sclk, a);
  909. if (wm1.consumption_rate.full > fill_rate.full) {
  910. b.full = wm1.consumption_rate.full - fill_rate.full;
  911. b.full = rfixed_mul(b, wm1.active_time);
  912. a.full = rfixed_const(16);
  913. b.full = rfixed_div(b, a);
  914. a.full = rfixed_mul(wm1.worst_case_latency,
  915. wm1.consumption_rate);
  916. priority_mark12.full = a.full + b.full;
  917. } else {
  918. a.full = rfixed_mul(wm1.worst_case_latency,
  919. wm1.consumption_rate);
  920. b.full = rfixed_const(16 * 1000);
  921. priority_mark12.full = rfixed_div(a, b);
  922. }
  923. if (wm1.priority_mark.full > priority_mark12.full)
  924. priority_mark12.full = wm1.priority_mark.full;
  925. if (rfixed_trunc(priority_mark12) < 0)
  926. priority_mark12.full = 0;
  927. if (wm1.priority_mark_max.full > priority_mark12.full)
  928. priority_mark12.full = wm1.priority_mark_max.full;
  929. WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
  930. WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
  931. WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12));
  932. WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12));
  933. }
  934. }
  935. void rv515_bandwidth_update(struct radeon_device *rdev)
  936. {
  937. uint32_t tmp;
  938. struct drm_display_mode *mode0 = NULL;
  939. struct drm_display_mode *mode1 = NULL;
  940. if (rdev->mode_info.crtcs[0]->base.enabled)
  941. mode0 = &rdev->mode_info.crtcs[0]->base.mode;
  942. if (rdev->mode_info.crtcs[1]->base.enabled)
  943. mode1 = &rdev->mode_info.crtcs[1]->base.mode;
  944. /*
  945. * Set display0/1 priority up in the memory controller for
  946. * modes if the user specifies HIGH for displaypriority
  947. * option.
  948. */
  949. if (rdev->disp_priority == 2) {
  950. tmp = RREG32_MC(MC_MISC_LAT_TIMER);
  951. tmp &= ~MC_DISP1R_INIT_LAT_MASK;
  952. tmp &= ~MC_DISP0R_INIT_LAT_MASK;
  953. if (mode1)
  954. tmp |= (1 << MC_DISP1R_INIT_LAT_SHIFT);
  955. if (mode0)
  956. tmp |= (1 << MC_DISP0R_INIT_LAT_SHIFT);
  957. WREG32_MC(MC_MISC_LAT_TIMER, tmp);
  958. }
  959. rv515_bandwidth_avivo_update(rdev);
  960. }