msm: kgsl: Fix context reference counting
Get rid of kgsl_find_context. Use instead kgsl_context_get that does
correct RCU read locking around the itr_find and increases the
reference count on the context before returning it. This eliminates
the chance that a context will be destroyed while somebody is still
using it. Of course increased use of kgsl_context_get is accompanied
by kgsl_context_put in all the right places.
Change-Id: Ic0dedbad73d497fd9b451aefad8e5b28d33b829d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c
index 405f9ac..9d50e6b 100644
--- a/drivers/gpu/msm/adreno_ringbuffer.c
+++ b/drivers/gpu/msm/adreno_ringbuffer.c
@@ -1178,11 +1178,13 @@
if (0xFFFFFFFF == ft_data->start_of_replay_cmds)
return;
- k_ctxt = idr_find(&device->context_idr, ft_data->context_id);
+ k_ctxt = kgsl_context_get(device, ft_data->context_id);
+
if (k_ctxt) {
a_ctxt = k_ctxt->devctxt;
if (a_ctxt->flags & CTXT_FLAGS_PREAMBLE)
_turn_preamble_on_for_ib_seq(rb, rb_rptr);
+ kgsl_context_put(k_ctxt);
}
k_ctxt = NULL;
@@ -1213,7 +1215,8 @@
/* if context switches to a context that did not cause
* hang then start saving the rb contents as those
* commands can be executed */
- k_ctxt = idr_find(&rb->device->context_idr, val2);
+ k_ctxt = kgsl_context_get(rb->device, val2);
+
if (k_ctxt) {
a_ctxt = k_ctxt->devctxt;
@@ -1251,6 +1254,7 @@
copy_rb_contents = 0;
}
}
+ kgsl_context_put(k_ctxt);
}
if (copy_rb_contents)