From: "Kuehling, Felix" <Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>
To: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 3/7] drm/amdgpu: let amdgpu_vm_clear_bo figure out ats status
Date: Wed, 20 Feb 2019 00:42:40 +0000 [thread overview]
Message-ID: <676140a4-0d04-6f63-e4d5-cba21fc73f6b@amd.com> (raw)
In-Reply-To: <20190219134103.1531-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
On 2019-02-19 8:40 a.m., Christian König wrote:
> Instead of providing it from outside figure out the ats status in the
> function itself from the data structures.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
One suggestion inline. Other than that this patch is Reviewed-by: Felix
Kuehling <Felix.Kuehling@amd.com>
Regards,
Felix
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 52 ++++++++++++++------------
> 1 file changed, 29 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 3c7b98a758c9..48da4ac76837 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -747,8 +747,6 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)
> * @adev: amdgpu_device pointer
> * @vm: VM to clear BO from
> * @bo: BO to clear
> - * @level: level this BO is at
> - * @pte_support_ats: indicate ATS support from PTE
> *
> * Root PD needs to be reserved when calling this.
> *
> @@ -756,10 +754,11 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)
> * 0 on success, errno otherwise.
> */
> static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
> - struct amdgpu_vm *vm, struct amdgpu_bo *bo,
> - unsigned level, bool pte_support_ats)
> + struct amdgpu_vm *vm,
> + struct amdgpu_bo *bo)
> {
> struct ttm_operation_ctx ctx = { true, false };
> + unsigned level = adev->vm_manager.root_level;
> struct dma_fence *fence = NULL;
> unsigned entries, ats_entries;
> struct amdgpu_ring *ring;
> @@ -768,17 +767,32 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
> int r;
>
> entries = amdgpu_bo_size(bo) / 8;
> + if (vm->pte_support_ats) {
> + ats_entries = amdgpu_vm_level_shift(adev, level);
> + ats_entries += AMDGPU_GPU_PAGE_SHIFT;
> + ats_entries = AMDGPU_GMC_HOLE_START >> ats_entries;
>
> - if (pte_support_ats) {
> - if (level == adev->vm_manager.root_level) {
> - ats_entries = amdgpu_vm_level_shift(adev, level);
> - ats_entries += AMDGPU_GPU_PAGE_SHIFT;
> - ats_entries = AMDGPU_GMC_HOLE_START >> ats_entries;
> + if (!bo->parent) {
> ats_entries = min(ats_entries, entries);
> entries -= ats_entries;
> } else {
> - ats_entries = entries;
> - entries = 0;
> + struct amdgpu_bo *ancestor = bo;
> + struct amdgpu_vm_pt *pt;
> +
> + ++level;
> + while (ancestor->parent->parent) {
> + ancestor = ancestor->parent;
> + ++level;
> + }
This could be simplified as
do {
ancestor = ancestor->parent;
++level;
} while (ancestor->parent);
> +
> + pt = container_of(ancestor->vm_bo, struct amdgpu_vm_pt,
> + base);
> + if ((pt - vm->root.entries) >= ats_entries) {
> + ats_entries = 0;
> + } else {
> + ats_entries = entries;
> + entries = 0;
> + }
> }
> } else {
> ats_entries = 0;
> @@ -911,7 +925,6 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
> {
> struct amdgpu_vm_pt_cursor cursor;
> struct amdgpu_bo *pt;
> - bool ats = false;
> uint64_t eaddr;
> int r;
>
> @@ -921,9 +934,6 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
>
> eaddr = saddr + size - 1;
>
> - if (vm->pte_support_ats)
> - ats = saddr < AMDGPU_GMC_HOLE_START;
> -
> saddr /= AMDGPU_GPU_PAGE_SIZE;
> eaddr /= AMDGPU_GPU_PAGE_SIZE;
>
> @@ -972,7 +982,7 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
>
> amdgpu_vm_bo_base_init(&entry->base, vm, pt);
>
> - r = amdgpu_vm_clear_bo(adev, vm, pt, cursor.level, ats);
> + r = amdgpu_vm_clear_bo(adev, vm, pt);
> if (r)
> goto error_free_pt;
> }
> @@ -3047,9 +3057,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
>
> amdgpu_vm_bo_base_init(&vm->root.base, vm, root);
>
> - r = amdgpu_vm_clear_bo(adev, vm, root,
> - adev->vm_manager.root_level,
> - vm->pte_support_ats);
> + r = amdgpu_vm_clear_bo(adev, vm, root);
> if (r)
> goto error_unreserve;
>
> @@ -3144,9 +3152,8 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm, uns
> * changing any other state, in case it fails.
> */
> if (pte_support_ats != vm->pte_support_ats) {
> - r = amdgpu_vm_clear_bo(adev, vm, vm->root.base.bo,
> - adev->vm_manager.root_level,
> - pte_support_ats);
> + vm->pte_support_ats = pte_support_ats;
> + r = amdgpu_vm_clear_bo(adev, vm, vm->root.base.bo);
> if (r)
> goto free_idr;
> }
> @@ -3154,7 +3161,6 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm, uns
> /* Update VM state */
> vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
> AMDGPU_VM_USE_CPU_FOR_COMPUTE);
> - vm->pte_support_ats = pte_support_ats;
> DRM_DEBUG_DRIVER("VM update mode is %s\n",
> vm->use_cpu_for_update ? "CPU" : "SDMA");
> WARN_ONCE((vm->use_cpu_for_update && !amdgpu_gmc_vram_full_visible(&adev->gmc)),
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-02-20 0:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 13:40 [PATCH 1/7] drm/amdgpu: clear PDs/PTs only after initializing them Christian König
[not found] ` <20190219134103.1531-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-19 13:40 ` [PATCH 2/7] drm/amdgpu: rework shadow handling during PD clear Christian König
[not found] ` <20190219134103.1531-2-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-20 0:07 ` Kuehling, Felix
2019-02-22 15:51 ` Zeng, Oak
[not found] ` <BL0PR12MB258008B300413D2A0052EE5F807F0-b4cIHhjg/p/XzH18dTCKOgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-02-22 16:34 ` Grodzovsky, Andrey
2019-02-19 13:40 ` [PATCH 3/7] drm/amdgpu: let amdgpu_vm_clear_bo figure out ats status Christian König
[not found] ` <20190219134103.1531-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2019-02-20 0:42 ` Kuehling, Felix [this message]
2019-02-19 13:41 ` [PATCH 4/7] drm/amdgpu: allocate VM PDs/PTs on demand Christian König
2019-02-19 13:41 ` [PATCH 5/7] drm/amdgpu: free " Christian König
2019-02-19 13:41 ` [PATCH 6/7] drm/amdgpu: drop the huge page flag Christian König
2019-02-19 13:41 ` [PATCH 7/7] drm/amdgpu: allow huge invalid mappings on GMC8 Christian König
2019-02-20 0:43 ` [PATCH 1/7] drm/amdgpu: clear PDs/PTs only after initializing them Kuehling, Felix
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=676140a4-0d04-6f63-e4d5-cba21fc73f6b@amd.com \
--to=felix.kuehling-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox