Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | * Authors: Alex Deucher |
| 23 | */ |
| 24 | #include <linux/firmware.h> |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 25 | #include <linux/slab.h> |
| 26 | #include <linux/module.h> |
| 27 | #include "drmP.h" |
| 28 | #include "radeon.h" |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 29 | #include "radeon_asic.h" |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 30 | #include "cikd.h" |
| 31 | #include "atom.h" |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 32 | #include "cik_blit_shaders.h" |
Alex Deucher | 8c68e39 | 2013-06-21 15:38:37 -0400 | [diff] [blame] | 33 | #include "radeon_ucode.h" |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 34 | #include "clearstate_ci.h" |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 35 | |
| 36 | MODULE_FIRMWARE("radeon/BONAIRE_pfp.bin"); |
| 37 | MODULE_FIRMWARE("radeon/BONAIRE_me.bin"); |
| 38 | MODULE_FIRMWARE("radeon/BONAIRE_ce.bin"); |
| 39 | MODULE_FIRMWARE("radeon/BONAIRE_mec.bin"); |
| 40 | MODULE_FIRMWARE("radeon/BONAIRE_mc.bin"); |
| 41 | MODULE_FIRMWARE("radeon/BONAIRE_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 42 | MODULE_FIRMWARE("radeon/BONAIRE_sdma.bin"); |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 43 | MODULE_FIRMWARE("radeon/BONAIRE_smc.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 44 | MODULE_FIRMWARE("radeon/KAVERI_pfp.bin"); |
| 45 | MODULE_FIRMWARE("radeon/KAVERI_me.bin"); |
| 46 | MODULE_FIRMWARE("radeon/KAVERI_ce.bin"); |
| 47 | MODULE_FIRMWARE("radeon/KAVERI_mec.bin"); |
| 48 | MODULE_FIRMWARE("radeon/KAVERI_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 49 | MODULE_FIRMWARE("radeon/KAVERI_sdma.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 50 | MODULE_FIRMWARE("radeon/KABINI_pfp.bin"); |
| 51 | MODULE_FIRMWARE("radeon/KABINI_me.bin"); |
| 52 | MODULE_FIRMWARE("radeon/KABINI_ce.bin"); |
| 53 | MODULE_FIRMWARE("radeon/KABINI_mec.bin"); |
| 54 | MODULE_FIRMWARE("radeon/KABINI_rlc.bin"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 55 | MODULE_FIRMWARE("radeon/KABINI_sdma.bin"); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 56 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 57 | extern int r600_ih_ring_alloc(struct radeon_device *rdev); |
| 58 | extern void r600_ih_ring_fini(struct radeon_device *rdev); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 59 | extern void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save); |
| 60 | extern void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 61 | extern bool evergreen_is_display_hung(struct radeon_device *rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 62 | extern void sumo_rlc_fini(struct radeon_device *rdev); |
| 63 | extern int sumo_rlc_init(struct radeon_device *rdev); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 64 | extern void si_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 65 | extern void si_rlc_reset(struct radeon_device *rdev); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 66 | extern void si_init_uvd_internal_cg(struct radeon_device *rdev); |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 67 | extern int cik_sdma_resume(struct radeon_device *rdev); |
| 68 | extern void cik_sdma_enable(struct radeon_device *rdev, bool enable); |
| 69 | extern void cik_sdma_fini(struct radeon_device *rdev); |
| 70 | extern void cik_sdma_vm_set_page(struct radeon_device *rdev, |
| 71 | struct radeon_ib *ib, |
| 72 | uint64_t pe, |
| 73 | uint64_t addr, unsigned count, |
| 74 | uint32_t incr, uint32_t flags); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 75 | static void cik_rlc_stop(struct radeon_device *rdev); |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 76 | static void cik_pcie_gen3_enable(struct radeon_device *rdev); |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 77 | static void cik_program_aspm(struct radeon_device *rdev); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 78 | static void cik_init_pg(struct radeon_device *rdev); |
| 79 | static void cik_init_cg(struct radeon_device *rdev); |
Alex Deucher | fb2c7f4 | 2013-10-02 14:54:44 -0400 | [diff] [blame] | 80 | static void cik_fini_pg(struct radeon_device *rdev); |
| 81 | static void cik_fini_cg(struct radeon_device *rdev); |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 82 | static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev, |
| 83 | bool enable); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 84 | |
Alex Deucher | 286d9cc | 2013-06-21 15:50:47 -0400 | [diff] [blame] | 85 | /* get temperature in millidegrees */ |
| 86 | int ci_get_temp(struct radeon_device *rdev) |
| 87 | { |
| 88 | u32 temp; |
| 89 | int actual_temp = 0; |
| 90 | |
| 91 | temp = (RREG32_SMC(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >> |
| 92 | CTF_TEMP_SHIFT; |
| 93 | |
| 94 | if (temp & 0x200) |
| 95 | actual_temp = 255; |
| 96 | else |
| 97 | actual_temp = temp & 0x1ff; |
| 98 | |
| 99 | actual_temp = actual_temp * 1000; |
| 100 | |
| 101 | return actual_temp; |
| 102 | } |
| 103 | |
| 104 | /* get temperature in millidegrees */ |
| 105 | int kv_get_temp(struct radeon_device *rdev) |
| 106 | { |
| 107 | u32 temp; |
| 108 | int actual_temp = 0; |
| 109 | |
| 110 | temp = RREG32_SMC(0xC0300E0C); |
| 111 | |
| 112 | if (temp) |
| 113 | actual_temp = (temp / 8) - 49; |
| 114 | else |
| 115 | actual_temp = 0; |
| 116 | |
| 117 | actual_temp = actual_temp * 1000; |
| 118 | |
| 119 | return actual_temp; |
| 120 | } |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 121 | |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 122 | /* |
| 123 | * Indirect registers accessor |
| 124 | */ |
| 125 | u32 cik_pciep_rreg(struct radeon_device *rdev, u32 reg) |
| 126 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 127 | unsigned long flags; |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 128 | u32 r; |
| 129 | |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 130 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 131 | WREG32(PCIE_INDEX, reg); |
| 132 | (void)RREG32(PCIE_INDEX); |
| 133 | r = RREG32(PCIE_DATA); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 134 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 135 | return r; |
| 136 | } |
| 137 | |
| 138 | void cik_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) |
| 139 | { |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 140 | unsigned long flags; |
| 141 | |
| 142 | spin_lock_irqsave(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 143 | WREG32(PCIE_INDEX, reg); |
| 144 | (void)RREG32(PCIE_INDEX); |
| 145 | WREG32(PCIE_DATA, v); |
| 146 | (void)RREG32(PCIE_DATA); |
Alex Deucher | 0a5b7b0 | 2013-09-03 19:00:09 -0400 | [diff] [blame] | 147 | spin_unlock_irqrestore(&rdev->pciep_idx_lock, flags); |
Alex Deucher | 6e2c3c0 | 2013-04-03 19:28:32 -0400 | [diff] [blame] | 148 | } |
| 149 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 150 | static const u32 spectre_rlc_save_restore_register_list[] = |
| 151 | { |
| 152 | (0x0e00 << 16) | (0xc12c >> 2), |
| 153 | 0x00000000, |
| 154 | (0x0e00 << 16) | (0xc140 >> 2), |
| 155 | 0x00000000, |
| 156 | (0x0e00 << 16) | (0xc150 >> 2), |
| 157 | 0x00000000, |
| 158 | (0x0e00 << 16) | (0xc15c >> 2), |
| 159 | 0x00000000, |
| 160 | (0x0e00 << 16) | (0xc168 >> 2), |
| 161 | 0x00000000, |
| 162 | (0x0e00 << 16) | (0xc170 >> 2), |
| 163 | 0x00000000, |
| 164 | (0x0e00 << 16) | (0xc178 >> 2), |
| 165 | 0x00000000, |
| 166 | (0x0e00 << 16) | (0xc204 >> 2), |
| 167 | 0x00000000, |
| 168 | (0x0e00 << 16) | (0xc2b4 >> 2), |
| 169 | 0x00000000, |
| 170 | (0x0e00 << 16) | (0xc2b8 >> 2), |
| 171 | 0x00000000, |
| 172 | (0x0e00 << 16) | (0xc2bc >> 2), |
| 173 | 0x00000000, |
| 174 | (0x0e00 << 16) | (0xc2c0 >> 2), |
| 175 | 0x00000000, |
| 176 | (0x0e00 << 16) | (0x8228 >> 2), |
| 177 | 0x00000000, |
| 178 | (0x0e00 << 16) | (0x829c >> 2), |
| 179 | 0x00000000, |
| 180 | (0x0e00 << 16) | (0x869c >> 2), |
| 181 | 0x00000000, |
| 182 | (0x0600 << 16) | (0x98f4 >> 2), |
| 183 | 0x00000000, |
| 184 | (0x0e00 << 16) | (0x98f8 >> 2), |
| 185 | 0x00000000, |
| 186 | (0x0e00 << 16) | (0x9900 >> 2), |
| 187 | 0x00000000, |
| 188 | (0x0e00 << 16) | (0xc260 >> 2), |
| 189 | 0x00000000, |
| 190 | (0x0e00 << 16) | (0x90e8 >> 2), |
| 191 | 0x00000000, |
| 192 | (0x0e00 << 16) | (0x3c000 >> 2), |
| 193 | 0x00000000, |
| 194 | (0x0e00 << 16) | (0x3c00c >> 2), |
| 195 | 0x00000000, |
| 196 | (0x0e00 << 16) | (0x8c1c >> 2), |
| 197 | 0x00000000, |
| 198 | (0x0e00 << 16) | (0x9700 >> 2), |
| 199 | 0x00000000, |
| 200 | (0x0e00 << 16) | (0xcd20 >> 2), |
| 201 | 0x00000000, |
| 202 | (0x4e00 << 16) | (0xcd20 >> 2), |
| 203 | 0x00000000, |
| 204 | (0x5e00 << 16) | (0xcd20 >> 2), |
| 205 | 0x00000000, |
| 206 | (0x6e00 << 16) | (0xcd20 >> 2), |
| 207 | 0x00000000, |
| 208 | (0x7e00 << 16) | (0xcd20 >> 2), |
| 209 | 0x00000000, |
| 210 | (0x8e00 << 16) | (0xcd20 >> 2), |
| 211 | 0x00000000, |
| 212 | (0x9e00 << 16) | (0xcd20 >> 2), |
| 213 | 0x00000000, |
| 214 | (0xae00 << 16) | (0xcd20 >> 2), |
| 215 | 0x00000000, |
| 216 | (0xbe00 << 16) | (0xcd20 >> 2), |
| 217 | 0x00000000, |
| 218 | (0x0e00 << 16) | (0x89bc >> 2), |
| 219 | 0x00000000, |
| 220 | (0x0e00 << 16) | (0x8900 >> 2), |
| 221 | 0x00000000, |
| 222 | 0x3, |
| 223 | (0x0e00 << 16) | (0xc130 >> 2), |
| 224 | 0x00000000, |
| 225 | (0x0e00 << 16) | (0xc134 >> 2), |
| 226 | 0x00000000, |
| 227 | (0x0e00 << 16) | (0xc1fc >> 2), |
| 228 | 0x00000000, |
| 229 | (0x0e00 << 16) | (0xc208 >> 2), |
| 230 | 0x00000000, |
| 231 | (0x0e00 << 16) | (0xc264 >> 2), |
| 232 | 0x00000000, |
| 233 | (0x0e00 << 16) | (0xc268 >> 2), |
| 234 | 0x00000000, |
| 235 | (0x0e00 << 16) | (0xc26c >> 2), |
| 236 | 0x00000000, |
| 237 | (0x0e00 << 16) | (0xc270 >> 2), |
| 238 | 0x00000000, |
| 239 | (0x0e00 << 16) | (0xc274 >> 2), |
| 240 | 0x00000000, |
| 241 | (0x0e00 << 16) | (0xc278 >> 2), |
| 242 | 0x00000000, |
| 243 | (0x0e00 << 16) | (0xc27c >> 2), |
| 244 | 0x00000000, |
| 245 | (0x0e00 << 16) | (0xc280 >> 2), |
| 246 | 0x00000000, |
| 247 | (0x0e00 << 16) | (0xc284 >> 2), |
| 248 | 0x00000000, |
| 249 | (0x0e00 << 16) | (0xc288 >> 2), |
| 250 | 0x00000000, |
| 251 | (0x0e00 << 16) | (0xc28c >> 2), |
| 252 | 0x00000000, |
| 253 | (0x0e00 << 16) | (0xc290 >> 2), |
| 254 | 0x00000000, |
| 255 | (0x0e00 << 16) | (0xc294 >> 2), |
| 256 | 0x00000000, |
| 257 | (0x0e00 << 16) | (0xc298 >> 2), |
| 258 | 0x00000000, |
| 259 | (0x0e00 << 16) | (0xc29c >> 2), |
| 260 | 0x00000000, |
| 261 | (0x0e00 << 16) | (0xc2a0 >> 2), |
| 262 | 0x00000000, |
| 263 | (0x0e00 << 16) | (0xc2a4 >> 2), |
| 264 | 0x00000000, |
| 265 | (0x0e00 << 16) | (0xc2a8 >> 2), |
| 266 | 0x00000000, |
| 267 | (0x0e00 << 16) | (0xc2ac >> 2), |
| 268 | 0x00000000, |
| 269 | (0x0e00 << 16) | (0xc2b0 >> 2), |
| 270 | 0x00000000, |
| 271 | (0x0e00 << 16) | (0x301d0 >> 2), |
| 272 | 0x00000000, |
| 273 | (0x0e00 << 16) | (0x30238 >> 2), |
| 274 | 0x00000000, |
| 275 | (0x0e00 << 16) | (0x30250 >> 2), |
| 276 | 0x00000000, |
| 277 | (0x0e00 << 16) | (0x30254 >> 2), |
| 278 | 0x00000000, |
| 279 | (0x0e00 << 16) | (0x30258 >> 2), |
| 280 | 0x00000000, |
| 281 | (0x0e00 << 16) | (0x3025c >> 2), |
| 282 | 0x00000000, |
| 283 | (0x4e00 << 16) | (0xc900 >> 2), |
| 284 | 0x00000000, |
| 285 | (0x5e00 << 16) | (0xc900 >> 2), |
| 286 | 0x00000000, |
| 287 | (0x6e00 << 16) | (0xc900 >> 2), |
| 288 | 0x00000000, |
| 289 | (0x7e00 << 16) | (0xc900 >> 2), |
| 290 | 0x00000000, |
| 291 | (0x8e00 << 16) | (0xc900 >> 2), |
| 292 | 0x00000000, |
| 293 | (0x9e00 << 16) | (0xc900 >> 2), |
| 294 | 0x00000000, |
| 295 | (0xae00 << 16) | (0xc900 >> 2), |
| 296 | 0x00000000, |
| 297 | (0xbe00 << 16) | (0xc900 >> 2), |
| 298 | 0x00000000, |
| 299 | (0x4e00 << 16) | (0xc904 >> 2), |
| 300 | 0x00000000, |
| 301 | (0x5e00 << 16) | (0xc904 >> 2), |
| 302 | 0x00000000, |
| 303 | (0x6e00 << 16) | (0xc904 >> 2), |
| 304 | 0x00000000, |
| 305 | (0x7e00 << 16) | (0xc904 >> 2), |
| 306 | 0x00000000, |
| 307 | (0x8e00 << 16) | (0xc904 >> 2), |
| 308 | 0x00000000, |
| 309 | (0x9e00 << 16) | (0xc904 >> 2), |
| 310 | 0x00000000, |
| 311 | (0xae00 << 16) | (0xc904 >> 2), |
| 312 | 0x00000000, |
| 313 | (0xbe00 << 16) | (0xc904 >> 2), |
| 314 | 0x00000000, |
| 315 | (0x4e00 << 16) | (0xc908 >> 2), |
| 316 | 0x00000000, |
| 317 | (0x5e00 << 16) | (0xc908 >> 2), |
| 318 | 0x00000000, |
| 319 | (0x6e00 << 16) | (0xc908 >> 2), |
| 320 | 0x00000000, |
| 321 | (0x7e00 << 16) | (0xc908 >> 2), |
| 322 | 0x00000000, |
| 323 | (0x8e00 << 16) | (0xc908 >> 2), |
| 324 | 0x00000000, |
| 325 | (0x9e00 << 16) | (0xc908 >> 2), |
| 326 | 0x00000000, |
| 327 | (0xae00 << 16) | (0xc908 >> 2), |
| 328 | 0x00000000, |
| 329 | (0xbe00 << 16) | (0xc908 >> 2), |
| 330 | 0x00000000, |
| 331 | (0x4e00 << 16) | (0xc90c >> 2), |
| 332 | 0x00000000, |
| 333 | (0x5e00 << 16) | (0xc90c >> 2), |
| 334 | 0x00000000, |
| 335 | (0x6e00 << 16) | (0xc90c >> 2), |
| 336 | 0x00000000, |
| 337 | (0x7e00 << 16) | (0xc90c >> 2), |
| 338 | 0x00000000, |
| 339 | (0x8e00 << 16) | (0xc90c >> 2), |
| 340 | 0x00000000, |
| 341 | (0x9e00 << 16) | (0xc90c >> 2), |
| 342 | 0x00000000, |
| 343 | (0xae00 << 16) | (0xc90c >> 2), |
| 344 | 0x00000000, |
| 345 | (0xbe00 << 16) | (0xc90c >> 2), |
| 346 | 0x00000000, |
| 347 | (0x4e00 << 16) | (0xc910 >> 2), |
| 348 | 0x00000000, |
| 349 | (0x5e00 << 16) | (0xc910 >> 2), |
| 350 | 0x00000000, |
| 351 | (0x6e00 << 16) | (0xc910 >> 2), |
| 352 | 0x00000000, |
| 353 | (0x7e00 << 16) | (0xc910 >> 2), |
| 354 | 0x00000000, |
| 355 | (0x8e00 << 16) | (0xc910 >> 2), |
| 356 | 0x00000000, |
| 357 | (0x9e00 << 16) | (0xc910 >> 2), |
| 358 | 0x00000000, |
| 359 | (0xae00 << 16) | (0xc910 >> 2), |
| 360 | 0x00000000, |
| 361 | (0xbe00 << 16) | (0xc910 >> 2), |
| 362 | 0x00000000, |
| 363 | (0x0e00 << 16) | (0xc99c >> 2), |
| 364 | 0x00000000, |
| 365 | (0x0e00 << 16) | (0x9834 >> 2), |
| 366 | 0x00000000, |
| 367 | (0x0000 << 16) | (0x30f00 >> 2), |
| 368 | 0x00000000, |
| 369 | (0x0001 << 16) | (0x30f00 >> 2), |
| 370 | 0x00000000, |
| 371 | (0x0000 << 16) | (0x30f04 >> 2), |
| 372 | 0x00000000, |
| 373 | (0x0001 << 16) | (0x30f04 >> 2), |
| 374 | 0x00000000, |
| 375 | (0x0000 << 16) | (0x30f08 >> 2), |
| 376 | 0x00000000, |
| 377 | (0x0001 << 16) | (0x30f08 >> 2), |
| 378 | 0x00000000, |
| 379 | (0x0000 << 16) | (0x30f0c >> 2), |
| 380 | 0x00000000, |
| 381 | (0x0001 << 16) | (0x30f0c >> 2), |
| 382 | 0x00000000, |
| 383 | (0x0600 << 16) | (0x9b7c >> 2), |
| 384 | 0x00000000, |
| 385 | (0x0e00 << 16) | (0x8a14 >> 2), |
| 386 | 0x00000000, |
| 387 | (0x0e00 << 16) | (0x8a18 >> 2), |
| 388 | 0x00000000, |
| 389 | (0x0600 << 16) | (0x30a00 >> 2), |
| 390 | 0x00000000, |
| 391 | (0x0e00 << 16) | (0x8bf0 >> 2), |
| 392 | 0x00000000, |
| 393 | (0x0e00 << 16) | (0x8bcc >> 2), |
| 394 | 0x00000000, |
| 395 | (0x0e00 << 16) | (0x8b24 >> 2), |
| 396 | 0x00000000, |
| 397 | (0x0e00 << 16) | (0x30a04 >> 2), |
| 398 | 0x00000000, |
| 399 | (0x0600 << 16) | (0x30a10 >> 2), |
| 400 | 0x00000000, |
| 401 | (0x0600 << 16) | (0x30a14 >> 2), |
| 402 | 0x00000000, |
| 403 | (0x0600 << 16) | (0x30a18 >> 2), |
| 404 | 0x00000000, |
| 405 | (0x0600 << 16) | (0x30a2c >> 2), |
| 406 | 0x00000000, |
| 407 | (0x0e00 << 16) | (0xc700 >> 2), |
| 408 | 0x00000000, |
| 409 | (0x0e00 << 16) | (0xc704 >> 2), |
| 410 | 0x00000000, |
| 411 | (0x0e00 << 16) | (0xc708 >> 2), |
| 412 | 0x00000000, |
| 413 | (0x0e00 << 16) | (0xc768 >> 2), |
| 414 | 0x00000000, |
| 415 | (0x0400 << 16) | (0xc770 >> 2), |
| 416 | 0x00000000, |
| 417 | (0x0400 << 16) | (0xc774 >> 2), |
| 418 | 0x00000000, |
| 419 | (0x0400 << 16) | (0xc778 >> 2), |
| 420 | 0x00000000, |
| 421 | (0x0400 << 16) | (0xc77c >> 2), |
| 422 | 0x00000000, |
| 423 | (0x0400 << 16) | (0xc780 >> 2), |
| 424 | 0x00000000, |
| 425 | (0x0400 << 16) | (0xc784 >> 2), |
| 426 | 0x00000000, |
| 427 | (0x0400 << 16) | (0xc788 >> 2), |
| 428 | 0x00000000, |
| 429 | (0x0400 << 16) | (0xc78c >> 2), |
| 430 | 0x00000000, |
| 431 | (0x0400 << 16) | (0xc798 >> 2), |
| 432 | 0x00000000, |
| 433 | (0x0400 << 16) | (0xc79c >> 2), |
| 434 | 0x00000000, |
| 435 | (0x0400 << 16) | (0xc7a0 >> 2), |
| 436 | 0x00000000, |
| 437 | (0x0400 << 16) | (0xc7a4 >> 2), |
| 438 | 0x00000000, |
| 439 | (0x0400 << 16) | (0xc7a8 >> 2), |
| 440 | 0x00000000, |
| 441 | (0x0400 << 16) | (0xc7ac >> 2), |
| 442 | 0x00000000, |
| 443 | (0x0400 << 16) | (0xc7b0 >> 2), |
| 444 | 0x00000000, |
| 445 | (0x0400 << 16) | (0xc7b4 >> 2), |
| 446 | 0x00000000, |
| 447 | (0x0e00 << 16) | (0x9100 >> 2), |
| 448 | 0x00000000, |
| 449 | (0x0e00 << 16) | (0x3c010 >> 2), |
| 450 | 0x00000000, |
| 451 | (0x0e00 << 16) | (0x92a8 >> 2), |
| 452 | 0x00000000, |
| 453 | (0x0e00 << 16) | (0x92ac >> 2), |
| 454 | 0x00000000, |
| 455 | (0x0e00 << 16) | (0x92b4 >> 2), |
| 456 | 0x00000000, |
| 457 | (0x0e00 << 16) | (0x92b8 >> 2), |
| 458 | 0x00000000, |
| 459 | (0x0e00 << 16) | (0x92bc >> 2), |
| 460 | 0x00000000, |
| 461 | (0x0e00 << 16) | (0x92c0 >> 2), |
| 462 | 0x00000000, |
| 463 | (0x0e00 << 16) | (0x92c4 >> 2), |
| 464 | 0x00000000, |
| 465 | (0x0e00 << 16) | (0x92c8 >> 2), |
| 466 | 0x00000000, |
| 467 | (0x0e00 << 16) | (0x92cc >> 2), |
| 468 | 0x00000000, |
| 469 | (0x0e00 << 16) | (0x92d0 >> 2), |
| 470 | 0x00000000, |
| 471 | (0x0e00 << 16) | (0x8c00 >> 2), |
| 472 | 0x00000000, |
| 473 | (0x0e00 << 16) | (0x8c04 >> 2), |
| 474 | 0x00000000, |
| 475 | (0x0e00 << 16) | (0x8c20 >> 2), |
| 476 | 0x00000000, |
| 477 | (0x0e00 << 16) | (0x8c38 >> 2), |
| 478 | 0x00000000, |
| 479 | (0x0e00 << 16) | (0x8c3c >> 2), |
| 480 | 0x00000000, |
| 481 | (0x0e00 << 16) | (0xae00 >> 2), |
| 482 | 0x00000000, |
| 483 | (0x0e00 << 16) | (0x9604 >> 2), |
| 484 | 0x00000000, |
| 485 | (0x0e00 << 16) | (0xac08 >> 2), |
| 486 | 0x00000000, |
| 487 | (0x0e00 << 16) | (0xac0c >> 2), |
| 488 | 0x00000000, |
| 489 | (0x0e00 << 16) | (0xac10 >> 2), |
| 490 | 0x00000000, |
| 491 | (0x0e00 << 16) | (0xac14 >> 2), |
| 492 | 0x00000000, |
| 493 | (0x0e00 << 16) | (0xac58 >> 2), |
| 494 | 0x00000000, |
| 495 | (0x0e00 << 16) | (0xac68 >> 2), |
| 496 | 0x00000000, |
| 497 | (0x0e00 << 16) | (0xac6c >> 2), |
| 498 | 0x00000000, |
| 499 | (0x0e00 << 16) | (0xac70 >> 2), |
| 500 | 0x00000000, |
| 501 | (0x0e00 << 16) | (0xac74 >> 2), |
| 502 | 0x00000000, |
| 503 | (0x0e00 << 16) | (0xac78 >> 2), |
| 504 | 0x00000000, |
| 505 | (0x0e00 << 16) | (0xac7c >> 2), |
| 506 | 0x00000000, |
| 507 | (0x0e00 << 16) | (0xac80 >> 2), |
| 508 | 0x00000000, |
| 509 | (0x0e00 << 16) | (0xac84 >> 2), |
| 510 | 0x00000000, |
| 511 | (0x0e00 << 16) | (0xac88 >> 2), |
| 512 | 0x00000000, |
| 513 | (0x0e00 << 16) | (0xac8c >> 2), |
| 514 | 0x00000000, |
| 515 | (0x0e00 << 16) | (0x970c >> 2), |
| 516 | 0x00000000, |
| 517 | (0x0e00 << 16) | (0x9714 >> 2), |
| 518 | 0x00000000, |
| 519 | (0x0e00 << 16) | (0x9718 >> 2), |
| 520 | 0x00000000, |
| 521 | (0x0e00 << 16) | (0x971c >> 2), |
| 522 | 0x00000000, |
| 523 | (0x0e00 << 16) | (0x31068 >> 2), |
| 524 | 0x00000000, |
| 525 | (0x4e00 << 16) | (0x31068 >> 2), |
| 526 | 0x00000000, |
| 527 | (0x5e00 << 16) | (0x31068 >> 2), |
| 528 | 0x00000000, |
| 529 | (0x6e00 << 16) | (0x31068 >> 2), |
| 530 | 0x00000000, |
| 531 | (0x7e00 << 16) | (0x31068 >> 2), |
| 532 | 0x00000000, |
| 533 | (0x8e00 << 16) | (0x31068 >> 2), |
| 534 | 0x00000000, |
| 535 | (0x9e00 << 16) | (0x31068 >> 2), |
| 536 | 0x00000000, |
| 537 | (0xae00 << 16) | (0x31068 >> 2), |
| 538 | 0x00000000, |
| 539 | (0xbe00 << 16) | (0x31068 >> 2), |
| 540 | 0x00000000, |
| 541 | (0x0e00 << 16) | (0xcd10 >> 2), |
| 542 | 0x00000000, |
| 543 | (0x0e00 << 16) | (0xcd14 >> 2), |
| 544 | 0x00000000, |
| 545 | (0x0e00 << 16) | (0x88b0 >> 2), |
| 546 | 0x00000000, |
| 547 | (0x0e00 << 16) | (0x88b4 >> 2), |
| 548 | 0x00000000, |
| 549 | (0x0e00 << 16) | (0x88b8 >> 2), |
| 550 | 0x00000000, |
| 551 | (0x0e00 << 16) | (0x88bc >> 2), |
| 552 | 0x00000000, |
| 553 | (0x0400 << 16) | (0x89c0 >> 2), |
| 554 | 0x00000000, |
| 555 | (0x0e00 << 16) | (0x88c4 >> 2), |
| 556 | 0x00000000, |
| 557 | (0x0e00 << 16) | (0x88c8 >> 2), |
| 558 | 0x00000000, |
| 559 | (0x0e00 << 16) | (0x88d0 >> 2), |
| 560 | 0x00000000, |
| 561 | (0x0e00 << 16) | (0x88d4 >> 2), |
| 562 | 0x00000000, |
| 563 | (0x0e00 << 16) | (0x88d8 >> 2), |
| 564 | 0x00000000, |
| 565 | (0x0e00 << 16) | (0x8980 >> 2), |
| 566 | 0x00000000, |
| 567 | (0x0e00 << 16) | (0x30938 >> 2), |
| 568 | 0x00000000, |
| 569 | (0x0e00 << 16) | (0x3093c >> 2), |
| 570 | 0x00000000, |
| 571 | (0x0e00 << 16) | (0x30940 >> 2), |
| 572 | 0x00000000, |
| 573 | (0x0e00 << 16) | (0x89a0 >> 2), |
| 574 | 0x00000000, |
| 575 | (0x0e00 << 16) | (0x30900 >> 2), |
| 576 | 0x00000000, |
| 577 | (0x0e00 << 16) | (0x30904 >> 2), |
| 578 | 0x00000000, |
| 579 | (0x0e00 << 16) | (0x89b4 >> 2), |
| 580 | 0x00000000, |
| 581 | (0x0e00 << 16) | (0x3c210 >> 2), |
| 582 | 0x00000000, |
| 583 | (0x0e00 << 16) | (0x3c214 >> 2), |
| 584 | 0x00000000, |
| 585 | (0x0e00 << 16) | (0x3c218 >> 2), |
| 586 | 0x00000000, |
| 587 | (0x0e00 << 16) | (0x8904 >> 2), |
| 588 | 0x00000000, |
| 589 | 0x5, |
| 590 | (0x0e00 << 16) | (0x8c28 >> 2), |
| 591 | (0x0e00 << 16) | (0x8c2c >> 2), |
| 592 | (0x0e00 << 16) | (0x8c30 >> 2), |
| 593 | (0x0e00 << 16) | (0x8c34 >> 2), |
| 594 | (0x0e00 << 16) | (0x9600 >> 2), |
| 595 | }; |
| 596 | |
| 597 | static const u32 kalindi_rlc_save_restore_register_list[] = |
| 598 | { |
| 599 | (0x0e00 << 16) | (0xc12c >> 2), |
| 600 | 0x00000000, |
| 601 | (0x0e00 << 16) | (0xc140 >> 2), |
| 602 | 0x00000000, |
| 603 | (0x0e00 << 16) | (0xc150 >> 2), |
| 604 | 0x00000000, |
| 605 | (0x0e00 << 16) | (0xc15c >> 2), |
| 606 | 0x00000000, |
| 607 | (0x0e00 << 16) | (0xc168 >> 2), |
| 608 | 0x00000000, |
| 609 | (0x0e00 << 16) | (0xc170 >> 2), |
| 610 | 0x00000000, |
| 611 | (0x0e00 << 16) | (0xc204 >> 2), |
| 612 | 0x00000000, |
| 613 | (0x0e00 << 16) | (0xc2b4 >> 2), |
| 614 | 0x00000000, |
| 615 | (0x0e00 << 16) | (0xc2b8 >> 2), |
| 616 | 0x00000000, |
| 617 | (0x0e00 << 16) | (0xc2bc >> 2), |
| 618 | 0x00000000, |
| 619 | (0x0e00 << 16) | (0xc2c0 >> 2), |
| 620 | 0x00000000, |
| 621 | (0x0e00 << 16) | (0x8228 >> 2), |
| 622 | 0x00000000, |
| 623 | (0x0e00 << 16) | (0x829c >> 2), |
| 624 | 0x00000000, |
| 625 | (0x0e00 << 16) | (0x869c >> 2), |
| 626 | 0x00000000, |
| 627 | (0x0600 << 16) | (0x98f4 >> 2), |
| 628 | 0x00000000, |
| 629 | (0x0e00 << 16) | (0x98f8 >> 2), |
| 630 | 0x00000000, |
| 631 | (0x0e00 << 16) | (0x9900 >> 2), |
| 632 | 0x00000000, |
| 633 | (0x0e00 << 16) | (0xc260 >> 2), |
| 634 | 0x00000000, |
| 635 | (0x0e00 << 16) | (0x90e8 >> 2), |
| 636 | 0x00000000, |
| 637 | (0x0e00 << 16) | (0x3c000 >> 2), |
| 638 | 0x00000000, |
| 639 | (0x0e00 << 16) | (0x3c00c >> 2), |
| 640 | 0x00000000, |
| 641 | (0x0e00 << 16) | (0x8c1c >> 2), |
| 642 | 0x00000000, |
| 643 | (0x0e00 << 16) | (0x9700 >> 2), |
| 644 | 0x00000000, |
| 645 | (0x0e00 << 16) | (0xcd20 >> 2), |
| 646 | 0x00000000, |
| 647 | (0x4e00 << 16) | (0xcd20 >> 2), |
| 648 | 0x00000000, |
| 649 | (0x5e00 << 16) | (0xcd20 >> 2), |
| 650 | 0x00000000, |
| 651 | (0x6e00 << 16) | (0xcd20 >> 2), |
| 652 | 0x00000000, |
| 653 | (0x7e00 << 16) | (0xcd20 >> 2), |
| 654 | 0x00000000, |
| 655 | (0x0e00 << 16) | (0x89bc >> 2), |
| 656 | 0x00000000, |
| 657 | (0x0e00 << 16) | (0x8900 >> 2), |
| 658 | 0x00000000, |
| 659 | 0x3, |
| 660 | (0x0e00 << 16) | (0xc130 >> 2), |
| 661 | 0x00000000, |
| 662 | (0x0e00 << 16) | (0xc134 >> 2), |
| 663 | 0x00000000, |
| 664 | (0x0e00 << 16) | (0xc1fc >> 2), |
| 665 | 0x00000000, |
| 666 | (0x0e00 << 16) | (0xc208 >> 2), |
| 667 | 0x00000000, |
| 668 | (0x0e00 << 16) | (0xc264 >> 2), |
| 669 | 0x00000000, |
| 670 | (0x0e00 << 16) | (0xc268 >> 2), |
| 671 | 0x00000000, |
| 672 | (0x0e00 << 16) | (0xc26c >> 2), |
| 673 | 0x00000000, |
| 674 | (0x0e00 << 16) | (0xc270 >> 2), |
| 675 | 0x00000000, |
| 676 | (0x0e00 << 16) | (0xc274 >> 2), |
| 677 | 0x00000000, |
| 678 | (0x0e00 << 16) | (0xc28c >> 2), |
| 679 | 0x00000000, |
| 680 | (0x0e00 << 16) | (0xc290 >> 2), |
| 681 | 0x00000000, |
| 682 | (0x0e00 << 16) | (0xc294 >> 2), |
| 683 | 0x00000000, |
| 684 | (0x0e00 << 16) | (0xc298 >> 2), |
| 685 | 0x00000000, |
| 686 | (0x0e00 << 16) | (0xc2a0 >> 2), |
| 687 | 0x00000000, |
| 688 | (0x0e00 << 16) | (0xc2a4 >> 2), |
| 689 | 0x00000000, |
| 690 | (0x0e00 << 16) | (0xc2a8 >> 2), |
| 691 | 0x00000000, |
| 692 | (0x0e00 << 16) | (0xc2ac >> 2), |
| 693 | 0x00000000, |
| 694 | (0x0e00 << 16) | (0x301d0 >> 2), |
| 695 | 0x00000000, |
| 696 | (0x0e00 << 16) | (0x30238 >> 2), |
| 697 | 0x00000000, |
| 698 | (0x0e00 << 16) | (0x30250 >> 2), |
| 699 | 0x00000000, |
| 700 | (0x0e00 << 16) | (0x30254 >> 2), |
| 701 | 0x00000000, |
| 702 | (0x0e00 << 16) | (0x30258 >> 2), |
| 703 | 0x00000000, |
| 704 | (0x0e00 << 16) | (0x3025c >> 2), |
| 705 | 0x00000000, |
| 706 | (0x4e00 << 16) | (0xc900 >> 2), |
| 707 | 0x00000000, |
| 708 | (0x5e00 << 16) | (0xc900 >> 2), |
| 709 | 0x00000000, |
| 710 | (0x6e00 << 16) | (0xc900 >> 2), |
| 711 | 0x00000000, |
| 712 | (0x7e00 << 16) | (0xc900 >> 2), |
| 713 | 0x00000000, |
| 714 | (0x4e00 << 16) | (0xc904 >> 2), |
| 715 | 0x00000000, |
| 716 | (0x5e00 << 16) | (0xc904 >> 2), |
| 717 | 0x00000000, |
| 718 | (0x6e00 << 16) | (0xc904 >> 2), |
| 719 | 0x00000000, |
| 720 | (0x7e00 << 16) | (0xc904 >> 2), |
| 721 | 0x00000000, |
| 722 | (0x4e00 << 16) | (0xc908 >> 2), |
| 723 | 0x00000000, |
| 724 | (0x5e00 << 16) | (0xc908 >> 2), |
| 725 | 0x00000000, |
| 726 | (0x6e00 << 16) | (0xc908 >> 2), |
| 727 | 0x00000000, |
| 728 | (0x7e00 << 16) | (0xc908 >> 2), |
| 729 | 0x00000000, |
| 730 | (0x4e00 << 16) | (0xc90c >> 2), |
| 731 | 0x00000000, |
| 732 | (0x5e00 << 16) | (0xc90c >> 2), |
| 733 | 0x00000000, |
| 734 | (0x6e00 << 16) | (0xc90c >> 2), |
| 735 | 0x00000000, |
| 736 | (0x7e00 << 16) | (0xc90c >> 2), |
| 737 | 0x00000000, |
| 738 | (0x4e00 << 16) | (0xc910 >> 2), |
| 739 | 0x00000000, |
| 740 | (0x5e00 << 16) | (0xc910 >> 2), |
| 741 | 0x00000000, |
| 742 | (0x6e00 << 16) | (0xc910 >> 2), |
| 743 | 0x00000000, |
| 744 | (0x7e00 << 16) | (0xc910 >> 2), |
| 745 | 0x00000000, |
| 746 | (0x0e00 << 16) | (0xc99c >> 2), |
| 747 | 0x00000000, |
| 748 | (0x0e00 << 16) | (0x9834 >> 2), |
| 749 | 0x00000000, |
| 750 | (0x0000 << 16) | (0x30f00 >> 2), |
| 751 | 0x00000000, |
| 752 | (0x0000 << 16) | (0x30f04 >> 2), |
| 753 | 0x00000000, |
| 754 | (0x0000 << 16) | (0x30f08 >> 2), |
| 755 | 0x00000000, |
| 756 | (0x0000 << 16) | (0x30f0c >> 2), |
| 757 | 0x00000000, |
| 758 | (0x0600 << 16) | (0x9b7c >> 2), |
| 759 | 0x00000000, |
| 760 | (0x0e00 << 16) | (0x8a14 >> 2), |
| 761 | 0x00000000, |
| 762 | (0x0e00 << 16) | (0x8a18 >> 2), |
| 763 | 0x00000000, |
| 764 | (0x0600 << 16) | (0x30a00 >> 2), |
| 765 | 0x00000000, |
| 766 | (0x0e00 << 16) | (0x8bf0 >> 2), |
| 767 | 0x00000000, |
| 768 | (0x0e00 << 16) | (0x8bcc >> 2), |
| 769 | 0x00000000, |
| 770 | (0x0e00 << 16) | (0x8b24 >> 2), |
| 771 | 0x00000000, |
| 772 | (0x0e00 << 16) | (0x30a04 >> 2), |
| 773 | 0x00000000, |
| 774 | (0x0600 << 16) | (0x30a10 >> 2), |
| 775 | 0x00000000, |
| 776 | (0x0600 << 16) | (0x30a14 >> 2), |
| 777 | 0x00000000, |
| 778 | (0x0600 << 16) | (0x30a18 >> 2), |
| 779 | 0x00000000, |
| 780 | (0x0600 << 16) | (0x30a2c >> 2), |
| 781 | 0x00000000, |
| 782 | (0x0e00 << 16) | (0xc700 >> 2), |
| 783 | 0x00000000, |
| 784 | (0x0e00 << 16) | (0xc704 >> 2), |
| 785 | 0x00000000, |
| 786 | (0x0e00 << 16) | (0xc708 >> 2), |
| 787 | 0x00000000, |
| 788 | (0x0e00 << 16) | (0xc768 >> 2), |
| 789 | 0x00000000, |
| 790 | (0x0400 << 16) | (0xc770 >> 2), |
| 791 | 0x00000000, |
| 792 | (0x0400 << 16) | (0xc774 >> 2), |
| 793 | 0x00000000, |
| 794 | (0x0400 << 16) | (0xc798 >> 2), |
| 795 | 0x00000000, |
| 796 | (0x0400 << 16) | (0xc79c >> 2), |
| 797 | 0x00000000, |
| 798 | (0x0e00 << 16) | (0x9100 >> 2), |
| 799 | 0x00000000, |
| 800 | (0x0e00 << 16) | (0x3c010 >> 2), |
| 801 | 0x00000000, |
| 802 | (0x0e00 << 16) | (0x8c00 >> 2), |
| 803 | 0x00000000, |
| 804 | (0x0e00 << 16) | (0x8c04 >> 2), |
| 805 | 0x00000000, |
| 806 | (0x0e00 << 16) | (0x8c20 >> 2), |
| 807 | 0x00000000, |
| 808 | (0x0e00 << 16) | (0x8c38 >> 2), |
| 809 | 0x00000000, |
| 810 | (0x0e00 << 16) | (0x8c3c >> 2), |
| 811 | 0x00000000, |
| 812 | (0x0e00 << 16) | (0xae00 >> 2), |
| 813 | 0x00000000, |
| 814 | (0x0e00 << 16) | (0x9604 >> 2), |
| 815 | 0x00000000, |
| 816 | (0x0e00 << 16) | (0xac08 >> 2), |
| 817 | 0x00000000, |
| 818 | (0x0e00 << 16) | (0xac0c >> 2), |
| 819 | 0x00000000, |
| 820 | (0x0e00 << 16) | (0xac10 >> 2), |
| 821 | 0x00000000, |
| 822 | (0x0e00 << 16) | (0xac14 >> 2), |
| 823 | 0x00000000, |
| 824 | (0x0e00 << 16) | (0xac58 >> 2), |
| 825 | 0x00000000, |
| 826 | (0x0e00 << 16) | (0xac68 >> 2), |
| 827 | 0x00000000, |
| 828 | (0x0e00 << 16) | (0xac6c >> 2), |
| 829 | 0x00000000, |
| 830 | (0x0e00 << 16) | (0xac70 >> 2), |
| 831 | 0x00000000, |
| 832 | (0x0e00 << 16) | (0xac74 >> 2), |
| 833 | 0x00000000, |
| 834 | (0x0e00 << 16) | (0xac78 >> 2), |
| 835 | 0x00000000, |
| 836 | (0x0e00 << 16) | (0xac7c >> 2), |
| 837 | 0x00000000, |
| 838 | (0x0e00 << 16) | (0xac80 >> 2), |
| 839 | 0x00000000, |
| 840 | (0x0e00 << 16) | (0xac84 >> 2), |
| 841 | 0x00000000, |
| 842 | (0x0e00 << 16) | (0xac88 >> 2), |
| 843 | 0x00000000, |
| 844 | (0x0e00 << 16) | (0xac8c >> 2), |
| 845 | 0x00000000, |
| 846 | (0x0e00 << 16) | (0x970c >> 2), |
| 847 | 0x00000000, |
| 848 | (0x0e00 << 16) | (0x9714 >> 2), |
| 849 | 0x00000000, |
| 850 | (0x0e00 << 16) | (0x9718 >> 2), |
| 851 | 0x00000000, |
| 852 | (0x0e00 << 16) | (0x971c >> 2), |
| 853 | 0x00000000, |
| 854 | (0x0e00 << 16) | (0x31068 >> 2), |
| 855 | 0x00000000, |
| 856 | (0x4e00 << 16) | (0x31068 >> 2), |
| 857 | 0x00000000, |
| 858 | (0x5e00 << 16) | (0x31068 >> 2), |
| 859 | 0x00000000, |
| 860 | (0x6e00 << 16) | (0x31068 >> 2), |
| 861 | 0x00000000, |
| 862 | (0x7e00 << 16) | (0x31068 >> 2), |
| 863 | 0x00000000, |
| 864 | (0x0e00 << 16) | (0xcd10 >> 2), |
| 865 | 0x00000000, |
| 866 | (0x0e00 << 16) | (0xcd14 >> 2), |
| 867 | 0x00000000, |
| 868 | (0x0e00 << 16) | (0x88b0 >> 2), |
| 869 | 0x00000000, |
| 870 | (0x0e00 << 16) | (0x88b4 >> 2), |
| 871 | 0x00000000, |
| 872 | (0x0e00 << 16) | (0x88b8 >> 2), |
| 873 | 0x00000000, |
| 874 | (0x0e00 << 16) | (0x88bc >> 2), |
| 875 | 0x00000000, |
| 876 | (0x0400 << 16) | (0x89c0 >> 2), |
| 877 | 0x00000000, |
| 878 | (0x0e00 << 16) | (0x88c4 >> 2), |
| 879 | 0x00000000, |
| 880 | (0x0e00 << 16) | (0x88c8 >> 2), |
| 881 | 0x00000000, |
| 882 | (0x0e00 << 16) | (0x88d0 >> 2), |
| 883 | 0x00000000, |
| 884 | (0x0e00 << 16) | (0x88d4 >> 2), |
| 885 | 0x00000000, |
| 886 | (0x0e00 << 16) | (0x88d8 >> 2), |
| 887 | 0x00000000, |
| 888 | (0x0e00 << 16) | (0x8980 >> 2), |
| 889 | 0x00000000, |
| 890 | (0x0e00 << 16) | (0x30938 >> 2), |
| 891 | 0x00000000, |
| 892 | (0x0e00 << 16) | (0x3093c >> 2), |
| 893 | 0x00000000, |
| 894 | (0x0e00 << 16) | (0x30940 >> 2), |
| 895 | 0x00000000, |
| 896 | (0x0e00 << 16) | (0x89a0 >> 2), |
| 897 | 0x00000000, |
| 898 | (0x0e00 << 16) | (0x30900 >> 2), |
| 899 | 0x00000000, |
| 900 | (0x0e00 << 16) | (0x30904 >> 2), |
| 901 | 0x00000000, |
| 902 | (0x0e00 << 16) | (0x89b4 >> 2), |
| 903 | 0x00000000, |
| 904 | (0x0e00 << 16) | (0x3e1fc >> 2), |
| 905 | 0x00000000, |
| 906 | (0x0e00 << 16) | (0x3c210 >> 2), |
| 907 | 0x00000000, |
| 908 | (0x0e00 << 16) | (0x3c214 >> 2), |
| 909 | 0x00000000, |
| 910 | (0x0e00 << 16) | (0x3c218 >> 2), |
| 911 | 0x00000000, |
| 912 | (0x0e00 << 16) | (0x8904 >> 2), |
| 913 | 0x00000000, |
| 914 | 0x5, |
| 915 | (0x0e00 << 16) | (0x8c28 >> 2), |
| 916 | (0x0e00 << 16) | (0x8c2c >> 2), |
| 917 | (0x0e00 << 16) | (0x8c30 >> 2), |
| 918 | (0x0e00 << 16) | (0x8c34 >> 2), |
| 919 | (0x0e00 << 16) | (0x9600 >> 2), |
| 920 | }; |
| 921 | |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 922 | static const u32 bonaire_golden_spm_registers[] = |
| 923 | { |
| 924 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 925 | }; |
| 926 | |
| 927 | static const u32 bonaire_golden_common_registers[] = |
| 928 | { |
| 929 | 0xc770, 0xffffffff, 0x00000800, |
| 930 | 0xc774, 0xffffffff, 0x00000800, |
| 931 | 0xc798, 0xffffffff, 0x00007fbf, |
| 932 | 0xc79c, 0xffffffff, 0x00007faf |
| 933 | }; |
| 934 | |
| 935 | static const u32 bonaire_golden_registers[] = |
| 936 | { |
| 937 | 0x3354, 0x00000333, 0x00000333, |
| 938 | 0x3350, 0x000c0fc0, 0x00040200, |
| 939 | 0x9a10, 0x00010000, 0x00058208, |
| 940 | 0x3c000, 0xffff1fff, 0x00140000, |
| 941 | 0x3c200, 0xfdfc0fff, 0x00000100, |
| 942 | 0x3c234, 0x40000000, 0x40000200, |
| 943 | 0x9830, 0xffffffff, 0x00000000, |
| 944 | 0x9834, 0xf00fffff, 0x00000400, |
| 945 | 0x9838, 0x0002021c, 0x00020200, |
| 946 | 0xc78, 0x00000080, 0x00000000, |
| 947 | 0x5bb0, 0x000000f0, 0x00000070, |
| 948 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 949 | 0x98f8, 0x73773777, 0x12010001, |
| 950 | 0x350c, 0x00810000, 0x408af000, |
| 951 | 0x7030, 0x31000111, 0x00000011, |
| 952 | 0x2f48, 0x73773777, 0x12010001, |
| 953 | 0x220c, 0x00007fb6, 0x0021a1b1, |
| 954 | 0x2210, 0x00007fb6, 0x002021b1, |
| 955 | 0x2180, 0x00007fb6, 0x00002191, |
| 956 | 0x2218, 0x00007fb6, 0x002121b1, |
| 957 | 0x221c, 0x00007fb6, 0x002021b1, |
| 958 | 0x21dc, 0x00007fb6, 0x00002191, |
| 959 | 0x21e0, 0x00007fb6, 0x00002191, |
| 960 | 0x3628, 0x0000003f, 0x0000000a, |
| 961 | 0x362c, 0x0000003f, 0x0000000a, |
| 962 | 0x2ae4, 0x00073ffe, 0x000022a2, |
| 963 | 0x240c, 0x000007ff, 0x00000000, |
| 964 | 0x8a14, 0xf000003f, 0x00000007, |
| 965 | 0x8bf0, 0x00002001, 0x00000001, |
| 966 | 0x8b24, 0xffffffff, 0x00ffffff, |
| 967 | 0x30a04, 0x0000ff0f, 0x00000000, |
| 968 | 0x28a4c, 0x07ffffff, 0x06000000, |
| 969 | 0x4d8, 0x00000fff, 0x00000100, |
| 970 | 0x3e78, 0x00000001, 0x00000002, |
| 971 | 0x9100, 0x03000000, 0x0362c688, |
| 972 | 0x8c00, 0x000000ff, 0x00000001, |
| 973 | 0xe40, 0x00001fff, 0x00001fff, |
| 974 | 0x9060, 0x0000007f, 0x00000020, |
| 975 | 0x9508, 0x00010000, 0x00010000, |
| 976 | 0xac14, 0x000003ff, 0x000000f3, |
| 977 | 0xac0c, 0xffffffff, 0x00001032 |
| 978 | }; |
| 979 | |
| 980 | static const u32 bonaire_mgcg_cgcg_init[] = |
| 981 | { |
| 982 | 0xc420, 0xffffffff, 0xfffffffc, |
| 983 | 0x30800, 0xffffffff, 0xe0000000, |
| 984 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 985 | 0x3c208, 0xffffffff, 0x00000100, |
| 986 | 0x3c2c0, 0xffffffff, 0xc0000100, |
| 987 | 0x3c2c8, 0xffffffff, 0xc0000100, |
| 988 | 0x3c2c4, 0xffffffff, 0xc0000100, |
| 989 | 0x55e4, 0xffffffff, 0x00600100, |
| 990 | 0x3c280, 0xffffffff, 0x00000100, |
| 991 | 0x3c214, 0xffffffff, 0x06000100, |
| 992 | 0x3c220, 0xffffffff, 0x00000100, |
| 993 | 0x3c218, 0xffffffff, 0x06000100, |
| 994 | 0x3c204, 0xffffffff, 0x00000100, |
| 995 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 996 | 0x3c224, 0xffffffff, 0x00000100, |
| 997 | 0x3c200, 0xffffffff, 0x00000100, |
| 998 | 0x3c230, 0xffffffff, 0x00000100, |
| 999 | 0x3c234, 0xffffffff, 0x00000100, |
| 1000 | 0x3c250, 0xffffffff, 0x00000100, |
| 1001 | 0x3c254, 0xffffffff, 0x00000100, |
| 1002 | 0x3c258, 0xffffffff, 0x00000100, |
| 1003 | 0x3c25c, 0xffffffff, 0x00000100, |
| 1004 | 0x3c260, 0xffffffff, 0x00000100, |
| 1005 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1006 | 0x3c278, 0xffffffff, 0x00000100, |
| 1007 | 0x3c210, 0xffffffff, 0x06000100, |
| 1008 | 0x3c290, 0xffffffff, 0x00000100, |
| 1009 | 0x3c274, 0xffffffff, 0x00000100, |
| 1010 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1011 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1012 | 0x3c270, 0xffffffff, 0x00000100, |
| 1013 | 0x30800, 0xffffffff, 0xe0000000, |
| 1014 | 0x3c020, 0xffffffff, 0x00010000, |
| 1015 | 0x3c024, 0xffffffff, 0x00030002, |
| 1016 | 0x3c028, 0xffffffff, 0x00040007, |
| 1017 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1018 | 0x3c030, 0xffffffff, 0x00090008, |
| 1019 | 0x3c034, 0xffffffff, 0x00010000, |
| 1020 | 0x3c038, 0xffffffff, 0x00030002, |
| 1021 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1022 | 0x3c040, 0xffffffff, 0x00060005, |
| 1023 | 0x3c044, 0xffffffff, 0x00090008, |
| 1024 | 0x3c048, 0xffffffff, 0x00010000, |
| 1025 | 0x3c04c, 0xffffffff, 0x00030002, |
| 1026 | 0x3c050, 0xffffffff, 0x00040007, |
| 1027 | 0x3c054, 0xffffffff, 0x00060005, |
| 1028 | 0x3c058, 0xffffffff, 0x00090008, |
| 1029 | 0x3c05c, 0xffffffff, 0x00010000, |
| 1030 | 0x3c060, 0xffffffff, 0x00030002, |
| 1031 | 0x3c064, 0xffffffff, 0x00040007, |
| 1032 | 0x3c068, 0xffffffff, 0x00060005, |
| 1033 | 0x3c06c, 0xffffffff, 0x00090008, |
| 1034 | 0x3c070, 0xffffffff, 0x00010000, |
| 1035 | 0x3c074, 0xffffffff, 0x00030002, |
| 1036 | 0x3c078, 0xffffffff, 0x00040007, |
| 1037 | 0x3c07c, 0xffffffff, 0x00060005, |
| 1038 | 0x3c080, 0xffffffff, 0x00090008, |
| 1039 | 0x3c084, 0xffffffff, 0x00010000, |
| 1040 | 0x3c088, 0xffffffff, 0x00030002, |
| 1041 | 0x3c08c, 0xffffffff, 0x00040007, |
| 1042 | 0x3c090, 0xffffffff, 0x00060005, |
| 1043 | 0x3c094, 0xffffffff, 0x00090008, |
| 1044 | 0x3c098, 0xffffffff, 0x00010000, |
| 1045 | 0x3c09c, 0xffffffff, 0x00030002, |
| 1046 | 0x3c0a0, 0xffffffff, 0x00040007, |
| 1047 | 0x3c0a4, 0xffffffff, 0x00060005, |
| 1048 | 0x3c0a8, 0xffffffff, 0x00090008, |
| 1049 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1050 | 0x8708, 0xffffffff, 0x00900100, |
| 1051 | 0xc424, 0xffffffff, 0x0020003f, |
| 1052 | 0x38, 0xffffffff, 0x0140001c, |
| 1053 | 0x3c, 0x000f0000, 0x000f0000, |
| 1054 | 0x220, 0xffffffff, 0xC060000C, |
| 1055 | 0x224, 0xc0000fff, 0x00000100, |
| 1056 | 0xf90, 0xffffffff, 0x00000100, |
| 1057 | 0xf98, 0x00000101, 0x00000000, |
| 1058 | 0x20a8, 0xffffffff, 0x00000104, |
| 1059 | 0x55e4, 0xff000fff, 0x00000100, |
| 1060 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1061 | 0xc1e4, 0x00000001, 0x00000001, |
| 1062 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1063 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1064 | }; |
| 1065 | |
| 1066 | static const u32 spectre_golden_spm_registers[] = |
| 1067 | { |
| 1068 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 1069 | }; |
| 1070 | |
| 1071 | static const u32 spectre_golden_common_registers[] = |
| 1072 | { |
| 1073 | 0xc770, 0xffffffff, 0x00000800, |
| 1074 | 0xc774, 0xffffffff, 0x00000800, |
| 1075 | 0xc798, 0xffffffff, 0x00007fbf, |
| 1076 | 0xc79c, 0xffffffff, 0x00007faf |
| 1077 | }; |
| 1078 | |
| 1079 | static const u32 spectre_golden_registers[] = |
| 1080 | { |
| 1081 | 0x3c000, 0xffff1fff, 0x96940200, |
| 1082 | 0x3c00c, 0xffff0001, 0xff000000, |
| 1083 | 0x3c200, 0xfffc0fff, 0x00000100, |
| 1084 | 0x6ed8, 0x00010101, 0x00010000, |
| 1085 | 0x9834, 0xf00fffff, 0x00000400, |
| 1086 | 0x9838, 0xfffffffc, 0x00020200, |
| 1087 | 0x5bb0, 0x000000f0, 0x00000070, |
| 1088 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 1089 | 0x98f8, 0x73773777, 0x12010001, |
| 1090 | 0x9b7c, 0x00ff0000, 0x00fc0000, |
| 1091 | 0x2f48, 0x73773777, 0x12010001, |
| 1092 | 0x8a14, 0xf000003f, 0x00000007, |
| 1093 | 0x8b24, 0xffffffff, 0x00ffffff, |
| 1094 | 0x28350, 0x3f3f3fff, 0x00000082, |
| 1095 | 0x28355, 0x0000003f, 0x00000000, |
| 1096 | 0x3e78, 0x00000001, 0x00000002, |
| 1097 | 0x913c, 0xffff03df, 0x00000004, |
| 1098 | 0xc768, 0x00000008, 0x00000008, |
| 1099 | 0x8c00, 0x000008ff, 0x00000800, |
| 1100 | 0x9508, 0x00010000, 0x00010000, |
| 1101 | 0xac0c, 0xffffffff, 0x54763210, |
| 1102 | 0x214f8, 0x01ff01ff, 0x00000002, |
| 1103 | 0x21498, 0x007ff800, 0x00200000, |
| 1104 | 0x2015c, 0xffffffff, 0x00000f40, |
| 1105 | 0x30934, 0xffffffff, 0x00000001 |
| 1106 | }; |
| 1107 | |
| 1108 | static const u32 spectre_mgcg_cgcg_init[] = |
| 1109 | { |
| 1110 | 0xc420, 0xffffffff, 0xfffffffc, |
| 1111 | 0x30800, 0xffffffff, 0xe0000000, |
| 1112 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 1113 | 0x3c208, 0xffffffff, 0x00000100, |
| 1114 | 0x3c2c0, 0xffffffff, 0x00000100, |
| 1115 | 0x3c2c8, 0xffffffff, 0x00000100, |
| 1116 | 0x3c2c4, 0xffffffff, 0x00000100, |
| 1117 | 0x55e4, 0xffffffff, 0x00600100, |
| 1118 | 0x3c280, 0xffffffff, 0x00000100, |
| 1119 | 0x3c214, 0xffffffff, 0x06000100, |
| 1120 | 0x3c220, 0xffffffff, 0x00000100, |
| 1121 | 0x3c218, 0xffffffff, 0x06000100, |
| 1122 | 0x3c204, 0xffffffff, 0x00000100, |
| 1123 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 1124 | 0x3c224, 0xffffffff, 0x00000100, |
| 1125 | 0x3c200, 0xffffffff, 0x00000100, |
| 1126 | 0x3c230, 0xffffffff, 0x00000100, |
| 1127 | 0x3c234, 0xffffffff, 0x00000100, |
| 1128 | 0x3c250, 0xffffffff, 0x00000100, |
| 1129 | 0x3c254, 0xffffffff, 0x00000100, |
| 1130 | 0x3c258, 0xffffffff, 0x00000100, |
| 1131 | 0x3c25c, 0xffffffff, 0x00000100, |
| 1132 | 0x3c260, 0xffffffff, 0x00000100, |
| 1133 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1134 | 0x3c278, 0xffffffff, 0x00000100, |
| 1135 | 0x3c210, 0xffffffff, 0x06000100, |
| 1136 | 0x3c290, 0xffffffff, 0x00000100, |
| 1137 | 0x3c274, 0xffffffff, 0x00000100, |
| 1138 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1139 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1140 | 0x3c270, 0xffffffff, 0x00000100, |
| 1141 | 0x30800, 0xffffffff, 0xe0000000, |
| 1142 | 0x3c020, 0xffffffff, 0x00010000, |
| 1143 | 0x3c024, 0xffffffff, 0x00030002, |
| 1144 | 0x3c028, 0xffffffff, 0x00040007, |
| 1145 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1146 | 0x3c030, 0xffffffff, 0x00090008, |
| 1147 | 0x3c034, 0xffffffff, 0x00010000, |
| 1148 | 0x3c038, 0xffffffff, 0x00030002, |
| 1149 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1150 | 0x3c040, 0xffffffff, 0x00060005, |
| 1151 | 0x3c044, 0xffffffff, 0x00090008, |
| 1152 | 0x3c048, 0xffffffff, 0x00010000, |
| 1153 | 0x3c04c, 0xffffffff, 0x00030002, |
| 1154 | 0x3c050, 0xffffffff, 0x00040007, |
| 1155 | 0x3c054, 0xffffffff, 0x00060005, |
| 1156 | 0x3c058, 0xffffffff, 0x00090008, |
| 1157 | 0x3c05c, 0xffffffff, 0x00010000, |
| 1158 | 0x3c060, 0xffffffff, 0x00030002, |
| 1159 | 0x3c064, 0xffffffff, 0x00040007, |
| 1160 | 0x3c068, 0xffffffff, 0x00060005, |
| 1161 | 0x3c06c, 0xffffffff, 0x00090008, |
| 1162 | 0x3c070, 0xffffffff, 0x00010000, |
| 1163 | 0x3c074, 0xffffffff, 0x00030002, |
| 1164 | 0x3c078, 0xffffffff, 0x00040007, |
| 1165 | 0x3c07c, 0xffffffff, 0x00060005, |
| 1166 | 0x3c080, 0xffffffff, 0x00090008, |
| 1167 | 0x3c084, 0xffffffff, 0x00010000, |
| 1168 | 0x3c088, 0xffffffff, 0x00030002, |
| 1169 | 0x3c08c, 0xffffffff, 0x00040007, |
| 1170 | 0x3c090, 0xffffffff, 0x00060005, |
| 1171 | 0x3c094, 0xffffffff, 0x00090008, |
| 1172 | 0x3c098, 0xffffffff, 0x00010000, |
| 1173 | 0x3c09c, 0xffffffff, 0x00030002, |
| 1174 | 0x3c0a0, 0xffffffff, 0x00040007, |
| 1175 | 0x3c0a4, 0xffffffff, 0x00060005, |
| 1176 | 0x3c0a8, 0xffffffff, 0x00090008, |
| 1177 | 0x3c0ac, 0xffffffff, 0x00010000, |
| 1178 | 0x3c0b0, 0xffffffff, 0x00030002, |
| 1179 | 0x3c0b4, 0xffffffff, 0x00040007, |
| 1180 | 0x3c0b8, 0xffffffff, 0x00060005, |
| 1181 | 0x3c0bc, 0xffffffff, 0x00090008, |
| 1182 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1183 | 0x8708, 0xffffffff, 0x00900100, |
| 1184 | 0xc424, 0xffffffff, 0x0020003f, |
| 1185 | 0x38, 0xffffffff, 0x0140001c, |
| 1186 | 0x3c, 0x000f0000, 0x000f0000, |
| 1187 | 0x220, 0xffffffff, 0xC060000C, |
| 1188 | 0x224, 0xc0000fff, 0x00000100, |
| 1189 | 0xf90, 0xffffffff, 0x00000100, |
| 1190 | 0xf98, 0x00000101, 0x00000000, |
| 1191 | 0x20a8, 0xffffffff, 0x00000104, |
| 1192 | 0x55e4, 0xff000fff, 0x00000100, |
| 1193 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1194 | 0xc1e4, 0x00000001, 0x00000001, |
| 1195 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1196 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1197 | }; |
| 1198 | |
| 1199 | static const u32 kalindi_golden_spm_registers[] = |
| 1200 | { |
| 1201 | 0x30800, 0xe0ffffff, 0xe0000000 |
| 1202 | }; |
| 1203 | |
| 1204 | static const u32 kalindi_golden_common_registers[] = |
| 1205 | { |
| 1206 | 0xc770, 0xffffffff, 0x00000800, |
| 1207 | 0xc774, 0xffffffff, 0x00000800, |
| 1208 | 0xc798, 0xffffffff, 0x00007fbf, |
| 1209 | 0xc79c, 0xffffffff, 0x00007faf |
| 1210 | }; |
| 1211 | |
| 1212 | static const u32 kalindi_golden_registers[] = |
| 1213 | { |
| 1214 | 0x3c000, 0xffffdfff, 0x6e944040, |
| 1215 | 0x55e4, 0xff607fff, 0xfc000100, |
| 1216 | 0x3c220, 0xff000fff, 0x00000100, |
| 1217 | 0x3c224, 0xff000fff, 0x00000100, |
| 1218 | 0x3c200, 0xfffc0fff, 0x00000100, |
| 1219 | 0x6ed8, 0x00010101, 0x00010000, |
| 1220 | 0x9830, 0xffffffff, 0x00000000, |
| 1221 | 0x9834, 0xf00fffff, 0x00000400, |
| 1222 | 0x5bb0, 0x000000f0, 0x00000070, |
| 1223 | 0x5bc0, 0xf0311fff, 0x80300000, |
| 1224 | 0x98f8, 0x73773777, 0x12010001, |
| 1225 | 0x98fc, 0xffffffff, 0x00000010, |
| 1226 | 0x9b7c, 0x00ff0000, 0x00fc0000, |
| 1227 | 0x8030, 0x00001f0f, 0x0000100a, |
| 1228 | 0x2f48, 0x73773777, 0x12010001, |
| 1229 | 0x2408, 0x000fffff, 0x000c007f, |
| 1230 | 0x8a14, 0xf000003f, 0x00000007, |
| 1231 | 0x8b24, 0x3fff3fff, 0x00ffcfff, |
| 1232 | 0x30a04, 0x0000ff0f, 0x00000000, |
| 1233 | 0x28a4c, 0x07ffffff, 0x06000000, |
| 1234 | 0x4d8, 0x00000fff, 0x00000100, |
| 1235 | 0x3e78, 0x00000001, 0x00000002, |
| 1236 | 0xc768, 0x00000008, 0x00000008, |
| 1237 | 0x8c00, 0x000000ff, 0x00000003, |
| 1238 | 0x214f8, 0x01ff01ff, 0x00000002, |
| 1239 | 0x21498, 0x007ff800, 0x00200000, |
| 1240 | 0x2015c, 0xffffffff, 0x00000f40, |
| 1241 | 0x88c4, 0x001f3ae3, 0x00000082, |
| 1242 | 0x88d4, 0x0000001f, 0x00000010, |
| 1243 | 0x30934, 0xffffffff, 0x00000000 |
| 1244 | }; |
| 1245 | |
| 1246 | static const u32 kalindi_mgcg_cgcg_init[] = |
| 1247 | { |
| 1248 | 0xc420, 0xffffffff, 0xfffffffc, |
| 1249 | 0x30800, 0xffffffff, 0xe0000000, |
| 1250 | 0x3c2a0, 0xffffffff, 0x00000100, |
| 1251 | 0x3c208, 0xffffffff, 0x00000100, |
| 1252 | 0x3c2c0, 0xffffffff, 0x00000100, |
| 1253 | 0x3c2c8, 0xffffffff, 0x00000100, |
| 1254 | 0x3c2c4, 0xffffffff, 0x00000100, |
| 1255 | 0x55e4, 0xffffffff, 0x00600100, |
| 1256 | 0x3c280, 0xffffffff, 0x00000100, |
| 1257 | 0x3c214, 0xffffffff, 0x06000100, |
| 1258 | 0x3c220, 0xffffffff, 0x00000100, |
| 1259 | 0x3c218, 0xffffffff, 0x06000100, |
| 1260 | 0x3c204, 0xffffffff, 0x00000100, |
| 1261 | 0x3c2e0, 0xffffffff, 0x00000100, |
| 1262 | 0x3c224, 0xffffffff, 0x00000100, |
| 1263 | 0x3c200, 0xffffffff, 0x00000100, |
| 1264 | 0x3c230, 0xffffffff, 0x00000100, |
| 1265 | 0x3c234, 0xffffffff, 0x00000100, |
| 1266 | 0x3c250, 0xffffffff, 0x00000100, |
| 1267 | 0x3c254, 0xffffffff, 0x00000100, |
| 1268 | 0x3c258, 0xffffffff, 0x00000100, |
| 1269 | 0x3c25c, 0xffffffff, 0x00000100, |
| 1270 | 0x3c260, 0xffffffff, 0x00000100, |
| 1271 | 0x3c27c, 0xffffffff, 0x00000100, |
| 1272 | 0x3c278, 0xffffffff, 0x00000100, |
| 1273 | 0x3c210, 0xffffffff, 0x06000100, |
| 1274 | 0x3c290, 0xffffffff, 0x00000100, |
| 1275 | 0x3c274, 0xffffffff, 0x00000100, |
| 1276 | 0x3c2b4, 0xffffffff, 0x00000100, |
| 1277 | 0x3c2b0, 0xffffffff, 0x00000100, |
| 1278 | 0x3c270, 0xffffffff, 0x00000100, |
| 1279 | 0x30800, 0xffffffff, 0xe0000000, |
| 1280 | 0x3c020, 0xffffffff, 0x00010000, |
| 1281 | 0x3c024, 0xffffffff, 0x00030002, |
| 1282 | 0x3c028, 0xffffffff, 0x00040007, |
| 1283 | 0x3c02c, 0xffffffff, 0x00060005, |
| 1284 | 0x3c030, 0xffffffff, 0x00090008, |
| 1285 | 0x3c034, 0xffffffff, 0x00010000, |
| 1286 | 0x3c038, 0xffffffff, 0x00030002, |
| 1287 | 0x3c03c, 0xffffffff, 0x00040007, |
| 1288 | 0x3c040, 0xffffffff, 0x00060005, |
| 1289 | 0x3c044, 0xffffffff, 0x00090008, |
| 1290 | 0x3c000, 0xffffffff, 0x96e00200, |
| 1291 | 0x8708, 0xffffffff, 0x00900100, |
| 1292 | 0xc424, 0xffffffff, 0x0020003f, |
| 1293 | 0x38, 0xffffffff, 0x0140001c, |
| 1294 | 0x3c, 0x000f0000, 0x000f0000, |
| 1295 | 0x220, 0xffffffff, 0xC060000C, |
| 1296 | 0x224, 0xc0000fff, 0x00000100, |
| 1297 | 0x20a8, 0xffffffff, 0x00000104, |
| 1298 | 0x55e4, 0xff000fff, 0x00000100, |
| 1299 | 0x30cc, 0xc0000fff, 0x00000104, |
| 1300 | 0xc1e4, 0x00000001, 0x00000001, |
| 1301 | 0xd00c, 0xff000ff0, 0x00000100, |
| 1302 | 0xd80c, 0xff000ff0, 0x00000100 |
| 1303 | }; |
| 1304 | |
| 1305 | static void cik_init_golden_registers(struct radeon_device *rdev) |
| 1306 | { |
| 1307 | switch (rdev->family) { |
| 1308 | case CHIP_BONAIRE: |
| 1309 | radeon_program_register_sequence(rdev, |
| 1310 | bonaire_mgcg_cgcg_init, |
| 1311 | (const u32)ARRAY_SIZE(bonaire_mgcg_cgcg_init)); |
| 1312 | radeon_program_register_sequence(rdev, |
| 1313 | bonaire_golden_registers, |
| 1314 | (const u32)ARRAY_SIZE(bonaire_golden_registers)); |
| 1315 | radeon_program_register_sequence(rdev, |
| 1316 | bonaire_golden_common_registers, |
| 1317 | (const u32)ARRAY_SIZE(bonaire_golden_common_registers)); |
| 1318 | radeon_program_register_sequence(rdev, |
| 1319 | bonaire_golden_spm_registers, |
| 1320 | (const u32)ARRAY_SIZE(bonaire_golden_spm_registers)); |
| 1321 | break; |
| 1322 | case CHIP_KABINI: |
| 1323 | radeon_program_register_sequence(rdev, |
| 1324 | kalindi_mgcg_cgcg_init, |
| 1325 | (const u32)ARRAY_SIZE(kalindi_mgcg_cgcg_init)); |
| 1326 | radeon_program_register_sequence(rdev, |
| 1327 | kalindi_golden_registers, |
| 1328 | (const u32)ARRAY_SIZE(kalindi_golden_registers)); |
| 1329 | radeon_program_register_sequence(rdev, |
| 1330 | kalindi_golden_common_registers, |
| 1331 | (const u32)ARRAY_SIZE(kalindi_golden_common_registers)); |
| 1332 | radeon_program_register_sequence(rdev, |
| 1333 | kalindi_golden_spm_registers, |
| 1334 | (const u32)ARRAY_SIZE(kalindi_golden_spm_registers)); |
| 1335 | break; |
| 1336 | case CHIP_KAVERI: |
| 1337 | radeon_program_register_sequence(rdev, |
| 1338 | spectre_mgcg_cgcg_init, |
| 1339 | (const u32)ARRAY_SIZE(spectre_mgcg_cgcg_init)); |
| 1340 | radeon_program_register_sequence(rdev, |
| 1341 | spectre_golden_registers, |
| 1342 | (const u32)ARRAY_SIZE(spectre_golden_registers)); |
| 1343 | radeon_program_register_sequence(rdev, |
| 1344 | spectre_golden_common_registers, |
| 1345 | (const u32)ARRAY_SIZE(spectre_golden_common_registers)); |
| 1346 | radeon_program_register_sequence(rdev, |
| 1347 | spectre_golden_spm_registers, |
| 1348 | (const u32)ARRAY_SIZE(spectre_golden_spm_registers)); |
| 1349 | break; |
| 1350 | default: |
| 1351 | break; |
| 1352 | } |
| 1353 | } |
| 1354 | |
Alex Deucher | 2c67912 | 2013-04-09 13:32:18 -0400 | [diff] [blame] | 1355 | /** |
| 1356 | * cik_get_xclk - get the xclk |
| 1357 | * |
| 1358 | * @rdev: radeon_device pointer |
| 1359 | * |
| 1360 | * Returns the reference clock used by the gfx engine |
| 1361 | * (CIK). |
| 1362 | */ |
| 1363 | u32 cik_get_xclk(struct radeon_device *rdev) |
| 1364 | { |
| 1365 | u32 reference_clock = rdev->clock.spll.reference_freq; |
| 1366 | |
| 1367 | if (rdev->flags & RADEON_IS_IGP) { |
| 1368 | if (RREG32_SMC(GENERAL_PWRMGT) & GPU_COUNTER_CLK) |
| 1369 | return reference_clock / 2; |
| 1370 | } else { |
| 1371 | if (RREG32_SMC(CG_CLKPIN_CNTL) & XTALIN_DIVIDE) |
| 1372 | return reference_clock / 4; |
| 1373 | } |
| 1374 | return reference_clock; |
| 1375 | } |
| 1376 | |
Alex Deucher | 75efdee | 2013-03-04 12:47:46 -0500 | [diff] [blame] | 1377 | /** |
| 1378 | * cik_mm_rdoorbell - read a doorbell dword |
| 1379 | * |
| 1380 | * @rdev: radeon_device pointer |
| 1381 | * @offset: byte offset into the aperture |
| 1382 | * |
| 1383 | * Returns the value in the doorbell aperture at the |
| 1384 | * requested offset (CIK). |
| 1385 | */ |
| 1386 | u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset) |
| 1387 | { |
| 1388 | if (offset < rdev->doorbell.size) { |
| 1389 | return readl(((void __iomem *)rdev->doorbell.ptr) + offset); |
| 1390 | } else { |
| 1391 | DRM_ERROR("reading beyond doorbell aperture: 0x%08x!\n", offset); |
| 1392 | return 0; |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | /** |
| 1397 | * cik_mm_wdoorbell - write a doorbell dword |
| 1398 | * |
| 1399 | * @rdev: radeon_device pointer |
| 1400 | * @offset: byte offset into the aperture |
| 1401 | * @v: value to write |
| 1402 | * |
| 1403 | * Writes @v to the doorbell aperture at the |
| 1404 | * requested offset (CIK). |
| 1405 | */ |
| 1406 | void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v) |
| 1407 | { |
| 1408 | if (offset < rdev->doorbell.size) { |
| 1409 | writel(v, ((void __iomem *)rdev->doorbell.ptr) + offset); |
| 1410 | } else { |
| 1411 | DRM_ERROR("writing beyond doorbell aperture: 0x%08x!\n", offset); |
| 1412 | } |
| 1413 | } |
| 1414 | |
Alex Deucher | bc8273f | 2012-06-29 19:44:04 -0400 | [diff] [blame] | 1415 | #define BONAIRE_IO_MC_REGS_SIZE 36 |
| 1416 | |
| 1417 | static const u32 bonaire_io_mc_regs[BONAIRE_IO_MC_REGS_SIZE][2] = |
| 1418 | { |
| 1419 | {0x00000070, 0x04400000}, |
| 1420 | {0x00000071, 0x80c01803}, |
| 1421 | {0x00000072, 0x00004004}, |
| 1422 | {0x00000073, 0x00000100}, |
| 1423 | {0x00000074, 0x00ff0000}, |
| 1424 | {0x00000075, 0x34000000}, |
| 1425 | {0x00000076, 0x08000014}, |
| 1426 | {0x00000077, 0x00cc08ec}, |
| 1427 | {0x00000078, 0x00000400}, |
| 1428 | {0x00000079, 0x00000000}, |
| 1429 | {0x0000007a, 0x04090000}, |
| 1430 | {0x0000007c, 0x00000000}, |
| 1431 | {0x0000007e, 0x4408a8e8}, |
| 1432 | {0x0000007f, 0x00000304}, |
| 1433 | {0x00000080, 0x00000000}, |
| 1434 | {0x00000082, 0x00000001}, |
| 1435 | {0x00000083, 0x00000002}, |
| 1436 | {0x00000084, 0xf3e4f400}, |
| 1437 | {0x00000085, 0x052024e3}, |
| 1438 | {0x00000087, 0x00000000}, |
| 1439 | {0x00000088, 0x01000000}, |
| 1440 | {0x0000008a, 0x1c0a0000}, |
| 1441 | {0x0000008b, 0xff010000}, |
| 1442 | {0x0000008d, 0xffffefff}, |
| 1443 | {0x0000008e, 0xfff3efff}, |
| 1444 | {0x0000008f, 0xfff3efbf}, |
| 1445 | {0x00000092, 0xf7ffffff}, |
| 1446 | {0x00000093, 0xffffff7f}, |
| 1447 | {0x00000095, 0x00101101}, |
| 1448 | {0x00000096, 0x00000fff}, |
| 1449 | {0x00000097, 0x00116fff}, |
| 1450 | {0x00000098, 0x60010000}, |
| 1451 | {0x00000099, 0x10010000}, |
| 1452 | {0x0000009a, 0x00006000}, |
| 1453 | {0x0000009b, 0x00001000}, |
| 1454 | {0x0000009f, 0x00b48000} |
| 1455 | }; |
| 1456 | |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 1457 | /** |
| 1458 | * cik_srbm_select - select specific register instances |
| 1459 | * |
| 1460 | * @rdev: radeon_device pointer |
| 1461 | * @me: selected ME (micro engine) |
| 1462 | * @pipe: pipe |
| 1463 | * @queue: queue |
| 1464 | * @vmid: VMID |
| 1465 | * |
| 1466 | * Switches the currently active registers instances. Some |
| 1467 | * registers are instanced per VMID, others are instanced per |
| 1468 | * me/pipe/queue combination. |
| 1469 | */ |
| 1470 | static void cik_srbm_select(struct radeon_device *rdev, |
| 1471 | u32 me, u32 pipe, u32 queue, u32 vmid) |
| 1472 | { |
| 1473 | u32 srbm_gfx_cntl = (PIPEID(pipe & 0x3) | |
| 1474 | MEID(me & 0x3) | |
| 1475 | VMID(vmid & 0xf) | |
| 1476 | QUEUEID(queue & 0x7)); |
| 1477 | WREG32(SRBM_GFX_CNTL, srbm_gfx_cntl); |
| 1478 | } |
| 1479 | |
Alex Deucher | bc8273f | 2012-06-29 19:44:04 -0400 | [diff] [blame] | 1480 | /* ucode loading */ |
| 1481 | /** |
| 1482 | * ci_mc_load_microcode - load MC ucode into the hw |
| 1483 | * |
| 1484 | * @rdev: radeon_device pointer |
| 1485 | * |
| 1486 | * Load the GDDR MC ucode into the hw (CIK). |
| 1487 | * Returns 0 on success, error on failure. |
| 1488 | */ |
| 1489 | static int ci_mc_load_microcode(struct radeon_device *rdev) |
| 1490 | { |
| 1491 | const __be32 *fw_data; |
| 1492 | u32 running, blackout = 0; |
| 1493 | u32 *io_mc_regs; |
| 1494 | int i, ucode_size, regs_size; |
| 1495 | |
| 1496 | if (!rdev->mc_fw) |
| 1497 | return -EINVAL; |
| 1498 | |
| 1499 | switch (rdev->family) { |
| 1500 | case CHIP_BONAIRE: |
| 1501 | default: |
| 1502 | io_mc_regs = (u32 *)&bonaire_io_mc_regs; |
| 1503 | ucode_size = CIK_MC_UCODE_SIZE; |
| 1504 | regs_size = BONAIRE_IO_MC_REGS_SIZE; |
| 1505 | break; |
| 1506 | } |
| 1507 | |
| 1508 | running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK; |
| 1509 | |
| 1510 | if (running == 0) { |
| 1511 | if (running) { |
| 1512 | blackout = RREG32(MC_SHARED_BLACKOUT_CNTL); |
| 1513 | WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1); |
| 1514 | } |
| 1515 | |
| 1516 | /* reset the engine and set to writable */ |
| 1517 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); |
| 1518 | WREG32(MC_SEQ_SUP_CNTL, 0x00000010); |
| 1519 | |
| 1520 | /* load mc io regs */ |
| 1521 | for (i = 0; i < regs_size; i++) { |
| 1522 | WREG32(MC_SEQ_IO_DEBUG_INDEX, io_mc_regs[(i << 1)]); |
| 1523 | WREG32(MC_SEQ_IO_DEBUG_DATA, io_mc_regs[(i << 1) + 1]); |
| 1524 | } |
| 1525 | /* load the MC ucode */ |
| 1526 | fw_data = (const __be32 *)rdev->mc_fw->data; |
| 1527 | for (i = 0; i < ucode_size; i++) |
| 1528 | WREG32(MC_SEQ_SUP_PGM, be32_to_cpup(fw_data++)); |
| 1529 | |
| 1530 | /* put the engine back into the active state */ |
| 1531 | WREG32(MC_SEQ_SUP_CNTL, 0x00000008); |
| 1532 | WREG32(MC_SEQ_SUP_CNTL, 0x00000004); |
| 1533 | WREG32(MC_SEQ_SUP_CNTL, 0x00000001); |
| 1534 | |
| 1535 | /* wait for training to complete */ |
| 1536 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 1537 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D0) |
| 1538 | break; |
| 1539 | udelay(1); |
| 1540 | } |
| 1541 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 1542 | if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D1) |
| 1543 | break; |
| 1544 | udelay(1); |
| 1545 | } |
| 1546 | |
| 1547 | if (running) |
| 1548 | WREG32(MC_SHARED_BLACKOUT_CNTL, blackout); |
| 1549 | } |
| 1550 | |
| 1551 | return 0; |
| 1552 | } |
| 1553 | |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1554 | /** |
| 1555 | * cik_init_microcode - load ucode images from disk |
| 1556 | * |
| 1557 | * @rdev: radeon_device pointer |
| 1558 | * |
| 1559 | * Use the firmware interface to load the ucode images into |
| 1560 | * the driver (not loaded into hw). |
| 1561 | * Returns 0 on success, error on failure. |
| 1562 | */ |
| 1563 | static int cik_init_microcode(struct radeon_device *rdev) |
| 1564 | { |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1565 | const char *chip_name; |
| 1566 | size_t pfp_req_size, me_req_size, ce_req_size, |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1567 | mec_req_size, rlc_req_size, mc_req_size, |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1568 | sdma_req_size, smc_req_size; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1569 | char fw_name[30]; |
| 1570 | int err; |
| 1571 | |
| 1572 | DRM_DEBUG("\n"); |
| 1573 | |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1574 | switch (rdev->family) { |
| 1575 | case CHIP_BONAIRE: |
| 1576 | chip_name = "BONAIRE"; |
| 1577 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1578 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1579 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1580 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1581 | rlc_req_size = BONAIRE_RLC_UCODE_SIZE * 4; |
| 1582 | mc_req_size = CIK_MC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1583 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1584 | smc_req_size = ALIGN(BONAIRE_SMC_UCODE_SIZE, 4); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1585 | break; |
| 1586 | case CHIP_KAVERI: |
| 1587 | chip_name = "KAVERI"; |
| 1588 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1589 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1590 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1591 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1592 | rlc_req_size = KV_RLC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1593 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1594 | break; |
| 1595 | case CHIP_KABINI: |
| 1596 | chip_name = "KABINI"; |
| 1597 | pfp_req_size = CIK_PFP_UCODE_SIZE * 4; |
| 1598 | me_req_size = CIK_ME_UCODE_SIZE * 4; |
| 1599 | ce_req_size = CIK_CE_UCODE_SIZE * 4; |
| 1600 | mec_req_size = CIK_MEC_UCODE_SIZE * 4; |
| 1601 | rlc_req_size = KB_RLC_UCODE_SIZE * 4; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1602 | sdma_req_size = CIK_SDMA_UCODE_SIZE * 4; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1603 | break; |
| 1604 | default: BUG(); |
| 1605 | } |
| 1606 | |
| 1607 | DRM_INFO("Loading %s Microcode\n", chip_name); |
| 1608 | |
| 1609 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1610 | err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1611 | if (err) |
| 1612 | goto out; |
| 1613 | if (rdev->pfp_fw->size != pfp_req_size) { |
| 1614 | printk(KERN_ERR |
| 1615 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1616 | rdev->pfp_fw->size, fw_name); |
| 1617 | err = -EINVAL; |
| 1618 | goto out; |
| 1619 | } |
| 1620 | |
| 1621 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1622 | err = request_firmware(&rdev->me_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1623 | if (err) |
| 1624 | goto out; |
| 1625 | if (rdev->me_fw->size != me_req_size) { |
| 1626 | printk(KERN_ERR |
| 1627 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1628 | rdev->me_fw->size, fw_name); |
| 1629 | err = -EINVAL; |
| 1630 | } |
| 1631 | |
| 1632 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1633 | err = request_firmware(&rdev->ce_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1634 | if (err) |
| 1635 | goto out; |
| 1636 | if (rdev->ce_fw->size != ce_req_size) { |
| 1637 | printk(KERN_ERR |
| 1638 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1639 | rdev->ce_fw->size, fw_name); |
| 1640 | err = -EINVAL; |
| 1641 | } |
| 1642 | |
| 1643 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_mec.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1644 | err = request_firmware(&rdev->mec_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1645 | if (err) |
| 1646 | goto out; |
| 1647 | if (rdev->mec_fw->size != mec_req_size) { |
| 1648 | printk(KERN_ERR |
| 1649 | "cik_cp: Bogus length %zu in firmware \"%s\"\n", |
| 1650 | rdev->mec_fw->size, fw_name); |
| 1651 | err = -EINVAL; |
| 1652 | } |
| 1653 | |
| 1654 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1655 | err = request_firmware(&rdev->rlc_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1656 | if (err) |
| 1657 | goto out; |
| 1658 | if (rdev->rlc_fw->size != rlc_req_size) { |
| 1659 | printk(KERN_ERR |
| 1660 | "cik_rlc: Bogus length %zu in firmware \"%s\"\n", |
| 1661 | rdev->rlc_fw->size, fw_name); |
| 1662 | err = -EINVAL; |
| 1663 | } |
| 1664 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1665 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_sdma.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1666 | err = request_firmware(&rdev->sdma_fw, fw_name, rdev->dev); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 1667 | if (err) |
| 1668 | goto out; |
| 1669 | if (rdev->sdma_fw->size != sdma_req_size) { |
| 1670 | printk(KERN_ERR |
| 1671 | "cik_sdma: Bogus length %zu in firmware \"%s\"\n", |
| 1672 | rdev->sdma_fw->size, fw_name); |
| 1673 | err = -EINVAL; |
| 1674 | } |
| 1675 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1676 | /* No SMC, MC ucode on APUs */ |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1677 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 1678 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); |
Jerome Glisse | 0a16893 | 2013-07-11 15:53:01 -0400 | [diff] [blame] | 1679 | err = request_firmware(&rdev->mc_fw, fw_name, rdev->dev); |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1680 | if (err) |
| 1681 | goto out; |
| 1682 | if (rdev->mc_fw->size != mc_req_size) { |
| 1683 | printk(KERN_ERR |
| 1684 | "cik_mc: Bogus length %zu in firmware \"%s\"\n", |
| 1685 | rdev->mc_fw->size, fw_name); |
| 1686 | err = -EINVAL; |
| 1687 | } |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1688 | |
| 1689 | snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); |
| 1690 | err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); |
| 1691 | if (err) { |
| 1692 | printk(KERN_ERR |
| 1693 | "smc: error loading firmware \"%s\"\n", |
| 1694 | fw_name); |
| 1695 | release_firmware(rdev->smc_fw); |
| 1696 | rdev->smc_fw = NULL; |
| 1697 | } else if (rdev->smc_fw->size != smc_req_size) { |
| 1698 | printk(KERN_ERR |
| 1699 | "cik_smc: Bogus length %zu in firmware \"%s\"\n", |
| 1700 | rdev->smc_fw->size, fw_name); |
| 1701 | err = -EINVAL; |
| 1702 | } |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | out: |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1706 | if (err) { |
| 1707 | if (err != -EINVAL) |
| 1708 | printk(KERN_ERR |
| 1709 | "cik_cp: Failed to load firmware \"%s\"\n", |
| 1710 | fw_name); |
| 1711 | release_firmware(rdev->pfp_fw); |
| 1712 | rdev->pfp_fw = NULL; |
| 1713 | release_firmware(rdev->me_fw); |
| 1714 | rdev->me_fw = NULL; |
| 1715 | release_firmware(rdev->ce_fw); |
| 1716 | rdev->ce_fw = NULL; |
| 1717 | release_firmware(rdev->rlc_fw); |
| 1718 | rdev->rlc_fw = NULL; |
| 1719 | release_firmware(rdev->mc_fw); |
| 1720 | rdev->mc_fw = NULL; |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 1721 | release_firmware(rdev->smc_fw); |
| 1722 | rdev->smc_fw = NULL; |
Alex Deucher | 02c8132 | 2012-12-18 21:43:07 -0500 | [diff] [blame] | 1723 | } |
| 1724 | return err; |
| 1725 | } |
| 1726 | |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1727 | /* |
| 1728 | * Core functions |
| 1729 | */ |
| 1730 | /** |
| 1731 | * cik_tiling_mode_table_init - init the hw tiling table |
| 1732 | * |
| 1733 | * @rdev: radeon_device pointer |
| 1734 | * |
| 1735 | * Starting with SI, the tiling setup is done globally in a |
| 1736 | * set of 32 tiling modes. Rather than selecting each set of |
| 1737 | * parameters per surface as on older asics, we just select |
| 1738 | * which index in the tiling table we want to use, and the |
| 1739 | * surface uses those parameters (CIK). |
| 1740 | */ |
| 1741 | static void cik_tiling_mode_table_init(struct radeon_device *rdev) |
| 1742 | { |
| 1743 | const u32 num_tile_mode_states = 32; |
| 1744 | const u32 num_secondary_tile_mode_states = 16; |
| 1745 | u32 reg_offset, gb_tile_moden, split_equal_to_row_size; |
| 1746 | u32 num_pipe_configs; |
| 1747 | u32 num_rbs = rdev->config.cik.max_backends_per_se * |
| 1748 | rdev->config.cik.max_shader_engines; |
| 1749 | |
| 1750 | switch (rdev->config.cik.mem_row_size_in_kb) { |
| 1751 | case 1: |
| 1752 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB; |
| 1753 | break; |
| 1754 | case 2: |
| 1755 | default: |
| 1756 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB; |
| 1757 | break; |
| 1758 | case 4: |
| 1759 | split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB; |
| 1760 | break; |
| 1761 | } |
| 1762 | |
| 1763 | num_pipe_configs = rdev->config.cik.max_tile_pipes; |
| 1764 | if (num_pipe_configs > 8) |
| 1765 | num_pipe_configs = 8; /* ??? */ |
| 1766 | |
| 1767 | if (num_pipe_configs == 8) { |
| 1768 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 1769 | switch (reg_offset) { |
| 1770 | case 0: |
| 1771 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1772 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1773 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1774 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 1775 | break; |
| 1776 | case 1: |
| 1777 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1778 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1779 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1780 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 1781 | break; |
| 1782 | case 2: |
| 1783 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1784 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1785 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1786 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 1787 | break; |
| 1788 | case 3: |
| 1789 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1790 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1791 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1792 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 1793 | break; |
| 1794 | case 4: |
| 1795 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1796 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1797 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1798 | TILE_SPLIT(split_equal_to_row_size)); |
| 1799 | break; |
| 1800 | case 5: |
| 1801 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1802 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 1803 | break; |
| 1804 | case 6: |
| 1805 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1806 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1807 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1808 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 1809 | break; |
| 1810 | case 7: |
| 1811 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1812 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1813 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1814 | TILE_SPLIT(split_equal_to_row_size)); |
| 1815 | break; |
| 1816 | case 8: |
| 1817 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 1818 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16)); |
| 1819 | break; |
| 1820 | case 9: |
| 1821 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1822 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 1823 | break; |
| 1824 | case 10: |
| 1825 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1826 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1827 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1828 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1829 | break; |
| 1830 | case 11: |
| 1831 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1832 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1833 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1834 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1835 | break; |
| 1836 | case 12: |
| 1837 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1838 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 1839 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1840 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1841 | break; |
| 1842 | case 13: |
| 1843 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1844 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 1845 | break; |
| 1846 | case 14: |
| 1847 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1848 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1849 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1850 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1851 | break; |
| 1852 | case 16: |
| 1853 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1854 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1855 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1856 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1857 | break; |
| 1858 | case 17: |
| 1859 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1860 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 1861 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1862 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1863 | break; |
| 1864 | case 27: |
| 1865 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 1866 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 1867 | break; |
| 1868 | case 28: |
| 1869 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1870 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1871 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1872 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1873 | break; |
| 1874 | case 29: |
| 1875 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 1876 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1877 | PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) | |
| 1878 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1879 | break; |
| 1880 | case 30: |
| 1881 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 1882 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 1883 | PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) | |
| 1884 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 1885 | break; |
| 1886 | default: |
| 1887 | gb_tile_moden = 0; |
| 1888 | break; |
| 1889 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 1890 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 1891 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 1892 | } |
| 1893 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 1894 | switch (reg_offset) { |
| 1895 | case 0: |
| 1896 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1897 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 1898 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1899 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1900 | break; |
| 1901 | case 1: |
| 1902 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1903 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 1904 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1905 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1906 | break; |
| 1907 | case 2: |
| 1908 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1909 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1910 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1911 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1912 | break; |
| 1913 | case 3: |
| 1914 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1915 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1916 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1917 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1918 | break; |
| 1919 | case 4: |
| 1920 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1921 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1922 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1923 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 1924 | break; |
| 1925 | case 5: |
| 1926 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1927 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1928 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1929 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 1930 | break; |
| 1931 | case 6: |
| 1932 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1933 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1934 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1935 | NUM_BANKS(ADDR_SURF_2_BANK)); |
| 1936 | break; |
| 1937 | case 8: |
| 1938 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1939 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 1940 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1941 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1942 | break; |
| 1943 | case 9: |
| 1944 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1945 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 1946 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 1947 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1948 | break; |
| 1949 | case 10: |
| 1950 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1951 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 1952 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1953 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1954 | break; |
| 1955 | case 11: |
| 1956 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1957 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1958 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 1959 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 1960 | break; |
| 1961 | case 12: |
| 1962 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1963 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1964 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1965 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 1966 | break; |
| 1967 | case 13: |
| 1968 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1969 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1970 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1971 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 1972 | break; |
| 1973 | case 14: |
| 1974 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 1975 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 1976 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 1977 | NUM_BANKS(ADDR_SURF_2_BANK)); |
| 1978 | break; |
| 1979 | default: |
| 1980 | gb_tile_moden = 0; |
| 1981 | break; |
| 1982 | } |
| 1983 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 1984 | } |
| 1985 | } else if (num_pipe_configs == 4) { |
| 1986 | if (num_rbs == 4) { |
| 1987 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 1988 | switch (reg_offset) { |
| 1989 | case 0: |
| 1990 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1991 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1992 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 1993 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 1994 | break; |
| 1995 | case 1: |
| 1996 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 1997 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 1998 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 1999 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 2000 | break; |
| 2001 | case 2: |
| 2002 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2003 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2004 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2005 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2006 | break; |
| 2007 | case 3: |
| 2008 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2009 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2010 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2011 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2012 | break; |
| 2013 | case 4: |
| 2014 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2015 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2016 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2017 | TILE_SPLIT(split_equal_to_row_size)); |
| 2018 | break; |
| 2019 | case 5: |
| 2020 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2021 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2022 | break; |
| 2023 | case 6: |
| 2024 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2025 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2026 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2027 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2028 | break; |
| 2029 | case 7: |
| 2030 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2031 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2032 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2033 | TILE_SPLIT(split_equal_to_row_size)); |
| 2034 | break; |
| 2035 | case 8: |
| 2036 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 2037 | PIPE_CONFIG(ADDR_SURF_P4_16x16)); |
| 2038 | break; |
| 2039 | case 9: |
| 2040 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2041 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2042 | break; |
| 2043 | case 10: |
| 2044 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2045 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2046 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2047 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2048 | break; |
| 2049 | case 11: |
| 2050 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2051 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2052 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2053 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2054 | break; |
| 2055 | case 12: |
| 2056 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2057 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2058 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2059 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2060 | break; |
| 2061 | case 13: |
| 2062 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2063 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2064 | break; |
| 2065 | case 14: |
| 2066 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2067 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2068 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2069 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2070 | break; |
| 2071 | case 16: |
| 2072 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2073 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2074 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2075 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2076 | break; |
| 2077 | case 17: |
| 2078 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2079 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2080 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2081 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2082 | break; |
| 2083 | case 27: |
| 2084 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2085 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2086 | break; |
| 2087 | case 28: |
| 2088 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2089 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2090 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2091 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2092 | break; |
| 2093 | case 29: |
| 2094 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2095 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2096 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2097 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2098 | break; |
| 2099 | case 30: |
| 2100 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2101 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2102 | PIPE_CONFIG(ADDR_SURF_P4_16x16) | |
| 2103 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2104 | break; |
| 2105 | default: |
| 2106 | gb_tile_moden = 0; |
| 2107 | break; |
| 2108 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2109 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2110 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2111 | } |
| 2112 | } else if (num_rbs < 4) { |
| 2113 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 2114 | switch (reg_offset) { |
| 2115 | case 0: |
| 2116 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2117 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2118 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2119 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 2120 | break; |
| 2121 | case 1: |
| 2122 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2123 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2124 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2125 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 2126 | break; |
| 2127 | case 2: |
| 2128 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2129 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2130 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2131 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2132 | break; |
| 2133 | case 3: |
| 2134 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2135 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2136 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2137 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2138 | break; |
| 2139 | case 4: |
| 2140 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2141 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2142 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2143 | TILE_SPLIT(split_equal_to_row_size)); |
| 2144 | break; |
| 2145 | case 5: |
| 2146 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2147 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2148 | break; |
| 2149 | case 6: |
| 2150 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2151 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2152 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2153 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2154 | break; |
| 2155 | case 7: |
| 2156 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2157 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2158 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2159 | TILE_SPLIT(split_equal_to_row_size)); |
| 2160 | break; |
| 2161 | case 8: |
| 2162 | gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) | |
| 2163 | PIPE_CONFIG(ADDR_SURF_P4_8x16)); |
| 2164 | break; |
| 2165 | case 9: |
| 2166 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2167 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2168 | break; |
| 2169 | case 10: |
| 2170 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2171 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2172 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2173 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2174 | break; |
| 2175 | case 11: |
| 2176 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2177 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2178 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2179 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2180 | break; |
| 2181 | case 12: |
| 2182 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2183 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2184 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2185 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2186 | break; |
| 2187 | case 13: |
| 2188 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2189 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2190 | break; |
| 2191 | case 14: |
| 2192 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2193 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2194 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2195 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2196 | break; |
| 2197 | case 16: |
| 2198 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2199 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2200 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2201 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2202 | break; |
| 2203 | case 17: |
| 2204 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2205 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2206 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2207 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2208 | break; |
| 2209 | case 27: |
| 2210 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2211 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2212 | break; |
| 2213 | case 28: |
| 2214 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2215 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2216 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2217 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2218 | break; |
| 2219 | case 29: |
| 2220 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2221 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2222 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2223 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2224 | break; |
| 2225 | case 30: |
| 2226 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2227 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2228 | PIPE_CONFIG(ADDR_SURF_P4_8x16) | |
| 2229 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2230 | break; |
| 2231 | default: |
| 2232 | gb_tile_moden = 0; |
| 2233 | break; |
| 2234 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2235 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2236 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2237 | } |
| 2238 | } |
| 2239 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 2240 | switch (reg_offset) { |
| 2241 | case 0: |
| 2242 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2243 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2244 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2245 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2246 | break; |
| 2247 | case 1: |
| 2248 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2249 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2250 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2251 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2252 | break; |
| 2253 | case 2: |
| 2254 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2255 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2256 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2257 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2258 | break; |
| 2259 | case 3: |
| 2260 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2261 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2262 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2263 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2264 | break; |
| 2265 | case 4: |
| 2266 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2267 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2268 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2269 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2270 | break; |
| 2271 | case 5: |
| 2272 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2273 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2274 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2275 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2276 | break; |
| 2277 | case 6: |
| 2278 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2279 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2280 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 2281 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 2282 | break; |
| 2283 | case 8: |
| 2284 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2285 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 2286 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2287 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2288 | break; |
| 2289 | case 9: |
| 2290 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2291 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2292 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2293 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2294 | break; |
| 2295 | case 10: |
| 2296 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2297 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2298 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2299 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2300 | break; |
| 2301 | case 11: |
| 2302 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2303 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2304 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2305 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2306 | break; |
| 2307 | case 12: |
| 2308 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2309 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2310 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2311 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2312 | break; |
| 2313 | case 13: |
| 2314 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2315 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2316 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2317 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2318 | break; |
| 2319 | case 14: |
| 2320 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2321 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2322 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) | |
| 2323 | NUM_BANKS(ADDR_SURF_4_BANK)); |
| 2324 | break; |
| 2325 | default: |
| 2326 | gb_tile_moden = 0; |
| 2327 | break; |
| 2328 | } |
| 2329 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2330 | } |
| 2331 | } else if (num_pipe_configs == 2) { |
| 2332 | for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) { |
| 2333 | switch (reg_offset) { |
| 2334 | case 0: |
| 2335 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2336 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2337 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2338 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B)); |
| 2339 | break; |
| 2340 | case 1: |
| 2341 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2342 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2343 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2344 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B)); |
| 2345 | break; |
| 2346 | case 2: |
| 2347 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2348 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2349 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2350 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2351 | break; |
| 2352 | case 3: |
| 2353 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2354 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2355 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2356 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B)); |
| 2357 | break; |
| 2358 | case 4: |
| 2359 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2360 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2361 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2362 | TILE_SPLIT(split_equal_to_row_size)); |
| 2363 | break; |
| 2364 | case 5: |
| 2365 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2366 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING)); |
| 2367 | break; |
| 2368 | case 6: |
| 2369 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2370 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2371 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2372 | TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B)); |
| 2373 | break; |
| 2374 | case 7: |
| 2375 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2376 | MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING) | |
| 2377 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2378 | TILE_SPLIT(split_equal_to_row_size)); |
| 2379 | break; |
| 2380 | case 8: |
| 2381 | gb_tile_moden = ARRAY_MODE(ARRAY_LINEAR_ALIGNED); |
| 2382 | break; |
| 2383 | case 9: |
| 2384 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2385 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING)); |
| 2386 | break; |
| 2387 | case 10: |
| 2388 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2389 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2390 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2391 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2392 | break; |
| 2393 | case 11: |
| 2394 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2395 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2396 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2397 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2398 | break; |
| 2399 | case 12: |
| 2400 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2401 | MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) | |
| 2402 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2403 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2404 | break; |
| 2405 | case 13: |
| 2406 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2407 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING)); |
| 2408 | break; |
| 2409 | case 14: |
| 2410 | gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) | |
| 2411 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2412 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2413 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2414 | break; |
| 2415 | case 16: |
| 2416 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2417 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2418 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2419 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2420 | break; |
| 2421 | case 17: |
| 2422 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2423 | MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) | |
| 2424 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2425 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2426 | break; |
| 2427 | case 27: |
| 2428 | gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) | |
| 2429 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING)); |
| 2430 | break; |
| 2431 | case 28: |
| 2432 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2433 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2434 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2435 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2436 | break; |
| 2437 | case 29: |
| 2438 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) | |
| 2439 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2440 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2441 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2442 | break; |
| 2443 | case 30: |
| 2444 | gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_2D_TILED_THIN1) | |
| 2445 | MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) | |
| 2446 | PIPE_CONFIG(ADDR_SURF_P2) | |
| 2447 | SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2)); |
| 2448 | break; |
| 2449 | default: |
| 2450 | gb_tile_moden = 0; |
| 2451 | break; |
| 2452 | } |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 2453 | rdev->config.cik.tile_mode_array[reg_offset] = gb_tile_moden; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2454 | WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2455 | } |
| 2456 | for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) { |
| 2457 | switch (reg_offset) { |
| 2458 | case 0: |
| 2459 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2460 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2461 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2462 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2463 | break; |
| 2464 | case 1: |
| 2465 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2466 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2467 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2468 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2469 | break; |
| 2470 | case 2: |
| 2471 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2472 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2473 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2474 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2475 | break; |
| 2476 | case 3: |
| 2477 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2478 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2479 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2480 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2481 | break; |
| 2482 | case 4: |
| 2483 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2484 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2485 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2486 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2487 | break; |
| 2488 | case 5: |
| 2489 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2490 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2491 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2492 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2493 | break; |
| 2494 | case 6: |
| 2495 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2496 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2497 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2498 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2499 | break; |
| 2500 | case 8: |
| 2501 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) | |
| 2502 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) | |
| 2503 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2504 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2505 | break; |
| 2506 | case 9: |
| 2507 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) | |
| 2508 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2509 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2510 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2511 | break; |
| 2512 | case 10: |
| 2513 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2514 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) | |
| 2515 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2516 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2517 | break; |
| 2518 | case 11: |
| 2519 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) | |
| 2520 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2521 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2522 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2523 | break; |
| 2524 | case 12: |
| 2525 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2526 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) | |
| 2527 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2528 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2529 | break; |
| 2530 | case 13: |
| 2531 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2532 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2533 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) | |
| 2534 | NUM_BANKS(ADDR_SURF_16_BANK)); |
| 2535 | break; |
| 2536 | case 14: |
| 2537 | gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) | |
| 2538 | BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) | |
| 2539 | MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) | |
| 2540 | NUM_BANKS(ADDR_SURF_8_BANK)); |
| 2541 | break; |
| 2542 | default: |
| 2543 | gb_tile_moden = 0; |
| 2544 | break; |
| 2545 | } |
| 2546 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2547 | } |
| 2548 | } else |
| 2549 | DRM_ERROR("unknown num pipe config: 0x%x\n", num_pipe_configs); |
| 2550 | } |
| 2551 | |
| 2552 | /** |
| 2553 | * cik_select_se_sh - select which SE, SH to address |
| 2554 | * |
| 2555 | * @rdev: radeon_device pointer |
| 2556 | * @se_num: shader engine to address |
| 2557 | * @sh_num: sh block to address |
| 2558 | * |
| 2559 | * Select which SE, SH combinations to address. Certain |
| 2560 | * registers are instanced per SE or SH. 0xffffffff means |
| 2561 | * broadcast to all SEs or SHs (CIK). |
| 2562 | */ |
| 2563 | static void cik_select_se_sh(struct radeon_device *rdev, |
| 2564 | u32 se_num, u32 sh_num) |
| 2565 | { |
| 2566 | u32 data = INSTANCE_BROADCAST_WRITES; |
| 2567 | |
| 2568 | if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) |
Alex Deucher | b0fe3d3 | 2013-04-18 16:25:47 -0400 | [diff] [blame] | 2569 | data |= SH_BROADCAST_WRITES | SE_BROADCAST_WRITES; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2570 | else if (se_num == 0xffffffff) |
| 2571 | data |= SE_BROADCAST_WRITES | SH_INDEX(sh_num); |
| 2572 | else if (sh_num == 0xffffffff) |
| 2573 | data |= SH_BROADCAST_WRITES | SE_INDEX(se_num); |
| 2574 | else |
| 2575 | data |= SH_INDEX(sh_num) | SE_INDEX(se_num); |
| 2576 | WREG32(GRBM_GFX_INDEX, data); |
| 2577 | } |
| 2578 | |
| 2579 | /** |
| 2580 | * cik_create_bitmask - create a bitmask |
| 2581 | * |
| 2582 | * @bit_width: length of the mask |
| 2583 | * |
| 2584 | * create a variable length bit mask (CIK). |
| 2585 | * Returns the bitmask. |
| 2586 | */ |
| 2587 | static u32 cik_create_bitmask(u32 bit_width) |
| 2588 | { |
| 2589 | u32 i, mask = 0; |
| 2590 | |
| 2591 | for (i = 0; i < bit_width; i++) { |
| 2592 | mask <<= 1; |
| 2593 | mask |= 1; |
| 2594 | } |
| 2595 | return mask; |
| 2596 | } |
| 2597 | |
| 2598 | /** |
| 2599 | * cik_select_se_sh - select which SE, SH to address |
| 2600 | * |
| 2601 | * @rdev: radeon_device pointer |
| 2602 | * @max_rb_num: max RBs (render backends) for the asic |
| 2603 | * @se_num: number of SEs (shader engines) for the asic |
| 2604 | * @sh_per_se: number of SH blocks per SE for the asic |
| 2605 | * |
| 2606 | * Calculates the bitmask of disabled RBs (CIK). |
| 2607 | * Returns the disabled RB bitmask. |
| 2608 | */ |
| 2609 | static u32 cik_get_rb_disabled(struct radeon_device *rdev, |
| 2610 | u32 max_rb_num, u32 se_num, |
| 2611 | u32 sh_per_se) |
| 2612 | { |
| 2613 | u32 data, mask; |
| 2614 | |
| 2615 | data = RREG32(CC_RB_BACKEND_DISABLE); |
| 2616 | if (data & 1) |
| 2617 | data &= BACKEND_DISABLE_MASK; |
| 2618 | else |
| 2619 | data = 0; |
| 2620 | data |= RREG32(GC_USER_RB_BACKEND_DISABLE); |
| 2621 | |
| 2622 | data >>= BACKEND_DISABLE_SHIFT; |
| 2623 | |
| 2624 | mask = cik_create_bitmask(max_rb_num / se_num / sh_per_se); |
| 2625 | |
| 2626 | return data & mask; |
| 2627 | } |
| 2628 | |
| 2629 | /** |
| 2630 | * cik_setup_rb - setup the RBs on the asic |
| 2631 | * |
| 2632 | * @rdev: radeon_device pointer |
| 2633 | * @se_num: number of SEs (shader engines) for the asic |
| 2634 | * @sh_per_se: number of SH blocks per SE for the asic |
| 2635 | * @max_rb_num: max RBs (render backends) for the asic |
| 2636 | * |
| 2637 | * Configures per-SE/SH RB registers (CIK). |
| 2638 | */ |
| 2639 | static void cik_setup_rb(struct radeon_device *rdev, |
| 2640 | u32 se_num, u32 sh_per_se, |
| 2641 | u32 max_rb_num) |
| 2642 | { |
| 2643 | int i, j; |
| 2644 | u32 data, mask; |
| 2645 | u32 disabled_rbs = 0; |
| 2646 | u32 enabled_rbs = 0; |
| 2647 | |
| 2648 | for (i = 0; i < se_num; i++) { |
| 2649 | for (j = 0; j < sh_per_se; j++) { |
| 2650 | cik_select_se_sh(rdev, i, j); |
| 2651 | data = cik_get_rb_disabled(rdev, max_rb_num, se_num, sh_per_se); |
| 2652 | disabled_rbs |= data << ((i * sh_per_se + j) * CIK_RB_BITMAP_WIDTH_PER_SH); |
| 2653 | } |
| 2654 | } |
| 2655 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 2656 | |
| 2657 | mask = 1; |
| 2658 | for (i = 0; i < max_rb_num; i++) { |
| 2659 | if (!(disabled_rbs & mask)) |
| 2660 | enabled_rbs |= mask; |
| 2661 | mask <<= 1; |
| 2662 | } |
| 2663 | |
| 2664 | for (i = 0; i < se_num; i++) { |
| 2665 | cik_select_se_sh(rdev, i, 0xffffffff); |
| 2666 | data = 0; |
| 2667 | for (j = 0; j < sh_per_se; j++) { |
| 2668 | switch (enabled_rbs & 3) { |
| 2669 | case 1: |
| 2670 | data |= (RASTER_CONFIG_RB_MAP_0 << (i * sh_per_se + j) * 2); |
| 2671 | break; |
| 2672 | case 2: |
| 2673 | data |= (RASTER_CONFIG_RB_MAP_3 << (i * sh_per_se + j) * 2); |
| 2674 | break; |
| 2675 | case 3: |
| 2676 | default: |
| 2677 | data |= (RASTER_CONFIG_RB_MAP_2 << (i * sh_per_se + j) * 2); |
| 2678 | break; |
| 2679 | } |
| 2680 | enabled_rbs >>= 2; |
| 2681 | } |
| 2682 | WREG32(PA_SC_RASTER_CONFIG, data); |
| 2683 | } |
| 2684 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 2685 | } |
| 2686 | |
| 2687 | /** |
| 2688 | * cik_gpu_init - setup the 3D engine |
| 2689 | * |
| 2690 | * @rdev: radeon_device pointer |
| 2691 | * |
| 2692 | * Configures the 3D engine and tiling configuration |
| 2693 | * registers so that the 3D engine is usable. |
| 2694 | */ |
| 2695 | static void cik_gpu_init(struct radeon_device *rdev) |
| 2696 | { |
| 2697 | u32 gb_addr_config = RREG32(GB_ADDR_CONFIG); |
| 2698 | u32 mc_shared_chmap, mc_arb_ramcfg; |
| 2699 | u32 hdp_host_path_cntl; |
| 2700 | u32 tmp; |
| 2701 | int i, j; |
| 2702 | |
| 2703 | switch (rdev->family) { |
| 2704 | case CHIP_BONAIRE: |
| 2705 | rdev->config.cik.max_shader_engines = 2; |
| 2706 | rdev->config.cik.max_tile_pipes = 4; |
| 2707 | rdev->config.cik.max_cu_per_sh = 7; |
| 2708 | rdev->config.cik.max_sh_per_se = 1; |
| 2709 | rdev->config.cik.max_backends_per_se = 2; |
| 2710 | rdev->config.cik.max_texture_channel_caches = 4; |
| 2711 | rdev->config.cik.max_gprs = 256; |
| 2712 | rdev->config.cik.max_gs_threads = 32; |
| 2713 | rdev->config.cik.max_hw_contexts = 8; |
| 2714 | |
| 2715 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2716 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2717 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2718 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2719 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
| 2720 | break; |
| 2721 | case CHIP_KAVERI: |
Alex Deucher | b2e4c70 | 2013-06-10 15:18:26 -0400 | [diff] [blame] | 2722 | rdev->config.cik.max_shader_engines = 1; |
| 2723 | rdev->config.cik.max_tile_pipes = 4; |
| 2724 | if ((rdev->pdev->device == 0x1304) || |
| 2725 | (rdev->pdev->device == 0x1305) || |
| 2726 | (rdev->pdev->device == 0x130C) || |
| 2727 | (rdev->pdev->device == 0x130F) || |
| 2728 | (rdev->pdev->device == 0x1310) || |
| 2729 | (rdev->pdev->device == 0x1311) || |
| 2730 | (rdev->pdev->device == 0x131C)) { |
| 2731 | rdev->config.cik.max_cu_per_sh = 8; |
| 2732 | rdev->config.cik.max_backends_per_se = 2; |
| 2733 | } else if ((rdev->pdev->device == 0x1309) || |
| 2734 | (rdev->pdev->device == 0x130A) || |
| 2735 | (rdev->pdev->device == 0x130D) || |
Alex Deucher | 7c4622d | 2013-09-04 16:46:07 -0400 | [diff] [blame] | 2736 | (rdev->pdev->device == 0x1313) || |
| 2737 | (rdev->pdev->device == 0x131D)) { |
Alex Deucher | b2e4c70 | 2013-06-10 15:18:26 -0400 | [diff] [blame] | 2738 | rdev->config.cik.max_cu_per_sh = 6; |
| 2739 | rdev->config.cik.max_backends_per_se = 2; |
| 2740 | } else if ((rdev->pdev->device == 0x1306) || |
| 2741 | (rdev->pdev->device == 0x1307) || |
| 2742 | (rdev->pdev->device == 0x130B) || |
| 2743 | (rdev->pdev->device == 0x130E) || |
| 2744 | (rdev->pdev->device == 0x1315) || |
| 2745 | (rdev->pdev->device == 0x131B)) { |
| 2746 | rdev->config.cik.max_cu_per_sh = 4; |
| 2747 | rdev->config.cik.max_backends_per_se = 1; |
| 2748 | } else { |
| 2749 | rdev->config.cik.max_cu_per_sh = 3; |
| 2750 | rdev->config.cik.max_backends_per_se = 1; |
| 2751 | } |
| 2752 | rdev->config.cik.max_sh_per_se = 1; |
| 2753 | rdev->config.cik.max_texture_channel_caches = 4; |
| 2754 | rdev->config.cik.max_gprs = 256; |
| 2755 | rdev->config.cik.max_gs_threads = 16; |
| 2756 | rdev->config.cik.max_hw_contexts = 8; |
| 2757 | |
| 2758 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2759 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2760 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2761 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2762 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2763 | break; |
| 2764 | case CHIP_KABINI: |
| 2765 | default: |
| 2766 | rdev->config.cik.max_shader_engines = 1; |
| 2767 | rdev->config.cik.max_tile_pipes = 2; |
| 2768 | rdev->config.cik.max_cu_per_sh = 2; |
| 2769 | rdev->config.cik.max_sh_per_se = 1; |
| 2770 | rdev->config.cik.max_backends_per_se = 1; |
| 2771 | rdev->config.cik.max_texture_channel_caches = 2; |
| 2772 | rdev->config.cik.max_gprs = 256; |
| 2773 | rdev->config.cik.max_gs_threads = 16; |
| 2774 | rdev->config.cik.max_hw_contexts = 8; |
| 2775 | |
| 2776 | rdev->config.cik.sc_prim_fifo_size_frontend = 0x20; |
| 2777 | rdev->config.cik.sc_prim_fifo_size_backend = 0x100; |
| 2778 | rdev->config.cik.sc_hiz_tile_fifo_size = 0x30; |
| 2779 | rdev->config.cik.sc_earlyz_tile_fifo_size = 0x130; |
| 2780 | gb_addr_config = BONAIRE_GB_ADDR_CONFIG_GOLDEN; |
| 2781 | break; |
| 2782 | } |
| 2783 | |
| 2784 | /* Initialize HDP */ |
| 2785 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 2786 | WREG32((0x2c14 + j), 0x00000000); |
| 2787 | WREG32((0x2c18 + j), 0x00000000); |
| 2788 | WREG32((0x2c1c + j), 0x00000000); |
| 2789 | WREG32((0x2c20 + j), 0x00000000); |
| 2790 | WREG32((0x2c24 + j), 0x00000000); |
| 2791 | } |
| 2792 | |
| 2793 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); |
| 2794 | |
| 2795 | WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN); |
| 2796 | |
| 2797 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); |
| 2798 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); |
| 2799 | |
| 2800 | rdev->config.cik.num_tile_pipes = rdev->config.cik.max_tile_pipes; |
| 2801 | rdev->config.cik.mem_max_burst_length_bytes = 256; |
| 2802 | tmp = (mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT; |
| 2803 | rdev->config.cik.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024; |
| 2804 | if (rdev->config.cik.mem_row_size_in_kb > 4) |
| 2805 | rdev->config.cik.mem_row_size_in_kb = 4; |
| 2806 | /* XXX use MC settings? */ |
| 2807 | rdev->config.cik.shader_engine_tile_size = 32; |
| 2808 | rdev->config.cik.num_gpus = 1; |
| 2809 | rdev->config.cik.multi_gpu_tile_size = 64; |
| 2810 | |
| 2811 | /* fix up row size */ |
| 2812 | gb_addr_config &= ~ROW_SIZE_MASK; |
| 2813 | switch (rdev->config.cik.mem_row_size_in_kb) { |
| 2814 | case 1: |
| 2815 | default: |
| 2816 | gb_addr_config |= ROW_SIZE(0); |
| 2817 | break; |
| 2818 | case 2: |
| 2819 | gb_addr_config |= ROW_SIZE(1); |
| 2820 | break; |
| 2821 | case 4: |
| 2822 | gb_addr_config |= ROW_SIZE(2); |
| 2823 | break; |
| 2824 | } |
| 2825 | |
| 2826 | /* setup tiling info dword. gb_addr_config is not adequate since it does |
| 2827 | * not have bank info, so create a custom tiling dword. |
| 2828 | * bits 3:0 num_pipes |
| 2829 | * bits 7:4 num_banks |
| 2830 | * bits 11:8 group_size |
| 2831 | * bits 15:12 row_size |
| 2832 | */ |
| 2833 | rdev->config.cik.tile_config = 0; |
| 2834 | switch (rdev->config.cik.num_tile_pipes) { |
| 2835 | case 1: |
| 2836 | rdev->config.cik.tile_config |= (0 << 0); |
| 2837 | break; |
| 2838 | case 2: |
| 2839 | rdev->config.cik.tile_config |= (1 << 0); |
| 2840 | break; |
| 2841 | case 4: |
| 2842 | rdev->config.cik.tile_config |= (2 << 0); |
| 2843 | break; |
| 2844 | case 8: |
| 2845 | default: |
| 2846 | /* XXX what about 12? */ |
| 2847 | rdev->config.cik.tile_config |= (3 << 0); |
| 2848 | break; |
| 2849 | } |
Michel Dänzer | a537314 | 2013-09-18 15:39:41 +0200 | [diff] [blame] | 2850 | rdev->config.cik.tile_config |= |
| 2851 | ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2852 | rdev->config.cik.tile_config |= |
| 2853 | ((gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT) << 8; |
| 2854 | rdev->config.cik.tile_config |= |
| 2855 | ((gb_addr_config & ROW_SIZE_MASK) >> ROW_SIZE_SHIFT) << 12; |
| 2856 | |
| 2857 | WREG32(GB_ADDR_CONFIG, gb_addr_config); |
| 2858 | WREG32(HDP_ADDR_CONFIG, gb_addr_config); |
| 2859 | WREG32(DMIF_ADDR_CALC, gb_addr_config); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 2860 | WREG32(SDMA0_TILING_CONFIG + SDMA0_REGISTER_OFFSET, gb_addr_config & 0x70); |
| 2861 | WREG32(SDMA0_TILING_CONFIG + SDMA1_REGISTER_OFFSET, gb_addr_config & 0x70); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 2862 | WREG32(UVD_UDEC_ADDR_CONFIG, gb_addr_config); |
| 2863 | WREG32(UVD_UDEC_DB_ADDR_CONFIG, gb_addr_config); |
| 2864 | WREG32(UVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config); |
Alex Deucher | 8cc1a53 | 2013-04-09 12:41:24 -0400 | [diff] [blame] | 2865 | |
| 2866 | cik_tiling_mode_table_init(rdev); |
| 2867 | |
| 2868 | cik_setup_rb(rdev, rdev->config.cik.max_shader_engines, |
| 2869 | rdev->config.cik.max_sh_per_se, |
| 2870 | rdev->config.cik.max_backends_per_se); |
| 2871 | |
| 2872 | /* set HW defaults for 3D engine */ |
| 2873 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); |
| 2874 | |
| 2875 | WREG32(SX_DEBUG_1, 0x20); |
| 2876 | |
| 2877 | WREG32(TA_CNTL_AUX, 0x00010000); |
| 2878 | |
| 2879 | tmp = RREG32(SPI_CONFIG_CNTL); |
| 2880 | tmp |= 0x03000000; |
| 2881 | WREG32(SPI_CONFIG_CNTL, tmp); |
| 2882 | |
| 2883 | WREG32(SQ_CONFIG, 1); |
| 2884 | |
| 2885 | WREG32(DB_DEBUG, 0); |
| 2886 | |
| 2887 | tmp = RREG32(DB_DEBUG2) & ~0xf00fffff; |
| 2888 | tmp |= 0x00000400; |
| 2889 | WREG32(DB_DEBUG2, tmp); |
| 2890 | |
| 2891 | tmp = RREG32(DB_DEBUG3) & ~0x0002021c; |
| 2892 | tmp |= 0x00020200; |
| 2893 | WREG32(DB_DEBUG3, tmp); |
| 2894 | |
| 2895 | tmp = RREG32(CB_HW_CONTROL) & ~0x00010000; |
| 2896 | tmp |= 0x00018208; |
| 2897 | WREG32(CB_HW_CONTROL, tmp); |
| 2898 | |
| 2899 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); |
| 2900 | |
| 2901 | WREG32(PA_SC_FIFO_SIZE, (SC_FRONTEND_PRIM_FIFO_SIZE(rdev->config.cik.sc_prim_fifo_size_frontend) | |
| 2902 | SC_BACKEND_PRIM_FIFO_SIZE(rdev->config.cik.sc_prim_fifo_size_backend) | |
| 2903 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.cik.sc_hiz_tile_fifo_size) | |
| 2904 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.cik.sc_earlyz_tile_fifo_size))); |
| 2905 | |
| 2906 | WREG32(VGT_NUM_INSTANCES, 1); |
| 2907 | |
| 2908 | WREG32(CP_PERFMON_CNTL, 0); |
| 2909 | |
| 2910 | WREG32(SQ_CONFIG, 0); |
| 2911 | |
| 2912 | WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | |
| 2913 | FORCE_EOV_MAX_REZ_CNT(255))); |
| 2914 | |
| 2915 | WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(VC_AND_TC) | |
| 2916 | AUTO_INVLD_EN(ES_AND_GS_AUTO)); |
| 2917 | |
| 2918 | WREG32(VGT_GS_VERTEX_REUSE, 16); |
| 2919 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); |
| 2920 | |
| 2921 | tmp = RREG32(HDP_MISC_CNTL); |
| 2922 | tmp |= HDP_FLUSH_INVALIDATE_CACHE; |
| 2923 | WREG32(HDP_MISC_CNTL, tmp); |
| 2924 | |
| 2925 | hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); |
| 2926 | WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); |
| 2927 | |
| 2928 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); |
| 2929 | WREG32(PA_SC_ENHANCE, ENABLE_PA_SC_OUT_OF_ORDER); |
| 2930 | |
| 2931 | udelay(50); |
| 2932 | } |
| 2933 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 2934 | /* |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 2935 | * GPU scratch registers helpers function. |
| 2936 | */ |
| 2937 | /** |
| 2938 | * cik_scratch_init - setup driver info for CP scratch regs |
| 2939 | * |
| 2940 | * @rdev: radeon_device pointer |
| 2941 | * |
| 2942 | * Set up the number and offset of the CP scratch registers. |
| 2943 | * NOTE: use of CP scratch registers is a legacy inferface and |
| 2944 | * is not used by default on newer asics (r6xx+). On newer asics, |
| 2945 | * memory buffers are used for fences rather than scratch regs. |
| 2946 | */ |
| 2947 | static void cik_scratch_init(struct radeon_device *rdev) |
| 2948 | { |
| 2949 | int i; |
| 2950 | |
| 2951 | rdev->scratch.num_reg = 7; |
| 2952 | rdev->scratch.reg_base = SCRATCH_REG0; |
| 2953 | for (i = 0; i < rdev->scratch.num_reg; i++) { |
| 2954 | rdev->scratch.free[i] = true; |
| 2955 | rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4); |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | /** |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 2960 | * cik_ring_test - basic gfx ring test |
| 2961 | * |
| 2962 | * @rdev: radeon_device pointer |
| 2963 | * @ring: radeon_ring structure holding ring information |
| 2964 | * |
| 2965 | * Allocate a scratch register and write to it using the gfx ring (CIK). |
| 2966 | * Provides a basic gfx ring test to verify that the ring is working. |
| 2967 | * Used by cik_cp_gfx_resume(); |
| 2968 | * Returns 0 on success, error on failure. |
| 2969 | */ |
| 2970 | int cik_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) |
| 2971 | { |
| 2972 | uint32_t scratch; |
| 2973 | uint32_t tmp = 0; |
| 2974 | unsigned i; |
| 2975 | int r; |
| 2976 | |
| 2977 | r = radeon_scratch_get(rdev, &scratch); |
| 2978 | if (r) { |
| 2979 | DRM_ERROR("radeon: cp failed to get scratch reg (%d).\n", r); |
| 2980 | return r; |
| 2981 | } |
| 2982 | WREG32(scratch, 0xCAFEDEAD); |
| 2983 | r = radeon_ring_lock(rdev, ring, 3); |
| 2984 | if (r) { |
| 2985 | DRM_ERROR("radeon: cp failed to lock ring %d (%d).\n", ring->idx, r); |
| 2986 | radeon_scratch_free(rdev, scratch); |
| 2987 | return r; |
| 2988 | } |
| 2989 | radeon_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1)); |
| 2990 | radeon_ring_write(ring, ((scratch - PACKET3_SET_UCONFIG_REG_START) >> 2)); |
| 2991 | radeon_ring_write(ring, 0xDEADBEEF); |
| 2992 | radeon_ring_unlock_commit(rdev, ring); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 2993 | |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 2994 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 2995 | tmp = RREG32(scratch); |
| 2996 | if (tmp == 0xDEADBEEF) |
| 2997 | break; |
| 2998 | DRM_UDELAY(1); |
| 2999 | } |
| 3000 | if (i < rdev->usec_timeout) { |
| 3001 | DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i); |
| 3002 | } else { |
| 3003 | DRM_ERROR("radeon: ring %d test failed (scratch(0x%04X)=0x%08X)\n", |
| 3004 | ring->idx, scratch, tmp); |
| 3005 | r = -EINVAL; |
| 3006 | } |
| 3007 | radeon_scratch_free(rdev, scratch); |
| 3008 | return r; |
| 3009 | } |
| 3010 | |
| 3011 | /** |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3012 | * cik_fence_gfx_ring_emit - emit a fence on the gfx ring |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3013 | * |
| 3014 | * @rdev: radeon_device pointer |
| 3015 | * @fence: radeon fence object |
| 3016 | * |
| 3017 | * Emits a fence sequnce number on the gfx ring and flushes |
| 3018 | * GPU caches. |
| 3019 | */ |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3020 | void cik_fence_gfx_ring_emit(struct radeon_device *rdev, |
| 3021 | struct radeon_fence *fence) |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3022 | { |
| 3023 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
| 3024 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; |
| 3025 | |
| 3026 | /* EVENT_WRITE_EOP - flush caches, send int */ |
| 3027 | radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4)); |
| 3028 | radeon_ring_write(ring, (EOP_TCL1_ACTION_EN | |
| 3029 | EOP_TC_ACTION_EN | |
| 3030 | EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | |
| 3031 | EVENT_INDEX(5))); |
| 3032 | radeon_ring_write(ring, addr & 0xfffffffc); |
| 3033 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | DATA_SEL(1) | INT_SEL(2)); |
| 3034 | radeon_ring_write(ring, fence->seq); |
| 3035 | radeon_ring_write(ring, 0); |
| 3036 | /* HDP flush */ |
| 3037 | /* We should be using the new WAIT_REG_MEM special op packet here |
| 3038 | * but it causes the CP to hang |
| 3039 | */ |
| 3040 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3041 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 3042 | WRITE_DATA_DST_SEL(0))); |
| 3043 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 3044 | radeon_ring_write(ring, 0); |
| 3045 | radeon_ring_write(ring, 0); |
| 3046 | } |
| 3047 | |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 3048 | /** |
| 3049 | * cik_fence_compute_ring_emit - emit a fence on the compute ring |
| 3050 | * |
| 3051 | * @rdev: radeon_device pointer |
| 3052 | * @fence: radeon fence object |
| 3053 | * |
| 3054 | * Emits a fence sequnce number on the compute ring and flushes |
| 3055 | * GPU caches. |
| 3056 | */ |
| 3057 | void cik_fence_compute_ring_emit(struct radeon_device *rdev, |
| 3058 | struct radeon_fence *fence) |
| 3059 | { |
| 3060 | struct radeon_ring *ring = &rdev->ring[fence->ring]; |
| 3061 | u64 addr = rdev->fence_drv[fence->ring].gpu_addr; |
| 3062 | |
| 3063 | /* RELEASE_MEM - flush caches, send int */ |
| 3064 | radeon_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 5)); |
| 3065 | radeon_ring_write(ring, (EOP_TCL1_ACTION_EN | |
| 3066 | EOP_TC_ACTION_EN | |
| 3067 | EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | |
| 3068 | EVENT_INDEX(5))); |
| 3069 | radeon_ring_write(ring, DATA_SEL(1) | INT_SEL(2)); |
| 3070 | radeon_ring_write(ring, addr & 0xfffffffc); |
| 3071 | radeon_ring_write(ring, upper_32_bits(addr)); |
| 3072 | radeon_ring_write(ring, fence->seq); |
| 3073 | radeon_ring_write(ring, 0); |
| 3074 | /* HDP flush */ |
| 3075 | /* We should be using the new WAIT_REG_MEM special op packet here |
| 3076 | * but it causes the CP to hang |
| 3077 | */ |
| 3078 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3079 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 3080 | WRITE_DATA_DST_SEL(0))); |
| 3081 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 3082 | radeon_ring_write(ring, 0); |
| 3083 | radeon_ring_write(ring, 0); |
| 3084 | } |
| 3085 | |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3086 | void cik_semaphore_ring_emit(struct radeon_device *rdev, |
| 3087 | struct radeon_ring *ring, |
| 3088 | struct radeon_semaphore *semaphore, |
| 3089 | bool emit_wait) |
| 3090 | { |
| 3091 | uint64_t addr = semaphore->gpu_addr; |
| 3092 | unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL; |
| 3093 | |
| 3094 | radeon_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 1)); |
| 3095 | radeon_ring_write(ring, addr & 0xffffffff); |
| 3096 | radeon_ring_write(ring, (upper_32_bits(addr) & 0xffff) | sel); |
| 3097 | } |
| 3098 | |
| 3099 | /* |
| 3100 | * IB stuff |
| 3101 | */ |
| 3102 | /** |
| 3103 | * cik_ring_ib_execute - emit an IB (Indirect Buffer) on the gfx ring |
| 3104 | * |
| 3105 | * @rdev: radeon_device pointer |
| 3106 | * @ib: radeon indirect buffer object |
| 3107 | * |
| 3108 | * Emits an DE (drawing engine) or CE (constant engine) IB |
| 3109 | * on the gfx ring. IBs are usually generated by userspace |
| 3110 | * acceleration drivers and submitted to the kernel for |
| 3111 | * sheduling on the ring. This function schedules the IB |
| 3112 | * on the gfx ring for execution by the GPU. |
| 3113 | */ |
| 3114 | void cik_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) |
| 3115 | { |
| 3116 | struct radeon_ring *ring = &rdev->ring[ib->ring]; |
| 3117 | u32 header, control = INDIRECT_BUFFER_VALID; |
| 3118 | |
| 3119 | if (ib->is_const_ib) { |
| 3120 | /* set switch buffer packet before const IB */ |
| 3121 | radeon_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0)); |
| 3122 | radeon_ring_write(ring, 0); |
| 3123 | |
| 3124 | header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2); |
| 3125 | } else { |
| 3126 | u32 next_rptr; |
| 3127 | if (ring->rptr_save_reg) { |
| 3128 | next_rptr = ring->wptr + 3 + 4; |
| 3129 | radeon_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1)); |
| 3130 | radeon_ring_write(ring, ((ring->rptr_save_reg - |
| 3131 | PACKET3_SET_UCONFIG_REG_START) >> 2)); |
| 3132 | radeon_ring_write(ring, next_rptr); |
| 3133 | } else if (rdev->wb.enabled) { |
| 3134 | next_rptr = ring->wptr + 5 + 4; |
| 3135 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 3136 | radeon_ring_write(ring, WRITE_DATA_DST_SEL(1)); |
| 3137 | radeon_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc); |
| 3138 | radeon_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff); |
| 3139 | radeon_ring_write(ring, next_rptr); |
| 3140 | } |
| 3141 | |
| 3142 | header = PACKET3(PACKET3_INDIRECT_BUFFER, 2); |
| 3143 | } |
| 3144 | |
| 3145 | control |= ib->length_dw | |
| 3146 | (ib->vm ? (ib->vm->id << 24) : 0); |
| 3147 | |
| 3148 | radeon_ring_write(ring, header); |
| 3149 | radeon_ring_write(ring, |
| 3150 | #ifdef __BIG_ENDIAN |
| 3151 | (2 << 0) | |
| 3152 | #endif |
| 3153 | (ib->gpu_addr & 0xFFFFFFFC)); |
| 3154 | radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF); |
| 3155 | radeon_ring_write(ring, control); |
| 3156 | } |
| 3157 | |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3158 | /** |
| 3159 | * cik_ib_test - basic gfx ring IB test |
| 3160 | * |
| 3161 | * @rdev: radeon_device pointer |
| 3162 | * @ring: radeon_ring structure holding ring information |
| 3163 | * |
| 3164 | * Allocate an IB and execute it on the gfx ring (CIK). |
| 3165 | * Provides a basic gfx ring test to verify that IBs are working. |
| 3166 | * Returns 0 on success, error on failure. |
| 3167 | */ |
| 3168 | int cik_ib_test(struct radeon_device *rdev, struct radeon_ring *ring) |
| 3169 | { |
| 3170 | struct radeon_ib ib; |
| 3171 | uint32_t scratch; |
| 3172 | uint32_t tmp = 0; |
| 3173 | unsigned i; |
| 3174 | int r; |
| 3175 | |
| 3176 | r = radeon_scratch_get(rdev, &scratch); |
| 3177 | if (r) { |
| 3178 | DRM_ERROR("radeon: failed to get scratch reg (%d).\n", r); |
| 3179 | return r; |
| 3180 | } |
| 3181 | WREG32(scratch, 0xCAFEDEAD); |
| 3182 | r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256); |
| 3183 | if (r) { |
| 3184 | DRM_ERROR("radeon: failed to get ib (%d).\n", r); |
Christian König | 5510f12 | 2013-10-14 11:32:28 +0200 | [diff] [blame^] | 3185 | radeon_scratch_free(rdev, scratch); |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3186 | return r; |
| 3187 | } |
| 3188 | ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1); |
| 3189 | ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START) >> 2); |
| 3190 | ib.ptr[2] = 0xDEADBEEF; |
| 3191 | ib.length_dw = 3; |
| 3192 | r = radeon_ib_schedule(rdev, &ib, NULL); |
| 3193 | if (r) { |
| 3194 | radeon_scratch_free(rdev, scratch); |
| 3195 | radeon_ib_free(rdev, &ib); |
| 3196 | DRM_ERROR("radeon: failed to schedule ib (%d).\n", r); |
| 3197 | return r; |
| 3198 | } |
| 3199 | r = radeon_fence_wait(ib.fence, false); |
| 3200 | if (r) { |
| 3201 | DRM_ERROR("radeon: fence wait failed (%d).\n", r); |
Christian König | 5510f12 | 2013-10-14 11:32:28 +0200 | [diff] [blame^] | 3202 | radeon_scratch_free(rdev, scratch); |
| 3203 | radeon_ib_free(rdev, &ib); |
Alex Deucher | fbc832c | 2012-07-20 14:41:35 -0400 | [diff] [blame] | 3204 | return r; |
| 3205 | } |
| 3206 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3207 | tmp = RREG32(scratch); |
| 3208 | if (tmp == 0xDEADBEEF) |
| 3209 | break; |
| 3210 | DRM_UDELAY(1); |
| 3211 | } |
| 3212 | if (i < rdev->usec_timeout) { |
| 3213 | DRM_INFO("ib test on ring %d succeeded in %u usecs\n", ib.fence->ring, i); |
| 3214 | } else { |
| 3215 | DRM_ERROR("radeon: ib test failed (scratch(0x%04X)=0x%08X)\n", |
| 3216 | scratch, tmp); |
| 3217 | r = -EINVAL; |
| 3218 | } |
| 3219 | radeon_scratch_free(rdev, scratch); |
| 3220 | radeon_ib_free(rdev, &ib); |
| 3221 | return r; |
| 3222 | } |
| 3223 | |
Alex Deucher | 2cae3bc | 2012-07-05 11:45:40 -0400 | [diff] [blame] | 3224 | /* |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3225 | * CP. |
| 3226 | * On CIK, gfx and compute now have independant command processors. |
| 3227 | * |
| 3228 | * GFX |
| 3229 | * Gfx consists of a single ring and can process both gfx jobs and |
| 3230 | * compute jobs. The gfx CP consists of three microengines (ME): |
| 3231 | * PFP - Pre-Fetch Parser |
| 3232 | * ME - Micro Engine |
| 3233 | * CE - Constant Engine |
| 3234 | * The PFP and ME make up what is considered the Drawing Engine (DE). |
| 3235 | * The CE is an asynchronous engine used for updating buffer desciptors |
| 3236 | * used by the DE so that they can be loaded into cache in parallel |
| 3237 | * while the DE is processing state update packets. |
| 3238 | * |
| 3239 | * Compute |
| 3240 | * The compute CP consists of two microengines (ME): |
| 3241 | * MEC1 - Compute MicroEngine 1 |
| 3242 | * MEC2 - Compute MicroEngine 2 |
| 3243 | * Each MEC supports 4 compute pipes and each pipe supports 8 queues. |
| 3244 | * The queues are exposed to userspace and are programmed directly |
| 3245 | * by the compute runtime. |
| 3246 | */ |
| 3247 | /** |
| 3248 | * cik_cp_gfx_enable - enable/disable the gfx CP MEs |
| 3249 | * |
| 3250 | * @rdev: radeon_device pointer |
| 3251 | * @enable: enable or disable the MEs |
| 3252 | * |
| 3253 | * Halts or unhalts the gfx MEs. |
| 3254 | */ |
| 3255 | static void cik_cp_gfx_enable(struct radeon_device *rdev, bool enable) |
| 3256 | { |
| 3257 | if (enable) |
| 3258 | WREG32(CP_ME_CNTL, 0); |
| 3259 | else { |
| 3260 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT)); |
| 3261 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; |
| 3262 | } |
| 3263 | udelay(50); |
| 3264 | } |
| 3265 | |
| 3266 | /** |
| 3267 | * cik_cp_gfx_load_microcode - load the gfx CP ME ucode |
| 3268 | * |
| 3269 | * @rdev: radeon_device pointer |
| 3270 | * |
| 3271 | * Loads the gfx PFP, ME, and CE ucode. |
| 3272 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 3273 | */ |
| 3274 | static int cik_cp_gfx_load_microcode(struct radeon_device *rdev) |
| 3275 | { |
| 3276 | const __be32 *fw_data; |
| 3277 | int i; |
| 3278 | |
| 3279 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw) |
| 3280 | return -EINVAL; |
| 3281 | |
| 3282 | cik_cp_gfx_enable(rdev, false); |
| 3283 | |
| 3284 | /* PFP */ |
| 3285 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 3286 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3287 | for (i = 0; i < CIK_PFP_UCODE_SIZE; i++) |
| 3288 | WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3289 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3290 | |
| 3291 | /* CE */ |
| 3292 | fw_data = (const __be32 *)rdev->ce_fw->data; |
| 3293 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3294 | for (i = 0; i < CIK_CE_UCODE_SIZE; i++) |
| 3295 | WREG32(CP_CE_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3296 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3297 | |
| 3298 | /* ME */ |
| 3299 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 3300 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3301 | for (i = 0; i < CIK_ME_UCODE_SIZE; i++) |
| 3302 | WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++)); |
| 3303 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3304 | |
| 3305 | WREG32(CP_PFP_UCODE_ADDR, 0); |
| 3306 | WREG32(CP_CE_UCODE_ADDR, 0); |
| 3307 | WREG32(CP_ME_RAM_WADDR, 0); |
| 3308 | WREG32(CP_ME_RAM_RADDR, 0); |
| 3309 | return 0; |
| 3310 | } |
| 3311 | |
| 3312 | /** |
| 3313 | * cik_cp_gfx_start - start the gfx ring |
| 3314 | * |
| 3315 | * @rdev: radeon_device pointer |
| 3316 | * |
| 3317 | * Enables the ring and loads the clear state context and other |
| 3318 | * packets required to init the ring. |
| 3319 | * Returns 0 for success, error for failure. |
| 3320 | */ |
| 3321 | static int cik_cp_gfx_start(struct radeon_device *rdev) |
| 3322 | { |
| 3323 | struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 3324 | int r, i; |
| 3325 | |
| 3326 | /* init the CP */ |
| 3327 | WREG32(CP_MAX_CONTEXT, rdev->config.cik.max_hw_contexts - 1); |
| 3328 | WREG32(CP_ENDIAN_SWAP, 0); |
| 3329 | WREG32(CP_DEVICE_ID, 1); |
| 3330 | |
| 3331 | cik_cp_gfx_enable(rdev, true); |
| 3332 | |
| 3333 | r = radeon_ring_lock(rdev, ring, cik_default_size + 17); |
| 3334 | if (r) { |
| 3335 | DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r); |
| 3336 | return r; |
| 3337 | } |
| 3338 | |
| 3339 | /* init the CE partitions. CE only used for gfx on CIK */ |
| 3340 | radeon_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2)); |
| 3341 | radeon_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE)); |
| 3342 | radeon_ring_write(ring, 0xc000); |
| 3343 | radeon_ring_write(ring, 0xc000); |
| 3344 | |
| 3345 | /* setup clear context state */ |
| 3346 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 3347 | radeon_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE); |
| 3348 | |
| 3349 | radeon_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1)); |
| 3350 | radeon_ring_write(ring, 0x80000000); |
| 3351 | radeon_ring_write(ring, 0x80000000); |
| 3352 | |
| 3353 | for (i = 0; i < cik_default_size; i++) |
| 3354 | radeon_ring_write(ring, cik_default_state[i]); |
| 3355 | |
| 3356 | radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); |
| 3357 | radeon_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE); |
| 3358 | |
| 3359 | /* set clear context state */ |
| 3360 | radeon_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0)); |
| 3361 | radeon_ring_write(ring, 0); |
| 3362 | |
| 3363 | radeon_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2)); |
| 3364 | radeon_ring_write(ring, 0x00000316); |
| 3365 | radeon_ring_write(ring, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */ |
| 3366 | radeon_ring_write(ring, 0x00000010); /* VGT_OUT_DEALLOC_CNTL */ |
| 3367 | |
| 3368 | radeon_ring_unlock_commit(rdev, ring); |
| 3369 | |
| 3370 | return 0; |
| 3371 | } |
| 3372 | |
| 3373 | /** |
| 3374 | * cik_cp_gfx_fini - stop the gfx ring |
| 3375 | * |
| 3376 | * @rdev: radeon_device pointer |
| 3377 | * |
| 3378 | * Stop the gfx ring and tear down the driver ring |
| 3379 | * info. |
| 3380 | */ |
| 3381 | static void cik_cp_gfx_fini(struct radeon_device *rdev) |
| 3382 | { |
| 3383 | cik_cp_gfx_enable(rdev, false); |
| 3384 | radeon_ring_fini(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]); |
| 3385 | } |
| 3386 | |
| 3387 | /** |
| 3388 | * cik_cp_gfx_resume - setup the gfx ring buffer registers |
| 3389 | * |
| 3390 | * @rdev: radeon_device pointer |
| 3391 | * |
| 3392 | * Program the location and size of the gfx ring buffer |
| 3393 | * and test it to make sure it's working. |
| 3394 | * Returns 0 for success, error for failure. |
| 3395 | */ |
| 3396 | static int cik_cp_gfx_resume(struct radeon_device *rdev) |
| 3397 | { |
| 3398 | struct radeon_ring *ring; |
| 3399 | u32 tmp; |
| 3400 | u32 rb_bufsz; |
| 3401 | u64 rb_addr; |
| 3402 | int r; |
| 3403 | |
| 3404 | WREG32(CP_SEM_WAIT_TIMER, 0x0); |
| 3405 | WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0); |
| 3406 | |
| 3407 | /* Set the write pointer delay */ |
| 3408 | WREG32(CP_RB_WPTR_DELAY, 0); |
| 3409 | |
| 3410 | /* set the RB to use vmid 0 */ |
| 3411 | WREG32(CP_RB_VMID, 0); |
| 3412 | |
| 3413 | WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF); |
| 3414 | |
| 3415 | /* ring 0 - compute and gfx */ |
| 3416 | /* Set ring buffer size */ |
| 3417 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3418 | rb_bufsz = order_base_2(ring->ring_size / 8); |
| 3419 | tmp = (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3420 | #ifdef __BIG_ENDIAN |
| 3421 | tmp |= BUF_SWAP_32BIT; |
| 3422 | #endif |
| 3423 | WREG32(CP_RB0_CNTL, tmp); |
| 3424 | |
| 3425 | /* Initialize the ring buffer's read and write pointers */ |
| 3426 | WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA); |
| 3427 | ring->wptr = 0; |
| 3428 | WREG32(CP_RB0_WPTR, ring->wptr); |
| 3429 | |
| 3430 | /* set the wb address wether it's enabled or not */ |
| 3431 | WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC); |
| 3432 | WREG32(CP_RB0_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF); |
| 3433 | |
| 3434 | /* scratch register shadowing is no longer supported */ |
| 3435 | WREG32(SCRATCH_UMSK, 0); |
| 3436 | |
| 3437 | if (!rdev->wb.enabled) |
| 3438 | tmp |= RB_NO_UPDATE; |
| 3439 | |
| 3440 | mdelay(1); |
| 3441 | WREG32(CP_RB0_CNTL, tmp); |
| 3442 | |
| 3443 | rb_addr = ring->gpu_addr >> 8; |
| 3444 | WREG32(CP_RB0_BASE, rb_addr); |
| 3445 | WREG32(CP_RB0_BASE_HI, upper_32_bits(rb_addr)); |
| 3446 | |
| 3447 | ring->rptr = RREG32(CP_RB0_RPTR); |
| 3448 | |
| 3449 | /* start the ring */ |
| 3450 | cik_cp_gfx_start(rdev); |
| 3451 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = true; |
| 3452 | r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]); |
| 3453 | if (r) { |
| 3454 | rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false; |
| 3455 | return r; |
| 3456 | } |
| 3457 | return 0; |
| 3458 | } |
| 3459 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3460 | u32 cik_compute_ring_get_rptr(struct radeon_device *rdev, |
| 3461 | struct radeon_ring *ring) |
| 3462 | { |
| 3463 | u32 rptr; |
| 3464 | |
| 3465 | |
| 3466 | |
| 3467 | if (rdev->wb.enabled) { |
| 3468 | rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]); |
| 3469 | } else { |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3470 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3471 | cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); |
| 3472 | rptr = RREG32(CP_HQD_PQ_RPTR); |
| 3473 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3474 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3475 | } |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3476 | |
| 3477 | return rptr; |
| 3478 | } |
| 3479 | |
| 3480 | u32 cik_compute_ring_get_wptr(struct radeon_device *rdev, |
| 3481 | struct radeon_ring *ring) |
| 3482 | { |
| 3483 | u32 wptr; |
| 3484 | |
| 3485 | if (rdev->wb.enabled) { |
| 3486 | wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]); |
| 3487 | } else { |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3488 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3489 | cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); |
| 3490 | wptr = RREG32(CP_HQD_PQ_WPTR); |
| 3491 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3492 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3493 | } |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3494 | |
| 3495 | return wptr; |
| 3496 | } |
| 3497 | |
| 3498 | void cik_compute_ring_set_wptr(struct radeon_device *rdev, |
| 3499 | struct radeon_ring *ring) |
| 3500 | { |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 3501 | rdev->wb.wb[ring->wptr_offs/4] = cpu_to_le32(ring->wptr); |
| 3502 | WDOORBELL32(ring->doorbell_offset, ring->wptr); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3503 | } |
| 3504 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3505 | /** |
| 3506 | * cik_cp_compute_enable - enable/disable the compute CP MEs |
| 3507 | * |
| 3508 | * @rdev: radeon_device pointer |
| 3509 | * @enable: enable or disable the MEs |
| 3510 | * |
| 3511 | * Halts or unhalts the compute MEs. |
| 3512 | */ |
| 3513 | static void cik_cp_compute_enable(struct radeon_device *rdev, bool enable) |
| 3514 | { |
| 3515 | if (enable) |
| 3516 | WREG32(CP_MEC_CNTL, 0); |
| 3517 | else |
| 3518 | WREG32(CP_MEC_CNTL, (MEC_ME1_HALT | MEC_ME2_HALT)); |
| 3519 | udelay(50); |
| 3520 | } |
| 3521 | |
| 3522 | /** |
| 3523 | * cik_cp_compute_load_microcode - load the compute CP ME ucode |
| 3524 | * |
| 3525 | * @rdev: radeon_device pointer |
| 3526 | * |
| 3527 | * Loads the compute MEC1&2 ucode. |
| 3528 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 3529 | */ |
| 3530 | static int cik_cp_compute_load_microcode(struct radeon_device *rdev) |
| 3531 | { |
| 3532 | const __be32 *fw_data; |
| 3533 | int i; |
| 3534 | |
| 3535 | if (!rdev->mec_fw) |
| 3536 | return -EINVAL; |
| 3537 | |
| 3538 | cik_cp_compute_enable(rdev, false); |
| 3539 | |
| 3540 | /* MEC1 */ |
| 3541 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 3542 | WREG32(CP_MEC_ME1_UCODE_ADDR, 0); |
| 3543 | for (i = 0; i < CIK_MEC_UCODE_SIZE; i++) |
| 3544 | WREG32(CP_MEC_ME1_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3545 | WREG32(CP_MEC_ME1_UCODE_ADDR, 0); |
| 3546 | |
| 3547 | if (rdev->family == CHIP_KAVERI) { |
| 3548 | /* MEC2 */ |
| 3549 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 3550 | WREG32(CP_MEC_ME2_UCODE_ADDR, 0); |
| 3551 | for (i = 0; i < CIK_MEC_UCODE_SIZE; i++) |
| 3552 | WREG32(CP_MEC_ME2_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 3553 | WREG32(CP_MEC_ME2_UCODE_ADDR, 0); |
| 3554 | } |
| 3555 | |
| 3556 | return 0; |
| 3557 | } |
| 3558 | |
| 3559 | /** |
| 3560 | * cik_cp_compute_start - start the compute queues |
| 3561 | * |
| 3562 | * @rdev: radeon_device pointer |
| 3563 | * |
| 3564 | * Enable the compute queues. |
| 3565 | * Returns 0 for success, error for failure. |
| 3566 | */ |
| 3567 | static int cik_cp_compute_start(struct radeon_device *rdev) |
| 3568 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3569 | cik_cp_compute_enable(rdev, true); |
| 3570 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3571 | return 0; |
| 3572 | } |
| 3573 | |
| 3574 | /** |
| 3575 | * cik_cp_compute_fini - stop the compute queues |
| 3576 | * |
| 3577 | * @rdev: radeon_device pointer |
| 3578 | * |
| 3579 | * Stop the compute queues and tear down the driver queue |
| 3580 | * info. |
| 3581 | */ |
| 3582 | static void cik_cp_compute_fini(struct radeon_device *rdev) |
| 3583 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3584 | int i, idx, r; |
| 3585 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3586 | cik_cp_compute_enable(rdev, false); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3587 | |
| 3588 | for (i = 0; i < 2; i++) { |
| 3589 | if (i == 0) |
| 3590 | idx = CAYMAN_RING_TYPE_CP1_INDEX; |
| 3591 | else |
| 3592 | idx = CAYMAN_RING_TYPE_CP2_INDEX; |
| 3593 | |
| 3594 | if (rdev->ring[idx].mqd_obj) { |
| 3595 | r = radeon_bo_reserve(rdev->ring[idx].mqd_obj, false); |
| 3596 | if (unlikely(r != 0)) |
| 3597 | dev_warn(rdev->dev, "(%d) reserve MQD bo failed\n", r); |
| 3598 | |
| 3599 | radeon_bo_unpin(rdev->ring[idx].mqd_obj); |
| 3600 | radeon_bo_unreserve(rdev->ring[idx].mqd_obj); |
| 3601 | |
| 3602 | radeon_bo_unref(&rdev->ring[idx].mqd_obj); |
| 3603 | rdev->ring[idx].mqd_obj = NULL; |
| 3604 | } |
| 3605 | } |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3606 | } |
| 3607 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3608 | static void cik_mec_fini(struct radeon_device *rdev) |
| 3609 | { |
| 3610 | int r; |
| 3611 | |
| 3612 | if (rdev->mec.hpd_eop_obj) { |
| 3613 | r = radeon_bo_reserve(rdev->mec.hpd_eop_obj, false); |
| 3614 | if (unlikely(r != 0)) |
| 3615 | dev_warn(rdev->dev, "(%d) reserve HPD EOP bo failed\n", r); |
| 3616 | radeon_bo_unpin(rdev->mec.hpd_eop_obj); |
| 3617 | radeon_bo_unreserve(rdev->mec.hpd_eop_obj); |
| 3618 | |
| 3619 | radeon_bo_unref(&rdev->mec.hpd_eop_obj); |
| 3620 | rdev->mec.hpd_eop_obj = NULL; |
| 3621 | } |
| 3622 | } |
| 3623 | |
| 3624 | #define MEC_HPD_SIZE 2048 |
| 3625 | |
| 3626 | static int cik_mec_init(struct radeon_device *rdev) |
| 3627 | { |
| 3628 | int r; |
| 3629 | u32 *hpd; |
| 3630 | |
| 3631 | /* |
| 3632 | * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total |
| 3633 | * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total |
| 3634 | */ |
| 3635 | if (rdev->family == CHIP_KAVERI) |
| 3636 | rdev->mec.num_mec = 2; |
| 3637 | else |
| 3638 | rdev->mec.num_mec = 1; |
| 3639 | rdev->mec.num_pipe = 4; |
| 3640 | rdev->mec.num_queue = rdev->mec.num_mec * rdev->mec.num_pipe * 8; |
| 3641 | |
| 3642 | if (rdev->mec.hpd_eop_obj == NULL) { |
| 3643 | r = radeon_bo_create(rdev, |
| 3644 | rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2, |
| 3645 | PAGE_SIZE, true, |
| 3646 | RADEON_GEM_DOMAIN_GTT, NULL, |
| 3647 | &rdev->mec.hpd_eop_obj); |
| 3648 | if (r) { |
| 3649 | dev_warn(rdev->dev, "(%d) create HDP EOP bo failed\n", r); |
| 3650 | return r; |
| 3651 | } |
| 3652 | } |
| 3653 | |
| 3654 | r = radeon_bo_reserve(rdev->mec.hpd_eop_obj, false); |
| 3655 | if (unlikely(r != 0)) { |
| 3656 | cik_mec_fini(rdev); |
| 3657 | return r; |
| 3658 | } |
| 3659 | r = radeon_bo_pin(rdev->mec.hpd_eop_obj, RADEON_GEM_DOMAIN_GTT, |
| 3660 | &rdev->mec.hpd_eop_gpu_addr); |
| 3661 | if (r) { |
| 3662 | dev_warn(rdev->dev, "(%d) pin HDP EOP bo failed\n", r); |
| 3663 | cik_mec_fini(rdev); |
| 3664 | return r; |
| 3665 | } |
| 3666 | r = radeon_bo_kmap(rdev->mec.hpd_eop_obj, (void **)&hpd); |
| 3667 | if (r) { |
| 3668 | dev_warn(rdev->dev, "(%d) map HDP EOP bo failed\n", r); |
| 3669 | cik_mec_fini(rdev); |
| 3670 | return r; |
| 3671 | } |
| 3672 | |
| 3673 | /* clear memory. Not sure if this is required or not */ |
| 3674 | memset(hpd, 0, rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2); |
| 3675 | |
| 3676 | radeon_bo_kunmap(rdev->mec.hpd_eop_obj); |
| 3677 | radeon_bo_unreserve(rdev->mec.hpd_eop_obj); |
| 3678 | |
| 3679 | return 0; |
| 3680 | } |
| 3681 | |
| 3682 | struct hqd_registers |
| 3683 | { |
| 3684 | u32 cp_mqd_base_addr; |
| 3685 | u32 cp_mqd_base_addr_hi; |
| 3686 | u32 cp_hqd_active; |
| 3687 | u32 cp_hqd_vmid; |
| 3688 | u32 cp_hqd_persistent_state; |
| 3689 | u32 cp_hqd_pipe_priority; |
| 3690 | u32 cp_hqd_queue_priority; |
| 3691 | u32 cp_hqd_quantum; |
| 3692 | u32 cp_hqd_pq_base; |
| 3693 | u32 cp_hqd_pq_base_hi; |
| 3694 | u32 cp_hqd_pq_rptr; |
| 3695 | u32 cp_hqd_pq_rptr_report_addr; |
| 3696 | u32 cp_hqd_pq_rptr_report_addr_hi; |
| 3697 | u32 cp_hqd_pq_wptr_poll_addr; |
| 3698 | u32 cp_hqd_pq_wptr_poll_addr_hi; |
| 3699 | u32 cp_hqd_pq_doorbell_control; |
| 3700 | u32 cp_hqd_pq_wptr; |
| 3701 | u32 cp_hqd_pq_control; |
| 3702 | u32 cp_hqd_ib_base_addr; |
| 3703 | u32 cp_hqd_ib_base_addr_hi; |
| 3704 | u32 cp_hqd_ib_rptr; |
| 3705 | u32 cp_hqd_ib_control; |
| 3706 | u32 cp_hqd_iq_timer; |
| 3707 | u32 cp_hqd_iq_rptr; |
| 3708 | u32 cp_hqd_dequeue_request; |
| 3709 | u32 cp_hqd_dma_offload; |
| 3710 | u32 cp_hqd_sema_cmd; |
| 3711 | u32 cp_hqd_msg_type; |
| 3712 | u32 cp_hqd_atomic0_preop_lo; |
| 3713 | u32 cp_hqd_atomic0_preop_hi; |
| 3714 | u32 cp_hqd_atomic1_preop_lo; |
| 3715 | u32 cp_hqd_atomic1_preop_hi; |
| 3716 | u32 cp_hqd_hq_scheduler0; |
| 3717 | u32 cp_hqd_hq_scheduler1; |
| 3718 | u32 cp_mqd_control; |
| 3719 | }; |
| 3720 | |
| 3721 | struct bonaire_mqd |
| 3722 | { |
| 3723 | u32 header; |
| 3724 | u32 dispatch_initiator; |
| 3725 | u32 dimensions[3]; |
| 3726 | u32 start_idx[3]; |
| 3727 | u32 num_threads[3]; |
| 3728 | u32 pipeline_stat_enable; |
| 3729 | u32 perf_counter_enable; |
| 3730 | u32 pgm[2]; |
| 3731 | u32 tba[2]; |
| 3732 | u32 tma[2]; |
| 3733 | u32 pgm_rsrc[2]; |
| 3734 | u32 vmid; |
| 3735 | u32 resource_limits; |
| 3736 | u32 static_thread_mgmt01[2]; |
| 3737 | u32 tmp_ring_size; |
| 3738 | u32 static_thread_mgmt23[2]; |
| 3739 | u32 restart[3]; |
| 3740 | u32 thread_trace_enable; |
| 3741 | u32 reserved1; |
| 3742 | u32 user_data[16]; |
| 3743 | u32 vgtcs_invoke_count[2]; |
| 3744 | struct hqd_registers queue_state; |
| 3745 | u32 dequeue_cntr; |
| 3746 | u32 interrupt_queue[64]; |
| 3747 | }; |
| 3748 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3749 | /** |
| 3750 | * cik_cp_compute_resume - setup the compute queue registers |
| 3751 | * |
| 3752 | * @rdev: radeon_device pointer |
| 3753 | * |
| 3754 | * Program the compute queues and test them to make sure they |
| 3755 | * are working. |
| 3756 | * Returns 0 for success, error for failure. |
| 3757 | */ |
| 3758 | static int cik_cp_compute_resume(struct radeon_device *rdev) |
| 3759 | { |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3760 | int r, i, idx; |
| 3761 | u32 tmp; |
| 3762 | bool use_doorbell = true; |
| 3763 | u64 hqd_gpu_addr; |
| 3764 | u64 mqd_gpu_addr; |
| 3765 | u64 eop_gpu_addr; |
| 3766 | u64 wb_gpu_addr; |
| 3767 | u32 *buf; |
| 3768 | struct bonaire_mqd *mqd; |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3769 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3770 | r = cik_cp_compute_start(rdev); |
| 3771 | if (r) |
| 3772 | return r; |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3773 | |
| 3774 | /* fix up chicken bits */ |
| 3775 | tmp = RREG32(CP_CPF_DEBUG); |
| 3776 | tmp |= (1 << 23); |
| 3777 | WREG32(CP_CPF_DEBUG, tmp); |
| 3778 | |
| 3779 | /* init the pipes */ |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3780 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3781 | for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) { |
| 3782 | int me = (i < 4) ? 1 : 2; |
| 3783 | int pipe = (i < 4) ? i : (i - 4); |
| 3784 | |
| 3785 | eop_gpu_addr = rdev->mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE * 2); |
| 3786 | |
| 3787 | cik_srbm_select(rdev, me, pipe, 0, 0); |
| 3788 | |
| 3789 | /* write the EOP addr */ |
| 3790 | WREG32(CP_HPD_EOP_BASE_ADDR, eop_gpu_addr >> 8); |
| 3791 | WREG32(CP_HPD_EOP_BASE_ADDR_HI, upper_32_bits(eop_gpu_addr) >> 8); |
| 3792 | |
| 3793 | /* set the VMID assigned */ |
| 3794 | WREG32(CP_HPD_EOP_VMID, 0); |
| 3795 | |
| 3796 | /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */ |
| 3797 | tmp = RREG32(CP_HPD_EOP_CONTROL); |
| 3798 | tmp &= ~EOP_SIZE_MASK; |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3799 | tmp |= order_base_2(MEC_HPD_SIZE / 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3800 | WREG32(CP_HPD_EOP_CONTROL, tmp); |
| 3801 | } |
| 3802 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3803 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3804 | |
| 3805 | /* init the queues. Just two for now. */ |
| 3806 | for (i = 0; i < 2; i++) { |
| 3807 | if (i == 0) |
| 3808 | idx = CAYMAN_RING_TYPE_CP1_INDEX; |
| 3809 | else |
| 3810 | idx = CAYMAN_RING_TYPE_CP2_INDEX; |
| 3811 | |
| 3812 | if (rdev->ring[idx].mqd_obj == NULL) { |
| 3813 | r = radeon_bo_create(rdev, |
| 3814 | sizeof(struct bonaire_mqd), |
| 3815 | PAGE_SIZE, true, |
| 3816 | RADEON_GEM_DOMAIN_GTT, NULL, |
| 3817 | &rdev->ring[idx].mqd_obj); |
| 3818 | if (r) { |
| 3819 | dev_warn(rdev->dev, "(%d) create MQD bo failed\n", r); |
| 3820 | return r; |
| 3821 | } |
| 3822 | } |
| 3823 | |
| 3824 | r = radeon_bo_reserve(rdev->ring[idx].mqd_obj, false); |
| 3825 | if (unlikely(r != 0)) { |
| 3826 | cik_cp_compute_fini(rdev); |
| 3827 | return r; |
| 3828 | } |
| 3829 | r = radeon_bo_pin(rdev->ring[idx].mqd_obj, RADEON_GEM_DOMAIN_GTT, |
| 3830 | &mqd_gpu_addr); |
| 3831 | if (r) { |
| 3832 | dev_warn(rdev->dev, "(%d) pin MQD bo failed\n", r); |
| 3833 | cik_cp_compute_fini(rdev); |
| 3834 | return r; |
| 3835 | } |
| 3836 | r = radeon_bo_kmap(rdev->ring[idx].mqd_obj, (void **)&buf); |
| 3837 | if (r) { |
| 3838 | dev_warn(rdev->dev, "(%d) map MQD bo failed\n", r); |
| 3839 | cik_cp_compute_fini(rdev); |
| 3840 | return r; |
| 3841 | } |
| 3842 | |
| 3843 | /* doorbell offset */ |
| 3844 | rdev->ring[idx].doorbell_offset = |
| 3845 | (rdev->ring[idx].doorbell_page_num * PAGE_SIZE) + 0; |
| 3846 | |
| 3847 | /* init the mqd struct */ |
| 3848 | memset(buf, 0, sizeof(struct bonaire_mqd)); |
| 3849 | |
| 3850 | mqd = (struct bonaire_mqd *)buf; |
| 3851 | mqd->header = 0xC0310800; |
| 3852 | mqd->static_thread_mgmt01[0] = 0xffffffff; |
| 3853 | mqd->static_thread_mgmt01[1] = 0xffffffff; |
| 3854 | mqd->static_thread_mgmt23[0] = 0xffffffff; |
| 3855 | mqd->static_thread_mgmt23[1] = 0xffffffff; |
| 3856 | |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3857 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3858 | cik_srbm_select(rdev, rdev->ring[idx].me, |
| 3859 | rdev->ring[idx].pipe, |
| 3860 | rdev->ring[idx].queue, 0); |
| 3861 | |
| 3862 | /* disable wptr polling */ |
| 3863 | tmp = RREG32(CP_PQ_WPTR_POLL_CNTL); |
| 3864 | tmp &= ~WPTR_POLL_EN; |
| 3865 | WREG32(CP_PQ_WPTR_POLL_CNTL, tmp); |
| 3866 | |
| 3867 | /* enable doorbell? */ |
| 3868 | mqd->queue_state.cp_hqd_pq_doorbell_control = |
| 3869 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); |
| 3870 | if (use_doorbell) |
| 3871 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; |
| 3872 | else |
| 3873 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_EN; |
| 3874 | WREG32(CP_HQD_PQ_DOORBELL_CONTROL, |
| 3875 | mqd->queue_state.cp_hqd_pq_doorbell_control); |
| 3876 | |
| 3877 | /* disable the queue if it's active */ |
| 3878 | mqd->queue_state.cp_hqd_dequeue_request = 0; |
| 3879 | mqd->queue_state.cp_hqd_pq_rptr = 0; |
| 3880 | mqd->queue_state.cp_hqd_pq_wptr= 0; |
| 3881 | if (RREG32(CP_HQD_ACTIVE) & 1) { |
| 3882 | WREG32(CP_HQD_DEQUEUE_REQUEST, 1); |
| 3883 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 3884 | if (!(RREG32(CP_HQD_ACTIVE) & 1)) |
| 3885 | break; |
| 3886 | udelay(1); |
| 3887 | } |
| 3888 | WREG32(CP_HQD_DEQUEUE_REQUEST, mqd->queue_state.cp_hqd_dequeue_request); |
| 3889 | WREG32(CP_HQD_PQ_RPTR, mqd->queue_state.cp_hqd_pq_rptr); |
| 3890 | WREG32(CP_HQD_PQ_WPTR, mqd->queue_state.cp_hqd_pq_wptr); |
| 3891 | } |
| 3892 | |
| 3893 | /* set the pointer to the MQD */ |
| 3894 | mqd->queue_state.cp_mqd_base_addr = mqd_gpu_addr & 0xfffffffc; |
| 3895 | mqd->queue_state.cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr); |
| 3896 | WREG32(CP_MQD_BASE_ADDR, mqd->queue_state.cp_mqd_base_addr); |
| 3897 | WREG32(CP_MQD_BASE_ADDR_HI, mqd->queue_state.cp_mqd_base_addr_hi); |
| 3898 | /* set MQD vmid to 0 */ |
| 3899 | mqd->queue_state.cp_mqd_control = RREG32(CP_MQD_CONTROL); |
| 3900 | mqd->queue_state.cp_mqd_control &= ~MQD_VMID_MASK; |
| 3901 | WREG32(CP_MQD_CONTROL, mqd->queue_state.cp_mqd_control); |
| 3902 | |
| 3903 | /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */ |
| 3904 | hqd_gpu_addr = rdev->ring[idx].gpu_addr >> 8; |
| 3905 | mqd->queue_state.cp_hqd_pq_base = hqd_gpu_addr; |
| 3906 | mqd->queue_state.cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr); |
| 3907 | WREG32(CP_HQD_PQ_BASE, mqd->queue_state.cp_hqd_pq_base); |
| 3908 | WREG32(CP_HQD_PQ_BASE_HI, mqd->queue_state.cp_hqd_pq_base_hi); |
| 3909 | |
| 3910 | /* set up the HQD, this is similar to CP_RB0_CNTL */ |
| 3911 | mqd->queue_state.cp_hqd_pq_control = RREG32(CP_HQD_PQ_CONTROL); |
| 3912 | mqd->queue_state.cp_hqd_pq_control &= |
| 3913 | ~(QUEUE_SIZE_MASK | RPTR_BLOCK_SIZE_MASK); |
| 3914 | |
| 3915 | mqd->queue_state.cp_hqd_pq_control |= |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3916 | order_base_2(rdev->ring[idx].ring_size / 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3917 | mqd->queue_state.cp_hqd_pq_control |= |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 3918 | (order_base_2(RADEON_GPU_PAGE_SIZE/8) << 8); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3919 | #ifdef __BIG_ENDIAN |
| 3920 | mqd->queue_state.cp_hqd_pq_control |= BUF_SWAP_32BIT; |
| 3921 | #endif |
| 3922 | mqd->queue_state.cp_hqd_pq_control &= |
| 3923 | ~(UNORD_DISPATCH | ROQ_PQ_IB_FLIP | PQ_VOLATILE); |
| 3924 | mqd->queue_state.cp_hqd_pq_control |= |
| 3925 | PRIV_STATE | KMD_QUEUE; /* assuming kernel queue control */ |
| 3926 | WREG32(CP_HQD_PQ_CONTROL, mqd->queue_state.cp_hqd_pq_control); |
| 3927 | |
| 3928 | /* only used if CP_PQ_WPTR_POLL_CNTL.WPTR_POLL_EN=1 */ |
| 3929 | if (i == 0) |
| 3930 | wb_gpu_addr = rdev->wb.gpu_addr + CIK_WB_CP1_WPTR_OFFSET; |
| 3931 | else |
| 3932 | wb_gpu_addr = rdev->wb.gpu_addr + CIK_WB_CP2_WPTR_OFFSET; |
| 3933 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr = wb_gpu_addr & 0xfffffffc; |
| 3934 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff; |
| 3935 | WREG32(CP_HQD_PQ_WPTR_POLL_ADDR, mqd->queue_state.cp_hqd_pq_wptr_poll_addr); |
| 3936 | WREG32(CP_HQD_PQ_WPTR_POLL_ADDR_HI, |
| 3937 | mqd->queue_state.cp_hqd_pq_wptr_poll_addr_hi); |
| 3938 | |
| 3939 | /* set the wb address wether it's enabled or not */ |
| 3940 | if (i == 0) |
| 3941 | wb_gpu_addr = rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET; |
| 3942 | else |
| 3943 | wb_gpu_addr = rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET; |
| 3944 | mqd->queue_state.cp_hqd_pq_rptr_report_addr = wb_gpu_addr & 0xfffffffc; |
| 3945 | mqd->queue_state.cp_hqd_pq_rptr_report_addr_hi = |
| 3946 | upper_32_bits(wb_gpu_addr) & 0xffff; |
| 3947 | WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR, |
| 3948 | mqd->queue_state.cp_hqd_pq_rptr_report_addr); |
| 3949 | WREG32(CP_HQD_PQ_RPTR_REPORT_ADDR_HI, |
| 3950 | mqd->queue_state.cp_hqd_pq_rptr_report_addr_hi); |
| 3951 | |
| 3952 | /* enable the doorbell if requested */ |
| 3953 | if (use_doorbell) { |
| 3954 | mqd->queue_state.cp_hqd_pq_doorbell_control = |
| 3955 | RREG32(CP_HQD_PQ_DOORBELL_CONTROL); |
| 3956 | mqd->queue_state.cp_hqd_pq_doorbell_control &= ~DOORBELL_OFFSET_MASK; |
| 3957 | mqd->queue_state.cp_hqd_pq_doorbell_control |= |
| 3958 | DOORBELL_OFFSET(rdev->ring[idx].doorbell_offset / 4); |
| 3959 | mqd->queue_state.cp_hqd_pq_doorbell_control |= DOORBELL_EN; |
| 3960 | mqd->queue_state.cp_hqd_pq_doorbell_control &= |
| 3961 | ~(DOORBELL_SOURCE | DOORBELL_HIT); |
| 3962 | |
| 3963 | } else { |
| 3964 | mqd->queue_state.cp_hqd_pq_doorbell_control = 0; |
| 3965 | } |
| 3966 | WREG32(CP_HQD_PQ_DOORBELL_CONTROL, |
| 3967 | mqd->queue_state.cp_hqd_pq_doorbell_control); |
| 3968 | |
| 3969 | /* read and write pointers, similar to CP_RB0_WPTR/_RPTR */ |
| 3970 | rdev->ring[idx].wptr = 0; |
| 3971 | mqd->queue_state.cp_hqd_pq_wptr = rdev->ring[idx].wptr; |
| 3972 | WREG32(CP_HQD_PQ_WPTR, mqd->queue_state.cp_hqd_pq_wptr); |
| 3973 | rdev->ring[idx].rptr = RREG32(CP_HQD_PQ_RPTR); |
| 3974 | mqd->queue_state.cp_hqd_pq_rptr = rdev->ring[idx].rptr; |
| 3975 | |
| 3976 | /* set the vmid for the queue */ |
| 3977 | mqd->queue_state.cp_hqd_vmid = 0; |
| 3978 | WREG32(CP_HQD_VMID, mqd->queue_state.cp_hqd_vmid); |
| 3979 | |
| 3980 | /* activate the queue */ |
| 3981 | mqd->queue_state.cp_hqd_active = 1; |
| 3982 | WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active); |
| 3983 | |
| 3984 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 3985 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 3986 | |
| 3987 | radeon_bo_kunmap(rdev->ring[idx].mqd_obj); |
| 3988 | radeon_bo_unreserve(rdev->ring[idx].mqd_obj); |
| 3989 | |
| 3990 | rdev->ring[idx].ready = true; |
| 3991 | r = radeon_ring_test(rdev, idx, &rdev->ring[idx]); |
| 3992 | if (r) |
| 3993 | rdev->ring[idx].ready = false; |
| 3994 | } |
| 3995 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3996 | return 0; |
| 3997 | } |
| 3998 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 3999 | static void cik_cp_enable(struct radeon_device *rdev, bool enable) |
| 4000 | { |
| 4001 | cik_cp_gfx_enable(rdev, enable); |
| 4002 | cik_cp_compute_enable(rdev, enable); |
| 4003 | } |
| 4004 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4005 | static int cik_cp_load_microcode(struct radeon_device *rdev) |
| 4006 | { |
| 4007 | int r; |
| 4008 | |
| 4009 | r = cik_cp_gfx_load_microcode(rdev); |
| 4010 | if (r) |
| 4011 | return r; |
| 4012 | r = cik_cp_compute_load_microcode(rdev); |
| 4013 | if (r) |
| 4014 | return r; |
| 4015 | |
| 4016 | return 0; |
| 4017 | } |
| 4018 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4019 | static void cik_cp_fini(struct radeon_device *rdev) |
| 4020 | { |
| 4021 | cik_cp_gfx_fini(rdev); |
| 4022 | cik_cp_compute_fini(rdev); |
| 4023 | } |
| 4024 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4025 | static int cik_cp_resume(struct radeon_device *rdev) |
| 4026 | { |
| 4027 | int r; |
| 4028 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 4029 | cik_enable_gui_idle_interrupt(rdev, false); |
| 4030 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4031 | r = cik_cp_load_microcode(rdev); |
| 4032 | if (r) |
| 4033 | return r; |
| 4034 | |
| 4035 | r = cik_cp_gfx_resume(rdev); |
| 4036 | if (r) |
| 4037 | return r; |
| 4038 | r = cik_cp_compute_resume(rdev); |
| 4039 | if (r) |
| 4040 | return r; |
| 4041 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 4042 | cik_enable_gui_idle_interrupt(rdev, true); |
| 4043 | |
Alex Deucher | 841cf44 | 2012-12-18 21:47:44 -0500 | [diff] [blame] | 4044 | return 0; |
| 4045 | } |
| 4046 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4047 | static void cik_print_gpu_status_regs(struct radeon_device *rdev) |
| 4048 | { |
| 4049 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", |
| 4050 | RREG32(GRBM_STATUS)); |
| 4051 | dev_info(rdev->dev, " GRBM_STATUS2=0x%08X\n", |
| 4052 | RREG32(GRBM_STATUS2)); |
| 4053 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", |
| 4054 | RREG32(GRBM_STATUS_SE0)); |
| 4055 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", |
| 4056 | RREG32(GRBM_STATUS_SE1)); |
| 4057 | dev_info(rdev->dev, " GRBM_STATUS_SE2=0x%08X\n", |
| 4058 | RREG32(GRBM_STATUS_SE2)); |
| 4059 | dev_info(rdev->dev, " GRBM_STATUS_SE3=0x%08X\n", |
| 4060 | RREG32(GRBM_STATUS_SE3)); |
| 4061 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", |
| 4062 | RREG32(SRBM_STATUS)); |
| 4063 | dev_info(rdev->dev, " SRBM_STATUS2=0x%08X\n", |
| 4064 | RREG32(SRBM_STATUS2)); |
| 4065 | dev_info(rdev->dev, " SDMA0_STATUS_REG = 0x%08X\n", |
| 4066 | RREG32(SDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET)); |
| 4067 | dev_info(rdev->dev, " SDMA1_STATUS_REG = 0x%08X\n", |
| 4068 | RREG32(SDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 4069 | dev_info(rdev->dev, " CP_STAT = 0x%08x\n", RREG32(CP_STAT)); |
| 4070 | dev_info(rdev->dev, " CP_STALLED_STAT1 = 0x%08x\n", |
| 4071 | RREG32(CP_STALLED_STAT1)); |
| 4072 | dev_info(rdev->dev, " CP_STALLED_STAT2 = 0x%08x\n", |
| 4073 | RREG32(CP_STALLED_STAT2)); |
| 4074 | dev_info(rdev->dev, " CP_STALLED_STAT3 = 0x%08x\n", |
| 4075 | RREG32(CP_STALLED_STAT3)); |
| 4076 | dev_info(rdev->dev, " CP_CPF_BUSY_STAT = 0x%08x\n", |
| 4077 | RREG32(CP_CPF_BUSY_STAT)); |
| 4078 | dev_info(rdev->dev, " CP_CPF_STALLED_STAT1 = 0x%08x\n", |
| 4079 | RREG32(CP_CPF_STALLED_STAT1)); |
| 4080 | dev_info(rdev->dev, " CP_CPF_STATUS = 0x%08x\n", RREG32(CP_CPF_STATUS)); |
| 4081 | dev_info(rdev->dev, " CP_CPC_BUSY_STAT = 0x%08x\n", RREG32(CP_CPC_BUSY_STAT)); |
| 4082 | dev_info(rdev->dev, " CP_CPC_STALLED_STAT1 = 0x%08x\n", |
| 4083 | RREG32(CP_CPC_STALLED_STAT1)); |
| 4084 | dev_info(rdev->dev, " CP_CPC_STATUS = 0x%08x\n", RREG32(CP_CPC_STATUS)); |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4085 | } |
| 4086 | |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4087 | /** |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4088 | * cik_gpu_check_soft_reset - check which blocks are busy |
| 4089 | * |
| 4090 | * @rdev: radeon_device pointer |
| 4091 | * |
| 4092 | * Check which blocks are busy and return the relevant reset |
| 4093 | * mask to be used by cik_gpu_soft_reset(). |
| 4094 | * Returns a mask of the blocks to be reset. |
| 4095 | */ |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 4096 | u32 cik_gpu_check_soft_reset(struct radeon_device *rdev) |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4097 | { |
| 4098 | u32 reset_mask = 0; |
| 4099 | u32 tmp; |
| 4100 | |
| 4101 | /* GRBM_STATUS */ |
| 4102 | tmp = RREG32(GRBM_STATUS); |
| 4103 | if (tmp & (PA_BUSY | SC_BUSY | |
| 4104 | BCI_BUSY | SX_BUSY | |
| 4105 | TA_BUSY | VGT_BUSY | |
| 4106 | DB_BUSY | CB_BUSY | |
| 4107 | GDS_BUSY | SPI_BUSY | |
| 4108 | IA_BUSY | IA_BUSY_NO_DMA)) |
| 4109 | reset_mask |= RADEON_RESET_GFX; |
| 4110 | |
| 4111 | if (tmp & (CP_BUSY | CP_COHERENCY_BUSY)) |
| 4112 | reset_mask |= RADEON_RESET_CP; |
| 4113 | |
| 4114 | /* GRBM_STATUS2 */ |
| 4115 | tmp = RREG32(GRBM_STATUS2); |
| 4116 | if (tmp & RLC_BUSY) |
| 4117 | reset_mask |= RADEON_RESET_RLC; |
| 4118 | |
| 4119 | /* SDMA0_STATUS_REG */ |
| 4120 | tmp = RREG32(SDMA0_STATUS_REG + SDMA0_REGISTER_OFFSET); |
| 4121 | if (!(tmp & SDMA_IDLE)) |
| 4122 | reset_mask |= RADEON_RESET_DMA; |
| 4123 | |
| 4124 | /* SDMA1_STATUS_REG */ |
| 4125 | tmp = RREG32(SDMA0_STATUS_REG + SDMA1_REGISTER_OFFSET); |
| 4126 | if (!(tmp & SDMA_IDLE)) |
| 4127 | reset_mask |= RADEON_RESET_DMA1; |
| 4128 | |
| 4129 | /* SRBM_STATUS2 */ |
| 4130 | tmp = RREG32(SRBM_STATUS2); |
| 4131 | if (tmp & SDMA_BUSY) |
| 4132 | reset_mask |= RADEON_RESET_DMA; |
| 4133 | |
| 4134 | if (tmp & SDMA1_BUSY) |
| 4135 | reset_mask |= RADEON_RESET_DMA1; |
| 4136 | |
| 4137 | /* SRBM_STATUS */ |
| 4138 | tmp = RREG32(SRBM_STATUS); |
| 4139 | |
| 4140 | if (tmp & IH_BUSY) |
| 4141 | reset_mask |= RADEON_RESET_IH; |
| 4142 | |
| 4143 | if (tmp & SEM_BUSY) |
| 4144 | reset_mask |= RADEON_RESET_SEM; |
| 4145 | |
| 4146 | if (tmp & GRBM_RQ_PENDING) |
| 4147 | reset_mask |= RADEON_RESET_GRBM; |
| 4148 | |
| 4149 | if (tmp & VMC_BUSY) |
| 4150 | reset_mask |= RADEON_RESET_VMC; |
| 4151 | |
| 4152 | if (tmp & (MCB_BUSY | MCB_NON_DISPLAY_BUSY | |
| 4153 | MCC_BUSY | MCD_BUSY)) |
| 4154 | reset_mask |= RADEON_RESET_MC; |
| 4155 | |
| 4156 | if (evergreen_is_display_hung(rdev)) |
| 4157 | reset_mask |= RADEON_RESET_DISPLAY; |
| 4158 | |
| 4159 | /* Skip MC reset as it's mostly likely not hung, just busy */ |
| 4160 | if (reset_mask & RADEON_RESET_MC) { |
| 4161 | DRM_DEBUG("MC busy: 0x%08X, clearing.\n", reset_mask); |
| 4162 | reset_mask &= ~RADEON_RESET_MC; |
| 4163 | } |
| 4164 | |
| 4165 | return reset_mask; |
| 4166 | } |
| 4167 | |
| 4168 | /** |
| 4169 | * cik_gpu_soft_reset - soft reset GPU |
| 4170 | * |
| 4171 | * @rdev: radeon_device pointer |
| 4172 | * @reset_mask: mask of which blocks to reset |
| 4173 | * |
| 4174 | * Soft reset the blocks specified in @reset_mask. |
| 4175 | */ |
| 4176 | static void cik_gpu_soft_reset(struct radeon_device *rdev, u32 reset_mask) |
| 4177 | { |
| 4178 | struct evergreen_mc_save save; |
| 4179 | u32 grbm_soft_reset = 0, srbm_soft_reset = 0; |
| 4180 | u32 tmp; |
| 4181 | |
| 4182 | if (reset_mask == 0) |
| 4183 | return; |
| 4184 | |
| 4185 | dev_info(rdev->dev, "GPU softreset: 0x%08X\n", reset_mask); |
| 4186 | |
| 4187 | cik_print_gpu_status_regs(rdev); |
| 4188 | dev_info(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
| 4189 | RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR)); |
| 4190 | dev_info(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
| 4191 | RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS)); |
| 4192 | |
Alex Deucher | fb2c7f4 | 2013-10-02 14:54:44 -0400 | [diff] [blame] | 4193 | /* disable CG/PG */ |
| 4194 | cik_fini_pg(rdev); |
| 4195 | cik_fini_cg(rdev); |
| 4196 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4197 | /* stop the rlc */ |
| 4198 | cik_rlc_stop(rdev); |
| 4199 | |
| 4200 | /* Disable GFX parsing/prefetching */ |
| 4201 | WREG32(CP_ME_CNTL, CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT); |
| 4202 | |
| 4203 | /* Disable MEC parsing/prefetching */ |
| 4204 | WREG32(CP_MEC_CNTL, MEC_ME1_HALT | MEC_ME2_HALT); |
| 4205 | |
| 4206 | if (reset_mask & RADEON_RESET_DMA) { |
| 4207 | /* sdma0 */ |
| 4208 | tmp = RREG32(SDMA0_ME_CNTL + SDMA0_REGISTER_OFFSET); |
| 4209 | tmp |= SDMA_HALT; |
| 4210 | WREG32(SDMA0_ME_CNTL + SDMA0_REGISTER_OFFSET, tmp); |
| 4211 | } |
| 4212 | if (reset_mask & RADEON_RESET_DMA1) { |
| 4213 | /* sdma1 */ |
| 4214 | tmp = RREG32(SDMA0_ME_CNTL + SDMA1_REGISTER_OFFSET); |
| 4215 | tmp |= SDMA_HALT; |
| 4216 | WREG32(SDMA0_ME_CNTL + SDMA1_REGISTER_OFFSET, tmp); |
| 4217 | } |
| 4218 | |
| 4219 | evergreen_mc_stop(rdev, &save); |
| 4220 | if (evergreen_mc_wait_for_idle(rdev)) { |
| 4221 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4222 | } |
| 4223 | |
| 4224 | if (reset_mask & (RADEON_RESET_GFX | RADEON_RESET_COMPUTE | RADEON_RESET_CP)) |
| 4225 | grbm_soft_reset = SOFT_RESET_CP | SOFT_RESET_GFX; |
| 4226 | |
| 4227 | if (reset_mask & RADEON_RESET_CP) { |
| 4228 | grbm_soft_reset |= SOFT_RESET_CP; |
| 4229 | |
| 4230 | srbm_soft_reset |= SOFT_RESET_GRBM; |
| 4231 | } |
| 4232 | |
| 4233 | if (reset_mask & RADEON_RESET_DMA) |
| 4234 | srbm_soft_reset |= SOFT_RESET_SDMA; |
| 4235 | |
| 4236 | if (reset_mask & RADEON_RESET_DMA1) |
| 4237 | srbm_soft_reset |= SOFT_RESET_SDMA1; |
| 4238 | |
| 4239 | if (reset_mask & RADEON_RESET_DISPLAY) |
| 4240 | srbm_soft_reset |= SOFT_RESET_DC; |
| 4241 | |
| 4242 | if (reset_mask & RADEON_RESET_RLC) |
| 4243 | grbm_soft_reset |= SOFT_RESET_RLC; |
| 4244 | |
| 4245 | if (reset_mask & RADEON_RESET_SEM) |
| 4246 | srbm_soft_reset |= SOFT_RESET_SEM; |
| 4247 | |
| 4248 | if (reset_mask & RADEON_RESET_IH) |
| 4249 | srbm_soft_reset |= SOFT_RESET_IH; |
| 4250 | |
| 4251 | if (reset_mask & RADEON_RESET_GRBM) |
| 4252 | srbm_soft_reset |= SOFT_RESET_GRBM; |
| 4253 | |
| 4254 | if (reset_mask & RADEON_RESET_VMC) |
| 4255 | srbm_soft_reset |= SOFT_RESET_VMC; |
| 4256 | |
| 4257 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 4258 | if (reset_mask & RADEON_RESET_MC) |
| 4259 | srbm_soft_reset |= SOFT_RESET_MC; |
| 4260 | } |
| 4261 | |
| 4262 | if (grbm_soft_reset) { |
| 4263 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4264 | tmp |= grbm_soft_reset; |
| 4265 | dev_info(rdev->dev, "GRBM_SOFT_RESET=0x%08X\n", tmp); |
| 4266 | WREG32(GRBM_SOFT_RESET, tmp); |
| 4267 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4268 | |
| 4269 | udelay(50); |
| 4270 | |
| 4271 | tmp &= ~grbm_soft_reset; |
| 4272 | WREG32(GRBM_SOFT_RESET, tmp); |
| 4273 | tmp = RREG32(GRBM_SOFT_RESET); |
| 4274 | } |
| 4275 | |
| 4276 | if (srbm_soft_reset) { |
| 4277 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4278 | tmp |= srbm_soft_reset; |
| 4279 | dev_info(rdev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp); |
| 4280 | WREG32(SRBM_SOFT_RESET, tmp); |
| 4281 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4282 | |
| 4283 | udelay(50); |
| 4284 | |
| 4285 | tmp &= ~srbm_soft_reset; |
| 4286 | WREG32(SRBM_SOFT_RESET, tmp); |
| 4287 | tmp = RREG32(SRBM_SOFT_RESET); |
| 4288 | } |
| 4289 | |
| 4290 | /* Wait a little for things to settle down */ |
| 4291 | udelay(50); |
| 4292 | |
| 4293 | evergreen_mc_resume(rdev, &save); |
| 4294 | udelay(50); |
| 4295 | |
| 4296 | cik_print_gpu_status_regs(rdev); |
| 4297 | } |
| 4298 | |
| 4299 | /** |
| 4300 | * cik_asic_reset - soft reset GPU |
| 4301 | * |
| 4302 | * @rdev: radeon_device pointer |
| 4303 | * |
| 4304 | * Look up which blocks are hung and attempt |
| 4305 | * to reset them. |
| 4306 | * Returns 0 for success. |
| 4307 | */ |
| 4308 | int cik_asic_reset(struct radeon_device *rdev) |
| 4309 | { |
| 4310 | u32 reset_mask; |
| 4311 | |
| 4312 | reset_mask = cik_gpu_check_soft_reset(rdev); |
| 4313 | |
| 4314 | if (reset_mask) |
| 4315 | r600_set_bios_scratch_engine_hung(rdev, true); |
| 4316 | |
| 4317 | cik_gpu_soft_reset(rdev, reset_mask); |
| 4318 | |
| 4319 | reset_mask = cik_gpu_check_soft_reset(rdev); |
| 4320 | |
| 4321 | if (!reset_mask) |
| 4322 | r600_set_bios_scratch_engine_hung(rdev, false); |
| 4323 | |
| 4324 | return 0; |
| 4325 | } |
| 4326 | |
| 4327 | /** |
| 4328 | * cik_gfx_is_lockup - check if the 3D engine is locked up |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4329 | * |
| 4330 | * @rdev: radeon_device pointer |
| 4331 | * @ring: radeon_ring structure holding ring information |
| 4332 | * |
| 4333 | * Check if the 3D engine is locked up (CIK). |
| 4334 | * Returns true if the engine is locked, false if not. |
| 4335 | */ |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4336 | bool cik_gfx_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring) |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4337 | { |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4338 | u32 reset_mask = cik_gpu_check_soft_reset(rdev); |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4339 | |
Alex Deucher | cc06671 | 2013-04-09 12:59:51 -0400 | [diff] [blame] | 4340 | if (!(reset_mask & (RADEON_RESET_GFX | |
| 4341 | RADEON_RESET_COMPUTE | |
| 4342 | RADEON_RESET_CP))) { |
Alex Deucher | 6f2043c | 2013-04-09 12:43:41 -0400 | [diff] [blame] | 4343 | radeon_ring_lockup_update(ring); |
| 4344 | return false; |
| 4345 | } |
| 4346 | /* force CP activities */ |
| 4347 | radeon_ring_force_activity(rdev, ring); |
| 4348 | return radeon_ring_test_lockup(rdev, ring); |
| 4349 | } |
| 4350 | |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4351 | /* MC */ |
| 4352 | /** |
| 4353 | * cik_mc_program - program the GPU memory controller |
| 4354 | * |
| 4355 | * @rdev: radeon_device pointer |
| 4356 | * |
| 4357 | * Set the location of vram, gart, and AGP in the GPU's |
| 4358 | * physical address space (CIK). |
| 4359 | */ |
| 4360 | static void cik_mc_program(struct radeon_device *rdev) |
| 4361 | { |
| 4362 | struct evergreen_mc_save save; |
| 4363 | u32 tmp; |
| 4364 | int i, j; |
| 4365 | |
| 4366 | /* Initialize HDP */ |
| 4367 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { |
| 4368 | WREG32((0x2c14 + j), 0x00000000); |
| 4369 | WREG32((0x2c18 + j), 0x00000000); |
| 4370 | WREG32((0x2c1c + j), 0x00000000); |
| 4371 | WREG32((0x2c20 + j), 0x00000000); |
| 4372 | WREG32((0x2c24 + j), 0x00000000); |
| 4373 | } |
| 4374 | WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0); |
| 4375 | |
| 4376 | evergreen_mc_stop(rdev, &save); |
| 4377 | if (radeon_mc_wait_for_idle(rdev)) { |
| 4378 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4379 | } |
| 4380 | /* Lockout access through VGA aperture*/ |
| 4381 | WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE); |
| 4382 | /* Update configuration */ |
| 4383 | WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, |
| 4384 | rdev->mc.vram_start >> 12); |
| 4385 | WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, |
| 4386 | rdev->mc.vram_end >> 12); |
| 4387 | WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, |
| 4388 | rdev->vram_scratch.gpu_addr >> 12); |
| 4389 | tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16; |
| 4390 | tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF); |
| 4391 | WREG32(MC_VM_FB_LOCATION, tmp); |
| 4392 | /* XXX double check these! */ |
| 4393 | WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8)); |
| 4394 | WREG32(HDP_NONSURFACE_INFO, (2 << 7) | (1 << 30)); |
| 4395 | WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF); |
| 4396 | WREG32(MC_VM_AGP_BASE, 0); |
| 4397 | WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF); |
| 4398 | WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF); |
| 4399 | if (radeon_mc_wait_for_idle(rdev)) { |
| 4400 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); |
| 4401 | } |
| 4402 | evergreen_mc_resume(rdev, &save); |
| 4403 | /* we need to own VRAM, so turn off the VGA renderer here |
| 4404 | * to stop it overwriting our objects */ |
| 4405 | rv515_vga_render_disable(rdev); |
| 4406 | } |
| 4407 | |
| 4408 | /** |
| 4409 | * cik_mc_init - initialize the memory controller driver params |
| 4410 | * |
| 4411 | * @rdev: radeon_device pointer |
| 4412 | * |
| 4413 | * Look up the amount of vram, vram width, and decide how to place |
| 4414 | * vram and gart within the GPU's physical address space (CIK). |
| 4415 | * Returns 0 for success. |
| 4416 | */ |
| 4417 | static int cik_mc_init(struct radeon_device *rdev) |
| 4418 | { |
| 4419 | u32 tmp; |
| 4420 | int chansize, numchan; |
| 4421 | |
| 4422 | /* Get VRAM informations */ |
| 4423 | rdev->mc.vram_is_ddr = true; |
| 4424 | tmp = RREG32(MC_ARB_RAMCFG); |
| 4425 | if (tmp & CHANSIZE_MASK) { |
| 4426 | chansize = 64; |
| 4427 | } else { |
| 4428 | chansize = 32; |
| 4429 | } |
| 4430 | tmp = RREG32(MC_SHARED_CHMAP); |
| 4431 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 4432 | case 0: |
| 4433 | default: |
| 4434 | numchan = 1; |
| 4435 | break; |
| 4436 | case 1: |
| 4437 | numchan = 2; |
| 4438 | break; |
| 4439 | case 2: |
| 4440 | numchan = 4; |
| 4441 | break; |
| 4442 | case 3: |
| 4443 | numchan = 8; |
| 4444 | break; |
| 4445 | case 4: |
| 4446 | numchan = 3; |
| 4447 | break; |
| 4448 | case 5: |
| 4449 | numchan = 6; |
| 4450 | break; |
| 4451 | case 6: |
| 4452 | numchan = 10; |
| 4453 | break; |
| 4454 | case 7: |
| 4455 | numchan = 12; |
| 4456 | break; |
| 4457 | case 8: |
| 4458 | numchan = 16; |
| 4459 | break; |
| 4460 | } |
| 4461 | rdev->mc.vram_width = numchan * chansize; |
| 4462 | /* Could aper size report 0 ? */ |
| 4463 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
| 4464 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
| 4465 | /* size in MB on si */ |
Alex Deucher | 13c5bfd | 2013-09-24 10:56:55 -0400 | [diff] [blame] | 4466 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
| 4467 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4468 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
| 4469 | si_vram_gtt_location(rdev, &rdev->mc); |
| 4470 | radeon_update_bandwidth_info(rdev); |
| 4471 | |
| 4472 | return 0; |
| 4473 | } |
| 4474 | |
| 4475 | /* |
| 4476 | * GART |
| 4477 | * VMID 0 is the physical GPU addresses as used by the kernel. |
| 4478 | * VMIDs 1-15 are used for userspace clients and are handled |
| 4479 | * by the radeon vm/hsa code. |
| 4480 | */ |
| 4481 | /** |
| 4482 | * cik_pcie_gart_tlb_flush - gart tlb flush callback |
| 4483 | * |
| 4484 | * @rdev: radeon_device pointer |
| 4485 | * |
| 4486 | * Flush the TLB for the VMID 0 page table (CIK). |
| 4487 | */ |
| 4488 | void cik_pcie_gart_tlb_flush(struct radeon_device *rdev) |
| 4489 | { |
| 4490 | /* flush hdp cache */ |
| 4491 | WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
| 4492 | |
| 4493 | /* bits 0-15 are the VM contexts0-15 */ |
| 4494 | WREG32(VM_INVALIDATE_REQUEST, 0x1); |
| 4495 | } |
| 4496 | |
| 4497 | /** |
| 4498 | * cik_pcie_gart_enable - gart enable |
| 4499 | * |
| 4500 | * @rdev: radeon_device pointer |
| 4501 | * |
| 4502 | * This sets up the TLBs, programs the page tables for VMID0, |
| 4503 | * sets up the hw for VMIDs 1-15 which are allocated on |
| 4504 | * demand, and sets up the global locations for the LDS, GDS, |
| 4505 | * and GPUVM for FSA64 clients (CIK). |
| 4506 | * Returns 0 for success, errors for failure. |
| 4507 | */ |
| 4508 | static int cik_pcie_gart_enable(struct radeon_device *rdev) |
| 4509 | { |
| 4510 | int r, i; |
| 4511 | |
| 4512 | if (rdev->gart.robj == NULL) { |
| 4513 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); |
| 4514 | return -EINVAL; |
| 4515 | } |
| 4516 | r = radeon_gart_table_vram_pin(rdev); |
| 4517 | if (r) |
| 4518 | return r; |
| 4519 | radeon_gart_restore(rdev); |
| 4520 | /* Setup TLB control */ |
| 4521 | WREG32(MC_VM_MX_L1_TLB_CNTL, |
| 4522 | (0xA << 7) | |
| 4523 | ENABLE_L1_TLB | |
| 4524 | SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 4525 | ENABLE_ADVANCED_DRIVER_MODEL | |
| 4526 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); |
| 4527 | /* Setup L2 cache */ |
| 4528 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | |
| 4529 | ENABLE_L2_FRAGMENT_PROCESSING | |
| 4530 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 4531 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | |
| 4532 | EFFECTIVE_L2_QUEUE_SIZE(7) | |
| 4533 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); |
| 4534 | WREG32(VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS | INVALIDATE_L2_CACHE); |
| 4535 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | |
| 4536 | L2_CACHE_BIGK_FRAGMENT_SIZE(6)); |
| 4537 | /* setup context0 */ |
| 4538 | WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12); |
| 4539 | WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12); |
| 4540 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12); |
| 4541 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
| 4542 | (u32)(rdev->dummy_page.addr >> 12)); |
| 4543 | WREG32(VM_CONTEXT0_CNTL2, 0); |
| 4544 | WREG32(VM_CONTEXT0_CNTL, (ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) | |
| 4545 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT)); |
| 4546 | |
| 4547 | WREG32(0x15D4, 0); |
| 4548 | WREG32(0x15D8, 0); |
| 4549 | WREG32(0x15DC, 0); |
| 4550 | |
| 4551 | /* empty context1-15 */ |
| 4552 | /* FIXME start with 4G, once using 2 level pt switch to full |
| 4553 | * vm size space |
| 4554 | */ |
| 4555 | /* set vm size, must be a multiple of 4 */ |
| 4556 | WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); |
| 4557 | WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); |
| 4558 | for (i = 1; i < 16; i++) { |
| 4559 | if (i < 8) |
| 4560 | WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), |
| 4561 | rdev->gart.table_addr >> 12); |
| 4562 | else |
| 4563 | WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2), |
| 4564 | rdev->gart.table_addr >> 12); |
| 4565 | } |
| 4566 | |
| 4567 | /* enable context1-15 */ |
| 4568 | WREG32(VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR, |
| 4569 | (u32)(rdev->dummy_page.addr >> 12)); |
Alex Deucher | a00024b | 2012-09-18 16:06:01 -0400 | [diff] [blame] | 4570 | WREG32(VM_CONTEXT1_CNTL2, 4); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4571 | WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) | |
Alex Deucher | a00024b | 2012-09-18 16:06:01 -0400 | [diff] [blame] | 4572 | RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4573 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4574 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4575 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4576 | PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4577 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4578 | VALID_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4579 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4580 | READ_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4581 | READ_PROTECTION_FAULT_ENABLE_DEFAULT | |
| 4582 | WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT | |
| 4583 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4584 | |
| 4585 | /* TC cache setup ??? */ |
| 4586 | WREG32(TC_CFG_L1_LOAD_POLICY0, 0); |
| 4587 | WREG32(TC_CFG_L1_LOAD_POLICY1, 0); |
| 4588 | WREG32(TC_CFG_L1_STORE_POLICY, 0); |
| 4589 | |
| 4590 | WREG32(TC_CFG_L2_LOAD_POLICY0, 0); |
| 4591 | WREG32(TC_CFG_L2_LOAD_POLICY1, 0); |
| 4592 | WREG32(TC_CFG_L2_STORE_POLICY0, 0); |
| 4593 | WREG32(TC_CFG_L2_STORE_POLICY1, 0); |
| 4594 | WREG32(TC_CFG_L2_ATOMIC_POLICY, 0); |
| 4595 | |
| 4596 | WREG32(TC_CFG_L1_VOLATILE, 0); |
| 4597 | WREG32(TC_CFG_L2_VOLATILE, 0); |
| 4598 | |
| 4599 | if (rdev->family == CHIP_KAVERI) { |
| 4600 | u32 tmp = RREG32(CHUB_CONTROL); |
| 4601 | tmp &= ~BYPASS_VM; |
| 4602 | WREG32(CHUB_CONTROL, tmp); |
| 4603 | } |
| 4604 | |
| 4605 | /* XXX SH_MEM regs */ |
| 4606 | /* where to put LDS, scratch, GPUVM in FSA64 space */ |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 4607 | mutex_lock(&rdev->srbm_mutex); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4608 | for (i = 0; i < 16; i++) { |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 4609 | cik_srbm_select(rdev, 0, 0, 0, i); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 4610 | /* CP and shaders */ |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4611 | WREG32(SH_MEM_CONFIG, 0); |
| 4612 | WREG32(SH_MEM_APE1_BASE, 1); |
| 4613 | WREG32(SH_MEM_APE1_LIMIT, 0); |
| 4614 | WREG32(SH_MEM_BASES, 0); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 4615 | /* SDMA GFX */ |
| 4616 | WREG32(SDMA0_GFX_VIRTUAL_ADDR + SDMA0_REGISTER_OFFSET, 0); |
| 4617 | WREG32(SDMA0_GFX_APE1_CNTL + SDMA0_REGISTER_OFFSET, 0); |
| 4618 | WREG32(SDMA0_GFX_VIRTUAL_ADDR + SDMA1_REGISTER_OFFSET, 0); |
| 4619 | WREG32(SDMA0_GFX_APE1_CNTL + SDMA1_REGISTER_OFFSET, 0); |
| 4620 | /* XXX SDMA RLC - todo */ |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4621 | } |
Alex Deucher | b556b12 | 2013-01-29 10:44:22 -0500 | [diff] [blame] | 4622 | cik_srbm_select(rdev, 0, 0, 0, 0); |
Alex Deucher | f61d5b46 | 2013-08-06 12:40:16 -0400 | [diff] [blame] | 4623 | mutex_unlock(&rdev->srbm_mutex); |
Alex Deucher | 1c49165 | 2013-04-09 12:45:26 -0400 | [diff] [blame] | 4624 | |
| 4625 | cik_pcie_gart_tlb_flush(rdev); |
| 4626 | DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", |
| 4627 | (unsigned)(rdev->mc.gtt_size >> 20), |
| 4628 | (unsigned long long)rdev->gart.table_addr); |
| 4629 | rdev->gart.ready = true; |
| 4630 | return 0; |
| 4631 | } |
| 4632 | |
| 4633 | /** |
| 4634 | * cik_pcie_gart_disable - gart disable |
| 4635 | * |
| 4636 | * @rdev: radeon_device pointer |
| 4637 | * |
| 4638 | * This disables all VM page table (CIK). |
| 4639 | */ |
| 4640 | static void cik_pcie_gart_disable(struct radeon_device *rdev) |
| 4641 | { |
| 4642 | /* Disable all tables */ |
| 4643 | WREG32(VM_CONTEXT0_CNTL, 0); |
| 4644 | WREG32(VM_CONTEXT1_CNTL, 0); |
| 4645 | /* Setup TLB control */ |
| 4646 | WREG32(MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE_NOT_IN_SYS | |
| 4647 | SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU); |
| 4648 | /* Setup L2 cache */ |
| 4649 | WREG32(VM_L2_CNTL, |
| 4650 | ENABLE_L2_FRAGMENT_PROCESSING | |
| 4651 | ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE | |
| 4652 | ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE | |
| 4653 | EFFECTIVE_L2_QUEUE_SIZE(7) | |
| 4654 | CONTEXT1_IDENTITY_ACCESS_MODE(1)); |
| 4655 | WREG32(VM_L2_CNTL2, 0); |
| 4656 | WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY | |
| 4657 | L2_CACHE_BIGK_FRAGMENT_SIZE(6)); |
| 4658 | radeon_gart_table_vram_unpin(rdev); |
| 4659 | } |
| 4660 | |
| 4661 | /** |
| 4662 | * cik_pcie_gart_fini - vm fini callback |
| 4663 | * |
| 4664 | * @rdev: radeon_device pointer |
| 4665 | * |
| 4666 | * Tears down the driver GART/VM setup (CIK). |
| 4667 | */ |
| 4668 | static void cik_pcie_gart_fini(struct radeon_device *rdev) |
| 4669 | { |
| 4670 | cik_pcie_gart_disable(rdev); |
| 4671 | radeon_gart_table_vram_free(rdev); |
| 4672 | radeon_gart_fini(rdev); |
| 4673 | } |
| 4674 | |
| 4675 | /* vm parser */ |
| 4676 | /** |
| 4677 | * cik_ib_parse - vm ib_parse callback |
| 4678 | * |
| 4679 | * @rdev: radeon_device pointer |
| 4680 | * @ib: indirect buffer pointer |
| 4681 | * |
| 4682 | * CIK uses hw IB checking so this is a nop (CIK). |
| 4683 | */ |
| 4684 | int cik_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib) |
| 4685 | { |
| 4686 | return 0; |
| 4687 | } |
| 4688 | |
| 4689 | /* |
| 4690 | * vm |
| 4691 | * VMID 0 is the physical GPU addresses as used by the kernel. |
| 4692 | * VMIDs 1-15 are used for userspace clients and are handled |
| 4693 | * by the radeon vm/hsa code. |
| 4694 | */ |
| 4695 | /** |
| 4696 | * cik_vm_init - cik vm init callback |
| 4697 | * |
| 4698 | * @rdev: radeon_device pointer |
| 4699 | * |
| 4700 | * Inits cik specific vm parameters (number of VMs, base of vram for |
| 4701 | * VMIDs 1-15) (CIK). |
| 4702 | * Returns 0 for success. |
| 4703 | */ |
| 4704 | int cik_vm_init(struct radeon_device *rdev) |
| 4705 | { |
| 4706 | /* number of VMs */ |
| 4707 | rdev->vm_manager.nvm = 16; |
| 4708 | /* base offset of vram pages */ |
| 4709 | if (rdev->flags & RADEON_IS_IGP) { |
| 4710 | u64 tmp = RREG32(MC_VM_FB_OFFSET); |
| 4711 | tmp <<= 22; |
| 4712 | rdev->vm_manager.vram_base_offset = tmp; |
| 4713 | } else |
| 4714 | rdev->vm_manager.vram_base_offset = 0; |
| 4715 | |
| 4716 | return 0; |
| 4717 | } |
| 4718 | |
| 4719 | /** |
| 4720 | * cik_vm_fini - cik vm fini callback |
| 4721 | * |
| 4722 | * @rdev: radeon_device pointer |
| 4723 | * |
| 4724 | * Tear down any asic specific VM setup (CIK). |
| 4725 | */ |
| 4726 | void cik_vm_fini(struct radeon_device *rdev) |
| 4727 | { |
| 4728 | } |
| 4729 | |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4730 | /** |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4731 | * cik_vm_decode_fault - print human readable fault info |
| 4732 | * |
| 4733 | * @rdev: radeon_device pointer |
| 4734 | * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value |
| 4735 | * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value |
| 4736 | * |
| 4737 | * Print human readable fault information (CIK). |
| 4738 | */ |
| 4739 | static void cik_vm_decode_fault(struct radeon_device *rdev, |
| 4740 | u32 status, u32 addr, u32 mc_client) |
| 4741 | { |
| 4742 | u32 mc_id = (status & MEMORY_CLIENT_ID_MASK) >> MEMORY_CLIENT_ID_SHIFT; |
| 4743 | u32 vmid = (status & FAULT_VMID_MASK) >> FAULT_VMID_SHIFT; |
| 4744 | u32 protections = (status & PROTECTIONS_MASK) >> PROTECTIONS_SHIFT; |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4745 | char block[5] = { mc_client >> 24, (mc_client >> 16) & 0xff, |
| 4746 | (mc_client >> 8) & 0xff, mc_client & 0xff, 0 }; |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4747 | |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4748 | printk("VM fault (0x%02x, vmid %d) at page %u, %s from '%s' (0x%08x) (%d)\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4749 | protections, vmid, addr, |
| 4750 | (status & MEMORY_CLIENT_RW_MASK) ? "write" : "read", |
Michel Dänzer | 328a50c7b | 2013-09-18 15:39:40 +0200 | [diff] [blame] | 4751 | block, mc_client, mc_id); |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 4752 | } |
| 4753 | |
| 4754 | /** |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4755 | * cik_vm_flush - cik vm flush using the CP |
| 4756 | * |
| 4757 | * @rdev: radeon_device pointer |
| 4758 | * |
| 4759 | * Update the page table base and flush the VM TLB |
| 4760 | * using the CP (CIK). |
| 4761 | */ |
| 4762 | void cik_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm) |
| 4763 | { |
| 4764 | struct radeon_ring *ring = &rdev->ring[ridx]; |
| 4765 | |
| 4766 | if (vm == NULL) |
| 4767 | return; |
| 4768 | |
| 4769 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4770 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4771 | WRITE_DATA_DST_SEL(0))); |
| 4772 | if (vm->id < 8) { |
| 4773 | radeon_ring_write(ring, |
| 4774 | (VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (vm->id << 2)) >> 2); |
| 4775 | } else { |
| 4776 | radeon_ring_write(ring, |
| 4777 | (VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((vm->id - 8) << 2)) >> 2); |
| 4778 | } |
| 4779 | radeon_ring_write(ring, 0); |
| 4780 | radeon_ring_write(ring, vm->pd_gpu_addr >> 12); |
| 4781 | |
| 4782 | /* update SH_MEM_* regs */ |
| 4783 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4784 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4785 | WRITE_DATA_DST_SEL(0))); |
| 4786 | radeon_ring_write(ring, SRBM_GFX_CNTL >> 2); |
| 4787 | radeon_ring_write(ring, 0); |
| 4788 | radeon_ring_write(ring, VMID(vm->id)); |
| 4789 | |
| 4790 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 6)); |
| 4791 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4792 | WRITE_DATA_DST_SEL(0))); |
| 4793 | radeon_ring_write(ring, SH_MEM_BASES >> 2); |
| 4794 | radeon_ring_write(ring, 0); |
| 4795 | |
| 4796 | radeon_ring_write(ring, 0); /* SH_MEM_BASES */ |
| 4797 | radeon_ring_write(ring, 0); /* SH_MEM_CONFIG */ |
| 4798 | radeon_ring_write(ring, 1); /* SH_MEM_APE1_BASE */ |
| 4799 | radeon_ring_write(ring, 0); /* SH_MEM_APE1_LIMIT */ |
| 4800 | |
| 4801 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4802 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4803 | WRITE_DATA_DST_SEL(0))); |
| 4804 | radeon_ring_write(ring, SRBM_GFX_CNTL >> 2); |
| 4805 | radeon_ring_write(ring, 0); |
| 4806 | radeon_ring_write(ring, VMID(0)); |
| 4807 | |
| 4808 | /* HDP flush */ |
| 4809 | /* We should be using the WAIT_REG_MEM packet here like in |
| 4810 | * cik_fence_ring_emit(), but it causes the CP to hang in this |
| 4811 | * context... |
| 4812 | */ |
| 4813 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4814 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4815 | WRITE_DATA_DST_SEL(0))); |
| 4816 | radeon_ring_write(ring, HDP_MEM_COHERENCY_FLUSH_CNTL >> 2); |
| 4817 | radeon_ring_write(ring, 0); |
| 4818 | radeon_ring_write(ring, 0); |
| 4819 | |
| 4820 | /* bits 0-15 are the VM contexts0-15 */ |
| 4821 | radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3)); |
| 4822 | radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | |
| 4823 | WRITE_DATA_DST_SEL(0))); |
| 4824 | radeon_ring_write(ring, VM_INVALIDATE_REQUEST >> 2); |
| 4825 | radeon_ring_write(ring, 0); |
| 4826 | radeon_ring_write(ring, 1 << vm->id); |
| 4827 | |
Alex Deucher | b07fdd3 | 2013-04-11 09:36:17 -0400 | [diff] [blame] | 4828 | /* compute doesn't have PFP */ |
| 4829 | if (ridx == RADEON_RING_TYPE_GFX_INDEX) { |
| 4830 | /* sync PFP to ME, otherwise we might get invalid PFP reads */ |
| 4831 | radeon_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0)); |
| 4832 | radeon_ring_write(ring, 0x0); |
| 4833 | } |
Alex Deucher | f96ab48 | 2012-08-31 10:37:47 -0400 | [diff] [blame] | 4834 | } |
| 4835 | |
Alex Deucher | 605de6b | 2012-10-22 13:04:03 -0400 | [diff] [blame] | 4836 | /** |
Alex Deucher | d0e092d | 2012-08-31 11:00:53 -0400 | [diff] [blame] | 4837 | * cik_vm_set_page - update the page tables using sDMA |
| 4838 | * |
| 4839 | * @rdev: radeon_device pointer |
| 4840 | * @ib: indirect buffer to fill with commands |
| 4841 | * @pe: addr of the page entry |
| 4842 | * @addr: dst addr to write into pe |
| 4843 | * @count: number of page entries to update |
| 4844 | * @incr: increase next addr by incr bytes |
| 4845 | * @flags: access flags |
| 4846 | * |
| 4847 | * Update the page tables using CP or sDMA (CIK). |
| 4848 | */ |
| 4849 | void cik_vm_set_page(struct radeon_device *rdev, |
| 4850 | struct radeon_ib *ib, |
| 4851 | uint64_t pe, |
| 4852 | uint64_t addr, unsigned count, |
| 4853 | uint32_t incr, uint32_t flags) |
| 4854 | { |
| 4855 | uint32_t r600_flags = cayman_vm_page_flags(rdev, flags); |
| 4856 | uint64_t value; |
| 4857 | unsigned ndw; |
| 4858 | |
| 4859 | if (rdev->asic->vm.pt_ring_index == RADEON_RING_TYPE_GFX_INDEX) { |
| 4860 | /* CP */ |
| 4861 | while (count) { |
| 4862 | ndw = 2 + count * 2; |
| 4863 | if (ndw > 0x3FFE) |
| 4864 | ndw = 0x3FFE; |
| 4865 | |
| 4866 | ib->ptr[ib->length_dw++] = PACKET3(PACKET3_WRITE_DATA, ndw); |
| 4867 | ib->ptr[ib->length_dw++] = (WRITE_DATA_ENGINE_SEL(0) | |
| 4868 | WRITE_DATA_DST_SEL(1)); |
| 4869 | ib->ptr[ib->length_dw++] = pe; |
| 4870 | ib->ptr[ib->length_dw++] = upper_32_bits(pe); |
| 4871 | for (; ndw > 2; ndw -= 2, --count, pe += 8) { |
| 4872 | if (flags & RADEON_VM_PAGE_SYSTEM) { |
| 4873 | value = radeon_vm_map_gart(rdev, addr); |
| 4874 | value &= 0xFFFFFFFFFFFFF000ULL; |
| 4875 | } else if (flags & RADEON_VM_PAGE_VALID) { |
| 4876 | value = addr; |
| 4877 | } else { |
| 4878 | value = 0; |
| 4879 | } |
| 4880 | addr += incr; |
| 4881 | value |= r600_flags; |
| 4882 | ib->ptr[ib->length_dw++] = value; |
| 4883 | ib->ptr[ib->length_dw++] = upper_32_bits(value); |
| 4884 | } |
| 4885 | } |
| 4886 | } else { |
| 4887 | /* DMA */ |
Christian König | 2483b4e | 2013-08-13 11:56:54 +0200 | [diff] [blame] | 4888 | cik_sdma_vm_set_page(rdev, ib, pe, addr, count, incr, flags); |
Alex Deucher | d0e092d | 2012-08-31 11:00:53 -0400 | [diff] [blame] | 4889 | } |
| 4890 | } |
| 4891 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4892 | /* |
| 4893 | * RLC |
| 4894 | * The RLC is a multi-purpose microengine that handles a |
| 4895 | * variety of functions, the most important of which is |
| 4896 | * the interrupt controller. |
| 4897 | */ |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4898 | static void cik_enable_gui_idle_interrupt(struct radeon_device *rdev, |
| 4899 | bool enable) |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4900 | { |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4901 | u32 tmp = RREG32(CP_INT_CNTL_RING0); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4902 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4903 | if (enable) |
| 4904 | tmp |= (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 4905 | else |
| 4906 | tmp &= ~(CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4907 | WREG32(CP_INT_CNTL_RING0, tmp); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4908 | } |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4909 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4910 | static void cik_enable_lbpw(struct radeon_device *rdev, bool enable) |
| 4911 | { |
| 4912 | u32 tmp; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4913 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4914 | tmp = RREG32(RLC_LB_CNTL); |
| 4915 | if (enable) |
| 4916 | tmp |= LOAD_BALANCE_ENABLE; |
| 4917 | else |
| 4918 | tmp &= ~LOAD_BALANCE_ENABLE; |
| 4919 | WREG32(RLC_LB_CNTL, tmp); |
| 4920 | } |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4921 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 4922 | static void cik_wait_for_rlc_serdes(struct radeon_device *rdev) |
| 4923 | { |
| 4924 | u32 i, j, k; |
| 4925 | u32 mask; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 4926 | |
| 4927 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { |
| 4928 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { |
| 4929 | cik_select_se_sh(rdev, i, j); |
| 4930 | for (k = 0; k < rdev->usec_timeout; k++) { |
| 4931 | if (RREG32(RLC_SERDES_CU_MASTER_BUSY) == 0) |
| 4932 | break; |
| 4933 | udelay(1); |
| 4934 | } |
| 4935 | } |
| 4936 | } |
| 4937 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 4938 | |
| 4939 | mask = SE_MASTER_BUSY_MASK | GC_MASTER_BUSY | TC0_MASTER_BUSY | TC1_MASTER_BUSY; |
| 4940 | for (k = 0; k < rdev->usec_timeout; k++) { |
| 4941 | if ((RREG32(RLC_SERDES_NONCU_MASTER_BUSY) & mask) == 0) |
| 4942 | break; |
| 4943 | udelay(1); |
| 4944 | } |
| 4945 | } |
| 4946 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 4947 | static void cik_update_rlc(struct radeon_device *rdev, u32 rlc) |
| 4948 | { |
| 4949 | u32 tmp; |
| 4950 | |
| 4951 | tmp = RREG32(RLC_CNTL); |
| 4952 | if (tmp != rlc) |
| 4953 | WREG32(RLC_CNTL, rlc); |
| 4954 | } |
| 4955 | |
| 4956 | static u32 cik_halt_rlc(struct radeon_device *rdev) |
| 4957 | { |
| 4958 | u32 data, orig; |
| 4959 | |
| 4960 | orig = data = RREG32(RLC_CNTL); |
| 4961 | |
| 4962 | if (data & RLC_ENABLE) { |
| 4963 | u32 i; |
| 4964 | |
| 4965 | data &= ~RLC_ENABLE; |
| 4966 | WREG32(RLC_CNTL, data); |
| 4967 | |
| 4968 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 4969 | if ((RREG32(RLC_GPM_STAT) & RLC_GPM_BUSY) == 0) |
| 4970 | break; |
| 4971 | udelay(1); |
| 4972 | } |
| 4973 | |
| 4974 | cik_wait_for_rlc_serdes(rdev); |
| 4975 | } |
| 4976 | |
| 4977 | return orig; |
| 4978 | } |
| 4979 | |
Alex Deucher | a412fce | 2013-04-22 20:23:31 -0400 | [diff] [blame] | 4980 | void cik_enter_rlc_safe_mode(struct radeon_device *rdev) |
| 4981 | { |
| 4982 | u32 tmp, i, mask; |
| 4983 | |
| 4984 | tmp = REQ | MESSAGE(MSG_ENTER_RLC_SAFE_MODE); |
| 4985 | WREG32(RLC_GPR_REG2, tmp); |
| 4986 | |
| 4987 | mask = GFX_POWER_STATUS | GFX_CLOCK_STATUS; |
| 4988 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 4989 | if ((RREG32(RLC_GPM_STAT) & mask) == mask) |
| 4990 | break; |
| 4991 | udelay(1); |
| 4992 | } |
| 4993 | |
| 4994 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 4995 | if ((RREG32(RLC_GPR_REG2) & REQ) == 0) |
| 4996 | break; |
| 4997 | udelay(1); |
| 4998 | } |
| 4999 | } |
| 5000 | |
| 5001 | void cik_exit_rlc_safe_mode(struct radeon_device *rdev) |
| 5002 | { |
| 5003 | u32 tmp; |
| 5004 | |
| 5005 | tmp = REQ | MESSAGE(MSG_EXIT_RLC_SAFE_MODE); |
| 5006 | WREG32(RLC_GPR_REG2, tmp); |
| 5007 | } |
| 5008 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5009 | /** |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5010 | * cik_rlc_stop - stop the RLC ME |
| 5011 | * |
| 5012 | * @rdev: radeon_device pointer |
| 5013 | * |
| 5014 | * Halt the RLC ME (MicroEngine) (CIK). |
| 5015 | */ |
| 5016 | static void cik_rlc_stop(struct radeon_device *rdev) |
| 5017 | { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5018 | WREG32(RLC_CNTL, 0); |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5019 | |
| 5020 | cik_enable_gui_idle_interrupt(rdev, false); |
| 5021 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5022 | cik_wait_for_rlc_serdes(rdev); |
| 5023 | } |
| 5024 | |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5025 | /** |
| 5026 | * cik_rlc_start - start the RLC ME |
| 5027 | * |
| 5028 | * @rdev: radeon_device pointer |
| 5029 | * |
| 5030 | * Unhalt the RLC ME (MicroEngine) (CIK). |
| 5031 | */ |
| 5032 | static void cik_rlc_start(struct radeon_device *rdev) |
| 5033 | { |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5034 | WREG32(RLC_CNTL, RLC_ENABLE); |
| 5035 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5036 | cik_enable_gui_idle_interrupt(rdev, true); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5037 | |
| 5038 | udelay(50); |
| 5039 | } |
| 5040 | |
| 5041 | /** |
| 5042 | * cik_rlc_resume - setup the RLC hw |
| 5043 | * |
| 5044 | * @rdev: radeon_device pointer |
| 5045 | * |
| 5046 | * Initialize the RLC registers, load the ucode, |
| 5047 | * and start the RLC (CIK). |
| 5048 | * Returns 0 for success, -EINVAL if the ucode is not available. |
| 5049 | */ |
| 5050 | static int cik_rlc_resume(struct radeon_device *rdev) |
| 5051 | { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5052 | u32 i, size, tmp; |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5053 | const __be32 *fw_data; |
| 5054 | |
| 5055 | if (!rdev->rlc_fw) |
| 5056 | return -EINVAL; |
| 5057 | |
| 5058 | switch (rdev->family) { |
| 5059 | case CHIP_BONAIRE: |
| 5060 | default: |
| 5061 | size = BONAIRE_RLC_UCODE_SIZE; |
| 5062 | break; |
| 5063 | case CHIP_KAVERI: |
| 5064 | size = KV_RLC_UCODE_SIZE; |
| 5065 | break; |
| 5066 | case CHIP_KABINI: |
| 5067 | size = KB_RLC_UCODE_SIZE; |
| 5068 | break; |
| 5069 | } |
| 5070 | |
| 5071 | cik_rlc_stop(rdev); |
| 5072 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5073 | /* disable CG */ |
| 5074 | tmp = RREG32(RLC_CGCG_CGLS_CTRL) & 0xfffffffc; |
| 5075 | WREG32(RLC_CGCG_CGLS_CTRL, tmp); |
| 5076 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5077 | si_rlc_reset(rdev); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5078 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5079 | cik_init_pg(rdev); |
| 5080 | |
| 5081 | cik_init_cg(rdev); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5082 | |
| 5083 | WREG32(RLC_LB_CNTR_INIT, 0); |
| 5084 | WREG32(RLC_LB_CNTR_MAX, 0x00008000); |
| 5085 | |
| 5086 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5087 | WREG32(RLC_LB_INIT_CU_MASK, 0xffffffff); |
| 5088 | WREG32(RLC_LB_PARAMS, 0x00600408); |
| 5089 | WREG32(RLC_LB_CNTL, 0x80000004); |
| 5090 | |
| 5091 | WREG32(RLC_MC_CNTL, 0); |
| 5092 | WREG32(RLC_UCODE_CNTL, 0); |
| 5093 | |
| 5094 | fw_data = (const __be32 *)rdev->rlc_fw->data; |
| 5095 | WREG32(RLC_GPM_UCODE_ADDR, 0); |
| 5096 | for (i = 0; i < size; i++) |
| 5097 | WREG32(RLC_GPM_UCODE_DATA, be32_to_cpup(fw_data++)); |
| 5098 | WREG32(RLC_GPM_UCODE_ADDR, 0); |
| 5099 | |
Alex Deucher | 866d83d | 2013-04-15 17:13:29 -0400 | [diff] [blame] | 5100 | /* XXX - find out what chips support lbpw */ |
| 5101 | cik_enable_lbpw(rdev, false); |
| 5102 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5103 | if (rdev->family == CHIP_BONAIRE) |
| 5104 | WREG32(RLC_DRIVER_DMA_STATUS, 0); |
Alex Deucher | f6796ca | 2012-11-09 10:44:08 -0500 | [diff] [blame] | 5105 | |
| 5106 | cik_rlc_start(rdev); |
| 5107 | |
| 5108 | return 0; |
| 5109 | } |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5110 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5111 | static void cik_enable_cgcg(struct radeon_device *rdev, bool enable) |
| 5112 | { |
| 5113 | u32 data, orig, tmp, tmp2; |
| 5114 | |
| 5115 | orig = data = RREG32(RLC_CGCG_CGLS_CTRL); |
| 5116 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5117 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGCG)) { |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5118 | cik_enable_gui_idle_interrupt(rdev, true); |
| 5119 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5120 | tmp = cik_halt_rlc(rdev); |
| 5121 | |
| 5122 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5123 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5124 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5125 | tmp2 = BPM_ADDR_MASK | CGCG_OVERRIDE_0 | CGLS_ENABLE; |
| 5126 | WREG32(RLC_SERDES_WR_CTRL, tmp2); |
| 5127 | |
| 5128 | cik_update_rlc(rdev, tmp); |
| 5129 | |
| 5130 | data |= CGCG_EN | CGLS_EN; |
| 5131 | } else { |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5132 | cik_enable_gui_idle_interrupt(rdev, false); |
| 5133 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5134 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5135 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5136 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5137 | RREG32(CB_CGTT_SCLK_CTRL); |
| 5138 | |
| 5139 | data &= ~(CGCG_EN | CGLS_EN); |
| 5140 | } |
| 5141 | |
| 5142 | if (orig != data) |
| 5143 | WREG32(RLC_CGCG_CGLS_CTRL, data); |
| 5144 | |
| 5145 | } |
| 5146 | |
| 5147 | static void cik_enable_mgcg(struct radeon_device *rdev, bool enable) |
| 5148 | { |
| 5149 | u32 data, orig, tmp = 0; |
| 5150 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5151 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGCG)) { |
| 5152 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGLS) { |
| 5153 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CP_LS) { |
| 5154 | orig = data = RREG32(CP_MEM_SLP_CNTL); |
| 5155 | data |= CP_MEM_LS_EN; |
| 5156 | if (orig != data) |
| 5157 | WREG32(CP_MEM_SLP_CNTL, data); |
| 5158 | } |
| 5159 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5160 | |
| 5161 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); |
| 5162 | data &= 0xfffffffd; |
| 5163 | if (orig != data) |
| 5164 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); |
| 5165 | |
| 5166 | tmp = cik_halt_rlc(rdev); |
| 5167 | |
| 5168 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5169 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5170 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5171 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_0; |
| 5172 | WREG32(RLC_SERDES_WR_CTRL, data); |
| 5173 | |
| 5174 | cik_update_rlc(rdev, tmp); |
| 5175 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5176 | if (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGTS) { |
| 5177 | orig = data = RREG32(CGTS_SM_CTRL_REG); |
| 5178 | data &= ~SM_MODE_MASK; |
| 5179 | data |= SM_MODE(0x2); |
| 5180 | data |= SM_MODE_ENABLE; |
| 5181 | data &= ~CGTS_OVERRIDE; |
| 5182 | if ((rdev->cg_flags & RADEON_CG_SUPPORT_GFX_MGLS) && |
| 5183 | (rdev->cg_flags & RADEON_CG_SUPPORT_GFX_CGTS_LS)) |
| 5184 | data &= ~CGTS_LS_OVERRIDE; |
| 5185 | data &= ~ON_MONITOR_ADD_MASK; |
| 5186 | data |= ON_MONITOR_ADD_EN; |
| 5187 | data |= ON_MONITOR_ADD(0x96); |
| 5188 | if (orig != data) |
| 5189 | WREG32(CGTS_SM_CTRL_REG, data); |
| 5190 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5191 | } else { |
| 5192 | orig = data = RREG32(RLC_CGTT_MGCG_OVERRIDE); |
| 5193 | data |= 0x00000002; |
| 5194 | if (orig != data) |
| 5195 | WREG32(RLC_CGTT_MGCG_OVERRIDE, data); |
| 5196 | |
| 5197 | data = RREG32(RLC_MEM_SLP_CNTL); |
| 5198 | if (data & RLC_MEM_LS_EN) { |
| 5199 | data &= ~RLC_MEM_LS_EN; |
| 5200 | WREG32(RLC_MEM_SLP_CNTL, data); |
| 5201 | } |
| 5202 | |
| 5203 | data = RREG32(CP_MEM_SLP_CNTL); |
| 5204 | if (data & CP_MEM_LS_EN) { |
| 5205 | data &= ~CP_MEM_LS_EN; |
| 5206 | WREG32(CP_MEM_SLP_CNTL, data); |
| 5207 | } |
| 5208 | |
| 5209 | orig = data = RREG32(CGTS_SM_CTRL_REG); |
| 5210 | data |= CGTS_OVERRIDE | CGTS_LS_OVERRIDE; |
| 5211 | if (orig != data) |
| 5212 | WREG32(CGTS_SM_CTRL_REG, data); |
| 5213 | |
| 5214 | tmp = cik_halt_rlc(rdev); |
| 5215 | |
| 5216 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5217 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
| 5218 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
| 5219 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_1; |
| 5220 | WREG32(RLC_SERDES_WR_CTRL, data); |
| 5221 | |
| 5222 | cik_update_rlc(rdev, tmp); |
| 5223 | } |
| 5224 | } |
| 5225 | |
| 5226 | static const u32 mc_cg_registers[] = |
| 5227 | { |
| 5228 | MC_HUB_MISC_HUB_CG, |
| 5229 | MC_HUB_MISC_SIP_CG, |
| 5230 | MC_HUB_MISC_VM_CG, |
| 5231 | MC_XPB_CLK_GAT, |
| 5232 | ATC_MISC_CG, |
| 5233 | MC_CITF_MISC_WR_CG, |
| 5234 | MC_CITF_MISC_RD_CG, |
| 5235 | MC_CITF_MISC_VM_CG, |
| 5236 | VM_L2_CG, |
| 5237 | }; |
| 5238 | |
| 5239 | static void cik_enable_mc_ls(struct radeon_device *rdev, |
| 5240 | bool enable) |
| 5241 | { |
| 5242 | int i; |
| 5243 | u32 orig, data; |
| 5244 | |
| 5245 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { |
| 5246 | orig = data = RREG32(mc_cg_registers[i]); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5247 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_MC_LS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5248 | data |= MC_LS_ENABLE; |
| 5249 | else |
| 5250 | data &= ~MC_LS_ENABLE; |
| 5251 | if (data != orig) |
| 5252 | WREG32(mc_cg_registers[i], data); |
| 5253 | } |
| 5254 | } |
| 5255 | |
| 5256 | static void cik_enable_mc_mgcg(struct radeon_device *rdev, |
| 5257 | bool enable) |
| 5258 | { |
| 5259 | int i; |
| 5260 | u32 orig, data; |
| 5261 | |
| 5262 | for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) { |
| 5263 | orig = data = RREG32(mc_cg_registers[i]); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5264 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_MC_MGCG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5265 | data |= MC_CG_ENABLE; |
| 5266 | else |
| 5267 | data &= ~MC_CG_ENABLE; |
| 5268 | if (data != orig) |
| 5269 | WREG32(mc_cg_registers[i], data); |
| 5270 | } |
| 5271 | } |
| 5272 | |
| 5273 | static void cik_enable_sdma_mgcg(struct radeon_device *rdev, |
| 5274 | bool enable) |
| 5275 | { |
| 5276 | u32 orig, data; |
| 5277 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5278 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_SDMA_MGCG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5279 | WREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, 0x00000100); |
| 5280 | WREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, 0x00000100); |
| 5281 | } else { |
| 5282 | orig = data = RREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET); |
| 5283 | data |= 0xff000000; |
| 5284 | if (data != orig) |
| 5285 | WREG32(SDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, data); |
| 5286 | |
| 5287 | orig = data = RREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET); |
| 5288 | data |= 0xff000000; |
| 5289 | if (data != orig) |
| 5290 | WREG32(SDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, data); |
| 5291 | } |
| 5292 | } |
| 5293 | |
| 5294 | static void cik_enable_sdma_mgls(struct radeon_device *rdev, |
| 5295 | bool enable) |
| 5296 | { |
| 5297 | u32 orig, data; |
| 5298 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5299 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_SDMA_LS)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5300 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET); |
| 5301 | data |= 0x100; |
| 5302 | if (orig != data) |
| 5303 | WREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data); |
| 5304 | |
| 5305 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET); |
| 5306 | data |= 0x100; |
| 5307 | if (orig != data) |
| 5308 | WREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data); |
| 5309 | } else { |
| 5310 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET); |
| 5311 | data &= ~0x100; |
| 5312 | if (orig != data) |
| 5313 | WREG32(SDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET, data); |
| 5314 | |
| 5315 | orig = data = RREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET); |
| 5316 | data &= ~0x100; |
| 5317 | if (orig != data) |
| 5318 | WREG32(SDMA0_POWER_CNTL + SDMA1_REGISTER_OFFSET, data); |
| 5319 | } |
| 5320 | } |
| 5321 | |
| 5322 | static void cik_enable_uvd_mgcg(struct radeon_device *rdev, |
| 5323 | bool enable) |
| 5324 | { |
| 5325 | u32 orig, data; |
| 5326 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5327 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_UVD_MGCG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5328 | data = RREG32_UVD_CTX(UVD_CGC_MEM_CTRL); |
| 5329 | data = 0xfff; |
| 5330 | WREG32_UVD_CTX(UVD_CGC_MEM_CTRL, data); |
| 5331 | |
| 5332 | orig = data = RREG32(UVD_CGC_CTRL); |
| 5333 | data |= DCM; |
| 5334 | if (orig != data) |
| 5335 | WREG32(UVD_CGC_CTRL, data); |
| 5336 | } else { |
| 5337 | data = RREG32_UVD_CTX(UVD_CGC_MEM_CTRL); |
| 5338 | data &= ~0xfff; |
| 5339 | WREG32_UVD_CTX(UVD_CGC_MEM_CTRL, data); |
| 5340 | |
| 5341 | orig = data = RREG32(UVD_CGC_CTRL); |
| 5342 | data &= ~DCM; |
| 5343 | if (orig != data) |
| 5344 | WREG32(UVD_CGC_CTRL, data); |
| 5345 | } |
| 5346 | } |
| 5347 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5348 | static void cik_enable_bif_mgls(struct radeon_device *rdev, |
| 5349 | bool enable) |
| 5350 | { |
| 5351 | u32 orig, data; |
| 5352 | |
| 5353 | orig = data = RREG32_PCIE_PORT(PCIE_CNTL2); |
| 5354 | |
| 5355 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_BIF_LS)) |
| 5356 | data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | |
| 5357 | REPLAY_MEM_LS_EN | SLV_MEM_AGGRESSIVE_LS_EN; |
| 5358 | else |
| 5359 | data &= ~(SLV_MEM_LS_EN | MST_MEM_LS_EN | |
| 5360 | REPLAY_MEM_LS_EN | SLV_MEM_AGGRESSIVE_LS_EN); |
| 5361 | |
| 5362 | if (orig != data) |
| 5363 | WREG32_PCIE_PORT(PCIE_CNTL2, data); |
| 5364 | } |
| 5365 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5366 | static void cik_enable_hdp_mgcg(struct radeon_device *rdev, |
| 5367 | bool enable) |
| 5368 | { |
| 5369 | u32 orig, data; |
| 5370 | |
| 5371 | orig = data = RREG32(HDP_HOST_PATH_CNTL); |
| 5372 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5373 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_HDP_MGCG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5374 | data &= ~CLOCK_GATING_DIS; |
| 5375 | else |
| 5376 | data |= CLOCK_GATING_DIS; |
| 5377 | |
| 5378 | if (orig != data) |
| 5379 | WREG32(HDP_HOST_PATH_CNTL, data); |
| 5380 | } |
| 5381 | |
| 5382 | static void cik_enable_hdp_ls(struct radeon_device *rdev, |
| 5383 | bool enable) |
| 5384 | { |
| 5385 | u32 orig, data; |
| 5386 | |
| 5387 | orig = data = RREG32(HDP_MEM_POWER_LS); |
| 5388 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5389 | if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_HDP_LS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5390 | data |= HDP_LS_ENABLE; |
| 5391 | else |
| 5392 | data &= ~HDP_LS_ENABLE; |
| 5393 | |
| 5394 | if (orig != data) |
| 5395 | WREG32(HDP_MEM_POWER_LS, data); |
| 5396 | } |
| 5397 | |
| 5398 | void cik_update_cg(struct radeon_device *rdev, |
| 5399 | u32 block, bool enable) |
| 5400 | { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5401 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5402 | if (block & RADEON_CG_BLOCK_GFX) { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5403 | cik_enable_gui_idle_interrupt(rdev, false); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5404 | /* order matters! */ |
| 5405 | if (enable) { |
| 5406 | cik_enable_mgcg(rdev, true); |
| 5407 | cik_enable_cgcg(rdev, true); |
| 5408 | } else { |
| 5409 | cik_enable_cgcg(rdev, false); |
| 5410 | cik_enable_mgcg(rdev, false); |
| 5411 | } |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5412 | cik_enable_gui_idle_interrupt(rdev, true); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5413 | } |
| 5414 | |
| 5415 | if (block & RADEON_CG_BLOCK_MC) { |
| 5416 | if (!(rdev->flags & RADEON_IS_IGP)) { |
| 5417 | cik_enable_mc_mgcg(rdev, enable); |
| 5418 | cik_enable_mc_ls(rdev, enable); |
| 5419 | } |
| 5420 | } |
| 5421 | |
| 5422 | if (block & RADEON_CG_BLOCK_SDMA) { |
| 5423 | cik_enable_sdma_mgcg(rdev, enable); |
| 5424 | cik_enable_sdma_mgls(rdev, enable); |
| 5425 | } |
| 5426 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5427 | if (block & RADEON_CG_BLOCK_BIF) { |
| 5428 | cik_enable_bif_mgls(rdev, enable); |
| 5429 | } |
| 5430 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5431 | if (block & RADEON_CG_BLOCK_UVD) { |
| 5432 | if (rdev->has_uvd) |
| 5433 | cik_enable_uvd_mgcg(rdev, enable); |
| 5434 | } |
| 5435 | |
| 5436 | if (block & RADEON_CG_BLOCK_HDP) { |
| 5437 | cik_enable_hdp_mgcg(rdev, enable); |
| 5438 | cik_enable_hdp_ls(rdev, enable); |
| 5439 | } |
| 5440 | } |
| 5441 | |
| 5442 | static void cik_init_cg(struct radeon_device *rdev) |
| 5443 | { |
| 5444 | |
Alex Deucher | ddc76ff | 2013-08-12 17:25:26 -0400 | [diff] [blame] | 5445 | cik_update_cg(rdev, RADEON_CG_BLOCK_GFX, true); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5446 | |
| 5447 | if (rdev->has_uvd) |
| 5448 | si_init_uvd_internal_cg(rdev); |
| 5449 | |
| 5450 | cik_update_cg(rdev, (RADEON_CG_BLOCK_MC | |
| 5451 | RADEON_CG_BLOCK_SDMA | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5452 | RADEON_CG_BLOCK_BIF | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5453 | RADEON_CG_BLOCK_UVD | |
| 5454 | RADEON_CG_BLOCK_HDP), true); |
| 5455 | } |
| 5456 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5457 | static void cik_fini_cg(struct radeon_device *rdev) |
| 5458 | { |
| 5459 | cik_update_cg(rdev, (RADEON_CG_BLOCK_MC | |
| 5460 | RADEON_CG_BLOCK_SDMA | |
| 5461 | RADEON_CG_BLOCK_BIF | |
| 5462 | RADEON_CG_BLOCK_UVD | |
| 5463 | RADEON_CG_BLOCK_HDP), false); |
| 5464 | |
| 5465 | cik_update_cg(rdev, RADEON_CG_BLOCK_GFX, false); |
| 5466 | } |
| 5467 | |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5468 | static void cik_enable_sck_slowdown_on_pu(struct radeon_device *rdev, |
| 5469 | bool enable) |
| 5470 | { |
| 5471 | u32 data, orig; |
| 5472 | |
| 5473 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5474 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_RLC_SMU_HS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5475 | data |= SMU_CLK_SLOWDOWN_ON_PU_ENABLE; |
| 5476 | else |
| 5477 | data &= ~SMU_CLK_SLOWDOWN_ON_PU_ENABLE; |
| 5478 | if (orig != data) |
| 5479 | WREG32(RLC_PG_CNTL, data); |
| 5480 | } |
| 5481 | |
| 5482 | static void cik_enable_sck_slowdown_on_pd(struct radeon_device *rdev, |
| 5483 | bool enable) |
| 5484 | { |
| 5485 | u32 data, orig; |
| 5486 | |
| 5487 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5488 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_RLC_SMU_HS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5489 | data |= SMU_CLK_SLOWDOWN_ON_PD_ENABLE; |
| 5490 | else |
| 5491 | data &= ~SMU_CLK_SLOWDOWN_ON_PD_ENABLE; |
| 5492 | if (orig != data) |
| 5493 | WREG32(RLC_PG_CNTL, data); |
| 5494 | } |
| 5495 | |
| 5496 | static void cik_enable_cp_pg(struct radeon_device *rdev, bool enable) |
| 5497 | { |
| 5498 | u32 data, orig; |
| 5499 | |
| 5500 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5501 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_CP)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5502 | data &= ~DISABLE_CP_PG; |
| 5503 | else |
| 5504 | data |= DISABLE_CP_PG; |
| 5505 | if (orig != data) |
| 5506 | WREG32(RLC_PG_CNTL, data); |
| 5507 | } |
| 5508 | |
| 5509 | static void cik_enable_gds_pg(struct radeon_device *rdev, bool enable) |
| 5510 | { |
| 5511 | u32 data, orig; |
| 5512 | |
| 5513 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5514 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GDS)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5515 | data &= ~DISABLE_GDS_PG; |
| 5516 | else |
| 5517 | data |= DISABLE_GDS_PG; |
| 5518 | if (orig != data) |
| 5519 | WREG32(RLC_PG_CNTL, data); |
| 5520 | } |
| 5521 | |
| 5522 | #define CP_ME_TABLE_SIZE 96 |
| 5523 | #define CP_ME_TABLE_OFFSET 2048 |
| 5524 | #define CP_MEC_TABLE_OFFSET 4096 |
| 5525 | |
| 5526 | void cik_init_cp_pg_table(struct radeon_device *rdev) |
| 5527 | { |
| 5528 | const __be32 *fw_data; |
| 5529 | volatile u32 *dst_ptr; |
| 5530 | int me, i, max_me = 4; |
| 5531 | u32 bo_offset = 0; |
| 5532 | u32 table_offset; |
| 5533 | |
| 5534 | if (rdev->family == CHIP_KAVERI) |
| 5535 | max_me = 5; |
| 5536 | |
| 5537 | if (rdev->rlc.cp_table_ptr == NULL) |
| 5538 | return; |
| 5539 | |
| 5540 | /* write the cp table buffer */ |
| 5541 | dst_ptr = rdev->rlc.cp_table_ptr; |
| 5542 | for (me = 0; me < max_me; me++) { |
| 5543 | if (me == 0) { |
| 5544 | fw_data = (const __be32 *)rdev->ce_fw->data; |
| 5545 | table_offset = CP_ME_TABLE_OFFSET; |
| 5546 | } else if (me == 1) { |
| 5547 | fw_data = (const __be32 *)rdev->pfp_fw->data; |
| 5548 | table_offset = CP_ME_TABLE_OFFSET; |
| 5549 | } else if (me == 2) { |
| 5550 | fw_data = (const __be32 *)rdev->me_fw->data; |
| 5551 | table_offset = CP_ME_TABLE_OFFSET; |
| 5552 | } else { |
| 5553 | fw_data = (const __be32 *)rdev->mec_fw->data; |
| 5554 | table_offset = CP_MEC_TABLE_OFFSET; |
| 5555 | } |
| 5556 | |
| 5557 | for (i = 0; i < CP_ME_TABLE_SIZE; i ++) { |
| 5558 | dst_ptr[bo_offset + i] = be32_to_cpu(fw_data[table_offset + i]); |
| 5559 | } |
| 5560 | bo_offset += CP_ME_TABLE_SIZE; |
| 5561 | } |
| 5562 | } |
| 5563 | |
| 5564 | static void cik_enable_gfx_cgpg(struct radeon_device *rdev, |
| 5565 | bool enable) |
| 5566 | { |
| 5567 | u32 data, orig; |
| 5568 | |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5569 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG)) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5570 | orig = data = RREG32(RLC_PG_CNTL); |
| 5571 | data |= GFX_PG_ENABLE; |
| 5572 | if (orig != data) |
| 5573 | WREG32(RLC_PG_CNTL, data); |
| 5574 | |
| 5575 | orig = data = RREG32(RLC_AUTO_PG_CTRL); |
| 5576 | data |= AUTO_PG_EN; |
| 5577 | if (orig != data) |
| 5578 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5579 | } else { |
| 5580 | orig = data = RREG32(RLC_PG_CNTL); |
| 5581 | data &= ~GFX_PG_ENABLE; |
| 5582 | if (orig != data) |
| 5583 | WREG32(RLC_PG_CNTL, data); |
| 5584 | |
| 5585 | orig = data = RREG32(RLC_AUTO_PG_CTRL); |
| 5586 | data &= ~AUTO_PG_EN; |
| 5587 | if (orig != data) |
| 5588 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5589 | |
| 5590 | data = RREG32(DB_RENDER_CONTROL); |
| 5591 | } |
| 5592 | } |
| 5593 | |
| 5594 | static u32 cik_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh) |
| 5595 | { |
| 5596 | u32 mask = 0, tmp, tmp1; |
| 5597 | int i; |
| 5598 | |
| 5599 | cik_select_se_sh(rdev, se, sh); |
| 5600 | tmp = RREG32(CC_GC_SHADER_ARRAY_CONFIG); |
| 5601 | tmp1 = RREG32(GC_USER_SHADER_ARRAY_CONFIG); |
| 5602 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
| 5603 | |
| 5604 | tmp &= 0xffff0000; |
| 5605 | |
| 5606 | tmp |= tmp1; |
| 5607 | tmp >>= 16; |
| 5608 | |
| 5609 | for (i = 0; i < rdev->config.cik.max_cu_per_sh; i ++) { |
| 5610 | mask <<= 1; |
| 5611 | mask |= 1; |
| 5612 | } |
| 5613 | |
| 5614 | return (~tmp) & mask; |
| 5615 | } |
| 5616 | |
| 5617 | static void cik_init_ao_cu_mask(struct radeon_device *rdev) |
| 5618 | { |
| 5619 | u32 i, j, k, active_cu_number = 0; |
| 5620 | u32 mask, counter, cu_bitmap; |
| 5621 | u32 tmp = 0; |
| 5622 | |
| 5623 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { |
| 5624 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { |
| 5625 | mask = 1; |
| 5626 | cu_bitmap = 0; |
| 5627 | counter = 0; |
| 5628 | for (k = 0; k < rdev->config.cik.max_cu_per_sh; k ++) { |
| 5629 | if (cik_get_cu_active_bitmap(rdev, i, j) & mask) { |
| 5630 | if (counter < 2) |
| 5631 | cu_bitmap |= mask; |
| 5632 | counter ++; |
| 5633 | } |
| 5634 | mask <<= 1; |
| 5635 | } |
| 5636 | |
| 5637 | active_cu_number += counter; |
| 5638 | tmp |= (cu_bitmap << (i * 16 + j * 8)); |
| 5639 | } |
| 5640 | } |
| 5641 | |
| 5642 | WREG32(RLC_PG_AO_CU_MASK, tmp); |
| 5643 | |
| 5644 | tmp = RREG32(RLC_MAX_PG_CU); |
| 5645 | tmp &= ~MAX_PU_CU_MASK; |
| 5646 | tmp |= MAX_PU_CU(active_cu_number); |
| 5647 | WREG32(RLC_MAX_PG_CU, tmp); |
| 5648 | } |
| 5649 | |
| 5650 | static void cik_enable_gfx_static_mgpg(struct radeon_device *rdev, |
| 5651 | bool enable) |
| 5652 | { |
| 5653 | u32 data, orig; |
| 5654 | |
| 5655 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5656 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_SMG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5657 | data |= STATIC_PER_CU_PG_ENABLE; |
| 5658 | else |
| 5659 | data &= ~STATIC_PER_CU_PG_ENABLE; |
| 5660 | if (orig != data) |
| 5661 | WREG32(RLC_PG_CNTL, data); |
| 5662 | } |
| 5663 | |
| 5664 | static void cik_enable_gfx_dynamic_mgpg(struct radeon_device *rdev, |
| 5665 | bool enable) |
| 5666 | { |
| 5667 | u32 data, orig; |
| 5668 | |
| 5669 | orig = data = RREG32(RLC_PG_CNTL); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5670 | if (enable && (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_DMG)) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5671 | data |= DYN_PER_CU_PG_ENABLE; |
| 5672 | else |
| 5673 | data &= ~DYN_PER_CU_PG_ENABLE; |
| 5674 | if (orig != data) |
| 5675 | WREG32(RLC_PG_CNTL, data); |
| 5676 | } |
| 5677 | |
| 5678 | #define RLC_SAVE_AND_RESTORE_STARTING_OFFSET 0x90 |
| 5679 | #define RLC_CLEAR_STATE_DESCRIPTOR_OFFSET 0x3D |
| 5680 | |
| 5681 | static void cik_init_gfx_cgpg(struct radeon_device *rdev) |
| 5682 | { |
| 5683 | u32 data, orig; |
| 5684 | u32 i; |
| 5685 | |
| 5686 | if (rdev->rlc.cs_data) { |
| 5687 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET); |
| 5688 | WREG32(RLC_GPM_SCRATCH_DATA, upper_32_bits(rdev->rlc.clear_state_gpu_addr)); |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5689 | WREG32(RLC_GPM_SCRATCH_DATA, lower_32_bits(rdev->rlc.clear_state_gpu_addr)); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5690 | WREG32(RLC_GPM_SCRATCH_DATA, rdev->rlc.clear_state_size); |
| 5691 | } else { |
| 5692 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_CLEAR_STATE_DESCRIPTOR_OFFSET); |
| 5693 | for (i = 0; i < 3; i++) |
| 5694 | WREG32(RLC_GPM_SCRATCH_DATA, 0); |
| 5695 | } |
| 5696 | if (rdev->rlc.reg_list) { |
| 5697 | WREG32(RLC_GPM_SCRATCH_ADDR, RLC_SAVE_AND_RESTORE_STARTING_OFFSET); |
| 5698 | for (i = 0; i < rdev->rlc.reg_list_size; i++) |
| 5699 | WREG32(RLC_GPM_SCRATCH_DATA, rdev->rlc.reg_list[i]); |
| 5700 | } |
| 5701 | |
| 5702 | orig = data = RREG32(RLC_PG_CNTL); |
| 5703 | data |= GFX_PG_SRC; |
| 5704 | if (orig != data) |
| 5705 | WREG32(RLC_PG_CNTL, data); |
| 5706 | |
| 5707 | WREG32(RLC_SAVE_AND_RESTORE_BASE, rdev->rlc.save_restore_gpu_addr >> 8); |
| 5708 | WREG32(RLC_CP_TABLE_RESTORE, rdev->rlc.cp_table_gpu_addr >> 8); |
| 5709 | |
| 5710 | data = RREG32(CP_RB_WPTR_POLL_CNTL); |
| 5711 | data &= ~IDLE_POLL_COUNT_MASK; |
| 5712 | data |= IDLE_POLL_COUNT(0x60); |
| 5713 | WREG32(CP_RB_WPTR_POLL_CNTL, data); |
| 5714 | |
| 5715 | data = 0x10101010; |
| 5716 | WREG32(RLC_PG_DELAY, data); |
| 5717 | |
| 5718 | data = RREG32(RLC_PG_DELAY_2); |
| 5719 | data &= ~0xff; |
| 5720 | data |= 0x3; |
| 5721 | WREG32(RLC_PG_DELAY_2, data); |
| 5722 | |
| 5723 | data = RREG32(RLC_AUTO_PG_CTRL); |
| 5724 | data &= ~GRBM_REG_SGIT_MASK; |
| 5725 | data |= GRBM_REG_SGIT(0x700); |
| 5726 | WREG32(RLC_AUTO_PG_CTRL, data); |
| 5727 | |
| 5728 | } |
| 5729 | |
| 5730 | static void cik_update_gfx_pg(struct radeon_device *rdev, bool enable) |
| 5731 | { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5732 | cik_enable_gfx_cgpg(rdev, enable); |
| 5733 | cik_enable_gfx_static_mgpg(rdev, enable); |
| 5734 | cik_enable_gfx_dynamic_mgpg(rdev, enable); |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5735 | } |
| 5736 | |
Alex Deucher | a0f3860 | 2013-08-22 11:57:46 -0400 | [diff] [blame] | 5737 | u32 cik_get_csb_size(struct radeon_device *rdev) |
| 5738 | { |
| 5739 | u32 count = 0; |
| 5740 | const struct cs_section_def *sect = NULL; |
| 5741 | const struct cs_extent_def *ext = NULL; |
| 5742 | |
| 5743 | if (rdev->rlc.cs_data == NULL) |
| 5744 | return 0; |
| 5745 | |
| 5746 | /* begin clear state */ |
| 5747 | count += 2; |
| 5748 | /* context control state */ |
| 5749 | count += 3; |
| 5750 | |
| 5751 | for (sect = rdev->rlc.cs_data; sect->section != NULL; ++sect) { |
| 5752 | for (ext = sect->section; ext->extent != NULL; ++ext) { |
| 5753 | if (sect->id == SECT_CONTEXT) |
| 5754 | count += 2 + ext->reg_count; |
| 5755 | else |
| 5756 | return 0; |
| 5757 | } |
| 5758 | } |
| 5759 | /* pa_sc_raster_config/pa_sc_raster_config1 */ |
| 5760 | count += 4; |
| 5761 | /* end clear state */ |
| 5762 | count += 2; |
| 5763 | /* clear state */ |
| 5764 | count += 2; |
| 5765 | |
| 5766 | return count; |
| 5767 | } |
| 5768 | |
| 5769 | void cik_get_csb_buffer(struct radeon_device *rdev, volatile u32 *buffer) |
| 5770 | { |
| 5771 | u32 count = 0, i; |
| 5772 | const struct cs_section_def *sect = NULL; |
| 5773 | const struct cs_extent_def *ext = NULL; |
| 5774 | |
| 5775 | if (rdev->rlc.cs_data == NULL) |
| 5776 | return; |
| 5777 | if (buffer == NULL) |
| 5778 | return; |
| 5779 | |
| 5780 | buffer[count++] = PACKET3(PACKET3_PREAMBLE_CNTL, 0); |
| 5781 | buffer[count++] = PACKET3_PREAMBLE_BEGIN_CLEAR_STATE; |
| 5782 | |
| 5783 | buffer[count++] = PACKET3(PACKET3_CONTEXT_CONTROL, 1); |
| 5784 | buffer[count++] = 0x80000000; |
| 5785 | buffer[count++] = 0x80000000; |
| 5786 | |
| 5787 | for (sect = rdev->rlc.cs_data; sect->section != NULL; ++sect) { |
| 5788 | for (ext = sect->section; ext->extent != NULL; ++ext) { |
| 5789 | if (sect->id == SECT_CONTEXT) { |
| 5790 | buffer[count++] = PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count); |
| 5791 | buffer[count++] = ext->reg_index - 0xa000; |
| 5792 | for (i = 0; i < ext->reg_count; i++) |
| 5793 | buffer[count++] = ext->extent[i]; |
| 5794 | } else { |
| 5795 | return; |
| 5796 | } |
| 5797 | } |
| 5798 | } |
| 5799 | |
| 5800 | buffer[count++] = PACKET3(PACKET3_SET_CONTEXT_REG, 2); |
| 5801 | buffer[count++] = PA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START; |
| 5802 | switch (rdev->family) { |
| 5803 | case CHIP_BONAIRE: |
| 5804 | buffer[count++] = 0x16000012; |
| 5805 | buffer[count++] = 0x00000000; |
| 5806 | break; |
| 5807 | case CHIP_KAVERI: |
| 5808 | buffer[count++] = 0x00000000; /* XXX */ |
| 5809 | buffer[count++] = 0x00000000; |
| 5810 | break; |
| 5811 | case CHIP_KABINI: |
| 5812 | buffer[count++] = 0x00000000; /* XXX */ |
| 5813 | buffer[count++] = 0x00000000; |
| 5814 | break; |
| 5815 | default: |
| 5816 | buffer[count++] = 0x00000000; |
| 5817 | buffer[count++] = 0x00000000; |
| 5818 | break; |
| 5819 | } |
| 5820 | |
| 5821 | buffer[count++] = PACKET3(PACKET3_PREAMBLE_CNTL, 0); |
| 5822 | buffer[count++] = PACKET3_PREAMBLE_END_CLEAR_STATE; |
| 5823 | |
| 5824 | buffer[count++] = PACKET3(PACKET3_CLEAR_STATE, 0); |
| 5825 | buffer[count++] = 0; |
| 5826 | } |
| 5827 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5828 | static void cik_init_pg(struct radeon_device *rdev) |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5829 | { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5830 | if (rdev->pg_flags) { |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5831 | cik_enable_sck_slowdown_on_pu(rdev, true); |
| 5832 | cik_enable_sck_slowdown_on_pd(rdev, true); |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5833 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5834 | cik_init_gfx_cgpg(rdev); |
| 5835 | cik_enable_cp_pg(rdev, true); |
| 5836 | cik_enable_gds_pg(rdev, true); |
| 5837 | } |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 5838 | cik_init_ao_cu_mask(rdev); |
| 5839 | cik_update_gfx_pg(rdev, true); |
| 5840 | } |
| 5841 | } |
| 5842 | |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5843 | static void cik_fini_pg(struct radeon_device *rdev) |
| 5844 | { |
| 5845 | if (rdev->pg_flags) { |
| 5846 | cik_update_gfx_pg(rdev, false); |
Alex Deucher | 2b19d17 | 2013-09-04 16:58:29 -0400 | [diff] [blame] | 5847 | if (rdev->pg_flags & RADEON_PG_SUPPORT_GFX_PG) { |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 5848 | cik_enable_cp_pg(rdev, false); |
| 5849 | cik_enable_gds_pg(rdev, false); |
| 5850 | } |
| 5851 | } |
| 5852 | } |
| 5853 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5854 | /* |
| 5855 | * Interrupts |
| 5856 | * Starting with r6xx, interrupts are handled via a ring buffer. |
| 5857 | * Ring buffers are areas of GPU accessible memory that the GPU |
| 5858 | * writes interrupt vectors into and the host reads vectors out of. |
| 5859 | * There is a rptr (read pointer) that determines where the |
| 5860 | * host is currently reading, and a wptr (write pointer) |
| 5861 | * which determines where the GPU has written. When the |
| 5862 | * pointers are equal, the ring is idle. When the GPU |
| 5863 | * writes vectors to the ring buffer, it increments the |
| 5864 | * wptr. When there is an interrupt, the host then starts |
| 5865 | * fetching commands and processing them until the pointers are |
| 5866 | * equal again at which point it updates the rptr. |
| 5867 | */ |
| 5868 | |
| 5869 | /** |
| 5870 | * cik_enable_interrupts - Enable the interrupt ring buffer |
| 5871 | * |
| 5872 | * @rdev: radeon_device pointer |
| 5873 | * |
| 5874 | * Enable the interrupt ring buffer (CIK). |
| 5875 | */ |
| 5876 | static void cik_enable_interrupts(struct radeon_device *rdev) |
| 5877 | { |
| 5878 | u32 ih_cntl = RREG32(IH_CNTL); |
| 5879 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 5880 | |
| 5881 | ih_cntl |= ENABLE_INTR; |
| 5882 | ih_rb_cntl |= IH_RB_ENABLE; |
| 5883 | WREG32(IH_CNTL, ih_cntl); |
| 5884 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 5885 | rdev->ih.enabled = true; |
| 5886 | } |
| 5887 | |
| 5888 | /** |
| 5889 | * cik_disable_interrupts - Disable the interrupt ring buffer |
| 5890 | * |
| 5891 | * @rdev: radeon_device pointer |
| 5892 | * |
| 5893 | * Disable the interrupt ring buffer (CIK). |
| 5894 | */ |
| 5895 | static void cik_disable_interrupts(struct radeon_device *rdev) |
| 5896 | { |
| 5897 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
| 5898 | u32 ih_cntl = RREG32(IH_CNTL); |
| 5899 | |
| 5900 | ih_rb_cntl &= ~IH_RB_ENABLE; |
| 5901 | ih_cntl &= ~ENABLE_INTR; |
| 5902 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 5903 | WREG32(IH_CNTL, ih_cntl); |
| 5904 | /* set rptr, wptr to 0 */ |
| 5905 | WREG32(IH_RB_RPTR, 0); |
| 5906 | WREG32(IH_RB_WPTR, 0); |
| 5907 | rdev->ih.enabled = false; |
| 5908 | rdev->ih.rptr = 0; |
| 5909 | } |
| 5910 | |
| 5911 | /** |
| 5912 | * cik_disable_interrupt_state - Disable all interrupt sources |
| 5913 | * |
| 5914 | * @rdev: radeon_device pointer |
| 5915 | * |
| 5916 | * Clear all interrupt enable bits used by the driver (CIK). |
| 5917 | */ |
| 5918 | static void cik_disable_interrupt_state(struct radeon_device *rdev) |
| 5919 | { |
| 5920 | u32 tmp; |
| 5921 | |
| 5922 | /* gfx ring */ |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 5923 | tmp = RREG32(CP_INT_CNTL_RING0) & |
| 5924 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 5925 | WREG32(CP_INT_CNTL_RING0, tmp); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 5926 | /* sdma */ |
| 5927 | tmp = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 5928 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, tmp); |
| 5929 | tmp = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 5930 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, tmp); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 5931 | /* compute queues */ |
| 5932 | WREG32(CP_ME1_PIPE0_INT_CNTL, 0); |
| 5933 | WREG32(CP_ME1_PIPE1_INT_CNTL, 0); |
| 5934 | WREG32(CP_ME1_PIPE2_INT_CNTL, 0); |
| 5935 | WREG32(CP_ME1_PIPE3_INT_CNTL, 0); |
| 5936 | WREG32(CP_ME2_PIPE0_INT_CNTL, 0); |
| 5937 | WREG32(CP_ME2_PIPE1_INT_CNTL, 0); |
| 5938 | WREG32(CP_ME2_PIPE2_INT_CNTL, 0); |
| 5939 | WREG32(CP_ME2_PIPE3_INT_CNTL, 0); |
| 5940 | /* grbm */ |
| 5941 | WREG32(GRBM_INT_CNTL, 0); |
| 5942 | /* vline/vblank, etc. */ |
| 5943 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); |
| 5944 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); |
| 5945 | if (rdev->num_crtc >= 4) { |
| 5946 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); |
| 5947 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); |
| 5948 | } |
| 5949 | if (rdev->num_crtc >= 6) { |
| 5950 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); |
| 5951 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); |
| 5952 | } |
| 5953 | |
| 5954 | /* dac hotplug */ |
| 5955 | WREG32(DAC_AUTODETECT_INT_CONTROL, 0); |
| 5956 | |
| 5957 | /* digital hotplug */ |
| 5958 | tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5959 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 5960 | tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5961 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 5962 | tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5963 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 5964 | tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5965 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 5966 | tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5967 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 5968 | tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; |
| 5969 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 5970 | |
| 5971 | } |
| 5972 | |
| 5973 | /** |
| 5974 | * cik_irq_init - init and enable the interrupt ring |
| 5975 | * |
| 5976 | * @rdev: radeon_device pointer |
| 5977 | * |
| 5978 | * Allocate a ring buffer for the interrupt controller, |
| 5979 | * enable the RLC, disable interrupts, enable the IH |
| 5980 | * ring buffer and enable it (CIK). |
| 5981 | * Called at device load and reume. |
| 5982 | * Returns 0 for success, errors for failure. |
| 5983 | */ |
| 5984 | static int cik_irq_init(struct radeon_device *rdev) |
| 5985 | { |
| 5986 | int ret = 0; |
| 5987 | int rb_bufsz; |
| 5988 | u32 interrupt_cntl, ih_cntl, ih_rb_cntl; |
| 5989 | |
| 5990 | /* allocate ring */ |
| 5991 | ret = r600_ih_ring_alloc(rdev); |
| 5992 | if (ret) |
| 5993 | return ret; |
| 5994 | |
| 5995 | /* disable irqs */ |
| 5996 | cik_disable_interrupts(rdev); |
| 5997 | |
| 5998 | /* init rlc */ |
| 5999 | ret = cik_rlc_resume(rdev); |
| 6000 | if (ret) { |
| 6001 | r600_ih_ring_fini(rdev); |
| 6002 | return ret; |
| 6003 | } |
| 6004 | |
| 6005 | /* setup interrupt control */ |
| 6006 | /* XXX this should actually be a bus address, not an MC address. same on older asics */ |
| 6007 | WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); |
| 6008 | interrupt_cntl = RREG32(INTERRUPT_CNTL); |
| 6009 | /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi |
| 6010 | * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN |
| 6011 | */ |
| 6012 | interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE; |
| 6013 | /* IH_REQ_NONSNOOP_EN=1 if ring is in non-cacheable memory, e.g., vram */ |
| 6014 | interrupt_cntl &= ~IH_REQ_NONSNOOP_EN; |
| 6015 | WREG32(INTERRUPT_CNTL, interrupt_cntl); |
| 6016 | |
| 6017 | WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8); |
Daniel Vetter | b72a892 | 2013-07-10 14:11:59 +0200 | [diff] [blame] | 6018 | rb_bufsz = order_base_2(rdev->ih.ring_size / 4); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6019 | |
| 6020 | ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE | |
| 6021 | IH_WPTR_OVERFLOW_CLEAR | |
| 6022 | (rb_bufsz << 1)); |
| 6023 | |
| 6024 | if (rdev->wb.enabled) |
| 6025 | ih_rb_cntl |= IH_WPTR_WRITEBACK_ENABLE; |
| 6026 | |
| 6027 | /* set the writeback address whether it's enabled or not */ |
| 6028 | WREG32(IH_RB_WPTR_ADDR_LO, (rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFFFFFFFC); |
| 6029 | WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFF); |
| 6030 | |
| 6031 | WREG32(IH_RB_CNTL, ih_rb_cntl); |
| 6032 | |
| 6033 | /* set rptr, wptr to 0 */ |
| 6034 | WREG32(IH_RB_RPTR, 0); |
| 6035 | WREG32(IH_RB_WPTR, 0); |
| 6036 | |
| 6037 | /* Default settings for IH_CNTL (disabled at first) */ |
| 6038 | ih_cntl = MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10) | MC_VMID(0); |
| 6039 | /* RPTR_REARM only works if msi's are enabled */ |
| 6040 | if (rdev->msi_enabled) |
| 6041 | ih_cntl |= RPTR_REARM; |
| 6042 | WREG32(IH_CNTL, ih_cntl); |
| 6043 | |
| 6044 | /* force the active interrupt state to all disabled */ |
| 6045 | cik_disable_interrupt_state(rdev); |
| 6046 | |
| 6047 | pci_set_master(rdev->pdev); |
| 6048 | |
| 6049 | /* enable irqs */ |
| 6050 | cik_enable_interrupts(rdev); |
| 6051 | |
| 6052 | return ret; |
| 6053 | } |
| 6054 | |
| 6055 | /** |
| 6056 | * cik_irq_set - enable/disable interrupt sources |
| 6057 | * |
| 6058 | * @rdev: radeon_device pointer |
| 6059 | * |
| 6060 | * Enable interrupt sources on the GPU (vblanks, hpd, |
| 6061 | * etc.) (CIK). |
| 6062 | * Returns 0 for success, errors for failure. |
| 6063 | */ |
| 6064 | int cik_irq_set(struct radeon_device *rdev) |
| 6065 | { |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 6066 | u32 cp_int_cntl; |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6067 | u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; |
| 6068 | u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6069 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
| 6070 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; |
| 6071 | u32 grbm_int_cntl = 0; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6072 | u32 dma_cntl, dma_cntl1; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6073 | u32 thermal_int; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6074 | |
| 6075 | if (!rdev->irq.installed) { |
| 6076 | WARN(1, "Can't enable IRQ/MSI because no handler is installed\n"); |
| 6077 | return -EINVAL; |
| 6078 | } |
| 6079 | /* don't enable anything if the ih is disabled */ |
| 6080 | if (!rdev->ih.enabled) { |
| 6081 | cik_disable_interrupts(rdev); |
| 6082 | /* force the active interrupt state to all disabled */ |
| 6083 | cik_disable_interrupt_state(rdev); |
| 6084 | return 0; |
| 6085 | } |
| 6086 | |
Alex Deucher | 4214faf | 2013-09-03 10:17:13 -0400 | [diff] [blame] | 6087 | cp_int_cntl = RREG32(CP_INT_CNTL_RING0) & |
| 6088 | (CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE); |
| 6089 | cp_int_cntl |= PRIV_INSTR_INT_ENABLE | PRIV_REG_INT_ENABLE; |
| 6090 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6091 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6092 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6093 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6094 | hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6095 | hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6096 | hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN; |
| 6097 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6098 | dma_cntl = RREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 6099 | dma_cntl1 = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; |
| 6100 | |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6101 | cp_m1p0 = RREG32(CP_ME1_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6102 | cp_m1p1 = RREG32(CP_ME1_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6103 | cp_m1p2 = RREG32(CP_ME1_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6104 | cp_m1p3 = RREG32(CP_ME1_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6105 | cp_m2p0 = RREG32(CP_ME2_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6106 | cp_m2p1 = RREG32(CP_ME2_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6107 | cp_m2p2 = RREG32(CP_ME2_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6108 | cp_m2p3 = RREG32(CP_ME2_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
| 6109 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6110 | if (rdev->flags & RADEON_IS_IGP) |
| 6111 | thermal_int = RREG32_SMC(CG_THERMAL_INT_CTRL) & |
| 6112 | ~(THERM_INTH_MASK | THERM_INTL_MASK); |
| 6113 | else |
| 6114 | thermal_int = RREG32_SMC(CG_THERMAL_INT) & |
| 6115 | ~(THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6116 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6117 | /* enable CP interrupts on all rings */ |
| 6118 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { |
| 6119 | DRM_DEBUG("cik_irq_set: sw int gfx\n"); |
| 6120 | cp_int_cntl |= TIME_STAMP_INT_ENABLE; |
| 6121 | } |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6122 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_CP1_INDEX])) { |
| 6123 | struct radeon_ring *ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 6124 | DRM_DEBUG("si_irq_set: sw int cp1\n"); |
| 6125 | if (ring->me == 1) { |
| 6126 | switch (ring->pipe) { |
| 6127 | case 0: |
| 6128 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
| 6129 | break; |
| 6130 | case 1: |
| 6131 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; |
| 6132 | break; |
| 6133 | case 2: |
| 6134 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6135 | break; |
| 6136 | case 3: |
| 6137 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6138 | break; |
| 6139 | default: |
| 6140 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); |
| 6141 | break; |
| 6142 | } |
| 6143 | } else if (ring->me == 2) { |
| 6144 | switch (ring->pipe) { |
| 6145 | case 0: |
| 6146 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; |
| 6147 | break; |
| 6148 | case 1: |
| 6149 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; |
| 6150 | break; |
| 6151 | case 2: |
| 6152 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6153 | break; |
| 6154 | case 3: |
| 6155 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6156 | break; |
| 6157 | default: |
| 6158 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); |
| 6159 | break; |
| 6160 | } |
| 6161 | } else { |
| 6162 | DRM_DEBUG("si_irq_set: sw int cp1 invalid me %d\n", ring->me); |
| 6163 | } |
| 6164 | } |
| 6165 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_CP2_INDEX])) { |
| 6166 | struct radeon_ring *ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 6167 | DRM_DEBUG("si_irq_set: sw int cp2\n"); |
| 6168 | if (ring->me == 1) { |
| 6169 | switch (ring->pipe) { |
| 6170 | case 0: |
| 6171 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
| 6172 | break; |
| 6173 | case 1: |
| 6174 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; |
| 6175 | break; |
| 6176 | case 2: |
| 6177 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6178 | break; |
| 6179 | case 3: |
| 6180 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; |
| 6181 | break; |
| 6182 | default: |
| 6183 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); |
| 6184 | break; |
| 6185 | } |
| 6186 | } else if (ring->me == 2) { |
| 6187 | switch (ring->pipe) { |
| 6188 | case 0: |
| 6189 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; |
| 6190 | break; |
| 6191 | case 1: |
| 6192 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; |
| 6193 | break; |
| 6194 | case 2: |
| 6195 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6196 | break; |
| 6197 | case 3: |
| 6198 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; |
| 6199 | break; |
| 6200 | default: |
| 6201 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); |
| 6202 | break; |
| 6203 | } |
| 6204 | } else { |
| 6205 | DRM_DEBUG("si_irq_set: sw int cp2 invalid me %d\n", ring->me); |
| 6206 | } |
| 6207 | } |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6208 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6209 | if (atomic_read(&rdev->irq.ring_int[R600_RING_TYPE_DMA_INDEX])) { |
| 6210 | DRM_DEBUG("cik_irq_set: sw int dma\n"); |
| 6211 | dma_cntl |= TRAP_ENABLE; |
| 6212 | } |
| 6213 | |
| 6214 | if (atomic_read(&rdev->irq.ring_int[CAYMAN_RING_TYPE_DMA1_INDEX])) { |
| 6215 | DRM_DEBUG("cik_irq_set: sw int dma1\n"); |
| 6216 | dma_cntl1 |= TRAP_ENABLE; |
| 6217 | } |
| 6218 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6219 | if (rdev->irq.crtc_vblank_int[0] || |
| 6220 | atomic_read(&rdev->irq.pflip[0])) { |
| 6221 | DRM_DEBUG("cik_irq_set: vblank 0\n"); |
| 6222 | crtc1 |= VBLANK_INTERRUPT_MASK; |
| 6223 | } |
| 6224 | if (rdev->irq.crtc_vblank_int[1] || |
| 6225 | atomic_read(&rdev->irq.pflip[1])) { |
| 6226 | DRM_DEBUG("cik_irq_set: vblank 1\n"); |
| 6227 | crtc2 |= VBLANK_INTERRUPT_MASK; |
| 6228 | } |
| 6229 | if (rdev->irq.crtc_vblank_int[2] || |
| 6230 | atomic_read(&rdev->irq.pflip[2])) { |
| 6231 | DRM_DEBUG("cik_irq_set: vblank 2\n"); |
| 6232 | crtc3 |= VBLANK_INTERRUPT_MASK; |
| 6233 | } |
| 6234 | if (rdev->irq.crtc_vblank_int[3] || |
| 6235 | atomic_read(&rdev->irq.pflip[3])) { |
| 6236 | DRM_DEBUG("cik_irq_set: vblank 3\n"); |
| 6237 | crtc4 |= VBLANK_INTERRUPT_MASK; |
| 6238 | } |
| 6239 | if (rdev->irq.crtc_vblank_int[4] || |
| 6240 | atomic_read(&rdev->irq.pflip[4])) { |
| 6241 | DRM_DEBUG("cik_irq_set: vblank 4\n"); |
| 6242 | crtc5 |= VBLANK_INTERRUPT_MASK; |
| 6243 | } |
| 6244 | if (rdev->irq.crtc_vblank_int[5] || |
| 6245 | atomic_read(&rdev->irq.pflip[5])) { |
| 6246 | DRM_DEBUG("cik_irq_set: vblank 5\n"); |
| 6247 | crtc6 |= VBLANK_INTERRUPT_MASK; |
| 6248 | } |
| 6249 | if (rdev->irq.hpd[0]) { |
| 6250 | DRM_DEBUG("cik_irq_set: hpd 1\n"); |
| 6251 | hpd1 |= DC_HPDx_INT_EN; |
| 6252 | } |
| 6253 | if (rdev->irq.hpd[1]) { |
| 6254 | DRM_DEBUG("cik_irq_set: hpd 2\n"); |
| 6255 | hpd2 |= DC_HPDx_INT_EN; |
| 6256 | } |
| 6257 | if (rdev->irq.hpd[2]) { |
| 6258 | DRM_DEBUG("cik_irq_set: hpd 3\n"); |
| 6259 | hpd3 |= DC_HPDx_INT_EN; |
| 6260 | } |
| 6261 | if (rdev->irq.hpd[3]) { |
| 6262 | DRM_DEBUG("cik_irq_set: hpd 4\n"); |
| 6263 | hpd4 |= DC_HPDx_INT_EN; |
| 6264 | } |
| 6265 | if (rdev->irq.hpd[4]) { |
| 6266 | DRM_DEBUG("cik_irq_set: hpd 5\n"); |
| 6267 | hpd5 |= DC_HPDx_INT_EN; |
| 6268 | } |
| 6269 | if (rdev->irq.hpd[5]) { |
| 6270 | DRM_DEBUG("cik_irq_set: hpd 6\n"); |
| 6271 | hpd6 |= DC_HPDx_INT_EN; |
| 6272 | } |
| 6273 | |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6274 | if (rdev->irq.dpm_thermal) { |
| 6275 | DRM_DEBUG("dpm thermal\n"); |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6276 | if (rdev->flags & RADEON_IS_IGP) |
| 6277 | thermal_int |= THERM_INTH_MASK | THERM_INTL_MASK; |
| 6278 | else |
| 6279 | thermal_int |= THERM_INT_MASK_HIGH | THERM_INT_MASK_LOW; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6280 | } |
| 6281 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6282 | WREG32(CP_INT_CNTL_RING0, cp_int_cntl); |
| 6283 | |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6284 | WREG32(SDMA0_CNTL + SDMA0_REGISTER_OFFSET, dma_cntl); |
| 6285 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, dma_cntl1); |
| 6286 | |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6287 | WREG32(CP_ME1_PIPE0_INT_CNTL, cp_m1p0); |
| 6288 | WREG32(CP_ME1_PIPE1_INT_CNTL, cp_m1p1); |
| 6289 | WREG32(CP_ME1_PIPE2_INT_CNTL, cp_m1p2); |
| 6290 | WREG32(CP_ME1_PIPE3_INT_CNTL, cp_m1p3); |
| 6291 | WREG32(CP_ME2_PIPE0_INT_CNTL, cp_m2p0); |
| 6292 | WREG32(CP_ME2_PIPE1_INT_CNTL, cp_m2p1); |
| 6293 | WREG32(CP_ME2_PIPE2_INT_CNTL, cp_m2p2); |
| 6294 | WREG32(CP_ME2_PIPE3_INT_CNTL, cp_m2p3); |
| 6295 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6296 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); |
| 6297 | |
| 6298 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1); |
| 6299 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2); |
| 6300 | if (rdev->num_crtc >= 4) { |
| 6301 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3); |
| 6302 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4); |
| 6303 | } |
| 6304 | if (rdev->num_crtc >= 6) { |
| 6305 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5); |
| 6306 | WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6); |
| 6307 | } |
| 6308 | |
| 6309 | WREG32(DC_HPD1_INT_CONTROL, hpd1); |
| 6310 | WREG32(DC_HPD2_INT_CONTROL, hpd2); |
| 6311 | WREG32(DC_HPD3_INT_CONTROL, hpd3); |
| 6312 | WREG32(DC_HPD4_INT_CONTROL, hpd4); |
| 6313 | WREG32(DC_HPD5_INT_CONTROL, hpd5); |
| 6314 | WREG32(DC_HPD6_INT_CONTROL, hpd6); |
| 6315 | |
Alex Deucher | cc8dbbb | 2013-08-14 01:03:41 -0400 | [diff] [blame] | 6316 | if (rdev->flags & RADEON_IS_IGP) |
| 6317 | WREG32_SMC(CG_THERMAL_INT_CTRL, thermal_int); |
| 6318 | else |
| 6319 | WREG32_SMC(CG_THERMAL_INT, thermal_int); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6320 | |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6321 | return 0; |
| 6322 | } |
| 6323 | |
| 6324 | /** |
| 6325 | * cik_irq_ack - ack interrupt sources |
| 6326 | * |
| 6327 | * @rdev: radeon_device pointer |
| 6328 | * |
| 6329 | * Ack interrupt sources on the GPU (vblanks, hpd, |
| 6330 | * etc.) (CIK). Certain interrupts sources are sw |
| 6331 | * generated and do not require an explicit ack. |
| 6332 | */ |
| 6333 | static inline void cik_irq_ack(struct radeon_device *rdev) |
| 6334 | { |
| 6335 | u32 tmp; |
| 6336 | |
| 6337 | rdev->irq.stat_regs.cik.disp_int = RREG32(DISP_INTERRUPT_STATUS); |
| 6338 | rdev->irq.stat_regs.cik.disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE); |
| 6339 | rdev->irq.stat_regs.cik.disp_int_cont2 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE2); |
| 6340 | rdev->irq.stat_regs.cik.disp_int_cont3 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE3); |
| 6341 | rdev->irq.stat_regs.cik.disp_int_cont4 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE4); |
| 6342 | rdev->irq.stat_regs.cik.disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5); |
| 6343 | rdev->irq.stat_regs.cik.disp_int_cont6 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE6); |
| 6344 | |
| 6345 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT) |
| 6346 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK); |
| 6347 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT) |
| 6348 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK); |
| 6349 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT) |
| 6350 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK); |
| 6351 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT) |
| 6352 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK); |
| 6353 | |
| 6354 | if (rdev->num_crtc >= 4) { |
| 6355 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) |
| 6356 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); |
| 6357 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) |
| 6358 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); |
| 6359 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) |
| 6360 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); |
| 6361 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) |
| 6362 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); |
| 6363 | } |
| 6364 | |
| 6365 | if (rdev->num_crtc >= 6) { |
| 6366 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) |
| 6367 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); |
| 6368 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) |
| 6369 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); |
| 6370 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) |
| 6371 | WREG32(LB_VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); |
| 6372 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) |
| 6373 | WREG32(LB_VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); |
| 6374 | } |
| 6375 | |
| 6376 | if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT) { |
| 6377 | tmp = RREG32(DC_HPD1_INT_CONTROL); |
| 6378 | tmp |= DC_HPDx_INT_ACK; |
| 6379 | WREG32(DC_HPD1_INT_CONTROL, tmp); |
| 6380 | } |
| 6381 | if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT) { |
| 6382 | tmp = RREG32(DC_HPD2_INT_CONTROL); |
| 6383 | tmp |= DC_HPDx_INT_ACK; |
| 6384 | WREG32(DC_HPD2_INT_CONTROL, tmp); |
| 6385 | } |
| 6386 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
| 6387 | tmp = RREG32(DC_HPD3_INT_CONTROL); |
| 6388 | tmp |= DC_HPDx_INT_ACK; |
| 6389 | WREG32(DC_HPD3_INT_CONTROL, tmp); |
| 6390 | } |
| 6391 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
| 6392 | tmp = RREG32(DC_HPD4_INT_CONTROL); |
| 6393 | tmp |= DC_HPDx_INT_ACK; |
| 6394 | WREG32(DC_HPD4_INT_CONTROL, tmp); |
| 6395 | } |
| 6396 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
| 6397 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 6398 | tmp |= DC_HPDx_INT_ACK; |
| 6399 | WREG32(DC_HPD5_INT_CONTROL, tmp); |
| 6400 | } |
| 6401 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
| 6402 | tmp = RREG32(DC_HPD5_INT_CONTROL); |
| 6403 | tmp |= DC_HPDx_INT_ACK; |
| 6404 | WREG32(DC_HPD6_INT_CONTROL, tmp); |
| 6405 | } |
| 6406 | } |
| 6407 | |
| 6408 | /** |
| 6409 | * cik_irq_disable - disable interrupts |
| 6410 | * |
| 6411 | * @rdev: radeon_device pointer |
| 6412 | * |
| 6413 | * Disable interrupts on the hw (CIK). |
| 6414 | */ |
| 6415 | static void cik_irq_disable(struct radeon_device *rdev) |
| 6416 | { |
| 6417 | cik_disable_interrupts(rdev); |
| 6418 | /* Wait and acknowledge irq */ |
| 6419 | mdelay(1); |
| 6420 | cik_irq_ack(rdev); |
| 6421 | cik_disable_interrupt_state(rdev); |
| 6422 | } |
| 6423 | |
| 6424 | /** |
| 6425 | * cik_irq_disable - disable interrupts for suspend |
| 6426 | * |
| 6427 | * @rdev: radeon_device pointer |
| 6428 | * |
| 6429 | * Disable interrupts and stop the RLC (CIK). |
| 6430 | * Used for suspend. |
| 6431 | */ |
| 6432 | static void cik_irq_suspend(struct radeon_device *rdev) |
| 6433 | { |
| 6434 | cik_irq_disable(rdev); |
| 6435 | cik_rlc_stop(rdev); |
| 6436 | } |
| 6437 | |
| 6438 | /** |
| 6439 | * cik_irq_fini - tear down interrupt support |
| 6440 | * |
| 6441 | * @rdev: radeon_device pointer |
| 6442 | * |
| 6443 | * Disable interrupts on the hw and free the IH ring |
| 6444 | * buffer (CIK). |
| 6445 | * Used for driver unload. |
| 6446 | */ |
| 6447 | static void cik_irq_fini(struct radeon_device *rdev) |
| 6448 | { |
| 6449 | cik_irq_suspend(rdev); |
| 6450 | r600_ih_ring_fini(rdev); |
| 6451 | } |
| 6452 | |
| 6453 | /** |
| 6454 | * cik_get_ih_wptr - get the IH ring buffer wptr |
| 6455 | * |
| 6456 | * @rdev: radeon_device pointer |
| 6457 | * |
| 6458 | * Get the IH ring buffer wptr from either the register |
| 6459 | * or the writeback memory buffer (CIK). Also check for |
| 6460 | * ring buffer overflow and deal with it. |
| 6461 | * Used by cik_irq_process(). |
| 6462 | * Returns the value of the wptr. |
| 6463 | */ |
| 6464 | static inline u32 cik_get_ih_wptr(struct radeon_device *rdev) |
| 6465 | { |
| 6466 | u32 wptr, tmp; |
| 6467 | |
| 6468 | if (rdev->wb.enabled) |
| 6469 | wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]); |
| 6470 | else |
| 6471 | wptr = RREG32(IH_RB_WPTR); |
| 6472 | |
| 6473 | if (wptr & RB_OVERFLOW) { |
| 6474 | /* When a ring buffer overflow happen start parsing interrupt |
| 6475 | * from the last not overwritten vector (wptr + 16). Hopefully |
| 6476 | * this should allow us to catchup. |
| 6477 | */ |
| 6478 | dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", |
| 6479 | wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); |
| 6480 | rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; |
| 6481 | tmp = RREG32(IH_RB_CNTL); |
| 6482 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 6483 | WREG32(IH_RB_CNTL, tmp); |
| 6484 | } |
| 6485 | return (wptr & rdev->ih.ptr_mask); |
| 6486 | } |
| 6487 | |
| 6488 | /* CIK IV Ring |
| 6489 | * Each IV ring entry is 128 bits: |
| 6490 | * [7:0] - interrupt source id |
| 6491 | * [31:8] - reserved |
| 6492 | * [59:32] - interrupt source data |
| 6493 | * [63:60] - reserved |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6494 | * [71:64] - RINGID |
| 6495 | * CP: |
| 6496 | * ME_ID [1:0], PIPE_ID[1:0], QUEUE_ID[2:0] |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6497 | * QUEUE_ID - for compute, which of the 8 queues owned by the dispatcher |
| 6498 | * - for gfx, hw shader state (0=PS...5=LS, 6=CS) |
| 6499 | * ME_ID - 0 = gfx, 1 = first 4 CS pipes, 2 = second 4 CS pipes |
| 6500 | * PIPE_ID - ME0 0=3D |
| 6501 | * - ME1&2 compute dispatcher (4 pipes each) |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6502 | * SDMA: |
| 6503 | * INSTANCE_ID [1:0], QUEUE_ID[1:0] |
| 6504 | * INSTANCE_ID - 0 = sdma0, 1 = sdma1 |
| 6505 | * QUEUE_ID - 0 = gfx, 1 = rlc0, 2 = rlc1 |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6506 | * [79:72] - VMID |
| 6507 | * [95:80] - PASID |
| 6508 | * [127:96] - reserved |
| 6509 | */ |
| 6510 | /** |
| 6511 | * cik_irq_process - interrupt handler |
| 6512 | * |
| 6513 | * @rdev: radeon_device pointer |
| 6514 | * |
| 6515 | * Interrupt hander (CIK). Walk the IH ring, |
| 6516 | * ack interrupts and schedule work to handle |
| 6517 | * interrupt events. |
| 6518 | * Returns irq process return code. |
| 6519 | */ |
| 6520 | int cik_irq_process(struct radeon_device *rdev) |
| 6521 | { |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6522 | struct radeon_ring *cp1_ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 6523 | struct radeon_ring *cp2_ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6524 | u32 wptr; |
| 6525 | u32 rptr; |
| 6526 | u32 src_id, src_data, ring_id; |
| 6527 | u8 me_id, pipe_id, queue_id; |
| 6528 | u32 ring_index; |
| 6529 | bool queue_hotplug = false; |
| 6530 | bool queue_reset = false; |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6531 | u32 addr, status, mc_client; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6532 | bool queue_thermal = false; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6533 | |
| 6534 | if (!rdev->ih.enabled || rdev->shutdown) |
| 6535 | return IRQ_NONE; |
| 6536 | |
| 6537 | wptr = cik_get_ih_wptr(rdev); |
| 6538 | |
| 6539 | restart_ih: |
| 6540 | /* is somebody else already processing irqs? */ |
| 6541 | if (atomic_xchg(&rdev->ih.lock, 1)) |
| 6542 | return IRQ_NONE; |
| 6543 | |
| 6544 | rptr = rdev->ih.rptr; |
| 6545 | DRM_DEBUG("cik_irq_process start: rptr %d, wptr %d\n", rptr, wptr); |
| 6546 | |
| 6547 | /* Order reading of wptr vs. reading of IH ring data */ |
| 6548 | rmb(); |
| 6549 | |
| 6550 | /* display interrupts */ |
| 6551 | cik_irq_ack(rdev); |
| 6552 | |
| 6553 | while (rptr != wptr) { |
| 6554 | /* wptr/rptr are in bytes! */ |
| 6555 | ring_index = rptr / 4; |
| 6556 | src_id = le32_to_cpu(rdev->ih.ring[ring_index]) & 0xff; |
| 6557 | src_data = le32_to_cpu(rdev->ih.ring[ring_index + 1]) & 0xfffffff; |
| 6558 | ring_id = le32_to_cpu(rdev->ih.ring[ring_index + 2]) & 0xff; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6559 | |
| 6560 | switch (src_id) { |
| 6561 | case 1: /* D1 vblank/vline */ |
| 6562 | switch (src_data) { |
| 6563 | case 0: /* D1 vblank */ |
| 6564 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VBLANK_INTERRUPT) { |
| 6565 | if (rdev->irq.crtc_vblank_int[0]) { |
| 6566 | drm_handle_vblank(rdev->ddev, 0); |
| 6567 | rdev->pm.vblank_sync = true; |
| 6568 | wake_up(&rdev->irq.vblank_queue); |
| 6569 | } |
| 6570 | if (atomic_read(&rdev->irq.pflip[0])) |
| 6571 | radeon_crtc_handle_flip(rdev, 0); |
| 6572 | rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VBLANK_INTERRUPT; |
| 6573 | DRM_DEBUG("IH: D1 vblank\n"); |
| 6574 | } |
| 6575 | break; |
| 6576 | case 1: /* D1 vline */ |
| 6577 | if (rdev->irq.stat_regs.cik.disp_int & LB_D1_VLINE_INTERRUPT) { |
| 6578 | rdev->irq.stat_regs.cik.disp_int &= ~LB_D1_VLINE_INTERRUPT; |
| 6579 | DRM_DEBUG("IH: D1 vline\n"); |
| 6580 | } |
| 6581 | break; |
| 6582 | default: |
| 6583 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6584 | break; |
| 6585 | } |
| 6586 | break; |
| 6587 | case 2: /* D2 vblank/vline */ |
| 6588 | switch (src_data) { |
| 6589 | case 0: /* D2 vblank */ |
| 6590 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VBLANK_INTERRUPT) { |
| 6591 | if (rdev->irq.crtc_vblank_int[1]) { |
| 6592 | drm_handle_vblank(rdev->ddev, 1); |
| 6593 | rdev->pm.vblank_sync = true; |
| 6594 | wake_up(&rdev->irq.vblank_queue); |
| 6595 | } |
| 6596 | if (atomic_read(&rdev->irq.pflip[1])) |
| 6597 | radeon_crtc_handle_flip(rdev, 1); |
| 6598 | rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; |
| 6599 | DRM_DEBUG("IH: D2 vblank\n"); |
| 6600 | } |
| 6601 | break; |
| 6602 | case 1: /* D2 vline */ |
| 6603 | if (rdev->irq.stat_regs.cik.disp_int_cont & LB_D2_VLINE_INTERRUPT) { |
| 6604 | rdev->irq.stat_regs.cik.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; |
| 6605 | DRM_DEBUG("IH: D2 vline\n"); |
| 6606 | } |
| 6607 | break; |
| 6608 | default: |
| 6609 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6610 | break; |
| 6611 | } |
| 6612 | break; |
| 6613 | case 3: /* D3 vblank/vline */ |
| 6614 | switch (src_data) { |
| 6615 | case 0: /* D3 vblank */ |
| 6616 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { |
| 6617 | if (rdev->irq.crtc_vblank_int[2]) { |
| 6618 | drm_handle_vblank(rdev->ddev, 2); |
| 6619 | rdev->pm.vblank_sync = true; |
| 6620 | wake_up(&rdev->irq.vblank_queue); |
| 6621 | } |
| 6622 | if (atomic_read(&rdev->irq.pflip[2])) |
| 6623 | radeon_crtc_handle_flip(rdev, 2); |
| 6624 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; |
| 6625 | DRM_DEBUG("IH: D3 vblank\n"); |
| 6626 | } |
| 6627 | break; |
| 6628 | case 1: /* D3 vline */ |
| 6629 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { |
| 6630 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; |
| 6631 | DRM_DEBUG("IH: D3 vline\n"); |
| 6632 | } |
| 6633 | break; |
| 6634 | default: |
| 6635 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6636 | break; |
| 6637 | } |
| 6638 | break; |
| 6639 | case 4: /* D4 vblank/vline */ |
| 6640 | switch (src_data) { |
| 6641 | case 0: /* D4 vblank */ |
| 6642 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { |
| 6643 | if (rdev->irq.crtc_vblank_int[3]) { |
| 6644 | drm_handle_vblank(rdev->ddev, 3); |
| 6645 | rdev->pm.vblank_sync = true; |
| 6646 | wake_up(&rdev->irq.vblank_queue); |
| 6647 | } |
| 6648 | if (atomic_read(&rdev->irq.pflip[3])) |
| 6649 | radeon_crtc_handle_flip(rdev, 3); |
| 6650 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; |
| 6651 | DRM_DEBUG("IH: D4 vblank\n"); |
| 6652 | } |
| 6653 | break; |
| 6654 | case 1: /* D4 vline */ |
| 6655 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { |
| 6656 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; |
| 6657 | DRM_DEBUG("IH: D4 vline\n"); |
| 6658 | } |
| 6659 | break; |
| 6660 | default: |
| 6661 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6662 | break; |
| 6663 | } |
| 6664 | break; |
| 6665 | case 5: /* D5 vblank/vline */ |
| 6666 | switch (src_data) { |
| 6667 | case 0: /* D5 vblank */ |
| 6668 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { |
| 6669 | if (rdev->irq.crtc_vblank_int[4]) { |
| 6670 | drm_handle_vblank(rdev->ddev, 4); |
| 6671 | rdev->pm.vblank_sync = true; |
| 6672 | wake_up(&rdev->irq.vblank_queue); |
| 6673 | } |
| 6674 | if (atomic_read(&rdev->irq.pflip[4])) |
| 6675 | radeon_crtc_handle_flip(rdev, 4); |
| 6676 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; |
| 6677 | DRM_DEBUG("IH: D5 vblank\n"); |
| 6678 | } |
| 6679 | break; |
| 6680 | case 1: /* D5 vline */ |
| 6681 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { |
| 6682 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; |
| 6683 | DRM_DEBUG("IH: D5 vline\n"); |
| 6684 | } |
| 6685 | break; |
| 6686 | default: |
| 6687 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6688 | break; |
| 6689 | } |
| 6690 | break; |
| 6691 | case 6: /* D6 vblank/vline */ |
| 6692 | switch (src_data) { |
| 6693 | case 0: /* D6 vblank */ |
| 6694 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { |
| 6695 | if (rdev->irq.crtc_vblank_int[5]) { |
| 6696 | drm_handle_vblank(rdev->ddev, 5); |
| 6697 | rdev->pm.vblank_sync = true; |
| 6698 | wake_up(&rdev->irq.vblank_queue); |
| 6699 | } |
| 6700 | if (atomic_read(&rdev->irq.pflip[5])) |
| 6701 | radeon_crtc_handle_flip(rdev, 5); |
| 6702 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; |
| 6703 | DRM_DEBUG("IH: D6 vblank\n"); |
| 6704 | } |
| 6705 | break; |
| 6706 | case 1: /* D6 vline */ |
| 6707 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { |
| 6708 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; |
| 6709 | DRM_DEBUG("IH: D6 vline\n"); |
| 6710 | } |
| 6711 | break; |
| 6712 | default: |
| 6713 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6714 | break; |
| 6715 | } |
| 6716 | break; |
| 6717 | case 42: /* HPD hotplug */ |
| 6718 | switch (src_data) { |
| 6719 | case 0: |
| 6720 | if (rdev->irq.stat_regs.cik.disp_int & DC_HPD1_INTERRUPT) { |
| 6721 | rdev->irq.stat_regs.cik.disp_int &= ~DC_HPD1_INTERRUPT; |
| 6722 | queue_hotplug = true; |
| 6723 | DRM_DEBUG("IH: HPD1\n"); |
| 6724 | } |
| 6725 | break; |
| 6726 | case 1: |
| 6727 | if (rdev->irq.stat_regs.cik.disp_int_cont & DC_HPD2_INTERRUPT) { |
| 6728 | rdev->irq.stat_regs.cik.disp_int_cont &= ~DC_HPD2_INTERRUPT; |
| 6729 | queue_hotplug = true; |
| 6730 | DRM_DEBUG("IH: HPD2\n"); |
| 6731 | } |
| 6732 | break; |
| 6733 | case 2: |
| 6734 | if (rdev->irq.stat_regs.cik.disp_int_cont2 & DC_HPD3_INTERRUPT) { |
| 6735 | rdev->irq.stat_regs.cik.disp_int_cont2 &= ~DC_HPD3_INTERRUPT; |
| 6736 | queue_hotplug = true; |
| 6737 | DRM_DEBUG("IH: HPD3\n"); |
| 6738 | } |
| 6739 | break; |
| 6740 | case 3: |
| 6741 | if (rdev->irq.stat_regs.cik.disp_int_cont3 & DC_HPD4_INTERRUPT) { |
| 6742 | rdev->irq.stat_regs.cik.disp_int_cont3 &= ~DC_HPD4_INTERRUPT; |
| 6743 | queue_hotplug = true; |
| 6744 | DRM_DEBUG("IH: HPD4\n"); |
| 6745 | } |
| 6746 | break; |
| 6747 | case 4: |
| 6748 | if (rdev->irq.stat_regs.cik.disp_int_cont4 & DC_HPD5_INTERRUPT) { |
| 6749 | rdev->irq.stat_regs.cik.disp_int_cont4 &= ~DC_HPD5_INTERRUPT; |
| 6750 | queue_hotplug = true; |
| 6751 | DRM_DEBUG("IH: HPD5\n"); |
| 6752 | } |
| 6753 | break; |
| 6754 | case 5: |
| 6755 | if (rdev->irq.stat_regs.cik.disp_int_cont5 & DC_HPD6_INTERRUPT) { |
| 6756 | rdev->irq.stat_regs.cik.disp_int_cont5 &= ~DC_HPD6_INTERRUPT; |
| 6757 | queue_hotplug = true; |
| 6758 | DRM_DEBUG("IH: HPD6\n"); |
| 6759 | } |
| 6760 | break; |
| 6761 | default: |
| 6762 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6763 | break; |
| 6764 | } |
| 6765 | break; |
Christian König | 6a3808b | 2013-08-30 11:10:33 +0200 | [diff] [blame] | 6766 | case 124: /* UVD */ |
| 6767 | DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); |
| 6768 | radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); |
| 6769 | break; |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6770 | case 146: |
| 6771 | case 147: |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6772 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
| 6773 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); |
| 6774 | mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6775 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); |
| 6776 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6777 | addr); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6778 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
Alex Deucher | 3ec7d11 | 2013-06-14 10:42:22 -0400 | [diff] [blame] | 6779 | status); |
| 6780 | cik_vm_decode_fault(rdev, status, addr, mc_client); |
Alex Deucher | 9d97c99 | 2012-09-06 14:24:48 -0400 | [diff] [blame] | 6781 | /* reset addr and status */ |
| 6782 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); |
| 6783 | break; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6784 | case 176: /* GFX RB CP_INT */ |
| 6785 | case 177: /* GFX IB CP_INT */ |
| 6786 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 6787 | break; |
| 6788 | case 181: /* CP EOP event */ |
| 6789 | DRM_DEBUG("IH: CP EOP\n"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6790 | /* XXX check the bitfield order! */ |
| 6791 | me_id = (ring_id & 0x60) >> 5; |
| 6792 | pipe_id = (ring_id & 0x18) >> 3; |
| 6793 | queue_id = (ring_id & 0x7) >> 0; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6794 | switch (me_id) { |
| 6795 | case 0: |
| 6796 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 6797 | break; |
| 6798 | case 1: |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6799 | case 2: |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6800 | if ((cp1_ring->me == me_id) & (cp1_ring->pipe == pipe_id)) |
| 6801 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP1_INDEX); |
| 6802 | if ((cp2_ring->me == me_id) & (cp2_ring->pipe == pipe_id)) |
| 6803 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP2_INDEX); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6804 | break; |
| 6805 | } |
| 6806 | break; |
| 6807 | case 184: /* CP Privileged reg access */ |
| 6808 | DRM_ERROR("Illegal register access in command stream\n"); |
| 6809 | /* XXX check the bitfield order! */ |
| 6810 | me_id = (ring_id & 0x60) >> 5; |
| 6811 | pipe_id = (ring_id & 0x18) >> 3; |
| 6812 | queue_id = (ring_id & 0x7) >> 0; |
| 6813 | switch (me_id) { |
| 6814 | case 0: |
| 6815 | /* This results in a full GPU reset, but all we need to do is soft |
| 6816 | * reset the CP for gfx |
| 6817 | */ |
| 6818 | queue_reset = true; |
| 6819 | break; |
| 6820 | case 1: |
| 6821 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6822 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6823 | break; |
| 6824 | case 2: |
| 6825 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6826 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6827 | break; |
| 6828 | } |
| 6829 | break; |
| 6830 | case 185: /* CP Privileged inst */ |
| 6831 | DRM_ERROR("Illegal instruction in command stream\n"); |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6832 | /* XXX check the bitfield order! */ |
| 6833 | me_id = (ring_id & 0x60) >> 5; |
| 6834 | pipe_id = (ring_id & 0x18) >> 3; |
| 6835 | queue_id = (ring_id & 0x7) >> 0; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6836 | switch (me_id) { |
| 6837 | case 0: |
| 6838 | /* This results in a full GPU reset, but all we need to do is soft |
| 6839 | * reset the CP for gfx |
| 6840 | */ |
| 6841 | queue_reset = true; |
| 6842 | break; |
| 6843 | case 1: |
| 6844 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6845 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6846 | break; |
| 6847 | case 2: |
| 6848 | /* XXX compute */ |
Alex Deucher | 2b0781a | 2013-04-09 14:26:16 -0400 | [diff] [blame] | 6849 | queue_reset = true; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6850 | break; |
| 6851 | } |
| 6852 | break; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6853 | case 224: /* SDMA trap event */ |
| 6854 | /* XXX check the bitfield order! */ |
| 6855 | me_id = (ring_id & 0x3) >> 0; |
| 6856 | queue_id = (ring_id & 0xc) >> 2; |
| 6857 | DRM_DEBUG("IH: SDMA trap\n"); |
| 6858 | switch (me_id) { |
| 6859 | case 0: |
| 6860 | switch (queue_id) { |
| 6861 | case 0: |
| 6862 | radeon_fence_process(rdev, R600_RING_TYPE_DMA_INDEX); |
| 6863 | break; |
| 6864 | case 1: |
| 6865 | /* XXX compute */ |
| 6866 | break; |
| 6867 | case 2: |
| 6868 | /* XXX compute */ |
| 6869 | break; |
| 6870 | } |
| 6871 | break; |
| 6872 | case 1: |
| 6873 | switch (queue_id) { |
| 6874 | case 0: |
| 6875 | radeon_fence_process(rdev, CAYMAN_RING_TYPE_DMA1_INDEX); |
| 6876 | break; |
| 6877 | case 1: |
| 6878 | /* XXX compute */ |
| 6879 | break; |
| 6880 | case 2: |
| 6881 | /* XXX compute */ |
| 6882 | break; |
| 6883 | } |
| 6884 | break; |
| 6885 | } |
| 6886 | break; |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6887 | case 230: /* thermal low to high */ |
| 6888 | DRM_DEBUG("IH: thermal low to high\n"); |
| 6889 | rdev->pm.dpm.thermal.high_to_low = false; |
| 6890 | queue_thermal = true; |
| 6891 | break; |
| 6892 | case 231: /* thermal high to low */ |
| 6893 | DRM_DEBUG("IH: thermal high to low\n"); |
| 6894 | rdev->pm.dpm.thermal.high_to_low = true; |
| 6895 | queue_thermal = true; |
| 6896 | break; |
| 6897 | case 233: /* GUI IDLE */ |
| 6898 | DRM_DEBUG("IH: GUI idle\n"); |
| 6899 | break; |
Alex Deucher | 21a93e1 | 2013-04-09 12:47:11 -0400 | [diff] [blame] | 6900 | case 241: /* SDMA Privileged inst */ |
| 6901 | case 247: /* SDMA Privileged inst */ |
| 6902 | DRM_ERROR("Illegal instruction in SDMA command stream\n"); |
| 6903 | /* XXX check the bitfield order! */ |
| 6904 | me_id = (ring_id & 0x3) >> 0; |
| 6905 | queue_id = (ring_id & 0xc) >> 2; |
| 6906 | switch (me_id) { |
| 6907 | case 0: |
| 6908 | switch (queue_id) { |
| 6909 | case 0: |
| 6910 | queue_reset = true; |
| 6911 | break; |
| 6912 | case 1: |
| 6913 | /* XXX compute */ |
| 6914 | queue_reset = true; |
| 6915 | break; |
| 6916 | case 2: |
| 6917 | /* XXX compute */ |
| 6918 | queue_reset = true; |
| 6919 | break; |
| 6920 | } |
| 6921 | break; |
| 6922 | case 1: |
| 6923 | switch (queue_id) { |
| 6924 | case 0: |
| 6925 | queue_reset = true; |
| 6926 | break; |
| 6927 | case 1: |
| 6928 | /* XXX compute */ |
| 6929 | queue_reset = true; |
| 6930 | break; |
| 6931 | case 2: |
| 6932 | /* XXX compute */ |
| 6933 | queue_reset = true; |
| 6934 | break; |
| 6935 | } |
| 6936 | break; |
| 6937 | } |
| 6938 | break; |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6939 | default: |
| 6940 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); |
| 6941 | break; |
| 6942 | } |
| 6943 | |
| 6944 | /* wptr/rptr are in bytes! */ |
| 6945 | rptr += 16; |
| 6946 | rptr &= rdev->ih.ptr_mask; |
| 6947 | } |
| 6948 | if (queue_hotplug) |
| 6949 | schedule_work(&rdev->hotplug_work); |
| 6950 | if (queue_reset) |
| 6951 | schedule_work(&rdev->reset_work); |
Alex Deucher | 41a524a | 2013-08-14 01:01:40 -0400 | [diff] [blame] | 6952 | if (queue_thermal) |
| 6953 | schedule_work(&rdev->pm.dpm.thermal.work); |
Alex Deucher | a59781b | 2012-11-09 10:45:57 -0500 | [diff] [blame] | 6954 | rdev->ih.rptr = rptr; |
| 6955 | WREG32(IH_RB_RPTR, rdev->ih.rptr); |
| 6956 | atomic_set(&rdev->ih.lock, 0); |
| 6957 | |
| 6958 | /* make sure wptr hasn't changed while processing */ |
| 6959 | wptr = cik_get_ih_wptr(rdev); |
| 6960 | if (wptr != rptr) |
| 6961 | goto restart_ih; |
| 6962 | |
| 6963 | return IRQ_HANDLED; |
| 6964 | } |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 6965 | |
| 6966 | /* |
| 6967 | * startup/shutdown callbacks |
| 6968 | */ |
| 6969 | /** |
| 6970 | * cik_startup - program the asic to a functional state |
| 6971 | * |
| 6972 | * @rdev: radeon_device pointer |
| 6973 | * |
| 6974 | * Programs the asic to a functional state (CIK). |
| 6975 | * Called by cik_init() and cik_resume(). |
| 6976 | * Returns 0 for success, error for failure. |
| 6977 | */ |
| 6978 | static int cik_startup(struct radeon_device *rdev) |
| 6979 | { |
| 6980 | struct radeon_ring *ring; |
| 6981 | int r; |
| 6982 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 6983 | /* enable pcie gen2/3 link */ |
| 6984 | cik_pcie_gen3_enable(rdev); |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 6985 | /* enable aspm */ |
| 6986 | cik_program_aspm(rdev); |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 6987 | |
Alex Deucher | e5903d3 | 2013-08-30 08:58:20 -0400 | [diff] [blame] | 6988 | /* scratch needs to be initialized before MC */ |
| 6989 | r = r600_vram_scratch_init(rdev); |
| 6990 | if (r) |
| 6991 | return r; |
| 6992 | |
Alex Deucher | 6fab3feb | 2013-08-04 12:13:17 -0400 | [diff] [blame] | 6993 | cik_mc_program(rdev); |
| 6994 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 6995 | if (rdev->flags & RADEON_IS_IGP) { |
| 6996 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || |
| 6997 | !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) { |
| 6998 | r = cik_init_microcode(rdev); |
| 6999 | if (r) { |
| 7000 | DRM_ERROR("Failed to load firmware!\n"); |
| 7001 | return r; |
| 7002 | } |
| 7003 | } |
| 7004 | } else { |
| 7005 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || |
| 7006 | !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw || |
| 7007 | !rdev->mc_fw) { |
| 7008 | r = cik_init_microcode(rdev); |
| 7009 | if (r) { |
| 7010 | DRM_ERROR("Failed to load firmware!\n"); |
| 7011 | return r; |
| 7012 | } |
| 7013 | } |
| 7014 | |
| 7015 | r = ci_mc_load_microcode(rdev); |
| 7016 | if (r) { |
| 7017 | DRM_ERROR("Failed to load MC firmware!\n"); |
| 7018 | return r; |
| 7019 | } |
| 7020 | } |
| 7021 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7022 | r = cik_pcie_gart_enable(rdev); |
| 7023 | if (r) |
| 7024 | return r; |
| 7025 | cik_gpu_init(rdev); |
| 7026 | |
| 7027 | /* allocate rlc buffers */ |
Alex Deucher | 22c775c | 2013-07-23 09:41:05 -0400 | [diff] [blame] | 7028 | if (rdev->flags & RADEON_IS_IGP) { |
| 7029 | if (rdev->family == CHIP_KAVERI) { |
| 7030 | rdev->rlc.reg_list = spectre_rlc_save_restore_register_list; |
| 7031 | rdev->rlc.reg_list_size = |
| 7032 | (u32)ARRAY_SIZE(spectre_rlc_save_restore_register_list); |
| 7033 | } else { |
| 7034 | rdev->rlc.reg_list = kalindi_rlc_save_restore_register_list; |
| 7035 | rdev->rlc.reg_list_size = |
| 7036 | (u32)ARRAY_SIZE(kalindi_rlc_save_restore_register_list); |
| 7037 | } |
| 7038 | } |
| 7039 | rdev->rlc.cs_data = ci_cs_data; |
| 7040 | rdev->rlc.cp_table_size = CP_ME_TABLE_SIZE * 5 * 4; |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7041 | r = sumo_rlc_init(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7042 | if (r) { |
| 7043 | DRM_ERROR("Failed to init rlc BOs!\n"); |
| 7044 | return r; |
| 7045 | } |
| 7046 | |
| 7047 | /* allocate wb buffer */ |
| 7048 | r = radeon_wb_init(rdev); |
| 7049 | if (r) |
| 7050 | return r; |
| 7051 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7052 | /* allocate mec buffers */ |
| 7053 | r = cik_mec_init(rdev); |
| 7054 | if (r) { |
| 7055 | DRM_ERROR("Failed to init MEC BOs!\n"); |
| 7056 | return r; |
| 7057 | } |
| 7058 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7059 | r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX); |
| 7060 | if (r) { |
| 7061 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7062 | return r; |
| 7063 | } |
| 7064 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7065 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP1_INDEX); |
| 7066 | if (r) { |
| 7067 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7068 | return r; |
| 7069 | } |
| 7070 | |
| 7071 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP2_INDEX); |
| 7072 | if (r) { |
| 7073 | dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r); |
| 7074 | return r; |
| 7075 | } |
| 7076 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7077 | r = radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_DMA_INDEX); |
| 7078 | if (r) { |
| 7079 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
| 7080 | return r; |
| 7081 | } |
| 7082 | |
| 7083 | r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_DMA1_INDEX); |
| 7084 | if (r) { |
| 7085 | dev_err(rdev->dev, "failed initializing DMA fences (%d).\n", r); |
| 7086 | return r; |
| 7087 | } |
| 7088 | |
Alex Deucher | 2ce529d | 2013-08-28 18:12:59 -0400 | [diff] [blame] | 7089 | r = radeon_uvd_resume(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7090 | if (!r) { |
Alex Deucher | 2ce529d | 2013-08-28 18:12:59 -0400 | [diff] [blame] | 7091 | r = uvd_v4_2_resume(rdev); |
| 7092 | if (!r) { |
| 7093 | r = radeon_fence_driver_start_ring(rdev, |
| 7094 | R600_RING_TYPE_UVD_INDEX); |
| 7095 | if (r) |
| 7096 | dev_err(rdev->dev, "UVD fences init error (%d).\n", r); |
| 7097 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7098 | } |
| 7099 | if (r) |
| 7100 | rdev->ring[R600_RING_TYPE_UVD_INDEX].ring_size = 0; |
| 7101 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7102 | /* Enable IRQ */ |
| 7103 | if (!rdev->irq.installed) { |
| 7104 | r = radeon_irq_kms_init(rdev); |
| 7105 | if (r) |
| 7106 | return r; |
| 7107 | } |
| 7108 | |
| 7109 | r = cik_irq_init(rdev); |
| 7110 | if (r) { |
| 7111 | DRM_ERROR("radeon: IH init failed (%d).\n", r); |
| 7112 | radeon_irq_kms_fini(rdev); |
| 7113 | return r; |
| 7114 | } |
| 7115 | cik_irq_set(rdev); |
| 7116 | |
| 7117 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 7118 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET, |
| 7119 | CP_RB0_RPTR, CP_RB0_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7120 | RADEON_CP_PACKET2); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7121 | if (r) |
| 7122 | return r; |
| 7123 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7124 | /* set up the compute queues */ |
Alex Deucher | 2615b53 | 2013-06-03 11:21:58 -0400 | [diff] [blame] | 7125 | /* type-2 packets are deprecated on MEC, use type-3 instead */ |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7126 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 7127 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP1_RPTR_OFFSET, |
| 7128 | CP_HQD_PQ_RPTR, CP_HQD_PQ_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7129 | PACKET3(PACKET3_NOP, 0x3FFF)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7130 | if (r) |
| 7131 | return r; |
| 7132 | ring->me = 1; /* first MEC */ |
| 7133 | ring->pipe = 0; /* first pipe */ |
| 7134 | ring->queue = 0; /* first queue */ |
| 7135 | ring->wptr_offs = CIK_WB_CP1_WPTR_OFFSET; |
| 7136 | |
Alex Deucher | 2615b53 | 2013-06-03 11:21:58 -0400 | [diff] [blame] | 7137 | /* type-2 packets are deprecated on MEC, use type-3 instead */ |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7138 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 7139 | r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP2_RPTR_OFFSET, |
| 7140 | CP_HQD_PQ_RPTR, CP_HQD_PQ_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7141 | PACKET3(PACKET3_NOP, 0x3FFF)); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7142 | if (r) |
| 7143 | return r; |
| 7144 | /* dGPU only have 1 MEC */ |
| 7145 | ring->me = 1; /* first MEC */ |
| 7146 | ring->pipe = 0; /* first pipe */ |
| 7147 | ring->queue = 1; /* second queue */ |
| 7148 | ring->wptr_offs = CIK_WB_CP2_WPTR_OFFSET; |
| 7149 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7150 | ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
| 7151 | r = radeon_ring_init(rdev, ring, ring->ring_size, R600_WB_DMA_RPTR_OFFSET, |
| 7152 | SDMA0_GFX_RB_RPTR + SDMA0_REGISTER_OFFSET, |
| 7153 | SDMA0_GFX_RB_WPTR + SDMA0_REGISTER_OFFSET, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7154 | SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0)); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7155 | if (r) |
| 7156 | return r; |
| 7157 | |
| 7158 | ring = &rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX]; |
| 7159 | r = radeon_ring_init(rdev, ring, ring->ring_size, CAYMAN_WB_DMA1_RPTR_OFFSET, |
| 7160 | SDMA0_GFX_RB_RPTR + SDMA1_REGISTER_OFFSET, |
| 7161 | SDMA0_GFX_RB_WPTR + SDMA1_REGISTER_OFFSET, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7162 | SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0)); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7163 | if (r) |
| 7164 | return r; |
| 7165 | |
| 7166 | r = cik_cp_resume(rdev); |
| 7167 | if (r) |
| 7168 | return r; |
| 7169 | |
| 7170 | r = cik_sdma_resume(rdev); |
| 7171 | if (r) |
| 7172 | return r; |
| 7173 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7174 | ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
| 7175 | if (ring->ring_size) { |
Christian König | 02c9f7f | 2013-08-13 11:56:51 +0200 | [diff] [blame] | 7176 | r = radeon_ring_init(rdev, ring, ring->ring_size, 0, |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7177 | UVD_RBC_RB_RPTR, UVD_RBC_RB_WPTR, |
Christian König | 2e1e6da | 2013-08-13 11:56:52 +0200 | [diff] [blame] | 7178 | RADEON_CP_PACKET2); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7179 | if (!r) |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7180 | r = uvd_v1_0_init(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7181 | if (r) |
| 7182 | DRM_ERROR("radeon: failed initializing UVD (%d).\n", r); |
| 7183 | } |
| 7184 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7185 | r = radeon_ib_pool_init(rdev); |
| 7186 | if (r) { |
| 7187 | dev_err(rdev->dev, "IB initialization failed (%d).\n", r); |
| 7188 | return r; |
| 7189 | } |
| 7190 | |
| 7191 | r = radeon_vm_manager_init(rdev); |
| 7192 | if (r) { |
| 7193 | dev_err(rdev->dev, "vm manager initialization failed (%d).\n", r); |
| 7194 | return r; |
| 7195 | } |
| 7196 | |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 7197 | r = dce6_audio_init(rdev); |
| 7198 | if (r) |
| 7199 | return r; |
| 7200 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7201 | return 0; |
| 7202 | } |
| 7203 | |
| 7204 | /** |
| 7205 | * cik_resume - resume the asic to a functional state |
| 7206 | * |
| 7207 | * @rdev: radeon_device pointer |
| 7208 | * |
| 7209 | * Programs the asic to a functional state (CIK). |
| 7210 | * Called at resume. |
| 7211 | * Returns 0 for success, error for failure. |
| 7212 | */ |
| 7213 | int cik_resume(struct radeon_device *rdev) |
| 7214 | { |
| 7215 | int r; |
| 7216 | |
| 7217 | /* post card */ |
| 7218 | atom_asic_init(rdev->mode_info.atom_context); |
| 7219 | |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 7220 | /* init golden registers */ |
| 7221 | cik_init_golden_registers(rdev); |
| 7222 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7223 | rdev->accel_working = true; |
| 7224 | r = cik_startup(rdev); |
| 7225 | if (r) { |
| 7226 | DRM_ERROR("cik startup failed on resume\n"); |
| 7227 | rdev->accel_working = false; |
| 7228 | return r; |
| 7229 | } |
| 7230 | |
| 7231 | return r; |
| 7232 | |
| 7233 | } |
| 7234 | |
| 7235 | /** |
| 7236 | * cik_suspend - suspend the asic |
| 7237 | * |
| 7238 | * @rdev: radeon_device pointer |
| 7239 | * |
| 7240 | * Bring the chip into a state suitable for suspend (CIK). |
| 7241 | * Called at suspend. |
| 7242 | * Returns 0 for success. |
| 7243 | */ |
| 7244 | int cik_suspend(struct radeon_device *rdev) |
| 7245 | { |
Alex Deucher | b530602 | 2013-07-31 16:51:33 -0400 | [diff] [blame] | 7246 | dce6_audio_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7247 | radeon_vm_manager_fini(rdev); |
| 7248 | cik_cp_enable(rdev, false); |
| 7249 | cik_sdma_enable(rdev, false); |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7250 | uvd_v1_0_fini(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7251 | radeon_uvd_suspend(rdev); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 7252 | cik_fini_pg(rdev); |
| 7253 | cik_fini_cg(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7254 | cik_irq_suspend(rdev); |
| 7255 | radeon_wb_disable(rdev); |
| 7256 | cik_pcie_gart_disable(rdev); |
| 7257 | return 0; |
| 7258 | } |
| 7259 | |
| 7260 | /* Plan is to move initialization in that function and use |
| 7261 | * helper function so that radeon_device_init pretty much |
| 7262 | * do nothing more than calling asic specific function. This |
| 7263 | * should also allow to remove a bunch of callback function |
| 7264 | * like vram_info. |
| 7265 | */ |
| 7266 | /** |
| 7267 | * cik_init - asic specific driver and hw init |
| 7268 | * |
| 7269 | * @rdev: radeon_device pointer |
| 7270 | * |
| 7271 | * Setup asic specific driver variables and program the hw |
| 7272 | * to a functional state (CIK). |
| 7273 | * Called at driver startup. |
| 7274 | * Returns 0 for success, errors for failure. |
| 7275 | */ |
| 7276 | int cik_init(struct radeon_device *rdev) |
| 7277 | { |
| 7278 | struct radeon_ring *ring; |
| 7279 | int r; |
| 7280 | |
| 7281 | /* Read BIOS */ |
| 7282 | if (!radeon_get_bios(rdev)) { |
| 7283 | if (ASIC_IS_AVIVO(rdev)) |
| 7284 | return -EINVAL; |
| 7285 | } |
| 7286 | /* Must be an ATOMBIOS */ |
| 7287 | if (!rdev->is_atom_bios) { |
| 7288 | dev_err(rdev->dev, "Expecting atombios for cayman GPU\n"); |
| 7289 | return -EINVAL; |
| 7290 | } |
| 7291 | r = radeon_atombios_init(rdev); |
| 7292 | if (r) |
| 7293 | return r; |
| 7294 | |
| 7295 | /* Post card if necessary */ |
| 7296 | if (!radeon_card_posted(rdev)) { |
| 7297 | if (!rdev->bios) { |
| 7298 | dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n"); |
| 7299 | return -EINVAL; |
| 7300 | } |
| 7301 | DRM_INFO("GPU not posted. posting now...\n"); |
| 7302 | atom_asic_init(rdev->mode_info.atom_context); |
| 7303 | } |
Alex Deucher | 0aafd31 | 2013-04-09 14:43:30 -0400 | [diff] [blame] | 7304 | /* init golden registers */ |
| 7305 | cik_init_golden_registers(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7306 | /* Initialize scratch registers */ |
| 7307 | cik_scratch_init(rdev); |
| 7308 | /* Initialize surface registers */ |
| 7309 | radeon_surface_init(rdev); |
| 7310 | /* Initialize clocks */ |
| 7311 | radeon_get_clock_info(rdev->ddev); |
| 7312 | |
| 7313 | /* Fence driver */ |
| 7314 | r = radeon_fence_driver_init(rdev); |
| 7315 | if (r) |
| 7316 | return r; |
| 7317 | |
| 7318 | /* initialize memory controller */ |
| 7319 | r = cik_mc_init(rdev); |
| 7320 | if (r) |
| 7321 | return r; |
| 7322 | /* Memory manager */ |
| 7323 | r = radeon_bo_init(rdev); |
| 7324 | if (r) |
| 7325 | return r; |
| 7326 | |
| 7327 | ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]; |
| 7328 | ring->ring_obj = NULL; |
| 7329 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7330 | |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7331 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]; |
| 7332 | ring->ring_obj = NULL; |
| 7333 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7334 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); |
| 7335 | if (r) |
| 7336 | return r; |
| 7337 | |
| 7338 | ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]; |
| 7339 | ring->ring_obj = NULL; |
| 7340 | r600_ring_init(rdev, ring, 1024 * 1024); |
| 7341 | r = radeon_doorbell_get(rdev, &ring->doorbell_page_num); |
| 7342 | if (r) |
| 7343 | return r; |
| 7344 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7345 | ring = &rdev->ring[R600_RING_TYPE_DMA_INDEX]; |
| 7346 | ring->ring_obj = NULL; |
| 7347 | r600_ring_init(rdev, ring, 256 * 1024); |
| 7348 | |
| 7349 | ring = &rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX]; |
| 7350 | ring->ring_obj = NULL; |
| 7351 | r600_ring_init(rdev, ring, 256 * 1024); |
| 7352 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7353 | r = radeon_uvd_init(rdev); |
| 7354 | if (!r) { |
| 7355 | ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; |
| 7356 | ring->ring_obj = NULL; |
| 7357 | r600_ring_init(rdev, ring, 4096); |
| 7358 | } |
| 7359 | |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7360 | rdev->ih.ring_obj = NULL; |
| 7361 | r600_ih_ring_init(rdev, 64 * 1024); |
| 7362 | |
| 7363 | r = r600_pcie_gart_init(rdev); |
| 7364 | if (r) |
| 7365 | return r; |
| 7366 | |
| 7367 | rdev->accel_working = true; |
| 7368 | r = cik_startup(rdev); |
| 7369 | if (r) { |
| 7370 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
| 7371 | cik_cp_fini(rdev); |
| 7372 | cik_sdma_fini(rdev); |
| 7373 | cik_irq_fini(rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7374 | sumo_rlc_fini(rdev); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7375 | cik_mec_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7376 | radeon_wb_fini(rdev); |
| 7377 | radeon_ib_pool_fini(rdev); |
| 7378 | radeon_vm_manager_fini(rdev); |
| 7379 | radeon_irq_kms_fini(rdev); |
| 7380 | cik_pcie_gart_fini(rdev); |
| 7381 | rdev->accel_working = false; |
| 7382 | } |
| 7383 | |
| 7384 | /* Don't start up if the MC ucode is missing. |
| 7385 | * The default clocks and voltages before the MC ucode |
| 7386 | * is loaded are not suffient for advanced operations. |
| 7387 | */ |
| 7388 | if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) { |
| 7389 | DRM_ERROR("radeon: MC ucode required for NI+.\n"); |
| 7390 | return -EINVAL; |
| 7391 | } |
| 7392 | |
| 7393 | return 0; |
| 7394 | } |
| 7395 | |
| 7396 | /** |
| 7397 | * cik_fini - asic specific driver and hw fini |
| 7398 | * |
| 7399 | * @rdev: radeon_device pointer |
| 7400 | * |
| 7401 | * Tear down the asic specific driver variables and program the hw |
| 7402 | * to an idle state (CIK). |
| 7403 | * Called at driver unload. |
| 7404 | */ |
| 7405 | void cik_fini(struct radeon_device *rdev) |
| 7406 | { |
| 7407 | cik_cp_fini(rdev); |
| 7408 | cik_sdma_fini(rdev); |
Alex Deucher | 473359b | 2013-08-09 11:18:39 -0400 | [diff] [blame] | 7409 | cik_fini_pg(rdev); |
| 7410 | cik_fini_cg(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7411 | cik_irq_fini(rdev); |
Alex Deucher | 1fd1177 | 2013-04-17 17:53:50 -0400 | [diff] [blame] | 7412 | sumo_rlc_fini(rdev); |
Alex Deucher | 963e81f | 2013-06-26 17:37:11 -0400 | [diff] [blame] | 7413 | cik_mec_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7414 | radeon_wb_fini(rdev); |
| 7415 | radeon_vm_manager_fini(rdev); |
| 7416 | radeon_ib_pool_fini(rdev); |
| 7417 | radeon_irq_kms_fini(rdev); |
Christian König | e409b12 | 2013-08-13 11:56:53 +0200 | [diff] [blame] | 7418 | uvd_v1_0_fini(rdev); |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 7419 | radeon_uvd_fini(rdev); |
Alex Deucher | 7bf94a2 | 2012-08-17 11:48:29 -0400 | [diff] [blame] | 7420 | cik_pcie_gart_fini(rdev); |
| 7421 | r600_vram_scratch_fini(rdev); |
| 7422 | radeon_gem_fini(rdev); |
| 7423 | radeon_fence_driver_fini(rdev); |
| 7424 | radeon_bo_fini(rdev); |
| 7425 | radeon_atombios_fini(rdev); |
| 7426 | kfree(rdev->bios); |
| 7427 | rdev->bios = NULL; |
| 7428 | } |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7429 | |
| 7430 | /* display watermark setup */ |
| 7431 | /** |
| 7432 | * dce8_line_buffer_adjust - Set up the line buffer |
| 7433 | * |
| 7434 | * @rdev: radeon_device pointer |
| 7435 | * @radeon_crtc: the selected display controller |
| 7436 | * @mode: the current display mode on the selected display |
| 7437 | * controller |
| 7438 | * |
| 7439 | * Setup up the line buffer allocation for |
| 7440 | * the selected display controller (CIK). |
| 7441 | * Returns the line buffer size in pixels. |
| 7442 | */ |
| 7443 | static u32 dce8_line_buffer_adjust(struct radeon_device *rdev, |
| 7444 | struct radeon_crtc *radeon_crtc, |
| 7445 | struct drm_display_mode *mode) |
| 7446 | { |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7447 | u32 tmp, buffer_alloc, i; |
| 7448 | u32 pipe_offset = radeon_crtc->crtc_id * 0x20; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7449 | /* |
| 7450 | * Line Buffer Setup |
| 7451 | * There are 6 line buffers, one for each display controllers. |
| 7452 | * There are 3 partitions per LB. Select the number of partitions |
| 7453 | * to enable based on the display width. For display widths larger |
| 7454 | * than 4096, you need use to use 2 display controllers and combine |
| 7455 | * them using the stereo blender. |
| 7456 | */ |
| 7457 | if (radeon_crtc->base.enabled && mode) { |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7458 | if (mode->crtc_hdisplay < 1920) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7459 | tmp = 1; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7460 | buffer_alloc = 2; |
| 7461 | } else if (mode->crtc_hdisplay < 2560) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7462 | tmp = 2; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7463 | buffer_alloc = 2; |
| 7464 | } else if (mode->crtc_hdisplay < 4096) { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7465 | tmp = 0; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7466 | buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
| 7467 | } else { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7468 | DRM_DEBUG_KMS("Mode too big for LB!\n"); |
| 7469 | tmp = 0; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7470 | buffer_alloc = (rdev->flags & RADEON_IS_IGP) ? 2 : 4; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7471 | } |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7472 | } else { |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7473 | tmp = 1; |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7474 | buffer_alloc = 0; |
| 7475 | } |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7476 | |
| 7477 | WREG32(LB_MEMORY_CTRL + radeon_crtc->crtc_offset, |
| 7478 | LB_MEMORY_CONFIG(tmp) | LB_MEMORY_SIZE(0x6B0)); |
| 7479 | |
Alex Deucher | bc01a8c | 2013-08-19 11:39:27 -0400 | [diff] [blame] | 7480 | WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset, |
| 7481 | DMIF_BUFFERS_ALLOCATED(buffer_alloc)); |
| 7482 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 7483 | if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) & |
| 7484 | DMIF_BUFFERS_ALLOCATED_COMPLETED) |
| 7485 | break; |
| 7486 | udelay(1); |
| 7487 | } |
| 7488 | |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7489 | if (radeon_crtc->base.enabled && mode) { |
| 7490 | switch (tmp) { |
| 7491 | case 0: |
| 7492 | default: |
| 7493 | return 4096 * 2; |
| 7494 | case 1: |
| 7495 | return 1920 * 2; |
| 7496 | case 2: |
| 7497 | return 2560 * 2; |
| 7498 | } |
| 7499 | } |
| 7500 | |
| 7501 | /* controller not enabled, so no lb used */ |
| 7502 | return 0; |
| 7503 | } |
| 7504 | |
| 7505 | /** |
| 7506 | * cik_get_number_of_dram_channels - get the number of dram channels |
| 7507 | * |
| 7508 | * @rdev: radeon_device pointer |
| 7509 | * |
| 7510 | * Look up the number of video ram channels (CIK). |
| 7511 | * Used for display watermark bandwidth calculations |
| 7512 | * Returns the number of dram channels |
| 7513 | */ |
| 7514 | static u32 cik_get_number_of_dram_channels(struct radeon_device *rdev) |
| 7515 | { |
| 7516 | u32 tmp = RREG32(MC_SHARED_CHMAP); |
| 7517 | |
| 7518 | switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) { |
| 7519 | case 0: |
| 7520 | default: |
| 7521 | return 1; |
| 7522 | case 1: |
| 7523 | return 2; |
| 7524 | case 2: |
| 7525 | return 4; |
| 7526 | case 3: |
| 7527 | return 8; |
| 7528 | case 4: |
| 7529 | return 3; |
| 7530 | case 5: |
| 7531 | return 6; |
| 7532 | case 6: |
| 7533 | return 10; |
| 7534 | case 7: |
| 7535 | return 12; |
| 7536 | case 8: |
| 7537 | return 16; |
| 7538 | } |
| 7539 | } |
| 7540 | |
| 7541 | struct dce8_wm_params { |
| 7542 | u32 dram_channels; /* number of dram channels */ |
| 7543 | u32 yclk; /* bandwidth per dram data pin in kHz */ |
| 7544 | u32 sclk; /* engine clock in kHz */ |
| 7545 | u32 disp_clk; /* display clock in kHz */ |
| 7546 | u32 src_width; /* viewport width */ |
| 7547 | u32 active_time; /* active display time in ns */ |
| 7548 | u32 blank_time; /* blank time in ns */ |
| 7549 | bool interlaced; /* mode is interlaced */ |
| 7550 | fixed20_12 vsc; /* vertical scale ratio */ |
| 7551 | u32 num_heads; /* number of active crtcs */ |
| 7552 | u32 bytes_per_pixel; /* bytes per pixel display + overlay */ |
| 7553 | u32 lb_size; /* line buffer allocated to pipe */ |
| 7554 | u32 vtaps; /* vertical scaler taps */ |
| 7555 | }; |
| 7556 | |
| 7557 | /** |
| 7558 | * dce8_dram_bandwidth - get the dram bandwidth |
| 7559 | * |
| 7560 | * @wm: watermark calculation data |
| 7561 | * |
| 7562 | * Calculate the raw dram bandwidth (CIK). |
| 7563 | * Used for display watermark bandwidth calculations |
| 7564 | * Returns the dram bandwidth in MBytes/s |
| 7565 | */ |
| 7566 | static u32 dce8_dram_bandwidth(struct dce8_wm_params *wm) |
| 7567 | { |
| 7568 | /* Calculate raw DRAM Bandwidth */ |
| 7569 | fixed20_12 dram_efficiency; /* 0.7 */ |
| 7570 | fixed20_12 yclk, dram_channels, bandwidth; |
| 7571 | fixed20_12 a; |
| 7572 | |
| 7573 | a.full = dfixed_const(1000); |
| 7574 | yclk.full = dfixed_const(wm->yclk); |
| 7575 | yclk.full = dfixed_div(yclk, a); |
| 7576 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 7577 | a.full = dfixed_const(10); |
| 7578 | dram_efficiency.full = dfixed_const(7); |
| 7579 | dram_efficiency.full = dfixed_div(dram_efficiency, a); |
| 7580 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 7581 | bandwidth.full = dfixed_mul(bandwidth, dram_efficiency); |
| 7582 | |
| 7583 | return dfixed_trunc(bandwidth); |
| 7584 | } |
| 7585 | |
| 7586 | /** |
| 7587 | * dce8_dram_bandwidth_for_display - get the dram bandwidth for display |
| 7588 | * |
| 7589 | * @wm: watermark calculation data |
| 7590 | * |
| 7591 | * Calculate the dram bandwidth used for display (CIK). |
| 7592 | * Used for display watermark bandwidth calculations |
| 7593 | * Returns the dram bandwidth for display in MBytes/s |
| 7594 | */ |
| 7595 | static u32 dce8_dram_bandwidth_for_display(struct dce8_wm_params *wm) |
| 7596 | { |
| 7597 | /* Calculate DRAM Bandwidth and the part allocated to display. */ |
| 7598 | fixed20_12 disp_dram_allocation; /* 0.3 to 0.7 */ |
| 7599 | fixed20_12 yclk, dram_channels, bandwidth; |
| 7600 | fixed20_12 a; |
| 7601 | |
| 7602 | a.full = dfixed_const(1000); |
| 7603 | yclk.full = dfixed_const(wm->yclk); |
| 7604 | yclk.full = dfixed_div(yclk, a); |
| 7605 | dram_channels.full = dfixed_const(wm->dram_channels * 4); |
| 7606 | a.full = dfixed_const(10); |
| 7607 | disp_dram_allocation.full = dfixed_const(3); /* XXX worse case value 0.3 */ |
| 7608 | disp_dram_allocation.full = dfixed_div(disp_dram_allocation, a); |
| 7609 | bandwidth.full = dfixed_mul(dram_channels, yclk); |
| 7610 | bandwidth.full = dfixed_mul(bandwidth, disp_dram_allocation); |
| 7611 | |
| 7612 | return dfixed_trunc(bandwidth); |
| 7613 | } |
| 7614 | |
| 7615 | /** |
| 7616 | * dce8_data_return_bandwidth - get the data return bandwidth |
| 7617 | * |
| 7618 | * @wm: watermark calculation data |
| 7619 | * |
| 7620 | * Calculate the data return bandwidth used for display (CIK). |
| 7621 | * Used for display watermark bandwidth calculations |
| 7622 | * Returns the data return bandwidth in MBytes/s |
| 7623 | */ |
| 7624 | static u32 dce8_data_return_bandwidth(struct dce8_wm_params *wm) |
| 7625 | { |
| 7626 | /* Calculate the display Data return Bandwidth */ |
| 7627 | fixed20_12 return_efficiency; /* 0.8 */ |
| 7628 | fixed20_12 sclk, bandwidth; |
| 7629 | fixed20_12 a; |
| 7630 | |
| 7631 | a.full = dfixed_const(1000); |
| 7632 | sclk.full = dfixed_const(wm->sclk); |
| 7633 | sclk.full = dfixed_div(sclk, a); |
| 7634 | a.full = dfixed_const(10); |
| 7635 | return_efficiency.full = dfixed_const(8); |
| 7636 | return_efficiency.full = dfixed_div(return_efficiency, a); |
| 7637 | a.full = dfixed_const(32); |
| 7638 | bandwidth.full = dfixed_mul(a, sclk); |
| 7639 | bandwidth.full = dfixed_mul(bandwidth, return_efficiency); |
| 7640 | |
| 7641 | return dfixed_trunc(bandwidth); |
| 7642 | } |
| 7643 | |
| 7644 | /** |
| 7645 | * dce8_dmif_request_bandwidth - get the dmif bandwidth |
| 7646 | * |
| 7647 | * @wm: watermark calculation data |
| 7648 | * |
| 7649 | * Calculate the dmif bandwidth used for display (CIK). |
| 7650 | * Used for display watermark bandwidth calculations |
| 7651 | * Returns the dmif bandwidth in MBytes/s |
| 7652 | */ |
| 7653 | static u32 dce8_dmif_request_bandwidth(struct dce8_wm_params *wm) |
| 7654 | { |
| 7655 | /* Calculate the DMIF Request Bandwidth */ |
| 7656 | fixed20_12 disp_clk_request_efficiency; /* 0.8 */ |
| 7657 | fixed20_12 disp_clk, bandwidth; |
| 7658 | fixed20_12 a, b; |
| 7659 | |
| 7660 | a.full = dfixed_const(1000); |
| 7661 | disp_clk.full = dfixed_const(wm->disp_clk); |
| 7662 | disp_clk.full = dfixed_div(disp_clk, a); |
| 7663 | a.full = dfixed_const(32); |
| 7664 | b.full = dfixed_mul(a, disp_clk); |
| 7665 | |
| 7666 | a.full = dfixed_const(10); |
| 7667 | disp_clk_request_efficiency.full = dfixed_const(8); |
| 7668 | disp_clk_request_efficiency.full = dfixed_div(disp_clk_request_efficiency, a); |
| 7669 | |
| 7670 | bandwidth.full = dfixed_mul(b, disp_clk_request_efficiency); |
| 7671 | |
| 7672 | return dfixed_trunc(bandwidth); |
| 7673 | } |
| 7674 | |
| 7675 | /** |
| 7676 | * dce8_available_bandwidth - get the min available bandwidth |
| 7677 | * |
| 7678 | * @wm: watermark calculation data |
| 7679 | * |
| 7680 | * Calculate the min available bandwidth used for display (CIK). |
| 7681 | * Used for display watermark bandwidth calculations |
| 7682 | * Returns the min available bandwidth in MBytes/s |
| 7683 | */ |
| 7684 | static u32 dce8_available_bandwidth(struct dce8_wm_params *wm) |
| 7685 | { |
| 7686 | /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */ |
| 7687 | u32 dram_bandwidth = dce8_dram_bandwidth(wm); |
| 7688 | u32 data_return_bandwidth = dce8_data_return_bandwidth(wm); |
| 7689 | u32 dmif_req_bandwidth = dce8_dmif_request_bandwidth(wm); |
| 7690 | |
| 7691 | return min(dram_bandwidth, min(data_return_bandwidth, dmif_req_bandwidth)); |
| 7692 | } |
| 7693 | |
| 7694 | /** |
| 7695 | * dce8_average_bandwidth - get the average available bandwidth |
| 7696 | * |
| 7697 | * @wm: watermark calculation data |
| 7698 | * |
| 7699 | * Calculate the average available bandwidth used for display (CIK). |
| 7700 | * Used for display watermark bandwidth calculations |
| 7701 | * Returns the average available bandwidth in MBytes/s |
| 7702 | */ |
| 7703 | static u32 dce8_average_bandwidth(struct dce8_wm_params *wm) |
| 7704 | { |
| 7705 | /* Calculate the display mode Average Bandwidth |
| 7706 | * DisplayMode should contain the source and destination dimensions, |
| 7707 | * timing, etc. |
| 7708 | */ |
| 7709 | fixed20_12 bpp; |
| 7710 | fixed20_12 line_time; |
| 7711 | fixed20_12 src_width; |
| 7712 | fixed20_12 bandwidth; |
| 7713 | fixed20_12 a; |
| 7714 | |
| 7715 | a.full = dfixed_const(1000); |
| 7716 | line_time.full = dfixed_const(wm->active_time + wm->blank_time); |
| 7717 | line_time.full = dfixed_div(line_time, a); |
| 7718 | bpp.full = dfixed_const(wm->bytes_per_pixel); |
| 7719 | src_width.full = dfixed_const(wm->src_width); |
| 7720 | bandwidth.full = dfixed_mul(src_width, bpp); |
| 7721 | bandwidth.full = dfixed_mul(bandwidth, wm->vsc); |
| 7722 | bandwidth.full = dfixed_div(bandwidth, line_time); |
| 7723 | |
| 7724 | return dfixed_trunc(bandwidth); |
| 7725 | } |
| 7726 | |
| 7727 | /** |
| 7728 | * dce8_latency_watermark - get the latency watermark |
| 7729 | * |
| 7730 | * @wm: watermark calculation data |
| 7731 | * |
| 7732 | * Calculate the latency watermark (CIK). |
| 7733 | * Used for display watermark bandwidth calculations |
| 7734 | * Returns the latency watermark in ns |
| 7735 | */ |
| 7736 | static u32 dce8_latency_watermark(struct dce8_wm_params *wm) |
| 7737 | { |
| 7738 | /* First calculate the latency in ns */ |
| 7739 | u32 mc_latency = 2000; /* 2000 ns. */ |
| 7740 | u32 available_bandwidth = dce8_available_bandwidth(wm); |
| 7741 | u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth; |
| 7742 | u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth; |
| 7743 | u32 dc_latency = 40000000 / wm->disp_clk; /* dc pipe latency */ |
| 7744 | u32 other_heads_data_return_time = ((wm->num_heads + 1) * worst_chunk_return_time) + |
| 7745 | (wm->num_heads * cursor_line_pair_return_time); |
| 7746 | u32 latency = mc_latency + other_heads_data_return_time + dc_latency; |
| 7747 | u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time; |
| 7748 | u32 tmp, dmif_size = 12288; |
| 7749 | fixed20_12 a, b, c; |
| 7750 | |
| 7751 | if (wm->num_heads == 0) |
| 7752 | return 0; |
| 7753 | |
| 7754 | a.full = dfixed_const(2); |
| 7755 | b.full = dfixed_const(1); |
| 7756 | if ((wm->vsc.full > a.full) || |
| 7757 | ((wm->vsc.full > b.full) && (wm->vtaps >= 3)) || |
| 7758 | (wm->vtaps >= 5) || |
| 7759 | ((wm->vsc.full >= a.full) && wm->interlaced)) |
| 7760 | max_src_lines_per_dst_line = 4; |
| 7761 | else |
| 7762 | max_src_lines_per_dst_line = 2; |
| 7763 | |
| 7764 | a.full = dfixed_const(available_bandwidth); |
| 7765 | b.full = dfixed_const(wm->num_heads); |
| 7766 | a.full = dfixed_div(a, b); |
| 7767 | |
| 7768 | b.full = dfixed_const(mc_latency + 512); |
| 7769 | c.full = dfixed_const(wm->disp_clk); |
| 7770 | b.full = dfixed_div(b, c); |
| 7771 | |
| 7772 | c.full = dfixed_const(dmif_size); |
| 7773 | b.full = dfixed_div(c, b); |
| 7774 | |
| 7775 | tmp = min(dfixed_trunc(a), dfixed_trunc(b)); |
| 7776 | |
| 7777 | b.full = dfixed_const(1000); |
| 7778 | c.full = dfixed_const(wm->disp_clk); |
| 7779 | b.full = dfixed_div(c, b); |
| 7780 | c.full = dfixed_const(wm->bytes_per_pixel); |
| 7781 | b.full = dfixed_mul(b, c); |
| 7782 | |
| 7783 | lb_fill_bw = min(tmp, dfixed_trunc(b)); |
| 7784 | |
| 7785 | a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel); |
| 7786 | b.full = dfixed_const(1000); |
| 7787 | c.full = dfixed_const(lb_fill_bw); |
| 7788 | b.full = dfixed_div(c, b); |
| 7789 | a.full = dfixed_div(a, b); |
| 7790 | line_fill_time = dfixed_trunc(a); |
| 7791 | |
| 7792 | if (line_fill_time < wm->active_time) |
| 7793 | return latency; |
| 7794 | else |
| 7795 | return latency + (line_fill_time - wm->active_time); |
| 7796 | |
| 7797 | } |
| 7798 | |
| 7799 | /** |
| 7800 | * dce8_average_bandwidth_vs_dram_bandwidth_for_display - check |
| 7801 | * average and available dram bandwidth |
| 7802 | * |
| 7803 | * @wm: watermark calculation data |
| 7804 | * |
| 7805 | * Check if the display average bandwidth fits in the display |
| 7806 | * dram bandwidth (CIK). |
| 7807 | * Used for display watermark bandwidth calculations |
| 7808 | * Returns true if the display fits, false if not. |
| 7809 | */ |
| 7810 | static bool dce8_average_bandwidth_vs_dram_bandwidth_for_display(struct dce8_wm_params *wm) |
| 7811 | { |
| 7812 | if (dce8_average_bandwidth(wm) <= |
| 7813 | (dce8_dram_bandwidth_for_display(wm) / wm->num_heads)) |
| 7814 | return true; |
| 7815 | else |
| 7816 | return false; |
| 7817 | } |
| 7818 | |
| 7819 | /** |
| 7820 | * dce8_average_bandwidth_vs_available_bandwidth - check |
| 7821 | * average and available bandwidth |
| 7822 | * |
| 7823 | * @wm: watermark calculation data |
| 7824 | * |
| 7825 | * Check if the display average bandwidth fits in the display |
| 7826 | * available bandwidth (CIK). |
| 7827 | * Used for display watermark bandwidth calculations |
| 7828 | * Returns true if the display fits, false if not. |
| 7829 | */ |
| 7830 | static bool dce8_average_bandwidth_vs_available_bandwidth(struct dce8_wm_params *wm) |
| 7831 | { |
| 7832 | if (dce8_average_bandwidth(wm) <= |
| 7833 | (dce8_available_bandwidth(wm) / wm->num_heads)) |
| 7834 | return true; |
| 7835 | else |
| 7836 | return false; |
| 7837 | } |
| 7838 | |
| 7839 | /** |
| 7840 | * dce8_check_latency_hiding - check latency hiding |
| 7841 | * |
| 7842 | * @wm: watermark calculation data |
| 7843 | * |
| 7844 | * Check latency hiding (CIK). |
| 7845 | * Used for display watermark bandwidth calculations |
| 7846 | * Returns true if the display fits, false if not. |
| 7847 | */ |
| 7848 | static bool dce8_check_latency_hiding(struct dce8_wm_params *wm) |
| 7849 | { |
| 7850 | u32 lb_partitions = wm->lb_size / wm->src_width; |
| 7851 | u32 line_time = wm->active_time + wm->blank_time; |
| 7852 | u32 latency_tolerant_lines; |
| 7853 | u32 latency_hiding; |
| 7854 | fixed20_12 a; |
| 7855 | |
| 7856 | a.full = dfixed_const(1); |
| 7857 | if (wm->vsc.full > a.full) |
| 7858 | latency_tolerant_lines = 1; |
| 7859 | else { |
| 7860 | if (lb_partitions <= (wm->vtaps + 1)) |
| 7861 | latency_tolerant_lines = 1; |
| 7862 | else |
| 7863 | latency_tolerant_lines = 2; |
| 7864 | } |
| 7865 | |
| 7866 | latency_hiding = (latency_tolerant_lines * line_time + wm->blank_time); |
| 7867 | |
| 7868 | if (dce8_latency_watermark(wm) <= latency_hiding) |
| 7869 | return true; |
| 7870 | else |
| 7871 | return false; |
| 7872 | } |
| 7873 | |
| 7874 | /** |
| 7875 | * dce8_program_watermarks - program display watermarks |
| 7876 | * |
| 7877 | * @rdev: radeon_device pointer |
| 7878 | * @radeon_crtc: the selected display controller |
| 7879 | * @lb_size: line buffer size |
| 7880 | * @num_heads: number of display controllers in use |
| 7881 | * |
| 7882 | * Calculate and program the display watermarks for the |
| 7883 | * selected display controller (CIK). |
| 7884 | */ |
| 7885 | static void dce8_program_watermarks(struct radeon_device *rdev, |
| 7886 | struct radeon_crtc *radeon_crtc, |
| 7887 | u32 lb_size, u32 num_heads) |
| 7888 | { |
| 7889 | struct drm_display_mode *mode = &radeon_crtc->base.mode; |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7890 | struct dce8_wm_params wm_low, wm_high; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7891 | u32 pixel_period; |
| 7892 | u32 line_time = 0; |
| 7893 | u32 latency_watermark_a = 0, latency_watermark_b = 0; |
| 7894 | u32 tmp, wm_mask; |
| 7895 | |
| 7896 | if (radeon_crtc->base.enabled && num_heads && mode) { |
| 7897 | pixel_period = 1000000 / (u32)mode->clock; |
| 7898 | line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535); |
| 7899 | |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7900 | /* watermark for high clocks */ |
| 7901 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && |
| 7902 | rdev->pm.dpm_enabled) { |
| 7903 | wm_high.yclk = |
| 7904 | radeon_dpm_get_mclk(rdev, false) * 10; |
| 7905 | wm_high.sclk = |
| 7906 | radeon_dpm_get_sclk(rdev, false) * 10; |
| 7907 | } else { |
| 7908 | wm_high.yclk = rdev->pm.current_mclk * 10; |
| 7909 | wm_high.sclk = rdev->pm.current_sclk * 10; |
| 7910 | } |
| 7911 | |
| 7912 | wm_high.disp_clk = mode->clock; |
| 7913 | wm_high.src_width = mode->crtc_hdisplay; |
| 7914 | wm_high.active_time = mode->crtc_hdisplay * pixel_period; |
| 7915 | wm_high.blank_time = line_time - wm_high.active_time; |
| 7916 | wm_high.interlaced = false; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7917 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7918 | wm_high.interlaced = true; |
| 7919 | wm_high.vsc = radeon_crtc->vsc; |
| 7920 | wm_high.vtaps = 1; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7921 | if (radeon_crtc->rmx_type != RMX_OFF) |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7922 | wm_high.vtaps = 2; |
| 7923 | wm_high.bytes_per_pixel = 4; /* XXX: get this from fb config */ |
| 7924 | wm_high.lb_size = lb_size; |
| 7925 | wm_high.dram_channels = cik_get_number_of_dram_channels(rdev); |
| 7926 | wm_high.num_heads = num_heads; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7927 | |
| 7928 | /* set for high clocks */ |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7929 | latency_watermark_a = min(dce8_latency_watermark(&wm_high), (u32)65535); |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7930 | |
| 7931 | /* possibly force display priority to high */ |
| 7932 | /* should really do this at mode validation time... */ |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 7933 | if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_high) || |
| 7934 | !dce8_average_bandwidth_vs_available_bandwidth(&wm_high) || |
| 7935 | !dce8_check_latency_hiding(&wm_high) || |
| 7936 | (rdev->disp_priority == 2)) { |
| 7937 | DRM_DEBUG_KMS("force priority to high\n"); |
| 7938 | } |
| 7939 | |
| 7940 | /* watermark for low clocks */ |
| 7941 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && |
| 7942 | rdev->pm.dpm_enabled) { |
| 7943 | wm_low.yclk = |
| 7944 | radeon_dpm_get_mclk(rdev, true) * 10; |
| 7945 | wm_low.sclk = |
| 7946 | radeon_dpm_get_sclk(rdev, true) * 10; |
| 7947 | } else { |
| 7948 | wm_low.yclk = rdev->pm.current_mclk * 10; |
| 7949 | wm_low.sclk = rdev->pm.current_sclk * 10; |
| 7950 | } |
| 7951 | |
| 7952 | wm_low.disp_clk = mode->clock; |
| 7953 | wm_low.src_width = mode->crtc_hdisplay; |
| 7954 | wm_low.active_time = mode->crtc_hdisplay * pixel_period; |
| 7955 | wm_low.blank_time = line_time - wm_low.active_time; |
| 7956 | wm_low.interlaced = false; |
| 7957 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
| 7958 | wm_low.interlaced = true; |
| 7959 | wm_low.vsc = radeon_crtc->vsc; |
| 7960 | wm_low.vtaps = 1; |
| 7961 | if (radeon_crtc->rmx_type != RMX_OFF) |
| 7962 | wm_low.vtaps = 2; |
| 7963 | wm_low.bytes_per_pixel = 4; /* XXX: get this from fb config */ |
| 7964 | wm_low.lb_size = lb_size; |
| 7965 | wm_low.dram_channels = cik_get_number_of_dram_channels(rdev); |
| 7966 | wm_low.num_heads = num_heads; |
| 7967 | |
| 7968 | /* set for low clocks */ |
| 7969 | latency_watermark_b = min(dce8_latency_watermark(&wm_low), (u32)65535); |
| 7970 | |
| 7971 | /* possibly force display priority to high */ |
| 7972 | /* should really do this at mode validation time... */ |
| 7973 | if (!dce8_average_bandwidth_vs_dram_bandwidth_for_display(&wm_low) || |
| 7974 | !dce8_average_bandwidth_vs_available_bandwidth(&wm_low) || |
| 7975 | !dce8_check_latency_hiding(&wm_low) || |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 7976 | (rdev->disp_priority == 2)) { |
| 7977 | DRM_DEBUG_KMS("force priority to high\n"); |
| 7978 | } |
| 7979 | } |
| 7980 | |
| 7981 | /* select wm A */ |
| 7982 | wm_mask = RREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset); |
| 7983 | tmp = wm_mask; |
| 7984 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 7985 | tmp |= LATENCY_WATERMARK_MASK(1); |
| 7986 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 7987 | WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset, |
| 7988 | (LATENCY_LOW_WATERMARK(latency_watermark_a) | |
| 7989 | LATENCY_HIGH_WATERMARK(line_time))); |
| 7990 | /* select wm B */ |
| 7991 | tmp = RREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset); |
| 7992 | tmp &= ~LATENCY_WATERMARK_MASK(3); |
| 7993 | tmp |= LATENCY_WATERMARK_MASK(2); |
| 7994 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 7995 | WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset, |
| 7996 | (LATENCY_LOW_WATERMARK(latency_watermark_b) | |
| 7997 | LATENCY_HIGH_WATERMARK(line_time))); |
| 7998 | /* restore original selection */ |
| 7999 | WREG32(DPG_WATERMARK_MASK_CONTROL + radeon_crtc->crtc_offset, wm_mask); |
Alex Deucher | 58ea2de | 2013-01-24 10:03:39 -0500 | [diff] [blame] | 8000 | |
| 8001 | /* save values for DPM */ |
| 8002 | radeon_crtc->line_time = line_time; |
| 8003 | radeon_crtc->wm_high = latency_watermark_a; |
| 8004 | radeon_crtc->wm_low = latency_watermark_b; |
Alex Deucher | cd84a27 | 2012-07-20 17:13:13 -0400 | [diff] [blame] | 8005 | } |
| 8006 | |
| 8007 | /** |
| 8008 | * dce8_bandwidth_update - program display watermarks |
| 8009 | * |
| 8010 | * @rdev: radeon_device pointer |
| 8011 | * |
| 8012 | * Calculate and program the display watermarks and line |
| 8013 | * buffer allocation (CIK). |
| 8014 | */ |
| 8015 | void dce8_bandwidth_update(struct radeon_device *rdev) |
| 8016 | { |
| 8017 | struct drm_display_mode *mode = NULL; |
| 8018 | u32 num_heads = 0, lb_size; |
| 8019 | int i; |
| 8020 | |
| 8021 | radeon_update_display_priority(rdev); |
| 8022 | |
| 8023 | for (i = 0; i < rdev->num_crtc; i++) { |
| 8024 | if (rdev->mode_info.crtcs[i]->base.enabled) |
| 8025 | num_heads++; |
| 8026 | } |
| 8027 | for (i = 0; i < rdev->num_crtc; i++) { |
| 8028 | mode = &rdev->mode_info.crtcs[i]->base.mode; |
| 8029 | lb_size = dce8_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i], mode); |
| 8030 | dce8_program_watermarks(rdev, rdev->mode_info.crtcs[i], lb_size, num_heads); |
| 8031 | } |
| 8032 | } |
Alex Deucher | 44fa346 | 2012-12-18 22:17:00 -0500 | [diff] [blame] | 8033 | |
| 8034 | /** |
| 8035 | * cik_get_gpu_clock_counter - return GPU clock counter snapshot |
| 8036 | * |
| 8037 | * @rdev: radeon_device pointer |
| 8038 | * |
| 8039 | * Fetches a GPU clock counter snapshot (SI). |
| 8040 | * Returns the 64 bit clock counter snapshot. |
| 8041 | */ |
| 8042 | uint64_t cik_get_gpu_clock_counter(struct radeon_device *rdev) |
| 8043 | { |
| 8044 | uint64_t clock; |
| 8045 | |
| 8046 | mutex_lock(&rdev->gpu_clock_mutex); |
| 8047 | WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT, 1); |
| 8048 | clock = (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB) | |
| 8049 | ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB) << 32ULL); |
| 8050 | mutex_unlock(&rdev->gpu_clock_mutex); |
| 8051 | return clock; |
| 8052 | } |
| 8053 | |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8054 | static int cik_set_uvd_clock(struct radeon_device *rdev, u32 clock, |
| 8055 | u32 cntl_reg, u32 status_reg) |
| 8056 | { |
| 8057 | int r, i; |
| 8058 | struct atom_clock_dividers dividers; |
| 8059 | uint32_t tmp; |
| 8060 | |
| 8061 | r = radeon_atom_get_clock_dividers(rdev, COMPUTE_GPUCLK_INPUT_FLAG_DEFAULT_GPUCLK, |
| 8062 | clock, false, ÷rs); |
| 8063 | if (r) |
| 8064 | return r; |
| 8065 | |
| 8066 | tmp = RREG32_SMC(cntl_reg); |
| 8067 | tmp &= ~(DCLK_DIR_CNTL_EN|DCLK_DIVIDER_MASK); |
| 8068 | tmp |= dividers.post_divider; |
| 8069 | WREG32_SMC(cntl_reg, tmp); |
| 8070 | |
| 8071 | for (i = 0; i < 100; i++) { |
| 8072 | if (RREG32_SMC(status_reg) & DCLK_STATUS) |
| 8073 | break; |
| 8074 | mdelay(10); |
| 8075 | } |
| 8076 | if (i == 100) |
| 8077 | return -ETIMEDOUT; |
| 8078 | |
| 8079 | return 0; |
| 8080 | } |
| 8081 | |
| 8082 | int cik_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk) |
| 8083 | { |
| 8084 | int r = 0; |
| 8085 | |
| 8086 | r = cik_set_uvd_clock(rdev, vclk, CG_VCLK_CNTL, CG_VCLK_STATUS); |
| 8087 | if (r) |
| 8088 | return r; |
| 8089 | |
| 8090 | r = cik_set_uvd_clock(rdev, dclk, CG_DCLK_CNTL, CG_DCLK_STATUS); |
| 8091 | return r; |
| 8092 | } |
| 8093 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8094 | static void cik_pcie_gen3_enable(struct radeon_device *rdev) |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8095 | { |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8096 | struct pci_dev *root = rdev->pdev->bus->self; |
| 8097 | int bridge_pos, gpu_pos; |
| 8098 | u32 speed_cntl, mask, current_data_rate; |
| 8099 | int ret, i; |
| 8100 | u16 tmp16; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8101 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8102 | if (radeon_pcie_gen2 == 0) |
| 8103 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8104 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8105 | if (rdev->flags & RADEON_IS_IGP) |
| 8106 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8107 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8108 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 8109 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8110 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8111 | ret = drm_pcie_get_speed_cap_mask(rdev->ddev, &mask); |
| 8112 | if (ret != 0) |
| 8113 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8114 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8115 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) |
| 8116 | return; |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8117 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8118 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8119 | current_data_rate = (speed_cntl & LC_CURRENT_DATA_RATE_MASK) >> |
| 8120 | LC_CURRENT_DATA_RATE_SHIFT; |
| 8121 | if (mask & DRM_PCIE_SPEED_80) { |
| 8122 | if (current_data_rate == 2) { |
| 8123 | DRM_INFO("PCIE gen 3 link speeds already enabled\n"); |
| 8124 | return; |
| 8125 | } |
| 8126 | DRM_INFO("enabling PCIE gen 3 link speeds, disable with radeon.pcie_gen2=0\n"); |
| 8127 | } else if (mask & DRM_PCIE_SPEED_50) { |
| 8128 | if (current_data_rate == 1) { |
| 8129 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); |
| 8130 | return; |
| 8131 | } |
| 8132 | DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); |
| 8133 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8134 | |
Alex Deucher | 8a7cd27 | 2013-08-06 11:29:39 -0400 | [diff] [blame] | 8135 | bridge_pos = pci_pcie_cap(root); |
| 8136 | if (!bridge_pos) |
| 8137 | return; |
| 8138 | |
| 8139 | gpu_pos = pci_pcie_cap(rdev->pdev); |
| 8140 | if (!gpu_pos) |
| 8141 | return; |
| 8142 | |
| 8143 | if (mask & DRM_PCIE_SPEED_80) { |
| 8144 | /* re-try equalization if gen3 is not already enabled */ |
| 8145 | if (current_data_rate != 2) { |
| 8146 | u16 bridge_cfg, gpu_cfg; |
| 8147 | u16 bridge_cfg2, gpu_cfg2; |
| 8148 | u32 max_lw, current_lw, tmp; |
| 8149 | |
| 8150 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); |
| 8151 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); |
| 8152 | |
| 8153 | tmp16 = bridge_cfg | PCI_EXP_LNKCTL_HAWD; |
| 8154 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); |
| 8155 | |
| 8156 | tmp16 = gpu_cfg | PCI_EXP_LNKCTL_HAWD; |
| 8157 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); |
| 8158 | |
| 8159 | tmp = RREG32_PCIE_PORT(PCIE_LC_STATUS1); |
| 8160 | max_lw = (tmp & LC_DETECTED_LINK_WIDTH_MASK) >> LC_DETECTED_LINK_WIDTH_SHIFT; |
| 8161 | current_lw = (tmp & LC_OPERATING_LINK_WIDTH_MASK) >> LC_OPERATING_LINK_WIDTH_SHIFT; |
| 8162 | |
| 8163 | if (current_lw < max_lw) { |
| 8164 | tmp = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
| 8165 | if (tmp & LC_RENEGOTIATION_SUPPORT) { |
| 8166 | tmp &= ~(LC_LINK_WIDTH_MASK | LC_UPCONFIGURE_DIS); |
| 8167 | tmp |= (max_lw << LC_LINK_WIDTH_SHIFT); |
| 8168 | tmp |= LC_UPCONFIGURE_SUPPORT | LC_RENEGOTIATE_EN | LC_RECONFIG_NOW; |
| 8169 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, tmp); |
| 8170 | } |
| 8171 | } |
| 8172 | |
| 8173 | for (i = 0; i < 10; i++) { |
| 8174 | /* check status */ |
| 8175 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_DEVSTA, &tmp16); |
| 8176 | if (tmp16 & PCI_EXP_DEVSTA_TRPND) |
| 8177 | break; |
| 8178 | |
| 8179 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &bridge_cfg); |
| 8180 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &gpu_cfg); |
| 8181 | |
| 8182 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &bridge_cfg2); |
| 8183 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &gpu_cfg2); |
| 8184 | |
| 8185 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8186 | tmp |= LC_SET_QUIESCE; |
| 8187 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8188 | |
| 8189 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8190 | tmp |= LC_REDO_EQ; |
| 8191 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8192 | |
| 8193 | mdelay(100); |
| 8194 | |
| 8195 | /* linkctl */ |
| 8196 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL, &tmp16); |
| 8197 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; |
| 8198 | tmp16 |= (bridge_cfg & PCI_EXP_LNKCTL_HAWD); |
| 8199 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL, tmp16); |
| 8200 | |
| 8201 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, &tmp16); |
| 8202 | tmp16 &= ~PCI_EXP_LNKCTL_HAWD; |
| 8203 | tmp16 |= (gpu_cfg & PCI_EXP_LNKCTL_HAWD); |
| 8204 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL, tmp16); |
| 8205 | |
| 8206 | /* linkctl2 */ |
| 8207 | pci_read_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8208 | tmp16 &= ~((1 << 4) | (7 << 9)); |
| 8209 | tmp16 |= (bridge_cfg2 & ((1 << 4) | (7 << 9))); |
| 8210 | pci_write_config_word(root, bridge_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8211 | |
| 8212 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8213 | tmp16 &= ~((1 << 4) | (7 << 9)); |
| 8214 | tmp16 |= (gpu_cfg2 & ((1 << 4) | (7 << 9))); |
| 8215 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8216 | |
| 8217 | tmp = RREG32_PCIE_PORT(PCIE_LC_CNTL4); |
| 8218 | tmp &= ~LC_SET_QUIESCE; |
| 8219 | WREG32_PCIE_PORT(PCIE_LC_CNTL4, tmp); |
| 8220 | } |
| 8221 | } |
| 8222 | } |
| 8223 | |
| 8224 | /* set the link speed */ |
| 8225 | speed_cntl |= LC_FORCE_EN_SW_SPEED_CHANGE | LC_FORCE_DIS_HW_SPEED_CHANGE; |
| 8226 | speed_cntl &= ~LC_FORCE_DIS_SW_SPEED_CHANGE; |
| 8227 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 8228 | |
| 8229 | pci_read_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
| 8230 | tmp16 &= ~0xf; |
| 8231 | if (mask & DRM_PCIE_SPEED_80) |
| 8232 | tmp16 |= 3; /* gen3 */ |
| 8233 | else if (mask & DRM_PCIE_SPEED_50) |
| 8234 | tmp16 |= 2; /* gen2 */ |
| 8235 | else |
| 8236 | tmp16 |= 1; /* gen1 */ |
| 8237 | pci_write_config_word(rdev->pdev, gpu_pos + PCI_EXP_LNKCTL2, tmp16); |
| 8238 | |
| 8239 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8240 | speed_cntl |= LC_INITIATE_LINK_SPEED_CHANGE; |
| 8241 | WREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL, speed_cntl); |
| 8242 | |
| 8243 | for (i = 0; i < rdev->usec_timeout; i++) { |
| 8244 | speed_cntl = RREG32_PCIE_PORT(PCIE_LC_SPEED_CNTL); |
| 8245 | if ((speed_cntl & LC_INITIATE_LINK_SPEED_CHANGE) == 0) |
| 8246 | break; |
| 8247 | udelay(1); |
| 8248 | } |
| 8249 | } |
Alex Deucher | 7235711a4 | 2013-04-04 13:58:09 -0400 | [diff] [blame] | 8250 | |
| 8251 | static void cik_program_aspm(struct radeon_device *rdev) |
| 8252 | { |
| 8253 | u32 data, orig; |
| 8254 | bool disable_l0s = false, disable_l1 = false, disable_plloff_in_l1 = false; |
| 8255 | bool disable_clkreq = false; |
| 8256 | |
| 8257 | if (radeon_aspm == 0) |
| 8258 | return; |
| 8259 | |
| 8260 | /* XXX double check IGPs */ |
| 8261 | if (rdev->flags & RADEON_IS_IGP) |
| 8262 | return; |
| 8263 | |
| 8264 | if (!(rdev->flags & RADEON_IS_PCIE)) |
| 8265 | return; |
| 8266 | |
| 8267 | orig = data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
| 8268 | data &= ~LC_XMIT_N_FTS_MASK; |
| 8269 | data |= LC_XMIT_N_FTS(0x24) | LC_XMIT_N_FTS_OVERRIDE_EN; |
| 8270 | if (orig != data) |
| 8271 | WREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL, data); |
| 8272 | |
| 8273 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL3); |
| 8274 | data |= LC_GO_TO_RECOVERY; |
| 8275 | if (orig != data) |
| 8276 | WREG32_PCIE_PORT(PCIE_LC_CNTL3, data); |
| 8277 | |
| 8278 | orig = data = RREG32_PCIE_PORT(PCIE_P_CNTL); |
| 8279 | data |= P_IGNORE_EDB_ERR; |
| 8280 | if (orig != data) |
| 8281 | WREG32_PCIE_PORT(PCIE_P_CNTL, data); |
| 8282 | |
| 8283 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
| 8284 | data &= ~(LC_L0S_INACTIVITY_MASK | LC_L1_INACTIVITY_MASK); |
| 8285 | data |= LC_PMI_TO_L1_DIS; |
| 8286 | if (!disable_l0s) |
| 8287 | data |= LC_L0S_INACTIVITY(7); |
| 8288 | |
| 8289 | if (!disable_l1) { |
| 8290 | data |= LC_L1_INACTIVITY(7); |
| 8291 | data &= ~LC_PMI_TO_L1_DIS; |
| 8292 | if (orig != data) |
| 8293 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8294 | |
| 8295 | if (!disable_plloff_in_l1) { |
| 8296 | bool clk_req_support; |
| 8297 | |
| 8298 | orig = data = RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0); |
| 8299 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); |
| 8300 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); |
| 8301 | if (orig != data) |
| 8302 | WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_0, data); |
| 8303 | |
| 8304 | orig = data = RREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1); |
| 8305 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); |
| 8306 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); |
| 8307 | if (orig != data) |
| 8308 | WREG32_PCIE_PORT(PB0_PIF_PWRDOWN_1, data); |
| 8309 | |
| 8310 | orig = data = RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0); |
| 8311 | data &= ~(PLL_POWER_STATE_IN_OFF_0_MASK | PLL_POWER_STATE_IN_TXS2_0_MASK); |
| 8312 | data |= PLL_POWER_STATE_IN_OFF_0(7) | PLL_POWER_STATE_IN_TXS2_0(7); |
| 8313 | if (orig != data) |
| 8314 | WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_0, data); |
| 8315 | |
| 8316 | orig = data = RREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1); |
| 8317 | data &= ~(PLL_POWER_STATE_IN_OFF_1_MASK | PLL_POWER_STATE_IN_TXS2_1_MASK); |
| 8318 | data |= PLL_POWER_STATE_IN_OFF_1(7) | PLL_POWER_STATE_IN_TXS2_1(7); |
| 8319 | if (orig != data) |
| 8320 | WREG32_PCIE_PORT(PB1_PIF_PWRDOWN_1, data); |
| 8321 | |
| 8322 | orig = data = RREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL); |
| 8323 | data &= ~LC_DYN_LANES_PWR_STATE_MASK; |
| 8324 | data |= LC_DYN_LANES_PWR_STATE(3); |
| 8325 | if (orig != data) |
| 8326 | WREG32_PCIE_PORT(PCIE_LC_LINK_WIDTH_CNTL, data); |
| 8327 | |
| 8328 | if (!disable_clkreq) { |
| 8329 | struct pci_dev *root = rdev->pdev->bus->self; |
| 8330 | u32 lnkcap; |
| 8331 | |
| 8332 | clk_req_support = false; |
| 8333 | pcie_capability_read_dword(root, PCI_EXP_LNKCAP, &lnkcap); |
| 8334 | if (lnkcap & PCI_EXP_LNKCAP_CLKPM) |
| 8335 | clk_req_support = true; |
| 8336 | } else { |
| 8337 | clk_req_support = false; |
| 8338 | } |
| 8339 | |
| 8340 | if (clk_req_support) { |
| 8341 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL2); |
| 8342 | data |= LC_ALLOW_PDWN_IN_L1 | LC_ALLOW_PDWN_IN_L23; |
| 8343 | if (orig != data) |
| 8344 | WREG32_PCIE_PORT(PCIE_LC_CNTL2, data); |
| 8345 | |
| 8346 | orig = data = RREG32_SMC(THM_CLK_CNTL); |
| 8347 | data &= ~(CMON_CLK_SEL_MASK | TMON_CLK_SEL_MASK); |
| 8348 | data |= CMON_CLK_SEL(1) | TMON_CLK_SEL(1); |
| 8349 | if (orig != data) |
| 8350 | WREG32_SMC(THM_CLK_CNTL, data); |
| 8351 | |
| 8352 | orig = data = RREG32_SMC(MISC_CLK_CTRL); |
| 8353 | data &= ~(DEEP_SLEEP_CLK_SEL_MASK | ZCLK_SEL_MASK); |
| 8354 | data |= DEEP_SLEEP_CLK_SEL(1) | ZCLK_SEL(1); |
| 8355 | if (orig != data) |
| 8356 | WREG32_SMC(MISC_CLK_CTRL, data); |
| 8357 | |
| 8358 | orig = data = RREG32_SMC(CG_CLKPIN_CNTL); |
| 8359 | data &= ~BCLK_AS_XCLK; |
| 8360 | if (orig != data) |
| 8361 | WREG32_SMC(CG_CLKPIN_CNTL, data); |
| 8362 | |
| 8363 | orig = data = RREG32_SMC(CG_CLKPIN_CNTL_2); |
| 8364 | data &= ~FORCE_BIF_REFCLK_EN; |
| 8365 | if (orig != data) |
| 8366 | WREG32_SMC(CG_CLKPIN_CNTL_2, data); |
| 8367 | |
| 8368 | orig = data = RREG32_SMC(MPLL_BYPASSCLK_SEL); |
| 8369 | data &= ~MPLL_CLKOUT_SEL_MASK; |
| 8370 | data |= MPLL_CLKOUT_SEL(4); |
| 8371 | if (orig != data) |
| 8372 | WREG32_SMC(MPLL_BYPASSCLK_SEL, data); |
| 8373 | } |
| 8374 | } |
| 8375 | } else { |
| 8376 | if (orig != data) |
| 8377 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8378 | } |
| 8379 | |
| 8380 | orig = data = RREG32_PCIE_PORT(PCIE_CNTL2); |
| 8381 | data |= SLV_MEM_LS_EN | MST_MEM_LS_EN | REPLAY_MEM_LS_EN; |
| 8382 | if (orig != data) |
| 8383 | WREG32_PCIE_PORT(PCIE_CNTL2, data); |
| 8384 | |
| 8385 | if (!disable_l0s) { |
| 8386 | data = RREG32_PCIE_PORT(PCIE_LC_N_FTS_CNTL); |
| 8387 | if((data & LC_N_FTS_MASK) == LC_N_FTS_MASK) { |
| 8388 | data = RREG32_PCIE_PORT(PCIE_LC_STATUS1); |
| 8389 | if ((data & LC_REVERSE_XMIT) && (data & LC_REVERSE_RCVR)) { |
| 8390 | orig = data = RREG32_PCIE_PORT(PCIE_LC_CNTL); |
| 8391 | data &= ~LC_L0S_INACTIVITY_MASK; |
| 8392 | if (orig != data) |
| 8393 | WREG32_PCIE_PORT(PCIE_LC_CNTL, data); |
| 8394 | } |
| 8395 | } |
| 8396 | } |
Christian König | 87167bb | 2013-04-09 13:39:21 -0400 | [diff] [blame] | 8397 | } |