aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.4/0095-drm-vc4-Drop-struct_mutex-around-CL-validation.patch
blob: 08c0010e026e269e347dd3e2db9a43d7ee0f8b89 (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
From 775a3408d94a474101066ac8dd8939a4cd5c793a Mon Sep 17 00:00:00 2001
From: Eric Anholt <eric@anholt.net>
Date: Mon, 19 Oct 2015 08:44:35 -0700
Subject: [PATCH] drm/vc4: Drop struct_mutex around CL validation.

We were using it so that we could make sure that shader validation
state didn't change while we were validating, but now shader
validation state is immutable.  The bcl/rcl generation doesn't do any
other BO dereferencing, and seems to have no other global state
dependency not covered by job_lock / bo_lock.

Fixes a lock order reversal between mmap_sem and struct_mutex.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_gem.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -244,13 +244,15 @@ static void
 vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
-	uint64_t seqno = ++vc4->emit_seqno;
+	uint64_t seqno;
 	unsigned long irqflags;
 
+	spin_lock_irqsave(&vc4->job_lock, irqflags);
+
+	seqno = ++vc4->emit_seqno;
 	exec->seqno = seqno;
 	vc4_update_bo_seqnos(exec, seqno);
 
-	spin_lock_irqsave(&vc4->job_lock, irqflags);
 	list_add_tail(&exec->head, &vc4->job_list);
 
 	/* If no job was executing, kick ours off.  Otherwise, it'll
@@ -608,8 +610,6 @@ vc4_submit_cl_ioctl(struct drm_device *d
 	exec->args = args;
 	INIT_LIST_HEAD(&exec->unref_list);
 
-	mutex_lock(&dev->struct_mutex);
-
 	ret = vc4_cl_lookup_bos(dev, file_priv, exec);
 	if (ret)
 		goto fail;
@@ -636,15 +636,11 @@ vc4_submit_cl_ioctl(struct drm_device *d
 	/* Return the seqno for our job. */
 	args->seqno = vc4->emit_seqno;
 
-	mutex_unlock(&dev->struct_mutex);
-
 	return 0;
 
 fail:
 	vc4_complete_exec(exec);
 
-	mutex_unlock(&dev->struct_mutex);
-
 	return ret;
 }