All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 2/6] drm/amdgpu: cleanup amdgpu_vm_validate_pt_bos v2
Date: Thu, 17 May 2018 11:49:32 +0200	[thread overview]
Message-ID: <20180517094936.4293-2-christian.koenig@amd.com> (raw)
In-Reply-To: <20180517094936.4293-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>

Use list_for_each_entry_safe here.

v2: Drop the optimization, it doesn't work as expected.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f0deedcaf1c9..3be4d5fc60b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -224,21 +224,16 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 			      void *param)
 {
 	struct ttm_bo_global *glob = adev->mman.bdev.glob;
-	int r;
-
-	while (!list_empty(&vm->evicted)) {
-		struct amdgpu_vm_bo_base *bo_base;
-		struct amdgpu_bo *bo;
+	struct amdgpu_vm_bo_base *bo_base, *tmp;
+	int r = 0;
 
-		bo_base = list_first_entry(&vm->evicted,
-					   struct amdgpu_vm_bo_base,
-					   vm_status);
+	list_for_each_entry_safe(bo_base, tmp, &vm->evicted, vm_status) {
+		struct amdgpu_bo *bo = bo_base->bo;
 
-		bo = bo_base->bo;
 		if (bo->parent) {
 			r = validate(param, bo);
 			if (r)
-				return r;
+				break;
 
 			spin_lock(&glob->lru_lock);
 			ttm_bo_move_to_lru_tail(&bo->tbo);
@@ -251,7 +246,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		    vm->use_cpu_for_update) {
 			r = amdgpu_bo_kmap(bo, NULL);
 			if (r)
-				return r;
+				break;
 		}
 
 		if (bo->tbo.type != ttm_bo_type_kernel) {
@@ -263,7 +258,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		}
 	}
 
-	return 0;
+	return r;
 }
 
 /**
-- 
2.14.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-05-17  9:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17  9:49 [PATCH 1/6] drm/amdgpu: rework VM state machine lock handling v2 Christian König
     [not found] ` <20180517094936.4293-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-05-17  9:49   ` Christian König [this message]
2018-05-17  9:49   ` [PATCH 3/6] drm/amdgpu: further optimize amdgpu_vm_handle_moved Christian König
2018-05-17  9:49   ` [PATCH 4/6] drm/amdgpu: kmap PDs/PTs in amdgpu_vm_update_directories Christian König
2018-05-17  9:49   ` [PATCH 5/6] drm/amdgpu: consistenly use VM moved flag Christian König
2018-05-17  9:49   ` [PATCH 6/6] drm/amdgpu: move VM BOs on LRU again Christian König
     [not found]     ` <20180517094936.4293-6-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-05-18  6:49       ` zhoucm1
2018-05-18  9:55   ` [PATCH 1/6] drm/amdgpu: rework VM state machine lock handling v2 Zhang, Jerry (Junwei)
     [not found]     ` <5AFEA313.8040905-5C7GfCeVMHo@public.gmane.org>
2018-05-19  8:00       ` Zhang, Jerry
     [not found]         ` <CY4PR12MB1414D3B8AE6ECEF5A9277A9AFF970-rpdhrqHFk04b0eJBKAp/BwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-22 13:07           ` 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=20180517094936.4293-2-christian.koenig@amd.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@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.