drm/amdgpu/uvd7: fix allocation size in enc ring test (v2)
We need to allocate a large enough buffer for the session info, otherwise the IB test can overwrite other memory. v2: - session info is 128K according to mesa - use the same session info for create and destroy Bug: https://bugzilla.kernel.org/show_bug.cgi?id=204241 Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: James Zhu <James.Zhu@amd.com> Tested-by: James Zhu <James.Zhu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
This commit is contained in:
parent
ce584a8e28
commit
5d230bc91f
|
@ -214,13 +214,14 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
|
||||||
* Open up a stream for HW test
|
* Open up a stream for HW test
|
||||||
*/
|
*/
|
||||||
static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
|
static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
|
||||||
|
struct amdgpu_bo *bo,
|
||||||
struct dma_fence **fence)
|
struct dma_fence **fence)
|
||||||
{
|
{
|
||||||
const unsigned ib_size_dw = 16;
|
const unsigned ib_size_dw = 16;
|
||||||
struct amdgpu_job *job;
|
struct amdgpu_job *job;
|
||||||
struct amdgpu_ib *ib;
|
struct amdgpu_ib *ib;
|
||||||
struct dma_fence *f = NULL;
|
struct dma_fence *f = NULL;
|
||||||
uint64_t dummy;
|
uint64_t addr;
|
||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job);
|
r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job);
|
||||||
|
@ -228,15 +229,15 @@ static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
ib = &job->ibs[0];
|
ib = &job->ibs[0];
|
||||||
dummy = ib->gpu_addr + 1024;
|
addr = amdgpu_bo_gpu_offset(bo);
|
||||||
|
|
||||||
ib->length_dw = 0;
|
ib->length_dw = 0;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000018;
|
ib->ptr[ib->length_dw++] = 0x00000018;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
|
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
|
||||||
ib->ptr[ib->length_dw++] = handle;
|
ib->ptr[ib->length_dw++] = handle;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000000;
|
ib->ptr[ib->length_dw++] = 0x00000000;
|
||||||
ib->ptr[ib->length_dw++] = upper_32_bits(dummy);
|
ib->ptr[ib->length_dw++] = upper_32_bits(addr);
|
||||||
ib->ptr[ib->length_dw++] = dummy;
|
ib->ptr[ib->length_dw++] = addr;
|
||||||
|
|
||||||
ib->ptr[ib->length_dw++] = 0x00000014;
|
ib->ptr[ib->length_dw++] = 0x00000014;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
|
ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
|
||||||
|
@ -275,13 +276,14 @@ err:
|
||||||
* Close up a stream for HW test or if userspace failed to do so
|
* Close up a stream for HW test or if userspace failed to do so
|
||||||
*/
|
*/
|
||||||
static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
|
static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
|
||||||
struct dma_fence **fence)
|
struct amdgpu_bo *bo,
|
||||||
|
struct dma_fence **fence)
|
||||||
{
|
{
|
||||||
const unsigned ib_size_dw = 16;
|
const unsigned ib_size_dw = 16;
|
||||||
struct amdgpu_job *job;
|
struct amdgpu_job *job;
|
||||||
struct amdgpu_ib *ib;
|
struct amdgpu_ib *ib;
|
||||||
struct dma_fence *f = NULL;
|
struct dma_fence *f = NULL;
|
||||||
uint64_t dummy;
|
uint64_t addr;
|
||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job);
|
r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job);
|
||||||
|
@ -289,15 +291,15 @@ static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handl
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
ib = &job->ibs[0];
|
ib = &job->ibs[0];
|
||||||
dummy = ib->gpu_addr + 1024;
|
addr = amdgpu_bo_gpu_offset(bo);
|
||||||
|
|
||||||
ib->length_dw = 0;
|
ib->length_dw = 0;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000018;
|
ib->ptr[ib->length_dw++] = 0x00000018;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000001;
|
ib->ptr[ib->length_dw++] = 0x00000001;
|
||||||
ib->ptr[ib->length_dw++] = handle;
|
ib->ptr[ib->length_dw++] = handle;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000000;
|
ib->ptr[ib->length_dw++] = 0x00000000;
|
||||||
ib->ptr[ib->length_dw++] = upper_32_bits(dummy);
|
ib->ptr[ib->length_dw++] = upper_32_bits(addr);
|
||||||
ib->ptr[ib->length_dw++] = dummy;
|
ib->ptr[ib->length_dw++] = addr;
|
||||||
|
|
||||||
ib->ptr[ib->length_dw++] = 0x00000014;
|
ib->ptr[ib->length_dw++] = 0x00000014;
|
||||||
ib->ptr[ib->length_dw++] = 0x00000002;
|
ib->ptr[ib->length_dw++] = 0x00000002;
|
||||||
|
@ -334,13 +336,20 @@ err:
|
||||||
static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
|
static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
|
||||||
{
|
{
|
||||||
struct dma_fence *fence = NULL;
|
struct dma_fence *fence = NULL;
|
||||||
|
struct amdgpu_bo *bo = NULL;
|
||||||
long r;
|
long r;
|
||||||
|
|
||||||
r = uvd_v7_0_enc_get_create_msg(ring, 1, NULL);
|
r = amdgpu_bo_create_reserved(ring->adev, 128 * 1024, PAGE_SIZE,
|
||||||
|
AMDGPU_GEM_DOMAIN_VRAM,
|
||||||
|
&bo, NULL, NULL);
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = uvd_v7_0_enc_get_create_msg(ring, 1, bo, NULL);
|
||||||
if (r)
|
if (r)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
r = uvd_v7_0_enc_get_destroy_msg(ring, 1, &fence);
|
r = uvd_v7_0_enc_get_destroy_msg(ring, 1, bo, &fence);
|
||||||
if (r)
|
if (r)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -352,6 +361,8 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
|
||||||
|
|
||||||
error:
|
error:
|
||||||
dma_fence_put(fence);
|
dma_fence_put(fence);
|
||||||
|
amdgpu_bo_unreserve(bo);
|
||||||
|
amdgpu_bo_unref(&bo);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue