Merge "msm: kgsl: Device mutex lock for kgsl_cmdbatch_destroy"
diff --git a/drivers/gpu/msm/adreno_dispatch.c b/drivers/gpu/msm/adreno_dispatch.c
index bcab791..d79a169 100644
--- a/drivers/gpu/msm/adreno_dispatch.c
+++ b/drivers/gpu/msm/adreno_dispatch.c
@@ -221,13 +221,17 @@
struct adreno_context *drawctxt, struct kgsl_cmdbatch *cmdbatch)
{
unsigned int prev;
+ struct kgsl_device *device;
spin_lock(&drawctxt->lock);
if (kgsl_context_detached(&drawctxt->base) ||
drawctxt->state == ADRENO_CONTEXT_STATE_INVALID) {
spin_unlock(&drawctxt->lock);
+ device = cmdbatch->device;
/* get rid of this cmdbatch since the context is bad */
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
kgsl_cmdbatch_destroy(cmdbatch);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
return -EINVAL;
}
@@ -414,7 +418,10 @@
*/
if (cmdbatch->flags & KGSL_CONTEXT_SYNC) {
+ struct kgsl_device *device = cmdbatch->device;
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
kgsl_cmdbatch_destroy(cmdbatch);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
continue;
}
@@ -931,11 +938,8 @@
drawctxt->state == ADRENO_CONTEXT_STATE_INVALID) {
replay[i] = NULL;
- kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
kgsl_cancel_events_timestamp(device, cmd->context,
cmd->timestamp);
- kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
-
kgsl_cmdbatch_destroy(cmd);
}
}
@@ -1084,7 +1088,8 @@
kgsl_device_snapshot(device, 1);
}
- kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
+
/* Allocate memory to store the inflight commands */
replay = kzalloc(sizeof(*replay) * dispatcher->inflight, GFP_KERNEL);
@@ -1092,6 +1097,7 @@
if (replay == NULL) {
unsigned int ptr = dispatcher->head;
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
/* Recovery failed - mark everybody guilty */
mark_guilty_context(device, 0);
@@ -1111,6 +1117,7 @@
*/
count = 0;
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
goto replay;
}
@@ -1168,7 +1175,9 @@
cmdbatch->context->id, cmdbatch->timestamp);
mark_guilty_context(device, cmdbatch->context->id);
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
adreno_drawctxt_invalidate(device, cmdbatch->context);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
}
/*
@@ -1277,7 +1286,9 @@
mark_guilty_context(device, cmdbatch->context->id);
/* Invalidate the context */
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
adreno_drawctxt_invalidate(device, cmdbatch->context);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
replay:
@@ -1296,8 +1307,10 @@
/* If adreno_reset() fails then what hope do we have for the future? */
BUG_ON(ret);
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
/* Remove any pending command batches that have been invalidated */
remove_invalidated_cmdbatches(device, replay, count);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
/* Replay the pending command buffers */
for (i = 0; i < count; i++) {
@@ -1339,9 +1352,11 @@
/* Mark this context as guilty (failed recovery) */
mark_guilty_context(device, replay[i]->context->id);
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
adreno_drawctxt_invalidate(device, replay[i]->context);
remove_invalidated_cmdbatches(device, &replay[i],
count - i);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
}
}
@@ -1449,8 +1464,10 @@
dispatcher->head = CMDQUEUE_NEXT(dispatcher->head,
ADRENO_DISPATCH_CMDQUEUE_SIZE);
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
/* Destroy the retired command batch */
kgsl_cmdbatch_destroy(cmdbatch);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
/* Update the expire time for the next command batch */
@@ -1695,16 +1712,19 @@
void adreno_dispatcher_close(struct adreno_device *adreno_dev)
{
struct adreno_dispatcher *dispatcher = &adreno_dev->dispatcher;
+ struct kgsl_device *device = &adreno_dev->dev;
mutex_lock(&dispatcher->mutex);
del_timer_sync(&dispatcher->timer);
del_timer_sync(&dispatcher->fault_timer);
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
while (dispatcher->head != dispatcher->tail) {
kgsl_cmdbatch_destroy(dispatcher->cmdqueue[dispatcher->head]);
dispatcher->head = (dispatcher->head + 1)
% ADRENO_DISPATCH_CMDQUEUE_SIZE;
}
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
mutex_unlock(&dispatcher->mutex);
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 060dbd2..a5b25a0 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -2311,8 +2311,11 @@
* -EPROTO is a "success" error - it just tells the user that the
* context had previously faulted
*/
- if (result && result != -EPROTO)
+ if (result && result != -EPROTO) {
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
kgsl_cmdbatch_destroy(cmdbatch);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
+ }
done:
kgsl_context_put(context);
@@ -2363,8 +2366,11 @@
* -EPROTO is a "success" error - it just tells the user that the
* context had previously faulted
*/
- if (result && result != -EPROTO)
+ if (result && result != -EPROTO) {
+ kgsl_mutex_lock(&device->mutex, &device->mutex_owner);
kgsl_cmdbatch_destroy(cmdbatch);
+ kgsl_mutex_unlock(&device->mutex, &device->mutex_owner);
+ }
done:
kgsl_context_put(context);