All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nirmoy <nirmodas@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Nirmoy Das" <nirmoy.das@amd.com>,
	amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com
Subject: Re: [PATCH 7/7] drm/amdgpu: do not allocate entries separately
Date: Fri, 21 May 2021 16:04:58 +0200	[thread overview]
Message-ID: <51900764-17e0-46b1-03a2-0f514b89fa17@amd.com> (raw)
In-Reply-To: <04e2e462-1e00-e5da-bc1b-e0255f09ad45@amd.com>


On 5/21/21 3:01 PM, Christian König wrote:
> Am 21.05.21 um 14:45 schrieb Nirmoy Das:
>> Allocate PD/PT entries while allocating VM BOs and use that
>> instead of allocating those entries separately.
>>
>> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 31 ++++++++++++++------------
>>   1 file changed, 17 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> index 120e6b7a0286..4717f075a391 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> @@ -880,7 +880,12 @@ static int amdgpu_vm_pt_create(struct 
>> amdgpu_device *adev,
>>       bp.domain = amdgpu_bo_get_preferred_pin_domain(adev, bp.domain);
>>       bp.flags = AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |
>>           AMDGPU_GEM_CREATE_CPU_GTT_USWC;
>> -    bp.bo_ptr_size = sizeof(struct amdgpu_bo_vm);
>> +    if (level < AMDGPU_VM_PTB)
>> +        bp.bo_ptr_size = struct_size((*vmbo), entries,
>> +                         amdgpu_vm_num_entries(adev, level));
>> +    else
>> +        bp.bo_ptr_size = sizeof(struct amdgpu_bo_vm);
>> +
>
> Rather do it like this here:
>
> if (level < AMDGPU_VM_PTB)
>     num_entries = amdgpu_vm_num_entries(...)
> else
>     num_entries = 0;
>
> bp.bo_ptr_size = struct_size(....)


Sure.


>
> If we have that calculation more than once then it might make sense to 
> unify it in a function, but I don't think so of hand.


Currently, we only need this calculation in amdgpu_vm_pt_create().


Nirmoy


>
>
> Regards,
> Christian.
>
>>       if (vm->use_cpu_for_update)
>>           bp.flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
>>   @@ -954,19 +959,14 @@ static int amdgpu_vm_alloc_pts(struct 
>> amdgpu_device *adev,
>>       struct amdgpu_bo_vm *pt;
>>       int r;
>>   -    if (cursor->level < AMDGPU_VM_PTB && !entry->entries) {
>> -        unsigned num_entries;
>> -
>> -        num_entries = amdgpu_vm_num_entries(adev, cursor->level);
>> -        entry->entries = kvmalloc_array(num_entries,
>> -                        sizeof(*entry->entries),
>> -                        GFP_KERNEL | __GFP_ZERO);
>> -        if (!entry->entries)
>> -            return -ENOMEM;
>> -    }
>> -
>> -    if (entry->base.bo)
>> +    if (entry->base.bo) {
>> +        if (cursor->level < AMDGPU_VM_PTB)
>> +            entry->entries =
>> +                to_amdgpu_bo_vm(entry->base.bo)->entries;
>> +        else
>> +            entry->entries = NULL;
>>           return 0;
>> +    }
>>         r = amdgpu_vm_pt_create(adev, vm, cursor->level, immediate, 
>> &pt);
>>       if (r)
>> @@ -978,6 +978,10 @@ static int amdgpu_vm_alloc_pts(struct 
>> amdgpu_device *adev,
>>       pt_bo = &pt->bo;
>>       pt_bo->parent = amdgpu_bo_ref(cursor->parent->base.bo);
>>       amdgpu_vm_bo_base_init(&entry->base, vm, pt_bo);
>> +    if (cursor->level < AMDGPU_VM_PTB)
>> +        entry->entries = pt->entries;
>> +    else
>> +        entry->entries = NULL;
>>         r = amdgpu_vm_clear_bo(adev, vm, pt_bo, immediate);
>>       if (r)
>> @@ -1005,7 +1009,6 @@ static void amdgpu_vm_free_table(struct 
>> amdgpu_vm_pt *entry)
>> amdgpu_bo_unref(&to_amdgpu_bo_vm(entry->base.bo)->shadow);
>>           amdgpu_bo_unref(&entry->base.bo);
>>       }
>> -    kvfree(entry->entries);
>>       entry->entries = NULL;
>>   }
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-05-21 14:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 12:45 [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Nirmoy Das
2021-05-21 12:45 ` [PATCH 2/7] drm/amdgpu: add a new identifier for amdgpu_bo Nirmoy Das
2021-05-21 12:58   ` Christian König
2021-05-21 13:54     ` Nirmoy
2021-05-21 12:45 ` [PATCH 3/7] drm/amdgpu: use amdgpu_bo_vm for vm code Nirmoy Das
2021-05-21 12:45 ` [PATCH 4/7] drm/amdgpu: create shadow bo directly Nirmoy Das
2021-05-21 12:45 ` [PATCH 5/7] drm/amdgpu: switch to amdgpu_bo_vm's shadow Nirmoy Das
2021-05-21 12:45 ` [PATCH 6/7] drm/amdgpu: remove unused code Nirmoy Das
2021-05-21 12:45 ` [PATCH 7/7] drm/amdgpu: do not allocate entries separately Nirmoy Das
2021-05-21 13:01   ` Christian König
2021-05-21 14:04     ` Nirmoy [this message]
2021-05-21 14:54 ` [PATCH 1/7] drm/amdgpu: add amdgpu_bo_vm bo type Alex Deucher
2021-05-21 15:19   ` Nirmoy

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=51900764-17e0-46b1-03a2-0f514b89fa17@amd.com \
    --to=nirmodas@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=nirmoy.das@amd.com \
    --subject='Re: [PATCH 7/7] drm/amdgpu: do not allocate entries separately' \
    /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

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.