mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 11:21:26 -04:00
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>
This commit is contained in:
@@ -522,6 +522,17 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring,
|
||||
ring->count_dw -= count_dw;
|
||||
}
|
||||
|
||||
static inline unsigned int amdgpu_ring_get_dw_distance(struct amdgpu_ring *ring,
|
||||
u64 start_wptr, u64 end_wptr)
|
||||
{
|
||||
unsigned int start = start_wptr & ring->buf_mask;
|
||||
unsigned int end = end_wptr & ring->buf_mask;
|
||||
|
||||
if (end < start)
|
||||
end += ring->ring_size >> 2;
|
||||
return end - start;
|
||||
}
|
||||
|
||||
/**
|
||||
* amdgpu_ring_patch_cond_exec - patch dw count of conditional execute
|
||||
* @ring: amdgpu_ring structure
|
||||
@@ -532,18 +543,13 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring,
|
||||
static inline void amdgpu_ring_patch_cond_exec(struct amdgpu_ring *ring,
|
||||
unsigned int offset)
|
||||
{
|
||||
unsigned cur;
|
||||
|
||||
if (!ring->funcs->init_cond_exec)
|
||||
return;
|
||||
|
||||
WARN_ON(offset > ring->buf_mask);
|
||||
WARN_ON(ring->ring[offset] != 0);
|
||||
|
||||
cur = (ring->wptr - 1) & ring->buf_mask;
|
||||
if (cur < offset)
|
||||
cur += ring->ring_size >> 2;
|
||||
ring->ring[offset] = cur - offset;
|
||||
ring->ring[offset] = amdgpu_ring_get_dw_distance(ring, offset, ring->wptr - 1);
|
||||
}
|
||||
|
||||
int amdgpu_ring_test_helper(struct amdgpu_ring *ring);
|
||||
|
||||
Reference in New Issue
Block a user