msm: kgsl: Add context reference counting to KGSL events

Add reference counting to all KGSL events since they are dependent
on the context.  This avoids a race condition where the context
could be destroyed while the events are being processed during cleanup.

Change-Id: Ifcd9655a6335d22c01f2606a0fbc5346d9a0314f
CRs-fixed: 438134
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
This commit is contained in:
Carter Cooper 2013-01-08 11:41:02 -07:00 committed by Iliyan Malchev
parent 0a449c19b2
commit d7c6db2e49

View file

@ -80,6 +80,10 @@ int kgsl_add_event(struct kgsl_device *device, u32 id, u32 ts,
event->func = cb;
event->owner = owner;
/* inc refcount to avoid race conditions in cleanup */
if (context)
kgsl_context_get(context);
/* Add the event to either the owning context or the global list */
if (context) {
@ -127,6 +131,7 @@ void kgsl_cancel_events_ctxt(struct kgsl_device *device,
if (event->func)
event->func(device, event->priv, id, cur);
kgsl_context_put(context);
list_del(&event->list);
kfree(event);
}
@ -163,6 +168,9 @@ void kgsl_cancel_events(struct kgsl_device *device,
event->func(device, event->priv, KGSL_MEMSTORE_GLOBAL,
cur);
if (event->context)
kgsl_context_put(event->context);
list_del(&event->list);
kfree(event);
}
@ -184,6 +192,9 @@ static void _process_event_list(struct kgsl_device *device,
if (event->func)
event->func(device, event->priv, id, timestamp);
if (event->context)
kgsl_context_put(event->context);
list_del(&event->list);
kfree(event);
}