blob: 4951172ede067f0beb9f9b863e77989c49bb84f3 [file] [log] [blame]
Rob Clark7198e6b2013-07-19 12:59:32 -04001/*
2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
4 *
Aravind Ganesan91b74e92014-09-08 10:57:28 -06005 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
6 *
Rob Clark7198e6b2013-07-19 12:59:32 -04007 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "adreno_gpu.h"
21#include "msm_gem.h"
Rob Clark871d8122013-11-16 12:56:06 -050022#include "msm_mmu.h"
Rob Clark7198e6b2013-07-19 12:59:32 -040023
Rob Clark7198e6b2013-07-19 12:59:32 -040024#define RB_SIZE SZ_32K
25#define RB_BLKSIZE 16
26
27int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
28{
29 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
30
31 switch (param) {
32 case MSM_PARAM_GPU_ID:
33 *value = adreno_gpu->info->revn;
34 return 0;
35 case MSM_PARAM_GMEM_SIZE:
Rob Clark55459962013-12-05 17:39:53 -050036 *value = adreno_gpu->gmem;
Rob Clark7198e6b2013-07-19 12:59:32 -040037 return 0;
Rob Clark4e1cbaa2014-02-04 14:16:04 -050038 case MSM_PARAM_CHIP_ID:
39 *value = adreno_gpu->rev.patchid |
40 (adreno_gpu->rev.minor << 8) |
41 (adreno_gpu->rev.major << 16) |
42 (adreno_gpu->rev.core << 24);
43 return 0;
Rob Clark4102a9e2016-02-09 12:05:30 -050044 case MSM_PARAM_MAX_FREQ:
45 *value = adreno_gpu->base.fast_rate;
46 return 0;
Rob Clark6c77d1a2016-02-22 06:26:21 -050047 case MSM_PARAM_TIMESTAMP:
48 if (adreno_gpu->funcs->get_timestamp)
49 return adreno_gpu->funcs->get_timestamp(gpu, value);
50 return -EINVAL;
Rob Clark7198e6b2013-07-19 12:59:32 -040051 default:
52 DBG("%s: invalid param: %u", gpu->name, param);
53 return -EINVAL;
54 }
55}
56
57#define rbmemptr(adreno_gpu, member) \
58 ((adreno_gpu)->memptrs_iova + offsetof(struct adreno_rbmemptrs, member))
59
60int adreno_hw_init(struct msm_gpu *gpu)
61{
62 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark944fc362014-07-09 22:08:15 -040063 int ret;
Rob Clark7198e6b2013-07-19 12:59:32 -040064
65 DBG("%s", gpu->name);
66
Rob Clarka1ad3522014-07-11 11:59:22 -040067 ret = msm_gem_get_iova(gpu->rb->bo, gpu->id, &gpu->rb_iova);
Rob Clark944fc362014-07-09 22:08:15 -040068 if (ret) {
69 gpu->rb_iova = 0;
70 dev_err(gpu->dev->dev, "could not map ringbuffer: %d\n", ret);
71 return ret;
72 }
73
Rob Clark7198e6b2013-07-19 12:59:32 -040074 /* Setup REG_CP_RB_CNTL: */
Aravind Ganesan91b74e92014-09-08 10:57:28 -060075 adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_CNTL,
Rob Clark7198e6b2013-07-19 12:59:32 -040076 /* size is log2(quad-words): */
77 AXXX_CP_RB_CNTL_BUFSZ(ilog2(gpu->rb->size / 8)) |
Craig Stout7d0c5ee2016-02-18 16:50:02 -080078 AXXX_CP_RB_CNTL_BLKSZ(ilog2(RB_BLKSIZE / 8)) |
79 (adreno_is_a430(adreno_gpu) ? AXXX_CP_RB_CNTL_NO_UPDATE : 0));
Rob Clark7198e6b2013-07-19 12:59:32 -040080
81 /* Setup ringbuffer address: */
Aravind Ganesan91b74e92014-09-08 10:57:28 -060082 adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_BASE, gpu->rb_iova);
Rob Clark7198e6b2013-07-19 12:59:32 -040083
Craig Stout7d0c5ee2016-02-18 16:50:02 -080084 if (!adreno_is_a430(adreno_gpu))
85 adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_RPTR_ADDR,
86 rbmemptr(adreno_gpu, rptr));
Rob Clark7198e6b2013-07-19 12:59:32 -040087
88 return 0;
89}
90
91static uint32_t get_wptr(struct msm_ringbuffer *ring)
92{
93 return ring->cur - ring->start;
94}
95
Craig Stout7d0c5ee2016-02-18 16:50:02 -080096/* Use this helper to read rptr, since a430 doesn't update rptr in memory */
97static uint32_t get_rptr(struct adreno_gpu *adreno_gpu)
98{
99 if (adreno_is_a430(adreno_gpu))
100 return adreno_gpu->memptrs->rptr = adreno_gpu_read(
101 adreno_gpu, REG_ADRENO_CP_RB_RPTR);
102 else
103 return adreno_gpu->memptrs->rptr;
104}
105
Rob Clark7198e6b2013-07-19 12:59:32 -0400106uint32_t adreno_last_fence(struct msm_gpu *gpu)
107{
108 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
109 return adreno_gpu->memptrs->fence;
110}
111
Rob Clarkbd6f82d2013-08-24 14:20:38 -0400112void adreno_recover(struct msm_gpu *gpu)
113{
114 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
115 struct drm_device *dev = gpu->dev;
116 int ret;
117
118 gpu->funcs->pm_suspend(gpu);
119
120 /* reset ringbuffer: */
121 gpu->rb->cur = gpu->rb->start;
122
123 /* reset completed fence seqno, just discard anything pending: */
124 adreno_gpu->memptrs->fence = gpu->submitted_fence;
Rob Clark26791c42013-09-03 07:12:03 -0400125 adreno_gpu->memptrs->rptr = 0;
126 adreno_gpu->memptrs->wptr = 0;
Rob Clarkbd6f82d2013-08-24 14:20:38 -0400127
128 gpu->funcs->pm_resume(gpu);
129 ret = gpu->funcs->hw_init(gpu);
130 if (ret) {
131 dev_err(dev->dev, "gpu hw init failed: %d\n", ret);
132 /* hmm, oh well? */
133 }
134}
135
Rob Clark7198e6b2013-07-19 12:59:32 -0400136int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
137 struct msm_file_private *ctx)
138{
139 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
140 struct msm_drm_private *priv = gpu->dev->dev_private;
141 struct msm_ringbuffer *ring = gpu->rb;
142 unsigned i, ibs = 0;
143
Rob Clark7198e6b2013-07-19 12:59:32 -0400144 for (i = 0; i < submit->nr_cmds; i++) {
145 switch (submit->cmd[i].type) {
146 case MSM_SUBMIT_CMD_IB_TARGET_BUF:
147 /* ignore IB-targets */
148 break;
149 case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
150 /* ignore if there has not been a ctx switch: */
151 if (priv->lastctx == ctx)
152 break;
153 case MSM_SUBMIT_CMD_BUF:
Craig Stout357ff002016-02-18 16:50:00 -0800154 OUT_PKT3(ring, adreno_is_a430(adreno_gpu) ?
155 CP_INDIRECT_BUFFER_PFE : CP_INDIRECT_BUFFER_PFD, 2);
Rob Clark7198e6b2013-07-19 12:59:32 -0400156 OUT_RING(ring, submit->cmd[i].iova);
157 OUT_RING(ring, submit->cmd[i].size);
158 ibs++;
159 break;
160 }
161 }
162
163 /* on a320, at least, we seem to need to pad things out to an
164 * even number of qwords to avoid issue w/ CP hanging on wrap-
165 * around:
166 */
167 if (ibs % 2)
168 OUT_PKT2(ring);
169
170 OUT_PKT0(ring, REG_AXXX_CP_SCRATCH_REG2, 1);
171 OUT_RING(ring, submit->fence);
172
Aravind Ganesan23bd62f2014-09-08 13:40:16 -0600173 if (adreno_is_a3xx(adreno_gpu) || adreno_is_a4xx(adreno_gpu)) {
Rob Clark7198e6b2013-07-19 12:59:32 -0400174 /* Flush HLSQ lazy updates to make sure there is nothing
175 * pending for indirect loads after the timestamp has
176 * passed:
177 */
178 OUT_PKT3(ring, CP_EVENT_WRITE, 1);
179 OUT_RING(ring, HLSQ_FLUSH);
180
181 OUT_PKT3(ring, CP_WAIT_FOR_IDLE, 1);
182 OUT_RING(ring, 0x00000000);
183 }
184
185 OUT_PKT3(ring, CP_EVENT_WRITE, 3);
186 OUT_RING(ring, CACHE_FLUSH_TS);
187 OUT_RING(ring, rbmemptr(adreno_gpu, fence));
188 OUT_RING(ring, submit->fence);
189
190 /* we could maybe be clever and only CP_COND_EXEC the interrupt: */
191 OUT_PKT3(ring, CP_INTERRUPT, 1);
192 OUT_RING(ring, 0x80000000);
193
Rob Clarkd735fdc2015-05-12 11:29:40 -0400194 /* Workaround for missing irq issue on 8x16/a306. Unsure if the
195 * root cause is a platform issue or some a306 quirk, but this
196 * keeps things humming along:
197 */
198 if (adreno_is_a306(adreno_gpu)) {
199 OUT_PKT3(ring, CP_WAIT_FOR_IDLE, 1);
200 OUT_RING(ring, 0x00000000);
201 OUT_PKT3(ring, CP_INTERRUPT, 1);
202 OUT_RING(ring, 0x80000000);
203 }
204
Rob Clark7198e6b2013-07-19 12:59:32 -0400205#if 0
206 if (adreno_is_a3xx(adreno_gpu)) {
207 /* Dummy set-constant to trigger context rollover */
208 OUT_PKT3(ring, CP_SET_CONSTANT, 2);
209 OUT_RING(ring, CP_REG(REG_A3XX_HLSQ_CL_KERNEL_GROUP_X_REG));
210 OUT_RING(ring, 0x00000000);
211 }
212#endif
213
214 gpu->funcs->flush(gpu);
215
216 return 0;
217}
218
219void adreno_flush(struct msm_gpu *gpu)
220{
Aravind Ganesan91b74e92014-09-08 10:57:28 -0600221 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark7198e6b2013-07-19 12:59:32 -0400222 uint32_t wptr = get_wptr(gpu->rb);
223
224 /* ensure writes to ringbuffer have hit system memory: */
225 mb();
226
Aravind Ganesan91b74e92014-09-08 10:57:28 -0600227 adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_WPTR, wptr);
Rob Clark7198e6b2013-07-19 12:59:32 -0400228}
229
230void adreno_idle(struct msm_gpu *gpu)
231{
232 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark09637562014-01-11 16:11:59 -0500233 uint32_t wptr = get_wptr(gpu->rb);
Craig Stout7d0c5ee2016-02-18 16:50:02 -0800234 int ret;
Rob Clark7198e6b2013-07-19 12:59:32 -0400235
Rob Clark09637562014-01-11 16:11:59 -0500236 /* wait for CP to drain ringbuffer: */
Craig Stout7d0c5ee2016-02-18 16:50:02 -0800237 ret = spin_until(get_rptr(adreno_gpu) == wptr);
238
239 if (ret)
Rob Clark09637562014-01-11 16:11:59 -0500240 DRM_ERROR("%s: timeout waiting to drain ringbuffer!\n", gpu->name);
Rob Clark7198e6b2013-07-19 12:59:32 -0400241
242 /* TODO maybe we need to reset GPU here to recover from hang? */
243}
244
245#ifdef CONFIG_DEBUG_FS
246void adreno_show(struct msm_gpu *gpu, struct seq_file *m)
247{
248 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark3bcefb02014-09-05 15:05:38 -0400249 int i;
Rob Clark7198e6b2013-07-19 12:59:32 -0400250
251 seq_printf(m, "revision: %d (%d.%d.%d.%d)\n",
252 adreno_gpu->info->revn, adreno_gpu->rev.core,
253 adreno_gpu->rev.major, adreno_gpu->rev.minor,
254 adreno_gpu->rev.patchid);
255
256 seq_printf(m, "fence: %d/%d\n", adreno_gpu->memptrs->fence,
Rob Clarkbd6f82d2013-08-24 14:20:38 -0400257 gpu->submitted_fence);
Craig Stout7d0c5ee2016-02-18 16:50:02 -0800258 seq_printf(m, "rptr: %d\n", get_rptr(adreno_gpu));
Rob Clark7198e6b2013-07-19 12:59:32 -0400259 seq_printf(m, "wptr: %d\n", adreno_gpu->memptrs->wptr);
260 seq_printf(m, "rb wptr: %d\n", get_wptr(gpu->rb));
Rob Clark3bcefb02014-09-05 15:05:38 -0400261
262 gpu->funcs->pm_resume(gpu);
263
264 /* dump these out in a form that can be parsed by demsm: */
265 seq_printf(m, "IO:region %s 00000000 00020000\n", gpu->name);
266 for (i = 0; adreno_gpu->registers[i] != ~0; i += 2) {
267 uint32_t start = adreno_gpu->registers[i];
268 uint32_t end = adreno_gpu->registers[i+1];
269 uint32_t addr;
270
271 for (addr = start; addr <= end; addr++) {
272 uint32_t val = gpu_read(gpu, addr);
273 seq_printf(m, "IO:R %08x %08x\n", addr<<2, val);
274 }
275 }
276
277 gpu->funcs->pm_suspend(gpu);
Rob Clark7198e6b2013-07-19 12:59:32 -0400278}
279#endif
280
Rob Clark26716182015-04-19 10:14:09 -0400281/* Dump common gpu status and scratch registers on any hang, to make
282 * the hangcheck logs more useful. The scratch registers seem always
283 * safe to read when GPU has hung (unlike some other regs, depending
284 * on how the GPU hung), and they are useful to match up to cmdstream
285 * dumps when debugging hangs:
286 */
287void adreno_dump_info(struct msm_gpu *gpu)
Rob Clark5b6ef082013-12-22 10:29:43 -0500288{
289 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark3bcefb02014-09-05 15:05:38 -0400290 int i;
Rob Clark5b6ef082013-12-22 10:29:43 -0500291
292 printk("revision: %d (%d.%d.%d.%d)\n",
293 adreno_gpu->info->revn, adreno_gpu->rev.core,
294 adreno_gpu->rev.major, adreno_gpu->rev.minor,
295 adreno_gpu->rev.patchid);
296
297 printk("fence: %d/%d\n", adreno_gpu->memptrs->fence,
298 gpu->submitted_fence);
Craig Stout7d0c5ee2016-02-18 16:50:02 -0800299 printk("rptr: %d\n", get_rptr(adreno_gpu));
Rob Clark5b6ef082013-12-22 10:29:43 -0500300 printk("wptr: %d\n", adreno_gpu->memptrs->wptr);
301 printk("rb wptr: %d\n", get_wptr(gpu->rb));
302
Rob Clark26716182015-04-19 10:14:09 -0400303 for (i = 0; i < 8; i++) {
304 printk("CP_SCRATCH_REG%d: %u\n", i,
305 gpu_read(gpu, REG_AXXX_CP_SCRATCH_REG0 + i));
306 }
307}
308
309/* would be nice to not have to duplicate the _show() stuff with printk(): */
310void adreno_dump(struct msm_gpu *gpu)
311{
312 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
313 int i;
314
Rob Clark3bcefb02014-09-05 15:05:38 -0400315 /* dump these out in a form that can be parsed by demsm: */
316 printk("IO:region %s 00000000 00020000\n", gpu->name);
317 for (i = 0; adreno_gpu->registers[i] != ~0; i += 2) {
318 uint32_t start = adreno_gpu->registers[i];
319 uint32_t end = adreno_gpu->registers[i+1];
320 uint32_t addr;
321
322 for (addr = start; addr <= end; addr++) {
323 uint32_t val = gpu_read(gpu, addr);
324 printk("IO:R %08x %08x\n", addr<<2, val);
325 }
326 }
Rob Clark5b6ef082013-12-22 10:29:43 -0500327}
328
Rob Clark09637562014-01-11 16:11:59 -0500329static uint32_t ring_freewords(struct msm_gpu *gpu)
Rob Clark7198e6b2013-07-19 12:59:32 -0400330{
331 struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
Rob Clark09637562014-01-11 16:11:59 -0500332 uint32_t size = gpu->rb->size / 4;
333 uint32_t wptr = get_wptr(gpu->rb);
Craig Stout7d0c5ee2016-02-18 16:50:02 -0800334 uint32_t rptr = get_rptr(adreno_gpu);
Rob Clark09637562014-01-11 16:11:59 -0500335 return (rptr + (size - 1) - wptr) % size;
336}
Rob Clark26791c42013-09-03 07:12:03 -0400337
Rob Clark09637562014-01-11 16:11:59 -0500338void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords)
339{
340 if (spin_until(ring_freewords(gpu) >= ndwords))
341 DRM_ERROR("%s: timeout waiting for ringbuffer space\n", gpu->name);
Rob Clark7198e6b2013-07-19 12:59:32 -0400342}
343
344static const char *iommu_ports[] = {
345 "gfx3d_user", "gfx3d_priv",
346 "gfx3d1_user", "gfx3d1_priv",
347};
348
Rob Clark7198e6b2013-07-19 12:59:32 -0400349int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
Rob Clark3526e9f2014-09-05 15:03:40 -0400350 struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs)
Rob Clark7198e6b2013-07-19 12:59:32 -0400351{
Rob Clark3526e9f2014-09-05 15:03:40 -0400352 struct adreno_platform_config *config = pdev->dev.platform_data;
353 struct msm_gpu *gpu = &adreno_gpu->base;
Rob Clark871d8122013-11-16 12:56:06 -0500354 struct msm_mmu *mmu;
Rob Clarke2550b72014-09-05 13:30:27 -0400355 int ret;
Rob Clark7198e6b2013-07-19 12:59:32 -0400356
Rob Clark3526e9f2014-09-05 15:03:40 -0400357 adreno_gpu->funcs = funcs;
358 adreno_gpu->info = adreno_info(config->rev);
359 adreno_gpu->gmem = adreno_gpu->info->gmem;
360 adreno_gpu->revn = adreno_gpu->info->revn;
361 adreno_gpu->rev = config->rev;
Rob Clark7198e6b2013-07-19 12:59:32 -0400362
Rob Clark3526e9f2014-09-05 15:03:40 -0400363 gpu->fast_rate = config->fast_rate;
364 gpu->slow_rate = config->slow_rate;
365 gpu->bus_freq = config->bus_freq;
Rob Clark6490ad42015-06-04 10:26:37 -0400366#ifdef DOWNSTREAM_CONFIG_MSM_BUS_SCALING
Rob Clark3526e9f2014-09-05 15:03:40 -0400367 gpu->bus_scale_table = config->bus_scale_table;
368#endif
369
370 DBG("fast_rate=%u, slow_rate=%u, bus_freq=%u",
371 gpu->fast_rate, gpu->slow_rate, gpu->bus_freq);
372
Rob Clark0122f962014-10-31 11:50:55 -0400373 ret = msm_gpu_init(drm, pdev, &adreno_gpu->base, &funcs->base,
374 adreno_gpu->info->name, "kgsl_3d0_reg_memory", "kgsl_3d0_irq",
375 RB_SIZE);
376 if (ret)
377 return ret;
378
Rob Clark3526e9f2014-09-05 15:03:40 -0400379 ret = request_firmware(&adreno_gpu->pm4, adreno_gpu->info->pm4fw, drm->dev);
Rob Clark7198e6b2013-07-19 12:59:32 -0400380 if (ret) {
381 dev_err(drm->dev, "failed to load %s PM4 firmware: %d\n",
Rob Clark3526e9f2014-09-05 15:03:40 -0400382 adreno_gpu->info->pm4fw, ret);
Rob Clark7198e6b2013-07-19 12:59:32 -0400383 return ret;
384 }
385
Rob Clark3526e9f2014-09-05 15:03:40 -0400386 ret = request_firmware(&adreno_gpu->pfp, adreno_gpu->info->pfpfw, drm->dev);
Rob Clark7198e6b2013-07-19 12:59:32 -0400387 if (ret) {
388 dev_err(drm->dev, "failed to load %s PFP firmware: %d\n",
Rob Clark3526e9f2014-09-05 15:03:40 -0400389 adreno_gpu->info->pfpfw, ret);
Rob Clark7198e6b2013-07-19 12:59:32 -0400390 return ret;
391 }
392
Rob Clark3526e9f2014-09-05 15:03:40 -0400393 mmu = gpu->mmu;
Rob Clark871d8122013-11-16 12:56:06 -0500394 if (mmu) {
395 ret = mmu->funcs->attach(mmu, iommu_ports,
396 ARRAY_SIZE(iommu_ports));
397 if (ret)
398 return ret;
399 }
Rob Clark7198e6b2013-07-19 12:59:32 -0400400
Rob Clarka1ad3522014-07-11 11:59:22 -0400401 mutex_lock(&drm->struct_mutex);
Rob Clark3526e9f2014-09-05 15:03:40 -0400402 adreno_gpu->memptrs_bo = msm_gem_new(drm, sizeof(*adreno_gpu->memptrs),
Rob Clark7198e6b2013-07-19 12:59:32 -0400403 MSM_BO_UNCACHED);
Rob Clarka1ad3522014-07-11 11:59:22 -0400404 mutex_unlock(&drm->struct_mutex);
Rob Clark3526e9f2014-09-05 15:03:40 -0400405 if (IS_ERR(adreno_gpu->memptrs_bo)) {
406 ret = PTR_ERR(adreno_gpu->memptrs_bo);
407 adreno_gpu->memptrs_bo = NULL;
Rob Clark7198e6b2013-07-19 12:59:32 -0400408 dev_err(drm->dev, "could not allocate memptrs: %d\n", ret);
409 return ret;
410 }
411
Rob Clark3526e9f2014-09-05 15:03:40 -0400412 adreno_gpu->memptrs = msm_gem_vaddr(adreno_gpu->memptrs_bo);
413 if (!adreno_gpu->memptrs) {
Rob Clark7198e6b2013-07-19 12:59:32 -0400414 dev_err(drm->dev, "could not vmap memptrs\n");
415 return -ENOMEM;
416 }
417
Rob Clark3526e9f2014-09-05 15:03:40 -0400418 ret = msm_gem_get_iova(adreno_gpu->memptrs_bo, gpu->id,
419 &adreno_gpu->memptrs_iova);
Rob Clark7198e6b2013-07-19 12:59:32 -0400420 if (ret) {
421 dev_err(drm->dev, "could not map memptrs: %d\n", ret);
422 return ret;
423 }
424
425 return 0;
426}
427
428void adreno_gpu_cleanup(struct adreno_gpu *gpu)
429{
430 if (gpu->memptrs_bo) {
431 if (gpu->memptrs_iova)
432 msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
Rob Clark774449e2015-05-15 09:19:36 -0400433 drm_gem_object_unreference_unlocked(gpu->memptrs_bo);
Rob Clark7198e6b2013-07-19 12:59:32 -0400434 }
Markus Elfring5acb07e2014-11-25 13:44:20 +0100435 release_firmware(gpu->pm4);
436 release_firmware(gpu->pfp);
Rob Clark7198e6b2013-07-19 12:59:32 -0400437 msm_gpu_cleanup(&gpu->base);
438}