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
|
From 32e438c9dba7e6e23aff875924db6fbe1591435a Mon Sep 17 00:00:00 2001
From: Eric Huang <JinHuiEric.Huang@amd.com>
Date: Tue, 22 Aug 2017 11:47:45 -0400
Subject: [PATCH 1773/4131] drm/amdkfd: fix CWSR memory allocation sequence
it makes CWSR memory kernel address valid after
memory eviction.
Change-Id: I805bb6653981048ee6a484681fe9b554bd379550
Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_process.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 3e966a3..2e784dd 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -115,10 +115,11 @@ static int kfd_process_alloc_gpuvm(struct kfd_process *p,
{
int err;
void *mem = NULL;
+ int handle;
err = kdev->kfd2kgd->alloc_memory_of_gpu(kdev->kgd, gpu_va, size,
pdd->vm,
- (struct kgd_mem **)&mem, NULL, kptr,
+ (struct kgd_mem **)&mem, NULL, NULL,
flags);
if (err)
goto err_alloc_mem;
@@ -142,15 +143,27 @@ static int kfd_process_alloc_gpuvm(struct kfd_process *p,
* We do not need to take p->mutex, because the process is just
* created and the ioctls have not had the chance to run.
*/
- if (kfd_process_device_create_obj_handle(
- pdd, mem, gpu_va, size, NULL) < 0) {
- err = -ENOMEM;
- *kptr = NULL;
+ handle = kfd_process_device_create_obj_handle(
+ pdd, mem, gpu_va, size, NULL);
+
+ if (handle < 0) {
+ err = handle;
goto free_gpuvm;
}
+ if (kptr) {
+ err = kdev->kfd2kgd->map_gtt_bo_to_kernel(kdev->kgd,
+ (struct kgd_mem *)mem, kptr);
+ if (err) {
+ pr_debug("Map GTT BO to kernel failed\n");
+ goto free_obj_handle;
+ }
+ }
+
return err;
+free_obj_handle:
+ kfd_process_device_remove_obj_handle(pdd, handle);
free_gpuvm:
sync_memory_failed:
kfd_process_free_gpuvm(mem, pdd);
--
2.7.4
|