drm/amdgpu:fix ring init sequence
authorMonk Liu <Monk.Liu@amd.com>
Tue, 21 Mar 2017 10:48:45 +0000 (18:48 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Mar 2017 03:55:38 +0000 (23:55 -0400)
ring->buf_mask need be set prior to ring_clear_ring invoke
and fix ring_clear_ring as well which should use buf_mask
instead of ptr_mask

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h

index bfd4022210ed2213261a543dff7a032cce0e07e8..783d52a007eafa70bbcb63372b02ad678d32e5f2 100644 (file)
@@ -235,6 +235,9 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
        ring->ring_size = roundup_pow_of_two(max_dw * 4 *
                                             amdgpu_sched_hw_submission);
 
+       ring->buf_mask = (ring->ring_size / 4) - 1;
+       ring->ptr_mask = ring->funcs->support_64bit_ptrs ?
+               0xffffffffffffffff : ring->buf_mask;
        /* Allocate ring buffer */
        if (ring->ring_obj == NULL) {
                r = amdgpu_bo_create_kernel(adev, ring->ring_size, PAGE_SIZE,
@@ -248,9 +251,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
                }
                amdgpu_ring_clear_ring(ring);
        }
-       ring->buf_mask = (ring->ring_size / 4) - 1;
-       ring->ptr_mask = ring->funcs->support_64bit_ptrs ?
-               0xffffffffffffffff : ring->buf_mask;
 
        ring->max_dw = max_dw;
 
index 9bc453f1855cc15a3d92e4766f9c4d78ec7c00a7..63e56398ca9ae0c873589a740582c459ffe4c5a1 100644 (file)
@@ -195,7 +195,7 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring);
 static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring)
 {
        int i = 0;
-       while (i <= ring->ptr_mask)
+       while (i <= ring->buf_mask)
                ring->ring[i++] = ring->funcs->nop;
 
 }