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

drm/amdgpu/vce: fix allocation size in enc ring test

We need to allocate a large enough buffer for the
feedback buffer, otherwise the IB test can overwrite
other memory.

Reviewed-by: James Zhu <James.Zhu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org

+16 -5
+15 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
··· 429 429 * Open up a stream for HW test 430 430 */ 431 431 int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, 432 + struct amdgpu_bo *bo, 432 433 struct dma_fence **fence) 433 434 { 434 435 const unsigned ib_size_dw = 1024; 435 436 struct amdgpu_job *job; 436 437 struct amdgpu_ib *ib; 437 438 struct dma_fence *f = NULL; 438 - uint64_t dummy; 439 + uint64_t addr; 439 440 int i, r; 440 441 441 442 r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); ··· 445 444 446 445 ib = &job->ibs[0]; 447 446 448 - dummy = ib->gpu_addr + 1024; 447 + addr = amdgpu_bo_gpu_offset(bo); 449 448 450 449 /* stitch together an VCE create msg */ 451 450 ib->length_dw = 0; ··· 477 476 478 477 ib->ptr[ib->length_dw++] = 0x00000014; /* len */ 479 478 ib->ptr[ib->length_dw++] = 0x05000005; /* feedback buffer */ 480 - ib->ptr[ib->length_dw++] = upper_32_bits(dummy); 481 - ib->ptr[ib->length_dw++] = dummy; 479 + ib->ptr[ib->length_dw++] = upper_32_bits(addr); 480 + ib->ptr[ib->length_dw++] = addr; 482 481 ib->ptr[ib->length_dw++] = 0x00000001; 483 482 484 483 for (i = ib->length_dw; i < ib_size_dw; ++i) ··· 1111 1110 int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) 1112 1111 { 1113 1112 struct dma_fence *fence = NULL; 1113 + struct amdgpu_bo *bo = NULL; 1114 1114 long r; 1115 1115 1116 1116 /* skip vce ring1/2 ib test for now, since it's not reliable */ 1117 1117 if (ring != &ring->adev->vce.ring[0]) 1118 1118 return 0; 1119 1119 1120 - r = amdgpu_vce_get_create_msg(ring, 1, NULL); 1120 + r = amdgpu_bo_create_reserved(ring->adev, 512, PAGE_SIZE, 1121 + AMDGPU_GEM_DOMAIN_VRAM, 1122 + &bo, NULL, NULL); 1123 + if (r) 1124 + return r; 1125 + 1126 + r = amdgpu_vce_get_create_msg(ring, 1, bo, NULL); 1121 1127 if (r) 1122 1128 goto error; 1123 1129 ··· 1140 1132 1141 1133 error: 1142 1134 dma_fence_put(fence); 1135 + amdgpu_bo_unreserve(bo); 1136 + amdgpu_bo_unref(&bo); 1143 1137 return r; 1144 1138 }
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
··· 59 59 int amdgpu_vce_suspend(struct amdgpu_device *adev); 60 60 int amdgpu_vce_resume(struct amdgpu_device *adev); 61 61 int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, 62 + struct amdgpu_bo *bo, 62 63 struct dma_fence **fence); 63 64 int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle, 64 65 bool direct, struct dma_fence **fence);