aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/5644-drm-amdkfd-CMA-Support-for-diff.-devices.patch
blob: 42a0b39e394025ae25e457ec5cc0306997a2ed74 (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 f0f6de00e634304b1cfffdc3a4525141bcaebdb0 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 5644/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 f480453..1bdbb36 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2126,8 +2126,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