All of lore.kernel.org
 help / color / mirror / Atom feed
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 5/6] drm/amdgpu: implement grab reserved vmid V3
Date: Thu, 27 Apr 2017 15:57:08 +0800	[thread overview]
Message-ID: <5901A454.3000906@amd.com> (raw)
In-Reply-To: <5901879F.2030407-5C7GfCeVMHo@public.gmane.org>

On 04/27/2017 01:54 PM, Zhang, Jerry (Junwei) wrote:
> On 04/27/2017 01:00 PM, Chunming Zhou wrote:
>> v2: move sync waiting only when flush needs
>> v3: fix racy
>>
>> Change-Id: I64da2701c9fdcf986afb90ba1492a78d5bef1b6c
>> Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 72 ++++++++++++++++++++++++++++++++--
>>   1 file changed, 68 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> index e6fdfa4..7752279 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> @@ -397,6 +397,65 @@ static bool amdgpu_vm_had_gpu_reset(struct amdgpu_device
>> *adev,
>>           atomic_read(&adev->gpu_reset_counter);
>>   }
>>
>> +static bool amdgpu_vm_reserved_vmid_ready(struct amdgpu_vm *vm, unsigned vmhub)
>> +{
>> +    return !!vm->reserved_vmid[vmhub];
>> +}
>
> It may be better to populate it into alloc reserved_vmid func as well, getting
> easy maintenance in the future.
>
>
>> +
>> +/* idr_mgr->lock must be held */
>> +static int amdgpu_vm_grab_reserved_vmid_locked(struct amdgpu_vm *vm,
>> +                           struct amdgpu_ring *ring,
>> +                           struct amdgpu_sync *sync,
>> +                           struct fence *fence,
>> +                           struct amdgpu_job *job)
>> +{
>> +    struct amdgpu_device *adev = ring->adev;
>> +    unsigned vmhub = ring->funcs->vmhub;
>> +    struct amdgpu_vm_id *id = vm->reserved_vmid[vmhub];
>> +    struct amdgpu_vm_id_manager *id_mgr = &adev->vm_manager.id_mgr[vmhub];
>> +    struct fence *updates = sync->last_vm_update;
>> +    int r = 0;
>> +    struct fence *flushed, *tmp;
>> +    bool needs_flush = false;
>> +
>> +    flushed  = id->flushed_updates;
>> +    if ((amdgpu_vm_had_gpu_reset(adev, id)) ||
>> +        (atomic64_read(&id->owner) != vm->client_id) ||
>> +        (job->vm_pd_addr != id->pd_gpu_addr) ||
>> +        (updates && (!flushed || updates->context != flushed->context ||
>> +            fence_is_later(updates, flushed)))) {
>> +        needs_flush = true;
>> +        tmp = amdgpu_sync_get_fence(&id->active);
>> +        if (tmp) {
>> +            r = amdgpu_sync_fence(adev, sync, tmp);
>> +            fence_put(tmp);
>> +            return r;
>
> Sorry, I didn't catch up this.
> Could you give me some tips?
> (in this case, we no need to update id info as below?)

Got that offline to wait for id idle.
That will always use the reserved id when it's idle.
Anyway, it should work.

>
> Jerry
>
>> +        }
>> +    }
>> +
>> +    /* Good we can use this VMID. Remember this submission as
>> +    * user of the VMID.
>> +    */
>> +    r = amdgpu_sync_fence(ring->adev, &id->active, fence);
>> +    if (r)
>> +        goto out;
>> +
>> +    if (updates && (!flushed || updates->context != flushed->context ||
>> +            fence_is_later(updates, flushed))) {
>> +        fence_put(id->flushed_updates);
>> +        id->flushed_updates = fence_get(updates);
>> +    }
>> +    id->pd_gpu_addr = job->vm_pd_addr;
>> +    id->current_gpu_reset_count = atomic_read(&adev->gpu_reset_counter);
>> +    atomic64_set(&id->owner, vm->client_id);
>> +    job->vm_needs_flush = needs_flush;
>> +
>> +    job->vm_id = id - id_mgr->ids;
>> +    trace_amdgpu_vm_grab_id(vm, ring, job);
>> +out:
>> +    return r;
>> +}
>> +
>>   /**
>>    * amdgpu_vm_grab_id - allocate the next free VMID
>>    *
>> @@ -421,12 +480,17 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct
>> amdgpu_ring *ring,
>>       unsigned i;
>>       int r = 0;
>>
>> +    mutex_lock(&id_mgr->lock);
>> +    if (amdgpu_vm_reserved_vmid_ready(vm, vmhub)) {
>> +        r = amdgpu_vm_grab_reserved_vmid_locked(vm, ring, sync, fence, job);
>> +        mutex_unlock(&id_mgr->lock);
>> +        return r;
>> +    }
>>       fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
>> -    if (!fences)
>> +    if (!fences) {
>> +        mutex_unlock(&id_mgr->lock);
>>           return -ENOMEM;
>> -
>> -    mutex_lock(&id_mgr->lock);
>> -
>> +    }
>>       /* Check if we have an idle VMID */
>>       i = 0;
>>       list_for_each_entry(idle, &id_mgr->ids_lru, list) {
>>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-04-27  7:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-27  5:00 [PATCH 0/6 v4] *** Dedicated vmid per process v4 *** Chunming Zhou
     [not found] ` <1493269238-26742-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-27  5:00   ` [PATCH 1/6] drm/amdgpu: add vm ioctl Chunming Zhou
2017-04-27  5:00   ` [PATCH 2/6] drm/amdgpu: add reserved vmid field in vm struct v2 Chunming Zhou
2017-04-27  5:00   ` [PATCH 3/6] drm/amdgpu: reserve/unreserve vmid by vm ioctl v4 Chunming Zhou
     [not found]     ` <1493269238-26742-4-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-27  5:41       ` Zhang, Jerry (Junwei)
2017-04-27  5:00   ` [PATCH 4/6] drm/amdgpu: add limitation for dedicated vm number v4 Chunming Zhou
2017-04-27  5:00   ` [PATCH 5/6] drm/amdgpu: implement grab reserved vmid V3 Chunming Zhou
     [not found]     ` <1493269238-26742-6-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-27  5:54       ` Zhang, Jerry (Junwei)
     [not found]         ` <5901879F.2030407-5C7GfCeVMHo@public.gmane.org>
2017-04-27  7:57           ` Zhang, Jerry (Junwei) [this message]
2017-04-27  5:00   ` [PATCH 6/6] drm/amdgpu: bump module verion for reserved vmid Chunming Zhou
2017-04-27  7:58   ` [PATCH 0/6 v4] *** Dedicated vmid per process v4 *** Zhang, Jerry (Junwei)
2017-04-27  9:51   ` Christian König
     [not found]     ` <78a42a6d-6e32-3f93-9fab-cecc9dab9fab-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-27 10:26       ` zhoucm1
     [not found]         ` <5901C757.9070103-5C7GfCeVMHo@public.gmane.org>
2017-04-27 12:10           ` 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=5901A454.3000906@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.