aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0462-drm-amdgpu-fix-unnecessary-wake-up.patch
blob: 7d78d4eb45bb5ecfba4c03c92bf966bb168441e7 (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
From 1c8f805af9af445a42b8dbda5f620752996cba44 Mon Sep 17 00:00:00 2001
From: Chunming Zhou <david1.zhou@amd.com>
Date: Thu, 13 Aug 2015 13:04:06 +0800
Subject: [PATCH 0462/1050] drm/amdgpu: fix unnecessary wake up

decrease CPU extra overhead.

Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian K?nig <christian.koenig@amd.com>
---
 drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 10 ++++++----
 drivers/gpu/drm/amd/scheduler/gpu_scheduler.h |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 5017c71..3d45ff2 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -158,7 +158,7 @@ exit:
 	if (sched->current_entity && (sched->current_entity != tmp))
 		wake_entity = sched->current_entity;
 	sched->current_entity = tmp;
-	if (wake_entity)
+	if (wake_entity && wake_entity->need_wakeup)
 		wake_up(&wake_entity->wait_queue);
 	return tmp;
 }
@@ -195,6 +195,7 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched,
 	entity->fence_context = fence_context_alloc(1);
 	snprintf(name, sizeof(name), "c_entity[%llu]", entity->fence_context);
 	memcpy(entity->name, name, 20);
+	entity->need_wakeup = false;
 	if(kfifo_alloc(&entity->job_queue,
 		       jobs * sizeof(void *),
 		       GFP_KERNEL))
@@ -257,7 +258,7 @@ int amd_sched_entity_fini(struct amd_gpu_scheduler *sched,
 
 	if (!is_context_entity_initialized(sched, entity))
 		return 0;
-
+	entity->need_wakeup = true;
 	/**
 	 * The client will not queue more IBs during this fini, consume existing
 	 * queued IBs
@@ -323,8 +324,9 @@ int amd_sched_push_job(struct amd_gpu_scheduler *sched,
 		*/
 		schedule();
 	}
-
-	wake_up_interruptible(&sched->wait_queue);
+	/* first job wake up scheduler */
+	if ((kfifo_len(&c_entity->job_queue) / sizeof(void *)) == 1)
+		wake_up_interruptible(&sched->wait_queue);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
index 5e35018..47823b4 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h
@@ -54,6 +54,7 @@ struct amd_sched_entity {
 	bool                            is_pending;
 	uint64_t                        fence_context;
 	char                            name[20];
+	bool                            need_wakeup;
 };
 
 /**
-- 
1.9.1