drm/ttm: add bit flag TTM_OPT_FLAG_FORCE_ALLOC
authorRoger He <Hongbo.He@amd.com>
Wed, 17 Jan 2018 07:07:23 +0000 (15:07 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 27 Feb 2018 04:09:34 +0000 (23:09 -0500)
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.

will be used later.

v2: set the FORCE_ALLOC always
v3: minor refine

Signed-off-by: Roger He <Hongbo.He@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/ttm/ttm_bo_vm.c
include/drm/ttm/ttm_bo_api.h

index 121f017ac7cac1b36a13b96b6d0bbbaf40c4a547..8eba95b3c73716c267e75eaa6d15eb346b79a801 100644 (file)
@@ -226,7 +226,9 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
        } else {
                struct ttm_operation_ctx ctx = {
                        .interruptible = false,
-                       .no_wait_gpu = false
+                       .no_wait_gpu = false,
+                       .flags = TTM_OPT_FLAG_FORCE_ALLOC
+
                };
 
                ttm = bo->ttm;
index 872ff6c1d709d6b3db7803b53c9448639ca45127..21426395820c749c9d04bb3964f11947c96cbb1f 100644 (file)
@@ -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