* [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2)
@ 2019-10-15 22:18 Alex Deucher
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Alex Deucher @ 2019-10-15 22:18 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher
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
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 31 ++++++++++++++++++---------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 670784a78512..217084d56ab8 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -206,13 +206,14 @@ static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
* Open up a stream for HW test
*/
static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
+ struct amdgpu_bo *bo,
struct dma_fence **fence)
{
const unsigned ib_size_dw = 16;
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);
@@ -220,15 +221,15 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
ib->ptr[ib->length_dw++] = handle;
ib->ptr[ib->length_dw++] = 0x00010000;
- 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++] = 0x00000014;
ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
@@ -268,13 +269,14 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
*/
static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
uint32_t handle,
+ struct amdgpu_bo *bo,
struct dma_fence **fence)
{
const unsigned ib_size_dw = 16;
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);
@@ -282,15 +284,15 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
ib->ptr[ib->length_dw++] = handle;
ib->ptr[ib->length_dw++] = 0x00010000;
- 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++] = 0x00000014;
ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
@@ -327,13 +329,20 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
{
struct dma_fence *fence = NULL;
+ struct amdgpu_bo *bo = NULL;
long r;
- r = uvd_v6_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_v6_0_enc_get_create_msg(ring, 1, bo, NULL);
if (r)
goto error;
- r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence);
+ r = uvd_v6_0_enc_get_destroy_msg(ring, 1, bo, &fence);
if (r)
goto error;
@@ -345,6 +354,8 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
error:
dma_fence_put(fence);
+ amdgpu_bo_unreserve(bo);
+ amdgpu_bo_unref(&bo);
return r;
}
--
2.23.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] drm/amdgpu/uvd7: fix allocation size in enc ring test (v2)
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2019-10-15 22:18 ` Alex Deucher
2019-10-15 22:18 ` [PATCH 3/3] drm/amdgpu/vcn: fix allocation size in enc ring test Alex Deucher
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2019-10-15 22:18 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher
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
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | 33 ++++++++++++++++++---------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 01f658fa72c6..0995378d8263 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -214,13 +214,14 @@ static int uvd_v7_0_enc_ring_test_ring(struct amdgpu_ring *ring)
* Open up a stream for HW test
*/
static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
+ struct amdgpu_bo *bo,
struct dma_fence **fence)
{
const unsigned ib_size_dw = 16;
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);
@@ -228,15 +229,15 @@ static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
ib->ptr[ib->length_dw++] = handle;
ib->ptr[ib->length_dw++] = 0x00000000;
- 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++] = 0x00000014;
ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
@@ -275,13 +276,14 @@ static int uvd_v7_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
* 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,
- struct dma_fence **fence)
+ struct amdgpu_bo *bo,
+ struct dma_fence **fence)
{
const unsigned ib_size_dw = 16;
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);
@@ -289,15 +291,15 @@ static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handl
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001;
ib->ptr[ib->length_dw++] = handle;
ib->ptr[ib->length_dw++] = 0x00000000;
- 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++] = 0x00000014;
ib->ptr[ib->length_dw++] = 0x00000002;
@@ -334,13 +336,20 @@ static int uvd_v7_0_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handl
static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
{
struct dma_fence *fence = NULL;
+ struct amdgpu_bo *bo = NULL;
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)
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)
goto error;
@@ -352,6 +361,8 @@ static int uvd_v7_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
error:
dma_fence_put(fence);
+ amdgpu_bo_unreserve(bo);
+ amdgpu_bo_unref(&bo);
return r;
}
--
2.23.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] drm/amdgpu/vcn: fix allocation size in enc ring test
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-15 22:18 ` [PATCH 2/3] drm/amdgpu/uvd7: " Alex Deucher
@ 2019-10-15 22:18 ` Alex Deucher
2019-10-16 9:03 ` [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2) Christian König
2019-10-16 15:12 ` James Zhu
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2019-10-15 22:18 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher
We need to allocate a large enough buffer for the
session info, otherwise the IB test can overwrite
other memory.
- 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
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 35 ++++++++++++++++---------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 7a6beb2e7c4e..3199e4a5ff12 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -569,13 +569,14 @@ int amdgpu_vcn_enc_ring_test_ring(struct amdgpu_ring *ring)
}
static int amdgpu_vcn_enc_get_create_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;
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);
@@ -583,14 +584,14 @@ static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t hand
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
ib->ptr[ib->length_dw++] = handle;
- 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++] = 0x0000000b;
ib->ptr[ib->length_dw++] = 0x00000014;
@@ -621,13 +622,14 @@ static int amdgpu_vcn_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t hand
}
static int amdgpu_vcn_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;
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);
@@ -635,14 +637,14 @@ static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t han
return r;
ib = &job->ibs[0];
- dummy = ib->gpu_addr + 1024;
+ addr = amdgpu_bo_gpu_offset(bo);
ib->length_dw = 0;
ib->ptr[ib->length_dw++] = 0x00000018;
ib->ptr[ib->length_dw++] = 0x00000001;
ib->ptr[ib->length_dw++] = handle;
- 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++] = 0x0000000b;
ib->ptr[ib->length_dw++] = 0x00000014;
@@ -675,13 +677,20 @@ static int amdgpu_vcn_enc_get_destroy_msg(struct amdgpu_ring *ring, uint32_t han
int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
{
struct dma_fence *fence = NULL;
+ struct amdgpu_bo *bo = NULL;
long r;
- r = amdgpu_vcn_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 = amdgpu_vcn_enc_get_create_msg(ring, 1, bo, NULL);
if (r)
goto error;
- r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, &fence);
+ r = amdgpu_vcn_enc_get_destroy_msg(ring, 1, bo, &fence);
if (r)
goto error;
@@ -693,6 +702,8 @@ int amdgpu_vcn_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
error:
dma_fence_put(fence);
+ amdgpu_bo_unreserve(bo);
+ amdgpu_bo_unref(&bo);
return r;
}
--
2.23.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2)
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-15 22:18 ` [PATCH 2/3] drm/amdgpu/uvd7: " Alex Deucher
2019-10-15 22:18 ` [PATCH 3/3] drm/amdgpu/vcn: fix allocation size in enc ring test Alex Deucher
@ 2019-10-16 9:03 ` Christian König
2019-10-16 15:12 ` James Zhu
3 siblings, 0 replies; 5+ messages in thread
From: Christian König @ 2019-10-16 9:03 UTC (permalink / raw)
To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher
Am 16.10.19 um 00:18 schrieb Alex Deucher:
> 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
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Yeah, that looks better than the version from James.
Acked-by: Christian König <christian.koenig@amd.com> for the series.
> ---
> drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 31 ++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> index 670784a78512..217084d56ab8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> @@ -206,13 +206,14 @@ static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
> * Open up a stream for HW test
> */
> static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
> + struct amdgpu_bo *bo,
> struct dma_fence **fence)
> {
> const unsigned ib_size_dw = 16;
> 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);
> @@ -220,15 +221,15 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
> return r;
>
> ib = &job->ibs[0];
> - dummy = ib->gpu_addr + 1024;
> + addr = amdgpu_bo_gpu_offset(bo);
>
> ib->length_dw = 0;
> ib->ptr[ib->length_dw++] = 0x00000018;
> ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
> ib->ptr[ib->length_dw++] = handle;
> ib->ptr[ib->length_dw++] = 0x00010000;
> - 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++] = 0x00000014;
> ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
> @@ -268,13 +269,14 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
> */
> static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> uint32_t handle,
> + struct amdgpu_bo *bo,
> struct dma_fence **fence)
> {
> const unsigned ib_size_dw = 16;
> 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);
> @@ -282,15 +284,15 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> return r;
>
> ib = &job->ibs[0];
> - dummy = ib->gpu_addr + 1024;
> + addr = amdgpu_bo_gpu_offset(bo);
>
> ib->length_dw = 0;
> ib->ptr[ib->length_dw++] = 0x00000018;
> ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
> ib->ptr[ib->length_dw++] = handle;
> ib->ptr[ib->length_dw++] = 0x00010000;
> - 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++] = 0x00000014;
> ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
> @@ -327,13 +329,20 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
> {
> struct dma_fence *fence = NULL;
> + struct amdgpu_bo *bo = NULL;
> long r;
>
> - r = uvd_v6_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_v6_0_enc_get_create_msg(ring, 1, bo, NULL);
> if (r)
> goto error;
>
> - r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence);
> + r = uvd_v6_0_enc_get_destroy_msg(ring, 1, bo, &fence);
> if (r)
> goto error;
>
> @@ -345,6 +354,8 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>
> error:
> dma_fence_put(fence);
> + amdgpu_bo_unreserve(bo);
> + amdgpu_bo_unref(&bo);
> return r;
> }
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2)
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
` (2 preceding siblings ...)
2019-10-16 9:03 ` [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2) Christian König
@ 2019-10-16 15:12 ` James Zhu
3 siblings, 0 replies; 5+ messages in thread
From: James Zhu @ 2019-10-16 15:12 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Reviewed-by: James Zhu <James.Zhu@amd.com> for this series
Tested-by: James Zhu <James.Zhu@amd.com> for this series
James
On 2019-10-15 6:18 p.m., Alex Deucher wrote:
> 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
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 31 ++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> index 670784a78512..217084d56ab8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
> @@ -206,13 +206,14 @@ static int uvd_v6_0_enc_ring_test_ring(struct amdgpu_ring *ring)
> * Open up a stream for HW test
> */
> static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
> + struct amdgpu_bo *bo,
> struct dma_fence **fence)
> {
> const unsigned ib_size_dw = 16;
> 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);
> @@ -220,15 +221,15 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
> return r;
>
> ib = &job->ibs[0];
> - dummy = ib->gpu_addr + 1024;
> + addr = amdgpu_bo_gpu_offset(bo);
>
> ib->length_dw = 0;
> ib->ptr[ib->length_dw++] = 0x00000018;
> ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
> ib->ptr[ib->length_dw++] = handle;
> ib->ptr[ib->length_dw++] = 0x00010000;
> - 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++] = 0x00000014;
> ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
> @@ -268,13 +269,14 @@ static int uvd_v6_0_enc_get_create_msg(struct amdgpu_ring *ring, uint32_t handle
> */
> static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> uint32_t handle,
> + struct amdgpu_bo *bo,
> struct dma_fence **fence)
> {
> const unsigned ib_size_dw = 16;
> 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);
> @@ -282,15 +284,15 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> return r;
>
> ib = &job->ibs[0];
> - dummy = ib->gpu_addr + 1024;
> + addr = amdgpu_bo_gpu_offset(bo);
>
> ib->length_dw = 0;
> ib->ptr[ib->length_dw++] = 0x00000018;
> ib->ptr[ib->length_dw++] = 0x00000001; /* session info */
> ib->ptr[ib->length_dw++] = handle;
> ib->ptr[ib->length_dw++] = 0x00010000;
> - 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++] = 0x00000014;
> ib->ptr[ib->length_dw++] = 0x00000002; /* task info */
> @@ -327,13 +329,20 @@ static int uvd_v6_0_enc_get_destroy_msg(struct amdgpu_ring *ring,
> static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
> {
> struct dma_fence *fence = NULL;
> + struct amdgpu_bo *bo = NULL;
> long r;
>
> - r = uvd_v6_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_v6_0_enc_get_create_msg(ring, 1, bo, NULL);
> if (r)
> goto error;
>
> - r = uvd_v6_0_enc_get_destroy_msg(ring, 1, &fence);
> + r = uvd_v6_0_enc_get_destroy_msg(ring, 1, bo, &fence);
> if (r)
> goto error;
>
> @@ -345,6 +354,8 @@ static int uvd_v6_0_enc_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>
> error:
> dma_fence_put(fence);
> + amdgpu_bo_unreserve(bo);
> + amdgpu_bo_unref(&bo);
> return r;
> }
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-10-16 15:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 22:18 [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2) Alex Deucher
[not found] ` <20191015221813.625024-1-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2019-10-15 22:18 ` [PATCH 2/3] drm/amdgpu/uvd7: " Alex Deucher
2019-10-15 22:18 ` [PATCH 3/3] drm/amdgpu/vcn: fix allocation size in enc ring test Alex Deucher
2019-10-16 9:03 ` [PATCH 1/3] drm/amdgpu/uvd6: fix allocation size in enc ring test (v2) Christian König
2019-10-16 15:12 ` James Zhu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.