All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: maraeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: [PATCH 6/6] drm/amdgpu: handle CPU access for split VRAM buffers
Date: Wed, 29 Mar 2017 14:55:46 +0200	[thread overview]
Message-ID: <1490792146-2218-7-git-send-email-deathsimple@vodafone.de> (raw)
In-Reply-To: <1490792146-2218-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>

From: Christian König <christian.koenig@amd.com>

This avoids merging them together on page fault.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c |  4 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 387d190..10237a8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -927,8 +927,7 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
 	size = bo->mem.num_pages << PAGE_SHIFT;
 	offset = bo->mem.start << PAGE_SHIFT;
 	/* TODO: figure out how to map scattered VRAM to the CPU */
-	if ((offset + size) <= adev->mc.visible_vram_size &&
-	    (abo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS))
+	if ((offset + size) <= adev->mc.visible_vram_size)
 		return 0;
 
 	/* Can't move a pinned BO to visible VRAM */
@@ -936,7 +935,6 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
 		return -EINVAL;
 
 	/* hurrah the memory is not visible ! */
-	abo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
 	amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
 	lpfn =	adev->mc.visible_vram_size >> PAGE_SHIFT;
 	for (i = 0; i < abo->placement.num_placement; i++) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 524abca..10b793a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -529,9 +529,6 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
 	case TTM_PL_TT:
 		break;
 	case TTM_PL_VRAM:
-		if (mem->start == AMDGPU_BO_INVALID_OFFSET)
-			return -EINVAL;
-
 		mem->bus.offset = mem->start << PAGE_SHIFT;
 		/* check if it's visible */
 		if ((mem->bus.offset + mem->bus.size) > adev->mc.visible_vram_size)
@@ -549,6 +546,17 @@ static void amdgpu_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_re
 {
 }
 
+static unsigned long amdgpu_ttm_io_mem_pfn(struct ttm_buffer_object *bo,
+					   unsigned long page_offset)
+{
+	struct drm_mm_node *mm = bo->mem.mm_node;
+	uint64_t size = mm->size;
+
+	mm += page_offset / size;
+	page_offset %= size;
+	return (bo->mem.bus.base >> PAGE_SHIFT) + mm->start + page_offset;
+}
+
 /*
  * TTM backend functions.
  */
@@ -1064,7 +1072,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
 	.fault_reserve_notify = &amdgpu_bo_fault_reserve_notify,
 	.io_mem_reserve = &amdgpu_ttm_io_mem_reserve,
 	.io_mem_free = &amdgpu_ttm_io_mem_free,
-	.io_mem_pfn = ttm_bo_default_io_mem_pfn,
+	.io_mem_pfn = amdgpu_ttm_io_mem_pfn,
 };
 
 int amdgpu_ttm_init(struct amdgpu_device *adev)
-- 
2.5.0

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

  parent reply	other threads:[~2017-03-29 12:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 12:55 CPU mapping of split VRAM buffers Christian König
     [not found] ` <1490792146-2218-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-29 12:55   ` [PATCH 1/6] drm/ttm: cleanup and optimize ttm_bo_mem_compat Christian König
2017-03-30  6:38     ` Michel Dänzer
     [not found]       ` <0aeb9046-86c6-f14f-490e-cbf74079e107-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-30  8:41         ` Christian König
2017-03-29 12:55   ` [PATCH 2/6] drm/ttm: add io_mem_pfn callback Christian König
2017-03-30  6:39     ` Michel Dänzer
2017-03-29 12:55   ` [PATCH 3/6] drm/ttm: add TTM_PL_FLAG_CONTIGUOUS Christian König
     [not found]     ` <1490792146-2218-4-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-30  6:39       ` Michel Dänzer
2017-03-29 12:55   ` [PATCH 4/6] drm/amdgpu: drop alpha support Christian König
2017-03-30  6:39     ` Michel Dänzer
2017-03-30 13:09       ` Alex Deucher
2017-03-30 13:22         ` Christian König
2017-03-31  1:07         ` Michel Dänzer
2017-03-31  7:09           ` Christian König
2017-03-31  7:19             ` Michel Dänzer
2017-03-29 12:55   ` [PATCH 5/6] drm/amdgpu: use TTM_PL_FLAG_CONTIGUOUS Christian König
2017-03-29 12:55   ` Christian König [this message]
2017-03-29 15:36   ` CPU mapping of split VRAM buffers Deucher, Alexander
     [not found]     ` <BN6PR12MB1652DD0CE69D4972798E40DEF7350-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-03-29 17:44       ` Christian König
2017-03-30  6:42 ` Michel Dänzer
2017-03-29 17:43 [PATCH 1/6] drm/ttm: cleanup and optimize ttm_bo_mem_compat Christian König
2017-03-29 17:43 ` [PATCH 6/6] drm/amdgpu: handle CPU access for split VRAM buffers Christian König
2017-03-31  9:47 [PATCH 1/6] drm/ttm: cleanup and optimize ttm_bo_mem_compat v2 Christian König
     [not found] ` <1490953652-3703-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-31  9:47   ` [PATCH 6/6] drm/amdgpu: handle CPU access for split VRAM buffers Christian König
2017-04-03 16:25     ` Nicolai Hähnle
2017-04-04 11:30       ` 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=1490792146-2218-7-git-send-email-deathsimple@vodafone.de \
    --to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=maraeo-Re5JQEeQqe8AvxtiuMwx3w@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.