aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/4256-drm-amdkfd-CMA-Support-for-diff.-devices.patch
blob: 147d7abaa7a5e635e6d950a8074baa7cd3851a99 (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
From 6c5d72666e8df579b1d136158e44bf219d3f0e97 Mon Sep 17 00:00:00 2001
From: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Date: Mon, 9 Apr 2018 16:27:07 -0400
Subject: [PATCH 4256/5725] drm/amdkfd: CMA: Support for diff. devices

Support CMA between System Memory BO and Local Memory BO even if they
are registered to separate devices. The copy will be done by the device
to which Local Memory BO belongs to. The system memory BO will be
temporarily mapped into this device's gart.

Change-Id: Ief4af0db8b5f6af1a2fa1ed0596cf9e2fd953841
Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 0972243..9be0ac1 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2159,8 +2159,14 @@ static int kfd_copy_bos(struct cma_iter *si, struct cma_iter *di,
 		dst_offset = di->bo_offset & (PAGE_SIZE - 1);
 		list_add_tail(&di->cma_bo->list, &di->cma_list);
 	} else if (src_bo->dev->kgd != dst_bo->dev->kgd) {
-		pr_err("CMA %d fail. Not same dev\n", cma_write);
-		return -EINVAL;
+		/* This indicates that either or/both BOs are in local mem. */
+		if (src_bo->mem_type == KFD_IOC_ALLOC_MEM_FLAGS_VRAM &&
+		    dst_bo->mem_type == KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
+			pr_err("CMA fail. Local mem & not in same dev\n");
+			return -EINVAL;
+		} else if (src_bo->mem_type == KFD_IOC_ALLOC_MEM_FLAGS_VRAM)
+			dev = src_bo->dev;
+		/* else already set to dst_bo->dev */
 	}
 
 	if (err) {
-- 
2.7.4