AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 1/4] drm/amdgpu: Update pin_size values before unpinning BO
Date: Fri, 15 Jun 2018 16:42:27 +0200	[thread overview]
Message-ID: <20180615144230.18480-2-michel@daenzer.net> (raw)
In-Reply-To: <20180615144230.18480-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>

From: Michel Dänzer <michel.daenzer@amd.com>

At least in theory, ttm_bo_validate may move the BO, in which case the
pin_size accounting would be inconsistent with when the BO was pinned.

Cc: stable@vger.kernel.org
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index f5b0b180a6cc..210e7631f4b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -969,15 +969,6 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
 	bo->pin_count--;
 	if (bo->pin_count)
 		return 0;
-	for (i = 0; i < bo->placement.num_placement; i++) {
-		bo->placements[i].lpfn = 0;
-		bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
-	}
-	r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
-	if (unlikely(r)) {
-		dev_err(adev->dev, "%p validate failed for unpin\n", bo);
-		goto error;
-	}
 
 	if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
 		adev->vram_pin_size -= amdgpu_bo_size(bo);
@@ -987,7 +978,14 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
 		adev->gart_pin_size -= amdgpu_bo_size(bo);
 	}
 
-error:
+	for (i = 0; i < bo->placement.num_placement; i++) {
+		bo->placements[i].lpfn = 0;
+		bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
+	}
+	r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+	if (unlikely(r))
+		dev_err(adev->dev, "%p validate failed for unpin\n", bo);
+
 	return r;
 }
 
-- 
2.17.1

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

  parent reply	other threads:[~2018-06-15 14:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 14:42 [PATCH 0/4] drm/amdgpu: pin_size fixes Michel Dänzer
     [not found] ` <20180615144230.18480-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-15 14:42   ` Michel Dänzer [this message]
2018-06-15 14:42   ` [PATCH 2/4] drm/amdgpu: Refactor amdgpu_vram_mgr_bo_invisible_size helper Michel Dänzer
2018-06-15 14:42   ` [PATCH 3/4] drm/amdgpu: Make amdgpu_vram_mgr_bo_invisible_size always accurate Michel Dänzer
     [not found]     ` <20180615144230.18480-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-15 15:11       ` Christian König
     [not found]         ` <093bbd7a-02cd-068f-a53a-2d4f1c5b3084-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-06-15 15:14           ` Michel Dänzer
     [not found]             ` <098df480-3db3-485f-8e39-4ebf8201b3a0-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-15 15:18               ` Christian König
     [not found]                 ` <b94d92e5-908d-534a-907a-ad97124b22ec-5C7GfCeVMHo@public.gmane.org>
2018-06-15 15:19                   ` Michel Dänzer
     [not found]                     ` <3140ef24-f8c9-5863-ff44-4c83192eabb1-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-18 11:30                       ` Christian König
2018-06-18 16:52       ` [PATCH v2 " Michel Dänzer
     [not found]         ` <20180618165233.5718-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org>
2018-06-18 17:04           ` Christian König
2018-06-15 14:42   ` [PATCH 4/4] drm/amdgpu: Use gmc_vram_full_visible in vram_mgr_bo_invisible_size Michel Dänzer

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=20180615144230.18480-2-michel@daenzer.net \
    --to=michel-otuistvhuppr7s880joybq@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