From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 4/4] drm/amdgpu: check whether the vmid can be reused first
Date: Wed, 10 May 2017 16:11:46 +0800 [thread overview]
Message-ID: <5912CB42.9040808@amd.com> (raw)
In-Reply-To: <1494401509-7198-4-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
On 05/10/2017 03:31 PM, Chunming Zhou wrote:
> Change-Id: If24a62b9c3097c9b040225ab0e768145b7a3db1e
> Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
I had same idea when read this code before.
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 92 +++++++++++++++++-----------------
> 1 file changed, 47 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index bbb3587..6259608 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -492,51 +492,6 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
> mutex_unlock(&id_mgr->lock);
> return r;
> }
> - fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
> - if (!fences) {
> - mutex_unlock(&id_mgr->lock);
> - return -ENOMEM;
> - }
> - /* Check if we have an idle VMID */
> - i = 0;
> - list_for_each_entry(idle, &id_mgr->ids_lru, list) {
> - fences[i] = amdgpu_sync_peek_fence(&idle->active, ring);
> - if (!fences[i])
> - break;
> - ++i;
> - }
> -
> - /* If we can't find a idle VMID to use, wait till one becomes available */
> - if (&idle->list == &id_mgr->ids_lru) {
> - u64 fence_context = adev->vm_manager.fence_context + ring->idx;
> - unsigned seqno = ++adev->vm_manager.seqno[ring->idx];
> - struct fence_array *array;
> - unsigned j;
> -
> - for (j = 0; j < i; ++j)
> - fence_get(fences[j]);
> -
> - array = fence_array_create(i, fences, fence_context,
> - seqno, true);
> - if (!array) {
> - for (j = 0; j < i; ++j)
> - fence_put(fences[j]);
> - kfree(fences);
> - r = -ENOMEM;
> - goto error;
> - }
> -
> -
> - r = amdgpu_sync_fence(ring->adev, sync, &array->base);
> - fence_put(&array->base);
> - if (r)
> - goto error;
> -
> - mutex_unlock(&id_mgr->lock);
> - return 0;
> -
> - }
> - kfree(fences);
>
> job->vm_needs_flush = false;
> /* Check if we can use a VMID already assigned to this VM */
> @@ -586,6 +541,53 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
>
> };
>
> + fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
> + if (!fences) {
> + mutex_unlock(&id_mgr->lock);
> + return -ENOMEM;
> + }
> + /* Check if we have an idle VMID */
> + i = 0;
> + list_for_each_entry(idle, &id_mgr->ids_lru, list) {
> + fences[i] = amdgpu_sync_peek_fence(&idle->active, ring);
> + if (!fences[i])
> + break;
> + ++i;
> + }
> +
> + /* If we can't find a idle VMID to use, wait till one becomes available */
> + if (&idle->list == &id_mgr->ids_lru) {
> + u64 fence_context = adev->vm_manager.fence_context + ring->idx;
> + unsigned seqno = ++adev->vm_manager.seqno[ring->idx];
> + struct fence_array *array;
> + unsigned j;
> +
> + for (j = 0; j < i; ++j)
> + fence_get(fences[j]);
> +
> + array = fence_array_create(i, fences, fence_context,
> + seqno, true);
> + if (!array) {
> + for (j = 0; j < i; ++j)
> + fence_put(fences[j]);
> + kfree(fences);
> + r = -ENOMEM;
> + goto error;
> + }
> +
> +
> + r = amdgpu_sync_fence(ring->adev, sync, &array->base);
> + fence_put(&array->base);
> + if (r)
> + goto error;
> +
> + mutex_unlock(&id_mgr->lock);
> + return 0;
> +
> + }
> + kfree(fences);
> +
> +
> /* Still no ID to use? Then use the idle one found earlier */
> id = idle;
>
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-05-10 8:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 7:31 [PATCH 1/4] drm/amdgpu: add sched sync for amdgpu job Chunming Zhou
[not found] ` <1494401509-7198-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-10 7:31 ` [PATCH 2/4] drm/amdgpu: make pipeline sync be in same place Chunming Zhou
[not found] ` <1494401509-7198-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-10 8:08 ` Zhang, Jerry (Junwei)
2017-05-10 8:28 ` Christian König
2017-05-10 7:31 ` [PATCH 3/4] drm/amdgpu: id reset count only is updated when used end Chunming Zhou
[not found] ` <1494401509-7198-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-10 8:14 ` Zhang, Jerry (Junwei)
2017-05-10 8:20 ` Christian König
2017-05-10 7:31 ` [PATCH 4/4] drm/amdgpu: check whether the vmid can be reused first Chunming Zhou
[not found] ` <1494401509-7198-4-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-05-10 8:11 ` Zhang, Jerry (Junwei) [this message]
2017-05-10 8:18 ` Christian König
2017-05-10 8:00 ` [PATCH 1/4] drm/amdgpu: add sched sync for amdgpu job Zhang, Jerry (Junwei)
2017-05-10 8:26 ` Christian König
[not found] ` <6c8f4299-d251-a0fe-c76f-b9124482fa0a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-10 8:38 ` zhoucm1
[not found] ` <5912D18F.8050204-5C7GfCeVMHo@public.gmane.org>
2017-05-10 8:50 ` Christian König
[not found] ` <7769dbea-68ad-e6a0-81be-f4e07677c731-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-10 9:00 ` zhoucm1
[not found] ` <5912D6BB.2080303-5C7GfCeVMHo@public.gmane.org>
2017-05-10 9:21 ` Christian König
[not found] ` <ab63e653-6eb3-c42f-1674-ac26528fd202-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-05-10 9:20 ` zhoucm1
[not found] ` <5912DB4F.7080607-5C7GfCeVMHo@public.gmane.org>
2017-05-10 9:44 ` 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=5912CB42.9040808@amd.com \
--to=jerry.zhang-5c7gfcevmho@public.gmane.org \
--cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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 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.