aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2017-07-28 12:14:15 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-08-15 14:46:08 -0400
commit97407b63ea605c12f328ce46b155026080b34246 (patch)
treebc917a5af723a143eb3e98b5655d3423e9e390f0 /drivers/gpu
parentb7cecbe8d5f139e3e60d1e8f31a0c4832bd29486 (diff)
drm/amdgpu: use 256 bit buffers for all wb allocations (v2)
May waste a bit of memory, but simplifies the interface significantly. v2: convert internal accounting to use 256bit slots Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c77
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c65
3 files changed, 20 insertions, 126 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d492ff79c296..19ee2a4e93f7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1131,10 +1131,6 @@ struct amdgpu_wb {
1131 1131
1132int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); 1132int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb);
1133void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); 1133void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb);
1134int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb);
1135int amdgpu_wb_get_256bit(struct amdgpu_device *adev, u32 *wb);
1136void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb);
1137void amdgpu_wb_free_256bit(struct amdgpu_device *adev, u32 wb);
1138 1134
1139void amdgpu_get_pcie_info(struct amdgpu_device *adev); 1135void amdgpu_get_pcie_info(struct amdgpu_device *adev);
1140 1136
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d33e1061e04b..a6f6cb0f2e02 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -504,7 +504,8 @@ static int amdgpu_wb_init(struct amdgpu_device *adev)
504 int r; 504 int r;
505 505
506 if (adev->wb.wb_obj == NULL) { 506 if (adev->wb.wb_obj == NULL) {
507 r = amdgpu_bo_create_kernel(adev, AMDGPU_MAX_WB * sizeof(uint32_t), 507 /* AMDGPU_MAX_WB * sizeof(uint32_t) * 8 = AMDGPU_MAX_WB 256bit slots */
508 r = amdgpu_bo_create_kernel(adev, AMDGPU_MAX_WB * sizeof(uint32_t) * 8,
508 PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT, 509 PAGE_SIZE, AMDGPU_GEM_DOMAIN_GTT,
509 &adev->wb.wb_obj, &adev->wb.gpu_addr, 510 &adev->wb.wb_obj, &adev->wb.gpu_addr,
510 (void **)&adev->wb.wb); 511 (void **)&adev->wb.wb);
@@ -535,47 +536,10 @@ static int amdgpu_wb_init(struct amdgpu_device *adev)
535int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb) 536int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb)
536{ 537{
537 unsigned long offset = find_first_zero_bit(adev->wb.used, adev->wb.num_wb); 538 unsigned long offset = find_first_zero_bit(adev->wb.used, adev->wb.num_wb);
538 if (offset < adev->wb.num_wb) {
539 __set_bit(offset, adev->wb.used);
540 *wb = offset;
541 return 0;
542 } else {
543 return -EINVAL;
544 }
545}
546 539
547/** 540 if (offset < adev->wb.num_wb) {
548 * amdgpu_wb_get_64bit - Allocate a wb entry
549 *
550 * @adev: amdgpu_device pointer
551 * @wb: wb index
552 *
553 * Allocate a wb slot for use by the driver (all asics).
554 * Returns 0 on success or -EINVAL on failure.
555 */
556int amdgpu_wb_get_64bit(struct amdgpu_device *adev, u32 *wb)
557{
558 unsigned long offset = bitmap_find_next_zero_area_off(adev->wb.used,
559 adev->wb.num_wb, 0, 2, 7, 0);
560 if ((offset + 1) < adev->wb.num_wb) {
561 __set_bit(offset, adev->wb.used); 541 __set_bit(offset, adev->wb.used);
562 __set_bit(offset + 1, adev->wb.used); 542 *wb = offset * 8; /* convert to dw offset */
563 *wb = offset;
564 return 0;
565 } else {
566 return -EINVAL;
567 }
568}
569
570int amdgpu_wb_get_256bit(struct amdgpu_device *adev, u32 *wb)
571{
572 int i = 0;
573 unsigned long offset = bitmap_find_next_zero_area_off(adev->wb.used,
574 adev->wb.num_wb, 0, 8, 63, 0);
575 if ((offset + 7) < adev->wb.num_wb) {
576 for (i = 0; i < 8; i++)
577 __set_bit(offset + i, adev->wb.used);
578 *wb = offset;
579 return 0; 543 return 0;
580 } else { 544 } else {
581 return -EINVAL; 545 return -EINVAL;
@@ -597,39 +561,6 @@ void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb)
597} 561}
598 562
599/** 563/**
600 * amdgpu_wb_free_64bit - Free a wb entry
601 *
602 * @adev: amdgpu_device pointer
603 * @wb: wb index
604 *
605 * Free a wb slot allocated for use by the driver (all asics)
606 */
607void amdgpu_wb_free_64bit(struct amdgpu_device *adev, u32 wb)
608{
609 if ((wb + 1) < adev->wb.num_wb) {
610 __clear_bit(wb, adev->wb.used);
611 __clear_bit(wb + 1, adev->wb.used);
612 }
613}
614
615/**
616 * amdgpu_wb_free_256bit - Free a wb entry
617 *
618 * @adev: amdgpu_device pointer
619 * @wb: wb index
620 *
621 * Free a wb slot allocated for use by the driver (all asics)
622 */
623void amdgpu_wb_free_256bit(struct amdgpu_device *adev, u32 wb)
624{
625 int i = 0;
626
627 if ((wb + 7) < adev->wb.num_wb)
628 for (i = 0; i < 8; i++)
629 __clear_bit(wb + i, adev->wb.used);
630}
631
632/**
633 * amdgpu_vram_location - try to find VRAM location 564 * amdgpu_vram_location - try to find VRAM location
634 * @adev: amdgpu device structure holding all necessary informations 565 * @adev: amdgpu device structure holding all necessary informations
635 * @mc: memory controller structure holding memory informations 566 * @mc: memory controller structure holding memory informations
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 3874be83de10..70447567438a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -184,47 +184,22 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
184 return r; 184 return r;
185 } 185 }
186 186
187 if (ring->funcs->support_64bit_ptrs) { 187 r = amdgpu_wb_get(adev, &ring->rptr_offs);
188 r = amdgpu_wb_get_64bit(adev, &ring->rptr_offs); 188 if (r) {
189 if (r) { 189 dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r);
190 dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); 190 return r;
191 return r;
192 }
193
194 r = amdgpu_wb_get_64bit(adev, &ring->wptr_offs);
195 if (r) {
196 dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r);
197 return r;
198 }
199
200 } else {
201 r = amdgpu_wb_get(adev, &ring->rptr_offs);
202 if (r) {
203 dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r);
204 return r;
205 }
206
207 r = amdgpu_wb_get(adev, &ring->wptr_offs);
208 if (r) {
209 dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r);
210 return r;
211 }
212
213 } 191 }
214 192
215 if (amdgpu_sriov_vf(adev) && ring->funcs->type == AMDGPU_RING_TYPE_GFX) { 193 r = amdgpu_wb_get(adev, &ring->wptr_offs);
216 r = amdgpu_wb_get_256bit(adev, &ring->fence_offs); 194 if (r) {
217 if (r) { 195 dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r);
218 dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); 196 return r;
219 return r; 197 }
220 }
221 198
222 } else { 199 r = amdgpu_wb_get(adev, &ring->fence_offs);
223 r = amdgpu_wb_get(adev, &ring->fence_offs); 200 if (r) {
224 if (r) { 201 dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r);
225 dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); 202 return r;
226 return r;
227 }
228 } 203 }
229 204
230 r = amdgpu_wb_get(adev, &ring->cond_exe_offs); 205 r = amdgpu_wb_get(adev, &ring->cond_exe_offs);
@@ -286,19 +261,11 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)
286{ 261{
287 ring->ready = false; 262 ring->ready = false;
288 263
289 if (ring->funcs->support_64bit_ptrs) { 264 amdgpu_wb_free(ring->adev, ring->rptr_offs);
290 amdgpu_wb_free_64bit(ring->adev, ring->rptr_offs); 265 amdgpu_wb_free(ring->adev, ring->wptr_offs);
291 amdgpu_wb_free_64bit(ring->adev, ring->wptr_offs);
292 } else {
293 amdgpu_wb_free(ring->adev, ring->rptr_offs);
294 amdgpu_wb_free(ring->adev, ring->wptr_offs);
295 }
296 266
297 amdgpu_wb_free(ring->adev, ring->cond_exe_offs); 267 amdgpu_wb_free(ring->adev, ring->cond_exe_offs);
298 if (amdgpu_sriov_vf(ring->adev) && ring->funcs->type == AMDGPU_RING_TYPE_GFX) 268 amdgpu_wb_free(ring->adev, ring->fence_offs);
299 amdgpu_wb_free_256bit(ring->adev, ring->fence_offs);
300 else
301 amdgpu_wb_free(ring->adev, ring->fence_offs);
302 269
303 amdgpu_bo_free_kernel(&ring->ring_obj, 270 amdgpu_bo_free_kernel(&ring->ring_obj,
304 &ring->gpu_addr, 271 &ring->gpu_addr,