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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: add a helper to calculate ring distance

Add a helper to calculate the distance in DWs between
two wptrs.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+12 -6
+12 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
··· 522 522 ring->count_dw -= count_dw; 523 523 } 524 524 525 + static inline unsigned int amdgpu_ring_get_dw_distance(struct amdgpu_ring *ring, 526 + u64 start_wptr, u64 end_wptr) 527 + { 528 + unsigned int start = start_wptr & ring->buf_mask; 529 + unsigned int end = end_wptr & ring->buf_mask; 530 + 531 + if (end < start) 532 + end += ring->ring_size >> 2; 533 + return end - start; 534 + } 535 + 525 536 /** 526 537 * amdgpu_ring_patch_cond_exec - patch dw count of conditional execute 527 538 * @ring: amdgpu_ring structure ··· 543 532 static inline void amdgpu_ring_patch_cond_exec(struct amdgpu_ring *ring, 544 533 unsigned int offset) 545 534 { 546 - unsigned cur; 547 - 548 535 if (!ring->funcs->init_cond_exec) 549 536 return; 550 537 551 538 WARN_ON(offset > ring->buf_mask); 552 539 WARN_ON(ring->ring[offset] != 0); 553 540 554 - cur = (ring->wptr - 1) & ring->buf_mask; 555 - if (cur < offset) 556 - cur += ring->ring_size >> 2; 557 - ring->ring[offset] = cur - offset; 541 + ring->ring[offset] = amdgpu_ring_get_dw_distance(ring, offset, ring->wptr - 1); 558 542 } 559 543 560 544 int amdgpu_ring_test_helper(struct amdgpu_ring *ring);