aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1780-drm-amdkcl-KFD-4.12-Use-kvmalloc_array-free-instead-.patch
blob: fda7ed4acce8f303e2ac1c891793c3c55cdef200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 51d1eef262f750a36752520f29ca1b8a6c4923aa Mon Sep 17 00:00:00 2001
From: "Le.Ma" <Le.Ma@amd.com>
Date: Mon, 11 Sep 2017 12:20:43 +0800
Subject: [PATCH 1780/4131] drm/amdkcl: [KFD][4.12] Use kvmalloc_array(free)
 instead of drm_calloc(free)_large

Change-Id: Ic5a9e414e849830391d8936026770a24e7ab797d
Signed-off-by: Le.Ma <Le.Ma@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index b7a5b44..528ddb9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -573,8 +573,14 @@ static int init_user_pages(struct kgd_mem *mem, struct mm_struct *mm,
 	 */
 	WARN(mem->user_pages, "Leaking user_pages array");
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 	mem->user_pages = drm_calloc_large(bo->tbo.ttm->num_pages,
 					   sizeof(struct page *));
+#else
+	mem->user_pages = kvmalloc_array(bo->tbo.ttm->num_pages,
+					   sizeof(struct page *),
+					   GFP_KERNEL | __GFP_ZERO);
+#endif
 	if (!mem->user_pages) {
 		pr_err("%s: Failed to allocate pages array\n", __func__);
 		ret = -ENOMEM;
@@ -608,7 +614,11 @@ static int init_user_pages(struct kgd_mem *mem, struct mm_struct *mm,
 	if (ret)
 		release_pages(mem->user_pages, bo->tbo.ttm->num_pages, 0);
 free_out:
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 	drm_free_large(mem->user_pages);
+#else
+	kvfree(mem->user_pages);
+#endif
 	mem->user_pages = NULL;
 unregister_out:
 	if (ret)
@@ -1194,7 +1204,11 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(
 		if (mem->user_pages[0])
 			release_pages(mem->user_pages,
 				      mem->bo->tbo.ttm->num_pages, 0);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 		drm_free_large(mem->user_pages);
+#else
+		kvfree(mem->user_pages);
+#endif
 	}
 
 	ret = reserve_bo_and_cond_vms(mem, NULL, VA_DO_NOT_CARE, &ctx);
@@ -1994,9 +2008,16 @@ static int update_invalid_user_pages(struct amdkfd_process_info *process_info,
 		bo = mem->bo;
 
 		if (!mem->user_pages) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 			mem->user_pages =
 				drm_calloc_large(bo->tbo.ttm->num_pages,
 						 sizeof(struct page *));
+#else
+			mem->user_pages =
+				kvmalloc_array(bo->tbo.ttm->num_pages,
+					   sizeof(struct page *),
+					   GFP_KERNEL | __GFP_ZERO);
+#endif
 			if (!mem->user_pages) {
 				ret = -ENOMEM;
 				pr_err("%s: Failed to allocate pages array\n",
@@ -2127,7 +2148,11 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info)
 		 * the userptr_valid_list. If we need to revalidate
 		 * it, we need to start from scratch.
 		 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
 		drm_free_large(mem->user_pages);
+#else
+		kvfree(mem->user_pages);
+#endif
 		mem->user_pages = NULL;
 		list_move_tail(&mem->validate_list.head,
 			       &process_info->userptr_valid_list);
-- 
2.7.4