aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-07-07 23:30:22 -0400
committerDave Airlie <airlied@redhat.com>2016-07-07 23:30:22 -0400
commit429a9ccdf24a38ed8a64d6d9c07ade59f0157bef (patch)
tree1a380e0eefe5d134d15968fc491463b888a2f022
parentccd0e7887b7920e5c8a198eb9600ae26f13d631a (diff)
parentc1c77b0e07dc6231db3c2c7b847c514849d53b99 (diff)
Merge branch 'drm-etnaviv-next' of git://git.pengutronix.de/git/lst/linux into drm-next
etnaviv-next only contains two patches to get rid of a confusing error message and finally one patch to enable the autonomous GPU clock gating. * 'drm-etnaviv-next' of git://git.pengutronix.de/git/lst/linux: drm/etnaviv: remove generic GPU init failure reporting drm/etnaviv: improve error reporting in GPU init path drm/etnaviv: enable GPU module level clock gating support
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_drv.c4
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gpu.c54
-rw-r--r--drivers/gpu/drm/etnaviv/state_hi.xml.h7
3 files changed, 60 insertions, 5 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 340d390306d8..ffd1b32caa8d 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -91,10 +91,8 @@ static void load_gpu(struct drm_device *dev)
91 int ret; 91 int ret;
92 92
93 ret = etnaviv_gpu_init(g); 93 ret = etnaviv_gpu_init(g);
94 if (ret) { 94 if (ret)
95 dev_err(g->dev, "hw init failed: %d\n", ret);
96 priv->gpu[i] = NULL; 95 priv->gpu[i] = NULL;
97 }
98 } 96 }
99 } 97 }
100} 98}
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index ff6aa5dfb2d7..87ef34150d46 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -487,6 +487,47 @@ static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
487 return 0; 487 return 0;
488} 488}
489 489
490static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu)
491{
492 u32 pmc, ppc;
493
494 /* enable clock gating */
495 ppc = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
496 ppc |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
497
498 /* Disable stall module clock gating for 4.3.0.1 and 4.3.0.2 revs */
499 if (gpu->identity.revision == 0x4301 ||
500 gpu->identity.revision == 0x4302)
501 ppc |= VIVS_PM_POWER_CONTROLS_DISABLE_STALL_MODULE_CLOCK_GATING;
502
503 gpu_write(gpu, VIVS_PM_POWER_CONTROLS, ppc);
504
505 pmc = gpu_read(gpu, VIVS_PM_MODULE_CONTROLS);
506
507 /* Disable PA clock gating for GC400+ except for GC420 */
508 if (gpu->identity.model >= chipModel_GC400 &&
509 gpu->identity.model != chipModel_GC420)
510 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PA;
511
512 /*
513 * Disable PE clock gating on revs < 5.0.0.0 when HZ is
514 * present without a bug fix.
515 */
516 if (gpu->identity.revision < 0x5000 &&
517 gpu->identity.minor_features0 & chipMinorFeatures0_HZ &&
518 !(gpu->identity.minor_features1 &
519 chipMinorFeatures1_DISABLE_PE_GATING))
520 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PE;
521
522 if (gpu->identity.revision < 0x5422)
523 pmc |= BIT(15); /* Unknown bit */
524
525 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ;
526 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ;
527
528 gpu_write(gpu, VIVS_PM_MODULE_CONTROLS, pmc);
529}
530
490static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu) 531static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
491{ 532{
492 u16 prefetch; 533 u16 prefetch;
@@ -506,6 +547,9 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
506 gpu_write(gpu, VIVS_MC_DEBUG_MEMORY, mc_memory_debug); 547 gpu_write(gpu, VIVS_MC_DEBUG_MEMORY, mc_memory_debug);
507 } 548 }
508 549
550 /* enable module-level clock gating */
551 etnaviv_gpu_enable_mlcg(gpu);
552
509 /* 553 /*
510 * Update GPU AXI cache atttribute to "cacheable, no allocate". 554 * Update GPU AXI cache atttribute to "cacheable, no allocate".
511 * This is necessary to prevent the iMX6 SoC locking up. 555 * This is necessary to prevent the iMX6 SoC locking up.
@@ -553,8 +597,10 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
553 bool mmuv2; 597 bool mmuv2;
554 598
555 ret = pm_runtime_get_sync(gpu->dev); 599 ret = pm_runtime_get_sync(gpu->dev);
556 if (ret < 0) 600 if (ret < 0) {
601 dev_err(gpu->dev, "Failed to enable GPU power domain\n");
557 return ret; 602 return ret;
603 }
558 604
559 etnaviv_hw_identify(gpu); 605 etnaviv_hw_identify(gpu);
560 606
@@ -591,8 +637,10 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
591 } 637 }
592 638
593 ret = etnaviv_hw_reset(gpu); 639 ret = etnaviv_hw_reset(gpu);
594 if (ret) 640 if (ret) {
641 dev_err(gpu->dev, "GPU reset failed\n");
595 goto fail; 642 goto fail;
643 }
596 644
597 /* Setup IOMMU.. eventually we will (I think) do this once per context 645 /* Setup IOMMU.. eventually we will (I think) do this once per context
598 * and have separate page tables per context. For now, to keep things 646 * and have separate page tables per context. For now, to keep things
@@ -610,12 +658,14 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
610 } 658 }
611 659
612 if (!iommu) { 660 if (!iommu) {
661 dev_err(gpu->dev, "Failed to allocate GPU IOMMU domain\n");
613 ret = -ENOMEM; 662 ret = -ENOMEM;
614 goto fail; 663 goto fail;
615 } 664 }
616 665
617 gpu->mmu = etnaviv_iommu_new(gpu, iommu, version); 666 gpu->mmu = etnaviv_iommu_new(gpu, iommu, version);
618 if (!gpu->mmu) { 667 if (!gpu->mmu) {
668 dev_err(gpu->dev, "Failed to instantiate GPU IOMMU\n");
619 iommu_domain_free(iommu); 669 iommu_domain_free(iommu);
620 ret = -ENOMEM; 670 ret = -ENOMEM;
621 goto fail; 671 goto fail;
diff --git a/drivers/gpu/drm/etnaviv/state_hi.xml.h b/drivers/gpu/drm/etnaviv/state_hi.xml.h
index 6a7de5f1454a..807a3d9e0dd5 100644
--- a/drivers/gpu/drm/etnaviv/state_hi.xml.h
+++ b/drivers/gpu/drm/etnaviv/state_hi.xml.h
@@ -218,6 +218,13 @@ Copyright (C) 2015
218#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_FE 0x00000001 218#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_FE 0x00000001
219#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_DE 0x00000002 219#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_DE 0x00000002
220#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PE 0x00000004 220#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PE 0x00000004
221#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_SH 0x00000008
222#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PA 0x00000010
223#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_SE 0x00000020
224#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA 0x00000040
225#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_TX 0x00000080
226#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ 0x00010000
227#define VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ 0x00020000
221 228
222#define VIVS_PM_MODULE_STATUS 0x00000108 229#define VIVS_PM_MODULE_STATUS 0x00000108
223#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_FE 0x00000001 230#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_FE 0x00000001