aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorMonk Liu <Monk.Liu@amd.com>2017-11-21 00:29:14 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:48:15 -0500
commitce1b1b66cd5ec60927c575858430c099b8b4bceb (patch)
treecf3882de00bc4a58d1ad1fc4f2b68653ddb6c981 /drivers/gpu/drm/amd
parent1bfcbad18fc0c2618ae141ff2d8c384cf81bf98e (diff)
drm/amdgpu:partially revert 1cfd8e237f0318e330190ac21d63c58ae6a1f66c
found RING0 test fail after S3 resume regression, which is introduced by 1cfd8e237f0318e330190ac21d63c58ae6a1f66c Because after suspend VRAM will be cleared, so driver must unpin the GART table(resident in VRAM) during suspend so it can be evicted to system ram and must correspondingly pin it during resume so the GART table could be restored to VRAM. Signed-off-by: Monk Liu <Monk.Liu@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c79
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c4
6 files changed, 94 insertions, 12 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index 707f85825996..1f51897acc5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -68,9 +68,75 @@
68 */ 68 */
69int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev) 69int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
70{ 70{
71 return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE, 71 int r;
72 AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.robj, 72
73 &adev->gart.table_addr, &adev->gart.ptr); 73 if (adev->gart.robj == NULL) {
74 r = amdgpu_bo_create(adev, adev->gart.table_size,
75 PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
76 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
77 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
78 NULL, NULL, 0, &adev->gart.robj);
79 if (r) {
80 return r;
81 }
82 }
83 return 0;
84}
85
86/**
87 * amdgpu_gart_table_vram_pin - pin gart page table in vram
88 *
89 * @adev: amdgpu_device pointer
90 *
91 * Pin the GART page table in vram so it will not be moved
92 * by the memory manager (pcie r4xx, r5xx+). These asics require the
93 * gart table to be in video memory.
94 * Returns 0 for success, error for failure.
95 */
96int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
97{
98 uint64_t gpu_addr;
99 int r;
100
101 r = amdgpu_bo_reserve(adev->gart.robj, false);
102 if (unlikely(r != 0))
103 return r;
104 r = amdgpu_bo_pin(adev->gart.robj,
105 AMDGPU_GEM_DOMAIN_VRAM, &gpu_addr);
106 if (r) {
107 amdgpu_bo_unreserve(adev->gart.robj);
108 return r;
109 }
110 r = amdgpu_bo_kmap(adev->gart.robj, &adev->gart.ptr);
111 if (r)
112 amdgpu_bo_unpin(adev->gart.robj);
113 amdgpu_bo_unreserve(adev->gart.robj);
114 adev->gart.table_addr = gpu_addr;
115 return r;
116}
117
118/**
119 * amdgpu_gart_table_vram_unpin - unpin gart page table in vram
120 *
121 * @adev: amdgpu_device pointer
122 *
123 * Unpin the GART page table in vram (pcie r4xx, r5xx+).
124 * These asics require the gart table to be in video memory.
125 */
126void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev)
127{
128 int r;
129
130 if (adev->gart.robj == NULL) {
131 return;
132 }
133 r = amdgpu_bo_reserve(adev->gart.robj, true);
134 if (likely(r == 0)) {
135 amdgpu_bo_kunmap(adev->gart.robj);
136 amdgpu_bo_unpin(adev->gart.robj);
137 amdgpu_bo_unreserve(adev->gart.robj);
138 adev->gart.ptr = NULL;
139 }
74} 140}
75 141
76/** 142/**
@@ -84,9 +150,10 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
84 */ 150 */
85void amdgpu_gart_table_vram_free(struct amdgpu_device *adev) 151void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
86{ 152{
87 amdgpu_bo_free_kernel(&adev->gart.robj, 153 if (adev->gart.robj == NULL) {
88 &adev->gart.table_addr, 154 return;
89 &adev->gart.ptr); 155 }
156 amdgpu_bo_unref(&adev->gart.robj);
90} 157}
91 158
92/* 159/*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
index 5eb1a6800f72..d4a43302c2be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h
@@ -58,6 +58,8 @@ struct amdgpu_gart {
58 58
59int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev); 59int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev);
60void amdgpu_gart_table_vram_free(struct amdgpu_device *adev); 60void amdgpu_gart_table_vram_free(struct amdgpu_device *adev);
61int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev);
62void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev);
61int amdgpu_gart_init(struct amdgpu_device *adev); 63int amdgpu_gart_init(struct amdgpu_device *adev);
62void amdgpu_gart_fini(struct amdgpu_device *adev); 64void amdgpu_gart_fini(struct amdgpu_device *adev);
63int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, 65int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 1e7f52f109b5..6098c773711f 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -478,14 +478,16 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)
478 478
479static int gmc_v6_0_gart_enable(struct amdgpu_device *adev) 479static int gmc_v6_0_gart_enable(struct amdgpu_device *adev)
480{ 480{
481 int i; 481 int r, i;
482 u32 field; 482 u32 field;
483 483
484 if (adev->gart.robj == NULL) { 484 if (adev->gart.robj == NULL) {
485 dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); 485 dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
486 return -EINVAL; 486 return -EINVAL;
487 } 487 }
488 488 r = amdgpu_gart_table_vram_pin(adev);
489 if (r)
490 return r;
489 /* Setup TLB control */ 491 /* Setup TLB control */
490 WREG32(mmMC_VM_MX_L1_TLB_CNTL, 492 WREG32(mmMC_VM_MX_L1_TLB_CNTL,
491 (0xA << 7) | 493 (0xA << 7) |
@@ -612,6 +614,7 @@ static void gmc_v6_0_gart_disable(struct amdgpu_device *adev)
612 WREG32(mmVM_L2_CNTL3, 614 WREG32(mmVM_L2_CNTL3,
613 VM_L2_CNTL3__L2_CACHE_BIGK_ASSOCIATIVITY_MASK | 615 VM_L2_CNTL3__L2_CACHE_BIGK_ASSOCIATIVITY_MASK |
614 (0UL << VM_L2_CNTL3__L2_CACHE_BIGK_FRAGMENT_SIZE__SHIFT)); 616 (0UL << VM_L2_CNTL3__L2_CACHE_BIGK_FRAGMENT_SIZE__SHIFT));
617 amdgpu_gart_table_vram_unpin(adev);
615} 618}
616 619
617static void gmc_v6_0_gart_fini(struct amdgpu_device *adev) 620static void gmc_v6_0_gart_fini(struct amdgpu_device *adev)
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index d521862804ea..8b460e9d4431 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -582,14 +582,16 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)
582 */ 582 */
583static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) 583static int gmc_v7_0_gart_enable(struct amdgpu_device *adev)
584{ 584{
585 int i; 585 int r, i;
586 u32 tmp, field; 586 u32 tmp, field;
587 587
588 if (adev->gart.robj == NULL) { 588 if (adev->gart.robj == NULL) {
589 dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); 589 dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
590 return -EINVAL; 590 return -EINVAL;
591 } 591 }
592 592 r = amdgpu_gart_table_vram_pin(adev);
593 if (r)
594 return r;
593 /* Setup TLB control */ 595 /* Setup TLB control */
594 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL); 596 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL);
595 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1); 597 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1);
@@ -722,6 +724,7 @@ static void gmc_v7_0_gart_disable(struct amdgpu_device *adev)
722 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0); 724 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
723 WREG32(mmVM_L2_CNTL, tmp); 725 WREG32(mmVM_L2_CNTL, tmp);
724 WREG32(mmVM_L2_CNTL2, 0); 726 WREG32(mmVM_L2_CNTL2, 0);
727 amdgpu_gart_table_vram_unpin(adev);
725} 728}
726 729
727/** 730/**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index bd3f842cca00..1fd7f9daab0a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -781,14 +781,16 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)
781 */ 781 */
782static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) 782static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
783{ 783{
784 int i; 784 int r, i;
785 u32 tmp, field; 785 u32 tmp, field;
786 786
787 if (adev->gart.robj == NULL) { 787 if (adev->gart.robj == NULL) {
788 dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); 788 dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
789 return -EINVAL; 789 return -EINVAL;
790 } 790 }
791 791 r = amdgpu_gart_table_vram_pin(adev);
792 if (r)
793 return r;
792 /* Setup TLB control */ 794 /* Setup TLB control */
793 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL); 795 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL);
794 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1); 796 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1);
@@ -938,6 +940,7 @@ static void gmc_v8_0_gart_disable(struct amdgpu_device *adev)
938 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0); 940 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
939 WREG32(mmVM_L2_CNTL, tmp); 941 WREG32(mmVM_L2_CNTL, tmp);
940 WREG32(mmVM_L2_CNTL2, 0); 942 WREG32(mmVM_L2_CNTL2, 0);
943 amdgpu_gart_table_vram_unpin(adev);
941} 944}
942 945
943/** 946/**
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 8529005a5022..c30e08d9f30b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -933,6 +933,9 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev)
933 dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); 933 dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
934 return -EINVAL; 934 return -EINVAL;
935 } 935 }
936 r = amdgpu_gart_table_vram_pin(adev);
937 if (r)
938 return r;
936 939
937 switch (adev->asic_type) { 940 switch (adev->asic_type) {
938 case CHIP_RAVEN: 941 case CHIP_RAVEN:
@@ -1010,6 +1013,7 @@ static void gmc_v9_0_gart_disable(struct amdgpu_device *adev)
1010{ 1013{
1011 gfxhub_v1_0_gart_disable(adev); 1014 gfxhub_v1_0_gart_disable(adev);
1012 mmhub_v1_0_gart_disable(adev); 1015 mmhub_v1_0_gart_disable(adev);
1016 amdgpu_gart_table_vram_unpin(adev);
1013} 1017}
1014 1018
1015static int gmc_v9_0_hw_fini(void *handle) 1019static int gmc_v9_0_hw_fini(void *handle)