dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ruhl, Michael J" <michael.j.ruhl@intel.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: RE: [PATCH 2/2] drm/ttm: make TT creation purely optional
Date: Fri, 26 Jun 2020 17:43:56 +0000	[thread overview]
Message-ID: <14063C7AD467DE4B82DEDB5C278E866301154CA0FA@FMSMSX108.amr.corp.intel.com> (raw)
In-Reply-To: <20200624133558.1758-2-christian.koenig@amd.com>

>-----Original Message-----
>From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of
>Christian König
>Sent: Wednesday, June 24, 2020 9:36 AM
>To: dri-devel@lists.freedesktop.org
>Subject: [PATCH 2/2] drm/ttm: make TT creation purely optional
>
>We only need the page array when the BO is about to be accessed.
>
>So not only populate, but also create it on demand.
>
>Signed-off-by: Christian König <christian.koenig@amd.com>
>---
> drivers/gpu/drm/ttm/ttm_bo.c      | 26 ++++----------------------
> drivers/gpu/drm/ttm/ttm_bo_util.c |  9 +++++++--
> drivers/gpu/drm/ttm/ttm_bo_vm.c   |  5 +++++
> 3 files changed, 16 insertions(+), 24 deletions(-)
>
>diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
>index 15f9b19fa00d..0e0a9dadf3ed 100644
>--- a/drivers/gpu/drm/ttm/ttm_bo.c
>+++ b/drivers/gpu/drm/ttm/ttm_bo.c
>@@ -667,13 +667,8 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
> 	placement.num_busy_placement = 0;
> 	bdev->driver->evict_flags(bo, &placement);
>
>-	if (!placement.num_placement &&
>!placement.num_busy_placement) {
>-		ret = ttm_bo_pipeline_gutting(bo);
>-		if (ret)
>-			return ret;
>-
>-		return ttm_tt_create(bo, false);
>-	}
>+	if (!placement.num_placement &&
>!placement.num_busy_placement)
>+		return ttm_bo_pipeline_gutting(bo);
>
> 	evict_mem = bo->mem;
> 	evict_mem.mm_node = NULL;
>@@ -1200,13 +1195,8 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
> 	/*
> 	 * Remove the backing store if no placement is given.
> 	 */
>-	if (!placement->num_placement && !placement-
>>num_busy_placement) {
>-		ret = ttm_bo_pipeline_gutting(bo);
>-		if (ret)
>-			return ret;
>-
>-		return ttm_tt_create(bo, false);
>-	}
>+	if (!placement->num_placement && !placement-
>>num_busy_placement)
>+		return ttm_bo_pipeline_gutting(bo);
>
> 	/*
> 	 * Check whether we need to move buffer.
>@@ -1223,14 +1213,6 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
> 		ttm_flag_masked(&bo->mem.placement, new_flags,
> 				~TTM_PL_MASK_MEMTYPE);
> 	}
>-	/*
>-	 * We might need to add a TTM.
>-	 */
>-	if (bo->mem.mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
>-		ret = ttm_tt_create(bo, true);
>-		if (ret)
>-			return ret;
>-	}
> 	return 0;
> }
> EXPORT_SYMBOL(ttm_bo_validate);
>diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c
>b/drivers/gpu/drm/ttm/ttm_bo_util.c
>index 52d2b71f1588..f8414f820350 100644
>--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
>+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
>@@ -580,12 +580,17 @@ static int ttm_bo_kmap_ttm(struct
>ttm_buffer_object *bo,
> 		.interruptible = false,
> 		.no_wait_gpu = false
> 	};
>-	struct ttm_tt *ttm = bo->ttm;
>+	struct ttm_tt *ttm;
> 	pgprot_t prot;
> 	int ret;
>
>-	BUG_ON(!ttm);
>+	if (!bo->ttm) {
>+		ret = ttm_tt_create(bo, true);

Would it be reasonable to move the NULL check into ttm_tt_create()?

Kind of an opposite path NULL check, but it makes the path a little
more clean.

Mike

>+		if (ret)
>+			return ret;
>+	}
>
>+	ttm = bo->ttm;
> 	ret = ttm_tt_populate(ttm, &ctx);
> 	if (ret)
> 		return ret;
>diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c
>b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>index 0ad30b112982..bdfed6725d6f 100644
>--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
>+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>@@ -349,6 +349,11 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct
>vm_fault *vmf,
>
> 		};
>
>+		if (!bo->ttm && ttm_tt_create(bo, true)) {
>+			ret = VM_FAULT_OOM;
>+			goto out_io_unlock;
>+		}
>+
> 		ttm = bo->ttm;
> 		if (ttm_tt_populate(bo->ttm, &ctx)) {
> 			ret = VM_FAULT_OOM;
>--
>2.17.1
>
>_______________________________________________
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-06-26 17:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 13:35 [PATCH 1/2] drm/ttm: cleanup ttm_mem_type_manager_func.get_node interface Christian König
2020-06-24 13:35 ` [PATCH 2/2] drm/ttm: make TT creation purely optional Christian König
2020-06-26 17:43   ` Ruhl, Michael J [this message]
2020-06-26 17:39 ` [PATCH 1/2] drm/ttm: cleanup ttm_mem_type_manager_func.get_node interface Ruhl, Michael J
2020-06-26 17:46   ` 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=14063C7AD467DE4B82DEDB5C278E866301154CA0FA@FMSMSX108.amr.corp.intel.com \
    --to=michael.j.ruhl@intel.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).