Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: remove rptr checking

With the scheduler enabled we don't need that any more.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
c7e6be23 a27de35c

+26 -56
+1 -4
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 822 822 unsigned wptr; 823 823 unsigned wptr_old; 824 824 unsigned ring_size; 825 - unsigned ring_free_dw; 825 + unsigned max_dw; 826 826 int count_dw; 827 827 uint64_t gpu_addr; 828 828 uint32_t align_mask; ··· 1186 1186 int amdgpu_ib_pool_init(struct amdgpu_device *adev); 1187 1187 void amdgpu_ib_pool_fini(struct amdgpu_device *adev); 1188 1188 int amdgpu_ib_ring_tests(struct amdgpu_device *adev); 1189 - /* Ring access between begin & end cannot sleep */ 1190 - void amdgpu_ring_free_size(struct amdgpu_ring *ring); 1191 1189 int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw); 1192 1190 void amdgpu_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count); 1193 1191 void amdgpu_ring_commit(struct amdgpu_ring *ring); ··· 2161 2163 ring->ring[ring->wptr++] = v; 2162 2164 ring->wptr &= ring->ptr_mask; 2163 2165 ring->count_dw--; 2164 - ring->ring_free_dw--; 2165 2166 } 2166 2167 2167 2168 static inline struct amdgpu_sdma_instance *
+25 -52
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
··· 49 49 static int amdgpu_debugfs_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring); 50 50 51 51 /** 52 - * amdgpu_ring_free_size - update the free size 53 - * 54 - * @adev: amdgpu_device pointer 55 - * @ring: amdgpu_ring structure holding ring information 56 - * 57 - * Update the free dw slots in the ring buffer (all asics). 58 - */ 59 - void amdgpu_ring_free_size(struct amdgpu_ring *ring) 60 - { 61 - uint32_t rptr = amdgpu_ring_get_rptr(ring); 62 - 63 - /* This works because ring_size is a power of 2 */ 64 - ring->ring_free_dw = rptr + (ring->ring_size / 4); 65 - ring->ring_free_dw -= ring->wptr; 66 - ring->ring_free_dw &= ring->ptr_mask; 67 - if (!ring->ring_free_dw) { 68 - /* this is an empty ring */ 69 - ring->ring_free_dw = ring->ring_size / 4; 70 - } 71 - } 72 - 73 - /** 74 52 * amdgpu_ring_alloc - allocate space on the ring buffer 75 53 * 76 54 * @adev: amdgpu_device pointer ··· 60 82 */ 61 83 int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw) 62 84 { 63 - int r; 64 - 65 - /* make sure we aren't trying to allocate more space than there is on the ring */ 66 - if (ndw > (ring->ring_size / 4)) 67 - return -ENOMEM; 68 85 /* Align requested size with padding so unlock_commit can 69 86 * pad safely */ 70 - amdgpu_ring_free_size(ring); 71 87 ndw = (ndw + ring->align_mask) & ~ring->align_mask; 72 - while (ndw > (ring->ring_free_dw - 1)) { 73 - amdgpu_ring_free_size(ring); 74 - if (ndw < ring->ring_free_dw) { 75 - break; 76 - } 77 - r = amdgpu_fence_wait_next(ring); 78 - if (r) 79 - return r; 80 - } 88 + 89 + /* Make sure we aren't trying to allocate more space 90 + * than the maximum for one submission 91 + */ 92 + if (WARN_ON_ONCE(ndw > ring->max_dw)) 93 + return -ENOMEM; 94 + 81 95 ring->count_dw = ndw; 82 96 ring->wptr_old = ring->wptr; 83 97 return 0; ··· 296 326 } 297 327 } 298 328 ring->ptr_mask = (ring->ring_size / 4) - 1; 299 - ring->ring_free_dw = ring->ring_size / 4; 329 + ring->max_dw = DIV_ROUND_UP(ring->ring_size / 4, 330 + amdgpu_sched_hw_submission); 300 331 301 332 if (amdgpu_debugfs_ring_init(adev, ring)) { 302 333 DRM_ERROR("Failed to register debugfs file for rings !\n"); ··· 377 406 struct amdgpu_ring *ring = (void *)(((uint8_t*)adev) + roffset); 378 407 379 408 uint32_t rptr, wptr, rptr_next; 380 - unsigned count, i, j; 381 - 382 - amdgpu_ring_free_size(ring); 383 - count = (ring->ring_size / 4) - ring->ring_free_dw; 409 + unsigned i; 384 410 385 411 wptr = amdgpu_ring_get_wptr(ring); 386 - seq_printf(m, "wptr: 0x%08x [%5d]\n", 387 - wptr, wptr); 412 + seq_printf(m, "wptr: 0x%08x [%5d]\n", wptr, wptr); 388 413 389 414 rptr = amdgpu_ring_get_rptr(ring); 390 - seq_printf(m, "rptr: 0x%08x [%5d]\n", 391 - rptr, rptr); 392 - 393 415 rptr_next = le32_to_cpu(*ring->next_rptr_cpu_addr); 416 + 417 + seq_printf(m, "rptr: 0x%08x [%5d]\n", rptr, rptr); 394 418 395 419 seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n", 396 420 ring->wptr, ring->wptr); 397 - seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw); 398 - seq_printf(m, "%u dwords in ring\n", count); 399 421 400 422 if (!ring->ready) 401 423 return 0; ··· 397 433 * packet that is the root issue 398 434 */ 399 435 i = (rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask; 400 - for (j = 0; j <= (count + 32); j++) { 436 + while (i != rptr) { 401 437 seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]); 402 - if (rptr == i) 438 + if (i == rptr) 403 439 seq_puts(m, " *"); 404 - if (rptr_next == i) 440 + if (i == rptr_next) 441 + seq_puts(m, " #"); 442 + seq_puts(m, "\n"); 443 + i = (i + 1) & ring->ptr_mask; 444 + } 445 + while (i != wptr) { 446 + seq_printf(m, "r[%5d]=0x%08x", i, ring->ring[i]); 447 + if (i == rptr) 448 + seq_puts(m, " *"); 449 + if (i == rptr_next) 405 450 seq_puts(m, " #"); 406 451 seq_puts(m, "\n"); 407 452 i = (i + 1) & ring->ptr_mask;