From: "Christian König" <christian.koenig@amd.com>
To: xinhui pan <xinhui.pan@amd.com>, amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com, leo.liu@amd.com, James.Zhu@amd.com
Subject: Re: [PATCH v4 2/3] drm/amdgpu: VCE avoid memory allocation during IB test
Date: Mon, 13 Sep 2021 11:03:46 +0200 [thread overview]
Message-ID: <b75f2a81-e922-1a24-7d32-900b6607b0bd@amd.com> (raw)
In-Reply-To: <20210913084253.241955-2-xinhui.pan@amd.com>
Am 13.09.21 um 10:42 schrieb xinhui pan:
> alloc extra msg from direct IB pool.
>
> Signed-off-by: xinhui pan <xinhui.pan@amd.com>
It would be cleaner if Leo could confirm that 256 byte alignment would
work as well.
But either way Reviewed-by: Christian König <christian.koenig@amd.com>
Regards,
Christian.
> ---
> change from v1:
> msg is allocated separately.
> msg is aligned to gpu page boundary
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 27 ++++++++++++-------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> index e9fdf49d69e8..caa4d3420e00 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
> @@ -82,7 +82,6 @@ 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);
> @@ -441,12 +440,12 @@ void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp)
> * Open up a stream for HW test
> */
> 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;
> struct amdgpu_ib *ib;
> + struct amdgpu_ib ib_msg;
> struct dma_fence *f = NULL;
> uint64_t addr;
> int i, r;
> @@ -456,9 +455,17 @@ static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
> if (r)
> return r;
>
> - ib = &job->ibs[0];
> + memset(&ib_msg, 0, sizeof(ib_msg));
> + /* only one gpu page is needed, alloc +1 page to make addr aligned. */
> + r = amdgpu_ib_get(ring->adev, NULL, AMDGPU_GPU_PAGE_SIZE * 2,
> + AMDGPU_IB_POOL_DIRECT,
> + &ib_msg);
> + if (r)
> + goto err;
>
> - addr = amdgpu_bo_gpu_offset(bo);
> + ib = &job->ibs[0];
> + /* let addr point to page boundary */
> + addr = AMDGPU_GPU_PAGE_ALIGN(ib_msg.gpu_addr);
>
> /* stitch together an VCE create msg */
> ib->length_dw = 0;
> @@ -498,6 +505,7 @@ static int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
> ib->ptr[i] = 0x0;
>
> r = amdgpu_job_submit_direct(job, ring, &f);
> + amdgpu_ib_free(ring->adev, &ib_msg, f);
> if (r)
> goto err;
>
> @@ -1134,20 +1142,13 @@ 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_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);
> + r = amdgpu_vce_get_create_msg(ring, 1, NULL);
> if (r)
> goto error;
>
> @@ -1163,8 +1164,6 @@ int amdgpu_vce_ring_test_ib(struct amdgpu_ring *ring, long timeout)
>
> error:
> dma_fence_put(fence);
> - amdgpu_bo_unreserve(bo);
> - amdgpu_bo_free_kernel(&bo, NULL, NULL);
> return r;
> }
>
next prev parent reply other threads:[~2021-09-13 9:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 8:42 [PATCH v4 1/3] drm/amdgpu: UVD avoid memory allocation during IB test xinhui pan
2021-09-13 8:42 ` [PATCH v4 2/3] drm/amdgpu: VCE " xinhui pan
2021-09-13 9:03 ` Christian König [this message]
2021-09-13 13:02 ` Liu, Leo
2021-09-13 8:42 ` [PATCH v4 3/3] drm/amdgpu: VCN " xinhui pan
2021-09-13 9:06 ` Christian König
2021-09-13 8:48 ` [PATCH v4 1/3] drm/amdgpu: UVD " Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b75f2a81-e922-1a24-7d32-900b6607b0bd@amd.com \
--to=christian.koenig@amd.com \
--cc=James.Zhu@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=leo.liu@amd.com \
--cc=xinhui.pan@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox