From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Chunming Zhou <zhoucm1-5C7GfCeVMHo@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 4/8] drm/amdgpu: remove last_entry_used from the VM code
Date: Mon, 11 Dec 2017 13:08:05 +0100 [thread overview]
Message-ID: <8d22ff81-e27f-abe5-c3f3-3fbdf80334be@gmail.com> (raw)
In-Reply-To: <a671871b-5bad-3d48-b76b-5db4d49c9624-5C7GfCeVMHo@public.gmane.org>
Am 11.12.2017 um 06:52 schrieb Chunming Zhou:
>
>
> On 2017年12月09日 00:41, Christian König wrote:
>> Not needed any more.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 52
>> +++++++++++++++++++---------------
>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 -
>> 2 files changed, 29 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> index 400a00fababd..ae5451bf5873 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>> @@ -329,9 +329,6 @@ static int amdgpu_vm_alloc_levels(struct
>> amdgpu_device *adev,
>> to >= amdgpu_vm_num_entries(adev, level))
>> return -EINVAL;
>> - if (to > parent->last_entry_used)
>> - parent->last_entry_used = to;
>> -
>> ++level;
>> saddr = saddr & ((1 << shift) - 1);
>> eaddr = eaddr & ((1 << shift) - 1);
>> @@ -1187,16 +1184,19 @@ static int amdgpu_vm_update_pde(struct
>> amdgpu_device *adev,
>> *
>> * Mark all PD level as invalid after an error.
>> */
>> -static void amdgpu_vm_invalidate_level(struct amdgpu_vm *vm,
>> - struct amdgpu_vm_pt *parent)
>> +static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev,
>> + struct amdgpu_vm *vm,
>> + struct amdgpu_vm_pt *parent,
>> + unsigned level)
> can we move level to struct amdgpu_vm_pt?
I considered this as well, but then abandoned the approach and moved to
using it as parameter again.
The general problem is that amdgpu_vm_pt is already *WAY* to big, we use
60 bytes to manage 4K in the worst case.
Working on getting this down to something sane again, but adding the
level here just to save passing it as parameter during the destruction
would make it worse.
Christian.
> otherwise, it looks ok to me.
>
> Regards,
> David Zhou
>> {
>> - unsigned pt_idx;
>> + unsigned pt_idx, num_entries;
>> /*
>> * Recurse into the subdirectories. This recursion is harmless
>> because
>> * we only have a maximum of 5 layers.
>> */
>> - for (pt_idx = 0; pt_idx <= parent->last_entry_used; ++pt_idx) {
>> + num_entries = amdgpu_vm_num_entries(adev, level);
>> + for (pt_idx = 0; pt_idx < num_entries; ++pt_idx) {
>> struct amdgpu_vm_pt *entry = &parent->entries[pt_idx];
>> if (!entry->base.bo)
>> @@ -1207,7 +1207,7 @@ static void amdgpu_vm_invalidate_level(struct
>> amdgpu_vm *vm,
>> if (list_empty(&entry->base.vm_status))
>> list_add(&entry->base.vm_status, &vm->relocated);
>> spin_unlock(&vm->status_lock);
>> - amdgpu_vm_invalidate_level(vm, entry);
>> + amdgpu_vm_invalidate_level(adev, vm, entry, level + 1);
>> }
>> }
>> @@ -1249,7 +1249,8 @@ int amdgpu_vm_update_directories(struct
>> amdgpu_device *adev,
>> r = amdgpu_vm_update_pde(adev, vm, pt, entry);
>> if (r) {
>> - amdgpu_vm_invalidate_level(vm, &vm->root);
>> + amdgpu_vm_invalidate_level(adev, vm,
>> + &vm->root, 0);
>> return r;
>> }
>> spin_lock(&vm->status_lock);
>> @@ -1652,7 +1653,7 @@ static int amdgpu_vm_bo_update_mapping(struct
>> amdgpu_device *adev,
>> error_free:
>> amdgpu_job_free(job);
>> - amdgpu_vm_invalidate_level(vm, &vm->root);
>> + amdgpu_vm_invalidate_level(adev, vm, &vm->root, 0);
>> return r;
>> }
>> @@ -2716,26 +2717,31 @@ int amdgpu_vm_init(struct amdgpu_device
>> *adev, struct amdgpu_vm *vm,
>> /**
>> * amdgpu_vm_free_levels - free PD/PT levels
>> *
>> - * @level: PD/PT starting level to free
>> + * @adev: amdgpu device structure
>> + * @parent: PD/PT starting level to free
>> + * @level: level of parent structure
>> *
>> * Free the page directory or page table level and all sub levels.
>> */
>> -static void amdgpu_vm_free_levels(struct amdgpu_vm_pt *level)
>> +static void amdgpu_vm_free_levels(struct amdgpu_device *adev,
>> + struct amdgpu_vm_pt *parent,
>> + unsigned level)
>> {
>> - unsigned i;
>> + unsigned i, num_entries = amdgpu_vm_num_entries(adev, level);
>> - if (level->base.bo) {
>> - list_del(&level->base.bo_list);
>> - list_del(&level->base.vm_status);
>> - amdgpu_bo_unref(&level->base.bo->shadow);
>> - amdgpu_bo_unref(&level->base.bo);
>> + if (parent->base.bo) {
>> + list_del(&parent->base.bo_list);
>> + list_del(&parent->base.vm_status);
>> + amdgpu_bo_unref(&parent->base.bo->shadow);
>> + amdgpu_bo_unref(&parent->base.bo);
>> }
>> - if (level->entries)
>> - for (i = 0; i <= level->last_entry_used; i++)
>> - amdgpu_vm_free_levels(&level->entries[i]);
>> + if (parent->entries)
>> + for (i = 0; i < num_entries; i++)
>> + amdgpu_vm_free_levels(adev, &parent->entries[i],
>> + level + 1);
>> - kvfree(level->entries);
>> + kvfree(parent->entries);
>> }
>> /**
>> @@ -2793,7 +2799,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev,
>> struct amdgpu_vm *vm)
>> if (r) {
>> dev_err(adev->dev, "Leaking page tables because BO
>> reservation failed\n");
>> } else {
>> - amdgpu_vm_free_levels(&vm->root);
>> + amdgpu_vm_free_levels(adev, &vm->root, 0);
>> amdgpu_bo_unreserve(root);
>> }
>> amdgpu_bo_unref(&root);
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
>> index 43ea131dd411..7a308a1ea048 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
>> @@ -141,7 +141,6 @@ struct amdgpu_vm_pt {
>> /* array of page tables, one for each directory entry */
>> struct amdgpu_vm_pt *entries;
>> - unsigned last_entry_used;
>> };
>> #define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr))
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-12-11 12:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 16:41 [PATCH 1/8] drm/amdgpu: stop joining PDEs Christian König
[not found] ` <20171208164107.1567-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-08 16:41 ` [PATCH 2/8] drm/amdgpu: update one PDE at a time Christian König
[not found] ` <20171208164107.1567-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 5:37 ` Chunming Zhou
2017-12-08 16:41 ` [PATCH 3/8] drm/amdgpu: avoid the modulo in amdgpu_vm_get_entry Christian König
[not found] ` <20171208164107.1567-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 5:40 ` Chunming Zhou
2017-12-08 16:41 ` [PATCH 4/8] drm/amdgpu: remove last_entry_used from the VM code Christian König
[not found] ` <20171208164107.1567-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 5:52 ` Chunming Zhou
[not found] ` <a671871b-5bad-3d48-b76b-5db4d49c9624-5C7GfCeVMHo@public.gmane.org>
2017-12-11 12:08 ` Christian König [this message]
[not found] ` <8d22ff81-e27f-abe5-c3f3-3fbdf80334be-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-12 9:23 ` Christian König
[not found] ` <aa19a12f-3d8b-74eb-75ae-e9c3cddf96b2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-12 9:32 ` Chunming Zhou
2017-12-08 16:41 ` [PATCH 5/8] drm/amdgpu: remove keeping the addr of the VM PDs Christian König
[not found] ` <20171208164107.1567-5-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 5:59 ` Chunming Zhou
2017-12-08 16:41 ` [PATCH 6/8] drm/amdgpu: batch PDE updates again Christian König
[not found] ` <20171208164107.1567-6-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 6:13 ` Chunming Zhou
2017-12-08 16:41 ` [PATCH 7/8] drm/amdgpu: allow get_vm_pde to change flags as well Christian König
2017-12-08 16:41 ` [PATCH 8/8] drm/amdgpu: implement 2+1 PD support for Raven Christian König
[not found] ` <20171208164107.1567-8-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-12-11 6:49 ` Chunming Zhou
[not found] ` <7c8d12b8-7d2e-f5be-b8e7-295245c29a92-5C7GfCeVMHo@public.gmane.org>
2017-12-11 10:14 ` Christian König
2017-12-12 7:58 ` Chunming Zhou
[not found] ` <ebea9c30-b89e-898e-92a4-c8a2317b8b86-5C7GfCeVMHo@public.gmane.org>
2017-12-12 9:28 ` Christian König
2017-12-11 5:15 ` [PATCH 1/8] drm/amdgpu: stop joining PDEs Chunming Zhou
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=8d22ff81-e27f-abe5-c3f3-3fbdf80334be@gmail.com \
--to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
--cc=zhoucm1-5C7GfCeVMHo@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.