aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2014-09-05 15:03:40 -0400
committerRob Clark <robdclark@gmail.com>2014-09-10 11:19:09 -0400
commit3526e9fb4f3f178fe9dbab3886c86e294e45816c (patch)
tree9b7bf726a22007076873597941efe0dc36426dfe
parente2550b7a7d8f2030cfea43343eb3fccc3a8e8167 (diff)
drm/msm/adreno: bit of init refactoring
Push a few bits down into adreno_gpu so they won't have to be duplicated as support for additional adreno generations is added. Signed-off-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--drivers/gpu/drm/msm/adreno/a3xx_gpu.c19
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_device.c4
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c55
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.h3
4 files changed, 40 insertions, 41 deletions
diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index 42bdcf72a771..b7116cb9b41c 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -35,10 +35,8 @@
35 A3XX_INT0_CP_AHB_ERROR_HALT | \ 35 A3XX_INT0_CP_AHB_ERROR_HALT | \
36 A3XX_INT0_UCHE_OOB_ACCESS) 36 A3XX_INT0_UCHE_OOB_ACCESS)
37 37
38extern bool hang_debug;
38 39
39static bool hang_debug = false;
40MODULE_PARM_DESC(hang_debug, "Dump registers when hang is detected (can be slow!)");
41module_param_named(hang_debug, hang_debug, bool, 0600);
42static void a3xx_dump(struct msm_gpu *gpu); 40static void a3xx_dump(struct msm_gpu *gpu);
43 41
44static void a3xx_me_init(struct msm_gpu *gpu) 42static void a3xx_me_init(struct msm_gpu *gpu)
@@ -474,7 +472,6 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
474 struct msm_gpu *gpu; 472 struct msm_gpu *gpu;
475 struct msm_drm_private *priv = dev->dev_private; 473 struct msm_drm_private *priv = dev->dev_private;
476 struct platform_device *pdev = priv->gpu_pdev; 474 struct platform_device *pdev = priv->gpu_pdev;
477 struct adreno_platform_config *config;
478 int ret; 475 int ret;
479 476
480 if (!pdev) { 477 if (!pdev) {
@@ -483,8 +480,6 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
483 goto fail; 480 goto fail;
484 } 481 }
485 482
486 config = pdev->dev.platform_data;
487
488 a3xx_gpu = kzalloc(sizeof(*a3xx_gpu), GFP_KERNEL); 483 a3xx_gpu = kzalloc(sizeof(*a3xx_gpu), GFP_KERNEL);
489 if (!a3xx_gpu) { 484 if (!a3xx_gpu) {
490 ret = -ENOMEM; 485 ret = -ENOMEM;
@@ -496,20 +491,10 @@ struct msm_gpu *a3xx_gpu_init(struct drm_device *dev)
496 491
497 a3xx_gpu->pdev = pdev; 492 a3xx_gpu->pdev = pdev;
498 493
499 gpu->fast_rate = config->fast_rate;
500 gpu->slow_rate = config->slow_rate;
501 gpu->bus_freq = config->bus_freq;
502#ifdef CONFIG_MSM_BUS_SCALING
503 gpu->bus_scale_table = config->bus_scale_table;
504#endif
505
506 DBG("fast_rate=%u, slow_rate=%u, bus_freq=%u",
507 gpu->fast_rate, gpu->slow_rate, gpu->bus_freq);
508
509 gpu->perfcntrs = perfcntrs; 494 gpu->perfcntrs = perfcntrs;
510 gpu->num_perfcntrs = ARRAY_SIZE(perfcntrs); 495 gpu->num_perfcntrs = ARRAY_SIZE(perfcntrs);
511 496
512 ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, config->rev); 497 ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs);
513 if (ret) 498 if (ret)
514 goto fail; 499 goto fail;
515 500
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index b03290e3948a..7ab85af3a7db 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -23,6 +23,10 @@
23 23
24#define ANY_ID 0xff 24#define ANY_ID 0xff
25 25
26bool hang_debug = false;
27MODULE_PARM_DESC(hang_debug, "Dump registers when hang is detected (can be slow!)");
28module_param_named(hang_debug, hang_debug, bool, 0600);
29
26struct msm_gpu *a3xx_gpu_init(struct drm_device *dev); 30struct msm_gpu *a3xx_gpu_init(struct drm_device *dev);
27 31
28static const struct adreno_info gpulist[] = { 32static const struct adreno_info gpulist[] = {
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index c64340fcfbfe..d25f85cdcf90 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -265,39 +265,50 @@ static const char *iommu_ports[] = {
265}; 265};
266 266
267int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, 267int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
268 struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs, 268 struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs)
269 struct adreno_rev rev)
270{ 269{
270 struct adreno_platform_config *config = pdev->dev.platform_data;
271 struct msm_gpu *gpu = &adreno_gpu->base;
271 struct msm_mmu *mmu; 272 struct msm_mmu *mmu;
272 int ret; 273 int ret;
273 274
274 gpu->funcs = funcs; 275 adreno_gpu->funcs = funcs;
275 gpu->info = adreno_info(rev); 276 adreno_gpu->info = adreno_info(config->rev);
276 gpu->gmem = gpu->info->gmem; 277 adreno_gpu->gmem = adreno_gpu->info->gmem;
277 gpu->revn = gpu->info->revn; 278 adreno_gpu->revn = adreno_gpu->info->revn;
278 gpu->rev = rev; 279 adreno_gpu->rev = config->rev;
280
281 gpu->fast_rate = config->fast_rate;
282 gpu->slow_rate = config->slow_rate;
283 gpu->bus_freq = config->bus_freq;
284#ifdef CONFIG_MSM_BUS_SCALING
285 gpu->bus_scale_table = config->bus_scale_table;
286#endif
287
288 DBG("fast_rate=%u, slow_rate=%u, bus_freq=%u",
289 gpu->fast_rate, gpu->slow_rate, gpu->bus_freq);
279 290
280 ret = request_firmware(&gpu->pm4, gpu->info->pm4fw, drm->dev); 291 ret = request_firmware(&adreno_gpu->pm4, adreno_gpu->info->pm4fw, drm->dev);
281 if (ret) { 292 if (ret) {
282 dev_err(drm->dev, "failed to load %s PM4 firmware: %d\n", 293 dev_err(drm->dev, "failed to load %s PM4 firmware: %d\n",
283 gpu->info->pm4fw, ret); 294 adreno_gpu->info->pm4fw, ret);
284 return ret; 295 return ret;
285 } 296 }
286 297
287 ret = request_firmware(&gpu->pfp, gpu->info->pfpfw, drm->dev); 298 ret = request_firmware(&adreno_gpu->pfp, adreno_gpu->info->pfpfw, drm->dev);
288 if (ret) { 299 if (ret) {
289 dev_err(drm->dev, "failed to load %s PFP firmware: %d\n", 300 dev_err(drm->dev, "failed to load %s PFP firmware: %d\n",
290 gpu->info->pfpfw, ret); 301 adreno_gpu->info->pfpfw, ret);
291 return ret; 302 return ret;
292 } 303 }
293 304
294 ret = msm_gpu_init(drm, pdev, &gpu->base, &funcs->base, 305 ret = msm_gpu_init(drm, pdev, &adreno_gpu->base, &funcs->base,
295 gpu->info->name, "kgsl_3d0_reg_memory", "kgsl_3d0_irq", 306 adreno_gpu->info->name, "kgsl_3d0_reg_memory", "kgsl_3d0_irq",
296 RB_SIZE); 307 RB_SIZE);
297 if (ret) 308 if (ret)
298 return ret; 309 return ret;
299 310
300 mmu = gpu->base.mmu; 311 mmu = gpu->mmu;
301 if (mmu) { 312 if (mmu) {
302 ret = mmu->funcs->attach(mmu, iommu_ports, 313 ret = mmu->funcs->attach(mmu, iommu_ports,
303 ARRAY_SIZE(iommu_ports)); 314 ARRAY_SIZE(iommu_ports));
@@ -306,24 +317,24 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
306 } 317 }
307 318
308 mutex_lock(&drm->struct_mutex); 319 mutex_lock(&drm->struct_mutex);
309 gpu->memptrs_bo = msm_gem_new(drm, sizeof(*gpu->memptrs), 320 adreno_gpu->memptrs_bo = msm_gem_new(drm, sizeof(*adreno_gpu->memptrs),
310 MSM_BO_UNCACHED); 321 MSM_BO_UNCACHED);
311 mutex_unlock(&drm->struct_mutex); 322 mutex_unlock(&drm->struct_mutex);
312 if (IS_ERR(gpu->memptrs_bo)) { 323 if (IS_ERR(adreno_gpu->memptrs_bo)) {
313 ret = PTR_ERR(gpu->memptrs_bo); 324 ret = PTR_ERR(adreno_gpu->memptrs_bo);
314 gpu->memptrs_bo = NULL; 325 adreno_gpu->memptrs_bo = NULL;
315 dev_err(drm->dev, "could not allocate memptrs: %d\n", ret); 326 dev_err(drm->dev, "could not allocate memptrs: %d\n", ret);
316 return ret; 327 return ret;
317 } 328 }
318 329
319 gpu->memptrs = msm_gem_vaddr(gpu->memptrs_bo); 330 adreno_gpu->memptrs = msm_gem_vaddr(adreno_gpu->memptrs_bo);
320 if (!gpu->memptrs) { 331 if (!adreno_gpu->memptrs) {
321 dev_err(drm->dev, "could not vmap memptrs\n"); 332 dev_err(drm->dev, "could not vmap memptrs\n");
322 return -ENOMEM; 333 return -ENOMEM;
323 } 334 }
324 335
325 ret = msm_gem_get_iova(gpu->memptrs_bo, gpu->base.id, 336 ret = msm_gem_get_iova(adreno_gpu->memptrs_bo, gpu->id,
326 &gpu->memptrs_iova); 337 &adreno_gpu->memptrs_iova);
327 if (ret) { 338 if (ret) {
328 dev_err(drm->dev, "could not map memptrs: %d\n", ret); 339 dev_err(drm->dev, "could not map memptrs: %d\n", ret);
329 return ret; 340 return ret;
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index a1e1fbb1f509..3664a0d98662 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -140,8 +140,7 @@ void adreno_dump(struct msm_gpu *gpu);
140void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords); 140void adreno_wait_ring(struct msm_gpu *gpu, uint32_t ndwords);
141 141
142int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, 142int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
143 struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs, 143 struct adreno_gpu *gpu, const struct adreno_gpu_funcs *funcs);
144 struct adreno_rev rev);
145void adreno_gpu_cleanup(struct adreno_gpu *gpu); 144void adreno_gpu_cleanup(struct adreno_gpu *gpu);
146 145
147 146