All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger He <Hongbo.He@amd.com>
To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Roger He <Hongbo.He@amd.com>, Christian.Koenig@amd.com
Subject: [PATCH 2/4] drm/ttm: add bit flag TTM_OPT_FLAG_FORCE_ALLOC
Date: Thu, 8 Feb 2018 17:05:59 +0800	[thread overview]
Message-ID: <1518080761-12952-2-git-send-email-Hongbo.He@amd.com> (raw)
In-Reply-To: <1518080761-12952-1-git-send-email-Hongbo.He@amd.com>

set TTM_OPT_FLAG_FORCE_ALLOC when we are servicing for page
fault routine.

for ttm_mem_global_reserve if in page fault routine, allow the gtt
pages reservation always. because page fault routing already grabbed
system memory and the allowance of this exception is harmless.
Otherwise, it will trigger OOM killer.

the subsequent patche will use this.

v2: keep original behavior except ttm bo with flag no_retry

Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c          | 6 ++++--
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 1 -
 include/drm/ttm/ttm_bo_api.h             | 4 +++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 716e724..f10b8a0 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -224,7 +224,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		cvma.vm_page_prot = ttm_io_prot(bo->mem.placement,
 						cvma.vm_page_prot);
 	} else {
-		struct ttm_operation_ctx ctx = {
+		struct ttm_operation_ctx ttm_opt_ctx = {
 			.interruptible = false,
 			.no_wait_gpu = false
 		};
@@ -233,8 +233,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		cvma.vm_page_prot = ttm_io_prot(bo->mem.placement,
 						cvma.vm_page_prot);
 
+		if (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY)
+			ttm_opt_ctx.flags |= TTM_OPT_FLAG_FORCE_ALLOC;
 		/* Allocate all page at once, most common usage */
-		if (ttm->bdev->driver->ttm_tt_populate(ttm, &ctx)) {
+		if (ttm->bdev->driver->ttm_tt_populate(ttm, &ttm_opt_ctx)) {
 			ret = VM_FAULT_OOM;
 			goto out_io_unlock;
 		}
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index b122f6e..354e0e1 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -944,7 +944,6 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,
 	i = 0;
 
 	type = ttm_to_type(ttm->page_flags, ttm->caching_state);
-
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 	if (ttm->page_flags & TTM_PAGE_FLAG_DMA32)
 		goto skip_huge;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 872ff6c..2142639 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -278,7 +278,9 @@ struct ttm_operation_ctx {
 };
 
 /* Allow eviction of reserved BOs */
-#define TTM_OPT_FLAG_ALLOW_RES_EVICT	0x1
+#define TTM_OPT_FLAG_ALLOW_RES_EVICT		0x1
+/* when serving page fault or suspend, allow alloc anyway */
+#define TTM_OPT_FLAG_FORCE_ALLOC		0x2
 
 /**
  * ttm_bo_reference - reference a struct ttm_buffer_object
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-02-08  9:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08  9:05 [PATCH 1/4] drm/ttm: use bit flag to replace allow_reserved_eviction in ttm_operation_ctx Roger He
2018-02-08  9:05 ` Roger He [this message]
     [not found]   ` <1518080761-12952-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2018-02-08 12:57     ` [PATCH 2/4] drm/ttm: add bit flag TTM_OPT_FLAG_FORCE_ALLOC Christian König
2018-02-08  9:06 ` [PATCH 3/4] drm/ttm: add input parameter force_alloc for ttm_bo_evict_mm Roger He
     [not found]   ` <1518080761-12952-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2018-02-08 12:58     ` Christian König
     [not found]       ` <c3465353-9dac-f0ba-a465-3c470b939f68-5C7GfCeVMHo@public.gmane.org>
2018-02-09  4:34         ` He, Roger
2018-02-08  9:06 ` [PATCH 4/4] drm/ttm: check if the mem free space is under lower limit Roger He
     [not found] ` <1518080761-12952-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2018-02-08  9:22   ` [PATCH 1/4] drm/ttm: use bit flag to replace allow_reserved_eviction in ttm_operation_ctx 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=1518080761-12952-2-git-send-email-Hongbo.He@amd.com \
    --to=hongbo.he@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --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 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.