drm/amdgpu/vce: fix allocation size in enc ring test
Subsystems (2)
PATCH 1/2 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 20 +++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +15 -5
@@ -429,13 +429,14 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)* Open up a stream for HW test */ int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence) {const unsigned ib_size_dw =1024 ;struct amdgpu_job *job;struct amdgpu_ib *ib;struct dma_fence *f =NULL ; -uint64_t dummy; +uint64_t addr;int i, r; r =amdgpu_job_alloc_with_ib (ring->adev, ib_size_dw *4 , &job);
@@ -444,7 +445,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib = &job->ibs[0 ]; - dummy = ib->gpu_addr +1024 ; + addr =amdgpu_bo_gpu_offset (bo);/* stitch together an VCE create msg */ ib->length_dw =0 ;
@@ -476,8 +477,8 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib->ptr[ib->length_dw++] =0x00000014 ;/* len */ ib->ptr[ib->length_dw++] =0x05000005 ;/* feedback buffer */ - ib->ptr[ib->length_dw++] =upper_32_bits (dummy); - ib->ptr[ib->length_dw++] = dummy; + ib->ptr[ib->length_dw++] =upper_32_bits (addr); + ib->ptr[ib->length_dw++] = addr; ib->ptr[ib->length_dw++] =0x00000001 ;for (i = ib->length_dw; i < ib_size_dw; ++i)
@@ -1110,13 +1111,20 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)int amdgpu_vce_ring_test_ib (struct amdgpu_ring *ring,long timeout) {struct dma_fence *fence =NULL ; +struct amdgpu_bo *bo =NULL ;long r;/* skip vce ring1/2 ib test for now, since it's not reliable */ if (ring != &ring->adev->vce.ring[0 ])return 0 ; - r =amdgpu_vce_get_create_msg (ring,1 ,NULL ); + r =amdgpu_bo_create_reserved (ring->adev,512 ,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &bo,NULL ,NULL ); +if (r) +return r; + + r =amdgpu_vce_get_create_msg (ring,1 , bo,NULL );if (r) goto error;
@@ -1132,5 +1140,7 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) error:dma_fence_put (fence); +amdgpu_bo_unreserve (bo); +amdgpu_bo_unref (&bo);return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +1 -0
@@ -59,6 +59,7 @@ int amdgpu_vce_entity_init(struct amdgpu_device *adev);int amdgpu_vce_suspend (struct amdgpu_device *adev);int amdgpu_vce_resume (struct amdgpu_device *adev);int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence);int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle,bool direct,struct dma_fence **fence);
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20191017154456.335015-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu/vce: make some functions static
They are not used outside of the file they are defined in.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 15 ++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | 5 ----- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +10 -5
@@ -80,6 +80,11 @@ MODULE_FIRMWARE(FIRMWARE_VEGA12);MODULE_FIRMWARE (FIRMWARE_VEGA20 );static void amdgpu_vce_idle_work_handler (struct work_struct *work); +static int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo, +struct dma_fence **fence); +static int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle, +bool direct,struct dma_fence **fence);/** * amdgpu_vce_init - allocate memory, load vce firmware
@@ -428,9 +433,9 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)* * Open up a stream for HW test */ -int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, -struct amdgpu_bo *bo, -struct dma_fence **fence) +static int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo, +struct dma_fence **fence) {const unsigned ib_size_dw =1024 ;struct amdgpu_job *job;
@@ -508,8 +513,8 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,* * Close up a stream for HW test or if userspace failed to do so */ -int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle, -bool direct,struct dma_fence **fence) +static int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle, +bool direct,struct dma_fence **fence) {const unsigned ib_size_dw =1024 ;struct amdgpu_job *job;
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +0 -5
@@ -58,11 +58,6 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev);int amdgpu_vce_entity_init (struct amdgpu_device *adev);int amdgpu_vce_suspend (struct amdgpu_device *adev);int amdgpu_vce_resume (struct amdgpu_device *adev); -int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, -struct amdgpu_bo *bo, -struct dma_fence **fence); -int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle, -bool direct,struct dma_fence **fence);void amdgpu_vce_free_handles (struct amdgpu_device *adev,struct drm_file *filp);int amdgpu_vce_ring_parse_cs (struct amdgpu_cs_parser *p,uint32_t ib_idx);int amdgpu_vce_ring_parse_cs_vm (struct amdgpu_cs_parser *p,uint32_t ib_idx);
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
James Zhu
Reviewed-byQuoted 85 lines · Alex Deucher
We need to allocate a large enough buffer for the feedback buffer, otherwise the IB test can overwrite other memory.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 20 +++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +15
-5@@ -429,13 +429,14 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)* Open up a stream for HW test */ int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence) {const unsigned ib_size_dw =1024 ;struct amdgpu_job *job;struct amdgpu_ib *ib;struct dma_fence *f =NULL ; -uint64_t dummy; +uint64_t addr;int i, r; r =amdgpu_job_alloc_with_ib (ring->adev, ib_size_dw *4 , &job);@@ -444,7 +445,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib = &job->ibs[0 ]; - dummy = ib->gpu_addr +1024 ; + addr =amdgpu_bo_gpu_offset (bo);/* stitch together an VCE create msg */ ib->length_dw =0 ;@@ -476,8 +477,8 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib->ptr[ib->length_dw++] =0x00000014 ;/* len */ ib->ptr[ib->length_dw++] =0x05000005 ;/* feedback buffer */ - ib->ptr[ib->length_dw++] =upper_32_bits (dummy); - ib->ptr[ib->length_dw++] = dummy; + ib->ptr[ib->length_dw++] =upper_32_bits (addr); + ib->ptr[ib->length_dw++] = addr; ib->ptr[ib->length_dw++] =0x00000001 ;for (i = ib->length_dw; i < ib_size_dw; ++i)@@ -1110,13 +1111,20 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)int amdgpu_vce_ring_test_ib (struct amdgpu_ring *ring,long timeout) {struct dma_fence *fence =NULL ; +struct amdgpu_bo *bo =NULL ;long r;/* skip vce ring1/2 ib test for now, since it's not reliable */ if (ring != &ring->adev->vce.ring[0 ])return 0 ; - r =amdgpu_vce_get_create_msg (ring,1 ,NULL ); + r =amdgpu_bo_create_reserved (ring->adev,512 ,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &bo,NULL ,NULL ); +if (r) +return r; + + r =amdgpu_vce_get_create_msg (ring,1 , bo,NULL );if (r) goto error;@@ -1132,5 +1140,7 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) error:dma_fence_put (fence); +amdgpu_bo_unreserve (bo); +amdgpu_bo_unref (&bo);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h int amdgpu_vce_entity_init(struct amdgpu_device *adev); · line 65
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +1
-0@@ -59,6 +59,7 @@ int amdgpu_vce_entity_init(struct amdgpu_device *adev);int amdgpu_vce_suspend (struct amdgpu_device *adev);int amdgpu_vce_resume (struct amdgpu_device *adev);int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence);int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle,bool direct,struct dma_fence **fence);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
Acked-byAm 17.10.19 um 17:44 schrieb Alex Deucher:
Quoted 5 lines
We need to allocate a large enough buffer for the feedback buffer, otherwise the IB test can overwrite other memory.
Signed-off-by Alex Deucher <[email protected]>
Quoted 80 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 20 +++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | 1 + 2 files changed, 16 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +15
-5@@ -429,13 +429,14 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)* Open up a stream for HW test */ int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence) {const unsigned ib_size_dw =1024 ;struct amdgpu_job *job;struct amdgpu_ib *ib;struct dma_fence *f =NULL ; -uint64_t dummy; +uint64_t addr;int i, r; r =amdgpu_job_alloc_with_ib (ring->adev, ib_size_dw *4 , &job);@@ -444,7 +445,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib = &job->ibs[0 ]; - dummy = ib->gpu_addr +1024 ; + addr =amdgpu_bo_gpu_offset (bo);/* stitch together an VCE create msg */ ib->length_dw =0 ;@@ -476,8 +477,8 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, ib->ptr[ib->length_dw++] =0x00000014 ;/* len */ ib->ptr[ib->length_dw++] =0x05000005 ;/* feedback buffer */ - ib->ptr[ib->length_dw++] =upper_32_bits (dummy); - ib->ptr[ib->length_dw++] = dummy; + ib->ptr[ib->length_dw++] =upper_32_bits (addr); + ib->ptr[ib->length_dw++] = addr; ib->ptr[ib->length_dw++] =0x00000001 ;for (i = ib->length_dw; i < ib_size_dw; ++i)@@ -1110,13 +1111,20 @@ int amdgpu_vce_ring_test_ring(struct amdgpu_ring *ring)int amdgpu_vce_ring_test_ib (struct amdgpu_ring *ring,long timeout) {struct dma_fence *fence =NULL ; +struct amdgpu_bo *bo =NULL ;long r;/* skip vce ring1/2 ib test for now, since it's not reliable */ if (ring != &ring->adev->vce.ring[0 ])return 0 ; - r =amdgpu_vce_get_create_msg (ring,1 ,NULL ); + r =amdgpu_bo_create_reserved (ring->adev,512 ,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM , + &bo,NULL ,NULL ); +if (r) +return r; + + r =amdgpu_vce_get_create_msg (ring,1 , bo,NULL );if (r) goto error;@@ -1132,5 +1140,7 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout) error:dma_fence_put (fence); +amdgpu_bo_unreserve (bo); +amdgpu_bo_unref (&bo);return r; }drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h int amdgpu_vce_entity_init(struct amdgpu_device *adev); · line 65
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +1
-0@@ -59,6 +59,7 @@ int amdgpu_vce_entity_init(struct amdgpu_device *adev);int amdgpu_vce_suspend (struct amdgpu_device *adev);int amdgpu_vce_resume (struct amdgpu_device *adev);int amdgpu_vce_get_create_msg (struct amdgpu_ring *ring,uint32_t handle, +struct amdgpu_bo *bo,struct dma_fence **fence);int amdgpu_vce_get_destroy_msg (struct amdgpu_ring *ring,uint32_t handle,bool direct,struct dma_fence **fence);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx