aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
diff options
context:
space:
mode:
authorMonk Liu <Monk.Liu@amd.com>2017-11-13 22:52:35 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:47:50 -0500
commitc79ee7d8c6cba8775b842063cf5bcdf101dc1e36 (patch)
treeccc3d216288e4b9b3bcfbeabdb69c42c5b2b2de7 /drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
parent11c6b82afb4cd696e10ab1cfaad3bbfb8dd4f16f (diff)
drm/amdgpu:cleanup GMC & gart garbage function
for gart_ram_alloc/free, they are never used in driver thus ripe them out totally. for gart_vram_pin/unpin, they are not needed becuase we can use bo_creat_kernel/free to replace the original manual way in the gart_vram_alloc/free, thus gart_vram_pin/unpin can also be riped out. 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/amdgpu/amdgpu_gart.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c136
1 files changed, 6 insertions, 130 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
index fe818501c520..10eeb307700c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
@@ -57,63 +57,6 @@
57 */ 57 */
58 58
59/** 59/**
60 * amdgpu_gart_table_ram_alloc - allocate system ram for gart page table
61 *
62 * @adev: amdgpu_device pointer
63 *
64 * Allocate system memory for GART page table
65 * (r1xx-r3xx, non-pcie r4xx, rs400). These asics require the
66 * gart table to be in system memory.
67 * Returns 0 for success, -ENOMEM for failure.
68 */
69int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev)
70{
71 void *ptr;
72
73 ptr = pci_alloc_consistent(adev->pdev, adev->gart.table_size,
74 &adev->gart.table_addr);
75 if (ptr == NULL) {
76 return -ENOMEM;
77 }
78#ifdef CONFIG_X86
79 if (0) {
80 set_memory_uc((unsigned long)ptr,
81 adev->gart.table_size >> PAGE_SHIFT);
82 }
83#endif
84 adev->gart.ptr = ptr;
85 memset((void *)adev->gart.ptr, 0, adev->gart.table_size);
86 return 0;
87}
88
89/**
90 * amdgpu_gart_table_ram_free - free system ram for gart page table
91 *
92 * @adev: amdgpu_device pointer
93 *
94 * Free system memory for GART page table
95 * (r1xx-r3xx, non-pcie r4xx, rs400). These asics require the
96 * gart table to be in system memory.
97 */
98void amdgpu_gart_table_ram_free(struct amdgpu_device *adev)
99{
100 if (adev->gart.ptr == NULL) {
101 return;
102 }
103#ifdef CONFIG_X86
104 if (0) {
105 set_memory_wb((unsigned long)adev->gart.ptr,
106 adev->gart.table_size >> PAGE_SHIFT);
107 }
108#endif
109 pci_free_consistent(adev->pdev, adev->gart.table_size,
110 (void *)adev->gart.ptr,
111 adev->gart.table_addr);
112 adev->gart.ptr = NULL;
113 adev->gart.table_addr = 0;
114}
115
116/**
117 * amdgpu_gart_table_vram_alloc - allocate vram for gart page table 60 * amdgpu_gart_table_vram_alloc - allocate vram for gart page table
118 * 61 *
119 * @adev: amdgpu_device pointer 62 * @adev: amdgpu_device pointer
@@ -125,75 +68,9 @@ void amdgpu_gart_table_ram_free(struct amdgpu_device *adev)
125 */ 68 */
126int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev) 69int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
127{ 70{
128 int r; 71 return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE,
129 72 AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.robj,
130 if (adev->gart.robj == NULL) { 73 &adev->gart.table_addr, &adev->gart.ptr);
131 r = amdgpu_bo_create(adev, adev->gart.table_size,
132 PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
133 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
134 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS,
135 NULL, NULL, 0, &adev->gart.robj);
136 if (r) {
137 return r;
138 }
139 }
140 return 0;
141}
142
143/**
144 * amdgpu_gart_table_vram_pin - pin gart page table in vram
145 *
146 * @adev: amdgpu_device pointer
147 *
148 * Pin the GART page table in vram so it will not be moved
149 * by the memory manager (pcie r4xx, r5xx+). These asics require the
150 * gart table to be in video memory.
151 * Returns 0 for success, error for failure.
152 */
153int amdgpu_gart_table_vram_pin(struct amdgpu_device *adev)
154{
155 uint64_t gpu_addr;
156 int r;
157
158 r = amdgpu_bo_reserve(adev->gart.robj, false);
159 if (unlikely(r != 0))
160 return r;
161 r = amdgpu_bo_pin(adev->gart.robj,
162 AMDGPU_GEM_DOMAIN_VRAM, &gpu_addr);
163 if (r) {
164 amdgpu_bo_unreserve(adev->gart.robj);
165 return r;
166 }
167 r = amdgpu_bo_kmap(adev->gart.robj, &adev->gart.ptr);
168 if (r)
169 amdgpu_bo_unpin(adev->gart.robj);
170 amdgpu_bo_unreserve(adev->gart.robj);
171 adev->gart.table_addr = gpu_addr;
172 return r;
173}
174
175/**
176 * amdgpu_gart_table_vram_unpin - unpin gart page table in vram
177 *
178 * @adev: amdgpu_device pointer
179 *
180 * Unpin the GART page table in vram (pcie r4xx, r5xx+).
181 * These asics require the gart table to be in video memory.
182 */
183void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev)
184{
185 int r;
186
187 if (adev->gart.robj == NULL) {
188 return;
189 }
190 r = amdgpu_bo_reserve(adev->gart.robj, true);
191 if (likely(r == 0)) {
192 amdgpu_bo_kunmap(adev->gart.robj);
193 amdgpu_bo_unpin(adev->gart.robj);
194 amdgpu_bo_unreserve(adev->gart.robj);
195 adev->gart.ptr = NULL;
196 }
197} 74}
198 75
199/** 76/**
@@ -207,10 +84,9 @@ void amdgpu_gart_table_vram_unpin(struct amdgpu_device *adev)
207 */ 84 */
208void amdgpu_gart_table_vram_free(struct amdgpu_device *adev) 85void amdgpu_gart_table_vram_free(struct amdgpu_device *adev)
209{ 86{
210 if (adev->gart.robj == NULL) { 87 amdgpu_bo_free_kernel(&adev->gart.robj,
211 return; 88 &adev->gart.table_addr,
212 } 89 &adev->gart.ptr);
213 amdgpu_bo_unref(&adev->gart.robj);
214} 90}
215 91
216/* 92/*