aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/3823-drm-amdkfd-fix-queue-snapshot-input-handling-and-ret.patch
blob: 9c90433930205ca10bc08a77da869da1e18a346c (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
89
90
91
92
93
94
95
96
97
98
99
From d3247f280efdb81b94cc45cf6aea5e2c32321be8 Mon Sep 17 00:00:00 2001
From: Jonathan Kim <jonathan.kim@amd.com>
Date: Wed, 11 Sep 2019 09:30:07 -0400
Subject: [PATCH 3823/4256] drm/amdkfd: fix queue snapshot input handling and
 return

queue snapshot doesn't need to set gpu id.  should get queues
from target process, not calling process.  set queues copied
to 0 if there are 0 queues or on errno.

New queue should clear unconditionally on any queue status word update.

Change-Id: If8bcf35ce27da2a8e07061a67298b5a29d5f7b99
Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c      | 15 +++++++++------
 drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c |  6 +++---
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 547e7f511775..fa1385d60235 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2611,6 +2611,7 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
 	uint32_t data2;
 	uint32_t data3;
 	bool is_suspend_or_resume;
+	bool is_q_snapshot;
 
 	debug_trap_action = args->op;
 	gpu_id = args->gpu_id;
@@ -2628,6 +2629,9 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
 		debug_trap_action == KFD_IOC_DBG_TRAP_NODE_SUSPEND ||
 		debug_trap_action == KFD_IOC_DBG_TRAP_NODE_RESUME;
 
+	is_q_snapshot =
+		debug_trap_action == KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT;
+
 	pid = find_get_pid(args->pid);
 	if (!pid) {
 		pr_err("Cannot find pid info for %i\n",
@@ -2661,7 +2665,7 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
 
 	mutex_lock(&target->mutex);
 
-	if (!is_suspend_or_resume) {
+	if (!(is_suspend_or_resume || is_q_snapshot)) {
 
 		dev = kfd_device_by_id(args->gpu_id);
 		if (!dev) {
@@ -2705,7 +2709,7 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
 			r = -EINVAL;
 			goto unlock_out;
 		}
-	} else {
+	} else if (!is_q_snapshot) {
 		/* data 2 has the number of queue IDs */
 		size_t queue_id_array_size = sizeof(uint32_t) * data2;
 
@@ -2801,14 +2805,13 @@ static int kfd_ioctl_dbg_set_debug_trap(struct file *filep,
 						 &args->data3);
 		break;
 	case KFD_IOC_DBG_TRAP_GET_QUEUE_SNAPSHOT:
-		r = pqm_get_queue_snapshot(&p->pqm, args->data1,
+		r = pqm_get_queue_snapshot(&target->pqm, args->data1,
 					   (void __user *)args->ptr,
 					   args->data2);
 
-		if (r > 0) {
-			args->data2 = r;
+		args->data2 = r < 0 ? 0 : r;
+		if (r > 0)
 			r = 0;
-		}
 
 		break;
 	default:
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c
index 5433b6527bae..cabf26f03077 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_debug_events.c
@@ -112,10 +112,10 @@ uint32_t kfd_dbg_get_queue_status_word(struct queue *q, int flags)
 	KFD_DBG_EV_SET_NEW_QUEUE_STATE(queue_status_word,
 				  q->properties.is_new);
 
-	if (flags & KFD_DBG_EV_FLAG_CLEAR_STATUS) {
-		q->properties.is_new = false;
+	if (flags & KFD_DBG_EV_FLAG_CLEAR_STATUS)
 		q->properties.debug_event_type = 0;
-	}
+
+	q->properties.is_new = false;
 
 	return queue_status_word;
 }
-- 
2.17.1