Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Red Hat |
| 3 | * Author: Rob Clark <robdclark@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include "msm_gpu.h" |
| 19 | #include "msm_gem.h" |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 20 | #include "msm_mmu.h" |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 21 | #include "msm_fence.h" |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 22 | |
| 23 | |
| 24 | /* |
| 25 | * Power Management: |
| 26 | */ |
| 27 | |
Rob Clark | 6490ad4 | 2015-06-04 10:26:37 -0400 | [diff] [blame] | 28 | #ifdef DOWNSTREAM_CONFIG_MSM_BUS_SCALING |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 29 | #include <mach/board.h> |
Rob Clark | bf2b33af | 2013-11-15 09:03:15 -0500 | [diff] [blame] | 30 | static void bs_init(struct msm_gpu *gpu) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 31 | { |
Rob Clark | bf2b33af | 2013-11-15 09:03:15 -0500 | [diff] [blame] | 32 | if (gpu->bus_scale_table) { |
| 33 | gpu->bsc = msm_bus_scale_register_client(gpu->bus_scale_table); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 34 | DBG("bus scale client: %08x", gpu->bsc); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | static void bs_fini(struct msm_gpu *gpu) |
| 39 | { |
| 40 | if (gpu->bsc) { |
| 41 | msm_bus_scale_unregister_client(gpu->bsc); |
| 42 | gpu->bsc = 0; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | static void bs_set(struct msm_gpu *gpu, int idx) |
| 47 | { |
| 48 | if (gpu->bsc) { |
| 49 | DBG("set bus scaling: %d", idx); |
| 50 | msm_bus_scale_client_update_request(gpu->bsc, idx); |
| 51 | } |
| 52 | } |
| 53 | #else |
Rob Clark | bf2b33af | 2013-11-15 09:03:15 -0500 | [diff] [blame] | 54 | static void bs_init(struct msm_gpu *gpu) {} |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 55 | static void bs_fini(struct msm_gpu *gpu) {} |
| 56 | static void bs_set(struct msm_gpu *gpu, int idx) {} |
| 57 | #endif |
| 58 | |
| 59 | static int enable_pwrrail(struct msm_gpu *gpu) |
| 60 | { |
| 61 | struct drm_device *dev = gpu->dev; |
| 62 | int ret = 0; |
| 63 | |
| 64 | if (gpu->gpu_reg) { |
| 65 | ret = regulator_enable(gpu->gpu_reg); |
| 66 | if (ret) { |
| 67 | dev_err(dev->dev, "failed to enable 'gpu_reg': %d\n", ret); |
| 68 | return ret; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if (gpu->gpu_cx) { |
| 73 | ret = regulator_enable(gpu->gpu_cx); |
| 74 | if (ret) { |
| 75 | dev_err(dev->dev, "failed to enable 'gpu_cx': %d\n", ret); |
| 76 | return ret; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | static int disable_pwrrail(struct msm_gpu *gpu) |
| 84 | { |
| 85 | if (gpu->gpu_cx) |
| 86 | regulator_disable(gpu->gpu_cx); |
| 87 | if (gpu->gpu_reg) |
| 88 | regulator_disable(gpu->gpu_reg); |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static int enable_clk(struct msm_gpu *gpu) |
| 93 | { |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 94 | int i; |
| 95 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 96 | if (gpu->core_clk && gpu->fast_rate) |
| 97 | clk_set_rate(gpu->core_clk, gpu->fast_rate); |
Jordan Crouse | 89d777a | 2016-11-28 12:28:31 -0700 | [diff] [blame] | 98 | |
Jordan Crouse | b5f103a | 2016-11-28 12:28:33 -0700 | [diff] [blame] | 99 | /* Set the RBBM timer rate to 19.2Mhz */ |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 100 | if (gpu->rbbmtimer_clk) |
| 101 | clk_set_rate(gpu->rbbmtimer_clk, 19200000); |
Jordan Crouse | b5f103a | 2016-11-28 12:28:33 -0700 | [diff] [blame] | 102 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 103 | for (i = gpu->nr_clocks - 1; i >= 0; i--) |
Jordan Crouse | 89d777a | 2016-11-28 12:28:31 -0700 | [diff] [blame] | 104 | if (gpu->grp_clks[i]) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 105 | clk_prepare(gpu->grp_clks[i]); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 106 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 107 | for (i = gpu->nr_clocks - 1; i >= 0; i--) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 108 | if (gpu->grp_clks[i]) |
| 109 | clk_enable(gpu->grp_clks[i]); |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static int disable_clk(struct msm_gpu *gpu) |
| 115 | { |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 116 | int i; |
| 117 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 118 | for (i = gpu->nr_clocks - 1; i >= 0; i--) |
Jordan Crouse | 89d777a | 2016-11-28 12:28:31 -0700 | [diff] [blame] | 119 | if (gpu->grp_clks[i]) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 120 | clk_disable(gpu->grp_clks[i]); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 121 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 122 | for (i = gpu->nr_clocks - 1; i >= 0; i--) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 123 | if (gpu->grp_clks[i]) |
| 124 | clk_unprepare(gpu->grp_clks[i]); |
| 125 | |
Jordan Crouse | bf5af4a | 2017-03-07 10:02:54 -0700 | [diff] [blame] | 126 | /* |
| 127 | * Set the clock to a deliberately low rate. On older targets the clock |
| 128 | * speed had to be non zero to avoid problems. On newer targets this |
| 129 | * will be rounded down to zero anyway so it all works out. |
| 130 | */ |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 131 | if (gpu->core_clk) |
| 132 | clk_set_rate(gpu->core_clk, 27000000); |
Jordan Crouse | 89d777a | 2016-11-28 12:28:31 -0700 | [diff] [blame] | 133 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 134 | if (gpu->rbbmtimer_clk) |
| 135 | clk_set_rate(gpu->rbbmtimer_clk, 0); |
Jordan Crouse | b5f103a | 2016-11-28 12:28:33 -0700 | [diff] [blame] | 136 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | static int enable_axi(struct msm_gpu *gpu) |
| 141 | { |
| 142 | if (gpu->ebi1_clk) |
| 143 | clk_prepare_enable(gpu->ebi1_clk); |
| 144 | if (gpu->bus_freq) |
| 145 | bs_set(gpu, gpu->bus_freq); |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static int disable_axi(struct msm_gpu *gpu) |
| 150 | { |
| 151 | if (gpu->ebi1_clk) |
| 152 | clk_disable_unprepare(gpu->ebi1_clk); |
| 153 | if (gpu->bus_freq) |
| 154 | bs_set(gpu, 0); |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | int msm_gpu_pm_resume(struct msm_gpu *gpu) |
| 159 | { |
| 160 | int ret; |
| 161 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 162 | DBG("%s", gpu->name); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 163 | |
| 164 | ret = enable_pwrrail(gpu); |
| 165 | if (ret) |
| 166 | return ret; |
| 167 | |
| 168 | ret = enable_clk(gpu); |
| 169 | if (ret) |
| 170 | return ret; |
| 171 | |
| 172 | ret = enable_axi(gpu); |
| 173 | if (ret) |
| 174 | return ret; |
| 175 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 176 | gpu->needs_hw_init = true; |
| 177 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 178 | return 0; |
| 179 | } |
| 180 | |
| 181 | int msm_gpu_pm_suspend(struct msm_gpu *gpu) |
| 182 | { |
| 183 | int ret; |
| 184 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 185 | DBG("%s", gpu->name); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 186 | |
| 187 | ret = disable_axi(gpu); |
| 188 | if (ret) |
| 189 | return ret; |
| 190 | |
| 191 | ret = disable_clk(gpu); |
| 192 | if (ret) |
| 193 | return ret; |
| 194 | |
| 195 | ret = disable_pwrrail(gpu); |
| 196 | if (ret) |
| 197 | return ret; |
| 198 | |
| 199 | return 0; |
| 200 | } |
| 201 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 202 | int msm_gpu_hw_init(struct msm_gpu *gpu) |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 203 | { |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 204 | int ret; |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 205 | |
Rob Clark | cb1e381 | 2017-06-13 09:15:36 -0400 | [diff] [blame] | 206 | WARN_ON(!mutex_is_locked(&gpu->dev->struct_mutex)); |
| 207 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 208 | if (!gpu->needs_hw_init) |
| 209 | return 0; |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 210 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 211 | disable_irq(gpu->irq); |
| 212 | ret = gpu->funcs->hw_init(gpu); |
| 213 | if (!ret) |
| 214 | gpu->needs_hw_init = false; |
| 215 | enable_irq(gpu->irq); |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 216 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 217 | return ret; |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 221 | * Hangcheck detection for locked gpu: |
| 222 | */ |
| 223 | |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 224 | static void retire_submits(struct msm_gpu *gpu); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 225 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 226 | static void recover_worker(struct work_struct *work) |
| 227 | { |
| 228 | struct msm_gpu *gpu = container_of(work, struct msm_gpu, recover_work); |
| 229 | struct drm_device *dev = gpu->dev; |
Rob Clark | 4816b62 | 2016-05-03 10:10:15 -0400 | [diff] [blame] | 230 | struct msm_gem_submit *submit; |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 231 | uint32_t fence = gpu->funcs->last_fence(gpu); |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 232 | |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 233 | msm_update_fence(gpu->fctx, fence + 1); |
| 234 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 235 | mutex_lock(&dev->struct_mutex); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 236 | |
Rob Clark | 4816b62 | 2016-05-03 10:10:15 -0400 | [diff] [blame] | 237 | dev_err(dev->dev, "%s: hangcheck recover!\n", gpu->name); |
| 238 | list_for_each_entry(submit, &gpu->submit_list, node) { |
| 239 | if (submit->fence->seqno == (fence + 1)) { |
| 240 | struct task_struct *task; |
| 241 | |
| 242 | rcu_read_lock(); |
| 243 | task = pid_task(submit->pid, PIDTYPE_PID); |
| 244 | if (task) { |
| 245 | dev_err(dev->dev, "%s: offending task: %s\n", |
| 246 | gpu->name, task->comm); |
| 247 | } |
| 248 | rcu_read_unlock(); |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | if (msm_gpu_active(gpu)) { |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 254 | /* retire completed submits, plus the one that hung: */ |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 255 | retire_submits(gpu); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 256 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 257 | pm_runtime_get_sync(&gpu->pdev->dev); |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 258 | gpu->funcs->recover(gpu); |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 259 | pm_runtime_put_sync(&gpu->pdev->dev); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 260 | |
| 261 | /* replay the remaining submits after the one that hung: */ |
| 262 | list_for_each_entry(submit, &gpu->submit_list, node) { |
| 263 | gpu->funcs->submit(gpu, submit, NULL); |
| 264 | } |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 265 | } |
Rob Clark | 4816b62 | 2016-05-03 10:10:15 -0400 | [diff] [blame] | 266 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 267 | mutex_unlock(&dev->struct_mutex); |
| 268 | |
| 269 | msm_gpu_retire(gpu); |
| 270 | } |
| 271 | |
| 272 | static void hangcheck_timer_reset(struct msm_gpu *gpu) |
| 273 | { |
| 274 | DBG("%s", gpu->name); |
| 275 | mod_timer(&gpu->hangcheck_timer, |
| 276 | round_jiffies_up(jiffies + DRM_MSM_HANGCHECK_JIFFIES)); |
| 277 | } |
| 278 | |
| 279 | static void hangcheck_handler(unsigned long data) |
| 280 | { |
| 281 | struct msm_gpu *gpu = (struct msm_gpu *)data; |
Rob Clark | 6b8819c | 2013-09-11 17:14:30 -0400 | [diff] [blame] | 282 | struct drm_device *dev = gpu->dev; |
| 283 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 284 | uint32_t fence = gpu->funcs->last_fence(gpu); |
| 285 | |
| 286 | if (fence != gpu->hangcheck_fence) { |
| 287 | /* some progress has been made.. ya! */ |
| 288 | gpu->hangcheck_fence = fence; |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 289 | } else if (fence < gpu->fctx->last_fence) { |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 290 | /* no progress and not done.. hung! */ |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 291 | gpu->hangcheck_fence = fence; |
Rob Clark | 26791c4 | 2013-09-03 07:12:03 -0400 | [diff] [blame] | 292 | dev_err(dev->dev, "%s: hangcheck detected gpu lockup!\n", |
| 293 | gpu->name); |
| 294 | dev_err(dev->dev, "%s: completed fence: %u\n", |
| 295 | gpu->name, fence); |
| 296 | dev_err(dev->dev, "%s: submitted fence: %u\n", |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 297 | gpu->name, gpu->fctx->last_fence); |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 298 | queue_work(priv->wq, &gpu->recover_work); |
| 299 | } |
| 300 | |
| 301 | /* if still more pending work, reset the hangcheck timer: */ |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 302 | if (gpu->fctx->last_fence > gpu->hangcheck_fence) |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 303 | hangcheck_timer_reset(gpu); |
Rob Clark | 6b8819c | 2013-09-11 17:14:30 -0400 | [diff] [blame] | 304 | |
| 305 | /* workaround for missing irq: */ |
| 306 | queue_work(priv->wq, &gpu->retire_work); |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | /* |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 310 | * Performance Counters: |
| 311 | */ |
| 312 | |
| 313 | /* called under perf_lock */ |
| 314 | static int update_hw_cntrs(struct msm_gpu *gpu, uint32_t ncntrs, uint32_t *cntrs) |
| 315 | { |
| 316 | uint32_t current_cntrs[ARRAY_SIZE(gpu->last_cntrs)]; |
| 317 | int i, n = min(ncntrs, gpu->num_perfcntrs); |
| 318 | |
| 319 | /* read current values: */ |
| 320 | for (i = 0; i < gpu->num_perfcntrs; i++) |
| 321 | current_cntrs[i] = gpu_read(gpu, gpu->perfcntrs[i].sample_reg); |
| 322 | |
| 323 | /* update cntrs: */ |
| 324 | for (i = 0; i < n; i++) |
| 325 | cntrs[i] = current_cntrs[i] - gpu->last_cntrs[i]; |
| 326 | |
| 327 | /* save current values: */ |
| 328 | for (i = 0; i < gpu->num_perfcntrs; i++) |
| 329 | gpu->last_cntrs[i] = current_cntrs[i]; |
| 330 | |
| 331 | return n; |
| 332 | } |
| 333 | |
| 334 | static void update_sw_cntrs(struct msm_gpu *gpu) |
| 335 | { |
| 336 | ktime_t time; |
| 337 | uint32_t elapsed; |
| 338 | unsigned long flags; |
| 339 | |
| 340 | spin_lock_irqsave(&gpu->perf_lock, flags); |
| 341 | if (!gpu->perfcntr_active) |
| 342 | goto out; |
| 343 | |
| 344 | time = ktime_get(); |
| 345 | elapsed = ktime_to_us(ktime_sub(time, gpu->last_sample.time)); |
| 346 | |
| 347 | gpu->totaltime += elapsed; |
| 348 | if (gpu->last_sample.active) |
| 349 | gpu->activetime += elapsed; |
| 350 | |
| 351 | gpu->last_sample.active = msm_gpu_active(gpu); |
| 352 | gpu->last_sample.time = time; |
| 353 | |
| 354 | out: |
| 355 | spin_unlock_irqrestore(&gpu->perf_lock, flags); |
| 356 | } |
| 357 | |
| 358 | void msm_gpu_perfcntr_start(struct msm_gpu *gpu) |
| 359 | { |
| 360 | unsigned long flags; |
| 361 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 362 | pm_runtime_get_sync(&gpu->pdev->dev); |
| 363 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 364 | spin_lock_irqsave(&gpu->perf_lock, flags); |
| 365 | /* we could dynamically enable/disable perfcntr registers too.. */ |
| 366 | gpu->last_sample.active = msm_gpu_active(gpu); |
| 367 | gpu->last_sample.time = ktime_get(); |
| 368 | gpu->activetime = gpu->totaltime = 0; |
| 369 | gpu->perfcntr_active = true; |
| 370 | update_hw_cntrs(gpu, 0, NULL); |
| 371 | spin_unlock_irqrestore(&gpu->perf_lock, flags); |
| 372 | } |
| 373 | |
| 374 | void msm_gpu_perfcntr_stop(struct msm_gpu *gpu) |
| 375 | { |
| 376 | gpu->perfcntr_active = false; |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 377 | pm_runtime_put_sync(&gpu->pdev->dev); |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | /* returns -errno or # of cntrs sampled */ |
| 381 | int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime, |
| 382 | uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs) |
| 383 | { |
| 384 | unsigned long flags; |
| 385 | int ret; |
| 386 | |
| 387 | spin_lock_irqsave(&gpu->perf_lock, flags); |
| 388 | |
| 389 | if (!gpu->perfcntr_active) { |
| 390 | ret = -EINVAL; |
| 391 | goto out; |
| 392 | } |
| 393 | |
| 394 | *activetime = gpu->activetime; |
| 395 | *totaltime = gpu->totaltime; |
| 396 | |
| 397 | gpu->activetime = gpu->totaltime = 0; |
| 398 | |
| 399 | ret = update_hw_cntrs(gpu, ncntrs, cntrs); |
| 400 | |
| 401 | out: |
| 402 | spin_unlock_irqrestore(&gpu->perf_lock, flags); |
| 403 | |
| 404 | return ret; |
| 405 | } |
| 406 | |
| 407 | /* |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 408 | * Cmdstream submission/retirement: |
| 409 | */ |
| 410 | |
Rob Clark | 7d12a27 | 2016-03-16 16:07:38 -0400 | [diff] [blame] | 411 | static void retire_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) |
| 412 | { |
| 413 | int i; |
| 414 | |
| 415 | for (i = 0; i < submit->nr_bos; i++) { |
| 416 | struct msm_gem_object *msm_obj = submit->bos[i].obj; |
| 417 | /* move to inactive: */ |
| 418 | msm_gem_move_to_inactive(&msm_obj->base); |
Rob Clark | 8bdcd94 | 2017-06-13 11:07:08 -0400 | [diff] [blame^] | 419 | msm_gem_put_iova(&msm_obj->base, gpu->aspace); |
Rob Clark | 7d12a27 | 2016-03-16 16:07:38 -0400 | [diff] [blame] | 420 | drm_gem_object_unreference(&msm_obj->base); |
| 421 | } |
| 422 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 423 | pm_runtime_mark_last_busy(&gpu->pdev->dev); |
| 424 | pm_runtime_put_autosuspend(&gpu->pdev->dev); |
Rob Clark | 40e6815 | 2016-05-03 09:50:26 -0400 | [diff] [blame] | 425 | msm_gem_submit_free(submit); |
Rob Clark | 7d12a27 | 2016-03-16 16:07:38 -0400 | [diff] [blame] | 426 | } |
| 427 | |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 428 | static void retire_submits(struct msm_gpu *gpu) |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 429 | { |
| 430 | struct drm_device *dev = gpu->dev; |
| 431 | |
| 432 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); |
| 433 | |
| 434 | while (!list_empty(&gpu->submit_list)) { |
| 435 | struct msm_gem_submit *submit; |
| 436 | |
| 437 | submit = list_first_entry(&gpu->submit_list, |
| 438 | struct msm_gem_submit, node); |
| 439 | |
Chris Wilson | f54d186 | 2016-10-25 13:00:45 +0100 | [diff] [blame] | 440 | if (dma_fence_is_signaled(submit->fence)) { |
Rob Clark | 7d12a27 | 2016-03-16 16:07:38 -0400 | [diff] [blame] | 441 | retire_submit(gpu, submit); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 442 | } else { |
| 443 | break; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 448 | static void retire_worker(struct work_struct *work) |
| 449 | { |
| 450 | struct msm_gpu *gpu = container_of(work, struct msm_gpu, retire_work); |
| 451 | struct drm_device *dev = gpu->dev; |
| 452 | uint32_t fence = gpu->funcs->last_fence(gpu); |
| 453 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 454 | msm_update_fence(gpu->fctx, fence); |
Rob Clark | edd4fc6 | 2013-09-14 14:01:55 -0400 | [diff] [blame] | 455 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 456 | mutex_lock(&dev->struct_mutex); |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 457 | retire_submits(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 458 | mutex_unlock(&dev->struct_mutex); |
| 459 | } |
| 460 | |
| 461 | /* call from irq handler to schedule work to retire bo's */ |
| 462 | void msm_gpu_retire(struct msm_gpu *gpu) |
| 463 | { |
| 464 | struct msm_drm_private *priv = gpu->dev->dev_private; |
| 465 | queue_work(priv->wq, &gpu->retire_work); |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 466 | update_sw_cntrs(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | /* add bo's to gpu's ring, and kick gpu: */ |
Rob Clark | f44d32c | 2016-06-16 16:37:38 -0400 | [diff] [blame] | 470 | void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 471 | struct msm_file_private *ctx) |
| 472 | { |
| 473 | struct drm_device *dev = gpu->dev; |
| 474 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | f44d32c | 2016-06-16 16:37:38 -0400 | [diff] [blame] | 475 | int i; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 476 | |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 477 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); |
| 478 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 479 | pm_runtime_get_sync(&gpu->pdev->dev); |
| 480 | |
| 481 | msm_gpu_hw_init(gpu); |
Rob Clark | 37d77c3 | 2014-01-11 16:25:08 -0500 | [diff] [blame] | 482 | |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 483 | list_add_tail(&submit->node, &gpu->submit_list); |
| 484 | |
Rob Clark | a7d3c95 | 2014-05-30 14:47:38 -0400 | [diff] [blame] | 485 | msm_rd_dump_submit(submit); |
| 486 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 487 | update_sw_cntrs(gpu); |
| 488 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 489 | for (i = 0; i < submit->nr_bos; i++) { |
| 490 | struct msm_gem_object *msm_obj = submit->bos[i].obj; |
Rob Clark | 78babc1 | 2016-11-11 12:06:46 -0500 | [diff] [blame] | 491 | uint64_t iova; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 492 | |
| 493 | /* can't happen yet.. but when we add 2d support we'll have |
| 494 | * to deal w/ cross-ring synchronization: |
| 495 | */ |
| 496 | WARN_ON(is_active(msm_obj) && (msm_obj->gpu != gpu)); |
| 497 | |
Rob Clark | 7d12a27 | 2016-03-16 16:07:38 -0400 | [diff] [blame] | 498 | /* submit takes a reference to the bo and iova until retired: */ |
| 499 | drm_gem_object_reference(&msm_obj->base); |
| 500 | msm_gem_get_iova_locked(&msm_obj->base, |
Rob Clark | 8bdcd94 | 2017-06-13 11:07:08 -0400 | [diff] [blame^] | 501 | submit->gpu->aspace, &iova); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 502 | |
Rob Clark | bf6811f | 2013-09-01 13:25:09 -0400 | [diff] [blame] | 503 | if (submit->bos[i].flags & MSM_SUBMIT_BO_WRITE) |
| 504 | msm_gem_move_to_active(&msm_obj->base, gpu, true, submit->fence); |
Rob Clark | b6295f9 | 2016-03-15 18:26:28 -0400 | [diff] [blame] | 505 | else if (submit->bos[i].flags & MSM_SUBMIT_BO_READ) |
| 506 | msm_gem_move_to_active(&msm_obj->base, gpu, false, submit->fence); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 507 | } |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 508 | |
Rob Clark | 1193c3b | 2016-05-03 09:46:49 -0400 | [diff] [blame] | 509 | gpu->funcs->submit(gpu, submit, ctx); |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 510 | priv->lastctx = ctx; |
| 511 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 512 | hangcheck_timer_reset(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /* |
| 516 | * Init/Cleanup: |
| 517 | */ |
| 518 | |
| 519 | static irqreturn_t irq_handler(int irq, void *data) |
| 520 | { |
| 521 | struct msm_gpu *gpu = data; |
| 522 | return gpu->funcs->irq(gpu); |
| 523 | } |
| 524 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 525 | static struct clk *get_clock(struct device *dev, const char *name) |
| 526 | { |
| 527 | struct clk *clk = devm_clk_get(dev, name); |
| 528 | |
| 529 | return IS_ERR(clk) ? NULL : clk; |
| 530 | } |
| 531 | |
| 532 | static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) |
| 533 | { |
| 534 | struct device *dev = &pdev->dev; |
| 535 | struct property *prop; |
| 536 | const char *name; |
| 537 | int i = 0; |
| 538 | |
| 539 | gpu->nr_clocks = of_property_count_strings(dev->of_node, "clock-names"); |
| 540 | if (gpu->nr_clocks < 1) { |
| 541 | gpu->nr_clocks = 0; |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | gpu->grp_clks = devm_kcalloc(dev, sizeof(struct clk *), gpu->nr_clocks, |
| 546 | GFP_KERNEL); |
| 547 | if (!gpu->grp_clks) |
| 548 | return -ENOMEM; |
| 549 | |
| 550 | of_property_for_each_string(dev->of_node, "clock-names", prop, name) { |
| 551 | gpu->grp_clks[i] = get_clock(dev, name); |
| 552 | |
| 553 | /* Remember the key clocks that we need to control later */ |
Rob Clark | 134ccad | 2017-05-03 10:43:14 -0400 | [diff] [blame] | 554 | if (!strcmp(name, "core") || !strcmp(name, "core_clk")) |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 555 | gpu->core_clk = gpu->grp_clks[i]; |
Rob Clark | 134ccad | 2017-05-03 10:43:14 -0400 | [diff] [blame] | 556 | else if (!strcmp(name, "rbbmtimer") || !strcmp(name, "rbbmtimer_clk")) |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 557 | gpu->rbbmtimer_clk = gpu->grp_clks[i]; |
| 558 | |
| 559 | ++i; |
| 560 | } |
| 561 | |
| 562 | return 0; |
| 563 | } |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 564 | |
| 565 | int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, |
| 566 | struct msm_gpu *gpu, const struct msm_gpu_funcs *funcs, |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 567 | const char *name, struct msm_gpu_config *config) |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 568 | { |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 569 | struct iommu_domain *iommu; |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 570 | int ret; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 571 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 572 | if (WARN_ON(gpu->num_perfcntrs > ARRAY_SIZE(gpu->last_cntrs))) |
| 573 | gpu->num_perfcntrs = ARRAY_SIZE(gpu->last_cntrs); |
| 574 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 575 | gpu->dev = drm; |
| 576 | gpu->funcs = funcs; |
| 577 | gpu->name = name; |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 578 | gpu->fctx = msm_fence_context_alloc(drm, name); |
| 579 | if (IS_ERR(gpu->fctx)) { |
| 580 | ret = PTR_ERR(gpu->fctx); |
| 581 | gpu->fctx = NULL; |
| 582 | goto fail; |
| 583 | } |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 584 | |
| 585 | INIT_LIST_HEAD(&gpu->active_list); |
| 586 | INIT_WORK(&gpu->retire_work, retire_worker); |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 587 | INIT_WORK(&gpu->recover_work, recover_worker); |
| 588 | |
Rob Clark | 1a370be | 2015-06-07 13:46:04 -0400 | [diff] [blame] | 589 | INIT_LIST_HEAD(&gpu->submit_list); |
| 590 | |
Rob Clark | bd6f82d | 2013-08-24 14:20:38 -0400 | [diff] [blame] | 591 | setup_timer(&gpu->hangcheck_timer, hangcheck_handler, |
| 592 | (unsigned long)gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 593 | |
Rob Clark | 70c70f0 | 2014-05-30 14:49:43 -0400 | [diff] [blame] | 594 | spin_lock_init(&gpu->perf_lock); |
| 595 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 596 | |
| 597 | /* Map registers: */ |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 598 | gpu->mmio = msm_ioremap(pdev, config->ioname, name); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 599 | if (IS_ERR(gpu->mmio)) { |
| 600 | ret = PTR_ERR(gpu->mmio); |
| 601 | goto fail; |
| 602 | } |
| 603 | |
| 604 | /* Get Interrupt: */ |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 605 | gpu->irq = platform_get_irq_byname(pdev, config->irqname); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 606 | if (gpu->irq < 0) { |
| 607 | ret = gpu->irq; |
| 608 | dev_err(drm->dev, "failed to get irq: %d\n", ret); |
| 609 | goto fail; |
| 610 | } |
| 611 | |
| 612 | ret = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, |
| 613 | IRQF_TRIGGER_HIGH, gpu->name, gpu); |
| 614 | if (ret) { |
| 615 | dev_err(drm->dev, "failed to request IRQ%u: %d\n", gpu->irq, ret); |
| 616 | goto fail; |
| 617 | } |
| 618 | |
Jordan Crouse | 98db803 | 2017-03-07 10:02:56 -0700 | [diff] [blame] | 619 | ret = get_clocks(pdev, gpu); |
| 620 | if (ret) |
| 621 | goto fail; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 622 | |
Rob Clark | 720c3bb | 2017-01-30 11:30:58 -0500 | [diff] [blame] | 623 | gpu->ebi1_clk = msm_clk_get(pdev, "bus"); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 624 | DBG("ebi1_clk: %p", gpu->ebi1_clk); |
| 625 | if (IS_ERR(gpu->ebi1_clk)) |
| 626 | gpu->ebi1_clk = NULL; |
| 627 | |
| 628 | /* Acquire regulators: */ |
| 629 | gpu->gpu_reg = devm_regulator_get(&pdev->dev, "vdd"); |
| 630 | DBG("gpu_reg: %p", gpu->gpu_reg); |
| 631 | if (IS_ERR(gpu->gpu_reg)) |
| 632 | gpu->gpu_reg = NULL; |
| 633 | |
| 634 | gpu->gpu_cx = devm_regulator_get(&pdev->dev, "vddcx"); |
| 635 | DBG("gpu_cx: %p", gpu->gpu_cx); |
| 636 | if (IS_ERR(gpu->gpu_cx)) |
| 637 | gpu->gpu_cx = NULL; |
| 638 | |
| 639 | /* Setup IOMMU.. eventually we will (I think) do this once per context |
| 640 | * and have separate page tables per context. For now, to keep things |
| 641 | * simple and to get something working, just use a single address space: |
| 642 | */ |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 643 | iommu = iommu_domain_alloc(&platform_bus_type); |
| 644 | if (iommu) { |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 645 | iommu->geometry.aperture_start = config->va_start; |
| 646 | iommu->geometry.aperture_end = config->va_end; |
Rob Clark | 667ce33 | 2016-09-28 19:58:32 -0400 | [diff] [blame] | 647 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 648 | dev_info(drm->dev, "%s: using IOMMU\n", name); |
Rob Clark | 667ce33 | 2016-09-28 19:58:32 -0400 | [diff] [blame] | 649 | gpu->aspace = msm_gem_address_space_create(&pdev->dev, |
| 650 | iommu, "gpu"); |
| 651 | if (IS_ERR(gpu->aspace)) { |
| 652 | ret = PTR_ERR(gpu->aspace); |
Stephane Viau | 5e921b1 | 2015-09-15 08:41:46 -0400 | [diff] [blame] | 653 | dev_err(drm->dev, "failed to init iommu: %d\n", ret); |
Rob Clark | 667ce33 | 2016-09-28 19:58:32 -0400 | [diff] [blame] | 654 | gpu->aspace = NULL; |
Stephane Viau | 5e921b1 | 2015-09-15 08:41:46 -0400 | [diff] [blame] | 655 | iommu_domain_free(iommu); |
| 656 | goto fail; |
| 657 | } |
| 658 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 659 | } else { |
| 660 | dev_info(drm->dev, "%s: no IOMMU, fallback to VRAM carveout!\n", name); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 661 | } |
Rob Clark | 667ce33 | 2016-09-28 19:58:32 -0400 | [diff] [blame] | 662 | gpu->id = msm_register_address_space(drm, gpu->aspace); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 663 | |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 664 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 665 | /* Create ringbuffer: */ |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 666 | mutex_lock(&drm->struct_mutex); |
Jordan Crouse | 5770fc7 | 2017-05-08 14:35:03 -0600 | [diff] [blame] | 667 | gpu->rb = msm_ringbuffer_new(gpu, config->ringsz); |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 668 | mutex_unlock(&drm->struct_mutex); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 669 | if (IS_ERR(gpu->rb)) { |
| 670 | ret = PTR_ERR(gpu->rb); |
| 671 | gpu->rb = NULL; |
| 672 | dev_err(drm->dev, "could not create ringbuffer: %d\n", ret); |
| 673 | goto fail; |
| 674 | } |
| 675 | |
Rob Clark | eeb7547 | 2017-02-10 15:36:33 -0500 | [diff] [blame] | 676 | gpu->pdev = pdev; |
| 677 | platform_set_drvdata(pdev, gpu); |
| 678 | |
Rob Clark | bf2b33af | 2013-11-15 09:03:15 -0500 | [diff] [blame] | 679 | bs_init(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 680 | |
| 681 | return 0; |
| 682 | |
| 683 | fail: |
| 684 | return ret; |
| 685 | } |
| 686 | |
| 687 | void msm_gpu_cleanup(struct msm_gpu *gpu) |
| 688 | { |
| 689 | DBG("%s", gpu->name); |
| 690 | |
| 691 | WARN_ON(!list_empty(&gpu->active_list)); |
| 692 | |
| 693 | bs_fini(gpu); |
| 694 | |
| 695 | if (gpu->rb) { |
| 696 | if (gpu->rb_iova) |
Rob Clark | 8bdcd94 | 2017-06-13 11:07:08 -0400 | [diff] [blame^] | 697 | msm_gem_put_iova(gpu->rb->bo, gpu->aspace); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 698 | msm_ringbuffer_destroy(gpu->rb); |
| 699 | } |
| 700 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 701 | if (gpu->fctx) |
| 702 | msm_fence_context_free(gpu->fctx); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 703 | } |