All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: "Christian König"
	<deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>,
	"Chunming Zhou" <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 3/6] drm/amdgpu: reserve vmid by vm ioctl
Date: Wed, 26 Apr 2017 17:04:26 +0800	[thread overview]
Message-ID: <5900629A.20701@amd.com> (raw)
In-Reply-To: <238b3d86-743a-4ca9-c008-92ae4e1ec79c-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>

On 04/26/2017 04:51 PM, Christian König wrote:
> Am 26.04.2017 um 09:09 schrieb Zhang, Jerry (Junwei):
>>
>>
>> On 04/24/2017 01:57 PM, Chunming Zhou wrote:
>>> Change-Id: I5f80dc39dc9d44660a96a2b710b0dbb4d3b9039d
>>> Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
>>> ---
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 56
>>> ++++++++++++++++++++++++++++++++++
>>>   1 file changed, 56 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>> index acf9102..5f4dcc9 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>> @@ -397,6 +397,17 @@ static bool amdgpu_vm_had_gpu_reset(struct
>>> amdgpu_device *adev,
>>>           atomic_read(&adev->gpu_reset_counter);
>>>   }
>>>
>>> +static bool amdgpu_vm_dedicated_vmid_ready(struct amdgpu_vm *vm)
>>> +{
>>> +    unsigned vmhub;
>>> +
>>> +    for (vmhub = 0; vmhub < AMDGPU_MAX_VMHUBS; vmhub++) {
>>> +        if (!vm->dedicated_vmid[vmhub])
>>> +            return false;
>>
>> Just note:
>> Seemingly for pre-gmcv9, it will always allocate one more dedicated/reserved
>> vmid for the 2nd un-used vmhub.
>> anyway it will not be used either.
>
> It's even worse. IIRC we don't initialize the 2nd hub on pre-gmcv9. So that
> could work with uninitialized data.

I saw AMDGPU_MAX_VMHUBS is defined 2 for all ASICs.
So the 2nd dedicated_vmid here will be 0 always, returning false.
Right?

Additionally, in amdgpu_vm_manager_init() the id_mgr[i] is initialized in loop 
of AMDGPU_MAX_VMHUBS as well.
Thus I though both vmhub are initialized.
Any missing, please correct me.
Thanks.

Jerry

>
> Christian.
>
>>
>> Jerry
>>> +    }
>>> +    return true;
>>> +}
>>> +
>>>   /**
>>>    * amdgpu_vm_grab_id - allocate the next free VMID
>>>    *
>>> @@ -546,6 +557,45 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct
>>> amdgpu_ring *ring,
>>>       return r;
>>>   }
>>>
>>> +static int amdgpu_vm_alloc_dedicated_vmid(struct amdgpu_device *adev,
>>> +                      struct amdgpu_vm *vm)
>>> +{
>>> +    struct amdgpu_vm_id_manager *id_mgr;
>>> +    struct amdgpu_vm_id *idle;
>>> +    unsigned vmhub;
>>> +    int r;
>>> +
>>> +    for (vmhub = 0; vmhub < AMDGPU_MAX_VMHUBS; vmhub++) {
>>> +        id_mgr = &adev->vm_manager.id_mgr[vmhub];
>>> +
>>> +        mutex_lock(&id_mgr->lock);
>>> +        /* Select the first entry VMID */
>>> +        idle = list_first_entry(&id_mgr->ids_lru, struct amdgpu_vm_id,
>>> +                    list);
>>> +        list_del_init(&idle->list);
>>> +        vm->dedicated_vmid[vmhub] = idle;
>>> +        mutex_unlock(&id_mgr->lock);
>>> +
>>> +        r = amdgpu_sync_wait(&idle->active);
>>> +        if (r)
>>> +            goto err;
>>> +    }
>>> +
>>> +    return 0;
>>> +err:
>>> +    for (vmhub = 0; vmhub < AMDGPU_MAX_VMHUBS; vmhub++) {
>>> +        id_mgr = &adev->vm_manager.id_mgr[vmhub];
>>> +
>>> +        mutex_lock(&id_mgr->lock);
>>> +        if (vm->dedicated_vmid[vmhub])
>>> + list_add(&vm->dedicated_vmid[vmhub]->list,
>>> +                 &id_mgr->ids_lru);
>>> +        vm->dedicated_vmid[vmhub] = NULL;
>>> +        mutex_unlock(&id_mgr->lock);
>>> +    }
>>> +    return r;
>>> +}
>>> +
>>>   static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
>>>   {
>>>       struct amdgpu_device *adev = ring->adev;
>>> @@ -2379,9 +2429,15 @@ int amdgpu_vm_ioctl(struct drm_device *dev, void
>>> *data, struct drm_file *filp)
>>>       union drm_amdgpu_vm *args = data;
>>>       struct amdgpu_device *adev = dev->dev_private;
>>>       struct amdgpu_fpriv *fpriv = filp->driver_priv;
>>> +    int r;
>>>
>>>       switch (args->in.op) {
>>>       case AMDGPU_VM_OP_RESERVE_VMID:
>>> +        if (!amdgpu_vm_dedicated_vmid_ready(&fpriv->vm)) {
>>> +            r = amdgpu_vm_alloc_dedicated_vmid(adev, &fpriv->vm);
>>
>> Could you change the return value in this ready checking func?
>> Usually we can easily get to know this kind of things.
>> if (sth_ready())
>>     do_sth();
>>
>>
>>> +            if (r)
>>> +                return r;
>>> +        }
>>>           break;
>>>       default:
>>>           return -EINVAL;
>>>
>> _______________________________________________
>> 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-26  9:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24  5:57 [PATCH 0/6] *** Dedicated vmid per process v2 *** Chunming Zhou
     [not found] ` <1493013460-13344-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-24  5:57   ` [PATCH 1/6] drm/amdgpu: add vm ioctl Chunming Zhou
     [not found]     ` <1493013460-13344-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-26  7:09       ` Zhang, Jerry (Junwei)
     [not found]         ` <590047A5.1070807-5C7GfCeVMHo@public.gmane.org>
2017-04-26  8:47           ` Christian König
2017-04-24  5:57   ` [PATCH 2/6] drm/amdgpu: add dedicated vmid field in vm struct Chunming Zhou
     [not found]     ` <1493013460-13344-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-26  7:09       ` Zhang, Jerry (Junwei)
     [not found]         ` <590047B3.7050109-5C7GfCeVMHo@public.gmane.org>
2017-04-26  8:49           ` Christian König
     [not found]             ` <291734a9-5306-f3e3-219c-c53cbf433358-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-26  9:05               ` zhoucm1
     [not found]                 ` <590062C5.6020402-5C7GfCeVMHo@public.gmane.org>
2017-04-26  9:10                   ` Christian König
     [not found]                     ` <05c4fcec-9dae-24ac-4a5d-26e0fd5bc148-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-26  9:14                       ` zhoucm1
     [not found]                         ` <59006508.7080907-5C7GfCeVMHo@public.gmane.org>
2017-04-26  9:45                           ` Christian König
     [not found]                             ` <f41de8f1-11d9-a727-c34f-d218b08f9047-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-26  9:46                               ` zhoucm1
2017-04-24  5:57   ` [PATCH 3/6] drm/amdgpu: reserve vmid by vm ioctl Chunming Zhou
     [not found]     ` <1493013460-13344-4-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-26  7:09       ` Zhang, Jerry (Junwei)
     [not found]         ` <590047C6.50005-5C7GfCeVMHo@public.gmane.org>
2017-04-26  8:51           ` Christian König
     [not found]             ` <238b3d86-743a-4ca9-c008-92ae4e1ec79c-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-26  9:04               ` Zhang, Jerry (Junwei) [this message]
     [not found]                 ` <5900629A.20701-5C7GfCeVMHo@public.gmane.org>
2017-04-26  9:08                   ` Christian König
2017-04-24  5:57   ` [PATCH 4/6] drm/amdgpu: add limitation for dedicated vm number v2 Chunming Zhou
     [not found]     ` <1493013460-13344-5-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-26  7:10       ` Zhang, Jerry (Junwei)
     [not found]         ` <590047D0.7080901-5C7GfCeVMHo@public.gmane.org>
2017-04-26  8:53           ` Christian König
2017-04-24  5:57   ` [PATCH 5/6] drm/amdgpu: implement grab dedicated vmid V2 Chunming Zhou
2017-04-24  5:57   ` [PATCH 6/6] drm/amdgpu: bump module verion for reserved vmid Chunming Zhou
2017-04-25  9:07   ` [PATCH 0/6] *** Dedicated vmid per process v2 *** zhoucm1
     [not found]     ` <58FF11E7.6040607-5C7GfCeVMHo@public.gmane.org>
2017-04-25 10:02       ` 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=5900629A.20701@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=deathsimple-ANTagKRnAhcb1SvskN2V4Q@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.