[PATCH 2/5] drm/ttm: keep original behavior except with flag no_retry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



set the no_retry flag in struct ttm_mem_global and init it
after ttm_mem_global_init

Signed-off-by: Roger He <Hongbo.He at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +++++---
 drivers/gpu/drm/ttm/ttm_memory.c        | 3 +++
 include/drm/ttm/ttm_memory.h            | 3 +++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 95f9901..f740248 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -75,6 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref)
 static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
 {
 	struct drm_global_reference *global_ref;
+	struct ttm_mem_global *mem_glob;
 	struct amdgpu_ring *ring;
 	struct drm_sched_rq *rq;
 	int r;
@@ -91,6 +92,8 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
 			  "subsystem.\n");
 		goto error_mem;
 	}
+	mem_glob = (struct ttm_mem_global *)global_ref->object;
+	mem_glob->no_retry = adev->mman.bdev.no_retry;
 
 	adev->mman.bo_global_ref.mem_glob =
 		adev->mman.mem_global_ref.object;
@@ -1371,6 +1374,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	int r;
 	u64 vis_vram_limit;
 
+	/* We opt to avoid OOM on system pages allocations */
+	adev->mman.bdev.no_retry = true;
 	r = amdgpu_ttm_global_init(adev);
 	if (r) {
 		return r;
@@ -1388,9 +1393,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	}
 	adev->mman.initialized = true;
 
-	/* We opt to avoid OOM on system pages allocations */
-	adev->mman.bdev.no_retry = true;
-
 	r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
 				adev->gmc.real_vram_size >> PAGE_SHIFT);
 	if (r) {
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index e19e727..3f00ed8 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -488,6 +488,9 @@ ttm_check_over_swaplimit(struct ttm_mem_global *glob)
 {
 	bool ret = false;
 
+	if (!glob->no_retry)
+		return ret;
+
 	if (get_nr_swap_pages() < FREE_SWAP_SPACE
 	    && si_mem_available() < glob->sys_mem_limit)
 		ret = true;
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
index ad7cf63..7fee446 100644
--- a/include/drm/ttm/ttm_memory.h
+++ b/include/drm/ttm/ttm_memory.h
@@ -56,6 +56,8 @@
  * @zone_kernel: Pointer to the kernel zone.
  * @zone_highmem: Pointer to the highmem zone if there is one.
  * @zone_dma32: Pointer to the dma32 zone if there is one.
+ * @no_retry: if free swap space is under the fixed limit, no retry for
+ * avoid OOM
  *
  * Note that this structure is not per device. It should be global for all
  * graphics devices.
@@ -78,6 +80,7 @@ struct ttm_mem_global {
 #else
 	struct ttm_mem_zone *zone_dma32;
 #endif
+	bool no_retry;
 };
 
 extern int ttm_mem_global_init(struct ttm_mem_global *glob);
-- 
2.7.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux