summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300/r300_context.c
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2011-02-19 00:16:44 +0100
committerMarek Olšák <maraeo@gmail.com>2011-02-19 00:17:27 +0100
commit0b436cf511316d4bf90246a39557900b4b566853 (patch)
tree2bb1f9850eef22452ca65b5439e40c2b2ec41ff3 /src/gallium/drivers/r300/r300_context.c
parente9e5380f22c230ea1276208baa40c3fe6482b296 (diff)
r300g: fix a possible race when counting contexts
Atomics aren't sufficient here.
Diffstat (limited to 'src/gallium/drivers/r300/r300_context.c')
-rw-r--r--src/gallium/drivers/r300/r300_context.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index a89bf7fac3..da6b0bb8aa 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -38,19 +38,21 @@
static void r300_update_num_contexts(struct r300_screen *r300screen,
int diff)
{
+ pipe_mutex_lock(r300screen->num_contexts_mutex);
if (diff > 0) {
- p_atomic_inc(&r300screen->num_contexts);
+ r300screen->num_contexts++;
if (r300screen->num_contexts > 1)
util_slab_set_thread_safety(&r300screen->pool_buffers,
UTIL_SLAB_MULTITHREADED);
} else {
- p_atomic_dec(&r300screen->num_contexts);
+ r300screen->num_contexts--;
if (r300screen->num_contexts <= 1)
util_slab_set_thread_safety(&r300screen->pool_buffers,
UTIL_SLAB_SINGLETHREADED);
}
+ pipe_mutex_unlock(r300screen->num_contexts_mutex);
}
static void r300_release_referenced_objects(struct r300_context *r300)