summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2014-03-10 12:25:18 +0800
committerChia-I Wu <[email protected]>2014-03-10 16:42:42 +0800
commit72956ed374b73391d4d033722d3032fa6496b5cb (patch)
tree018c5a84a9ec874a54a0fb0b6707705c0be4c1f1 /src/gallium/winsys
parentd80f0c34b733a874adfdd3a2267e4deec345cc6b (diff)
ilo: protect the decode context with a mutex
The decode context is not thread safe.
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/intel/drm/intel_drm_winsys.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
index 364f221dc2f..5789114b39f 100644
--- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c
+++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
@@ -35,6 +35,7 @@
#include <i915_drm.h>
#include <intel_bufmgr.h>
+#include "os/os_thread.h"
#include "state_tracker/drm_driver.h"
#include "pipe/p_state.h"
#include "util/u_inlines.h"
@@ -50,6 +51,8 @@ struct intel_winsys {
struct intel_winsys_info info;
unsigned long exec_flags;
+ /* these are protected by the mutex */
+ pipe_mutex mutex;
struct drm_intel_decode *decode;
};
@@ -177,6 +180,8 @@ intel_winsys_create_for_fd(int fd)
return NULL;
}
+ pipe_mutex_init(winsys->mutex);
+
if (!probe_winsys(winsys)) {
drm_intel_bufmgr_destroy(winsys->bufmgr);
FREE(winsys);
@@ -205,6 +210,7 @@ intel_winsys_destroy(struct intel_winsys *winsys)
if (winsys->decode)
drm_intel_decode_context_free(winsys->decode);
+ pipe_mutex_destroy(winsys->mutex);
drm_intel_bufmgr_destroy(winsys->bufmgr);
FREE(winsys);
}
@@ -416,21 +422,26 @@ intel_winsys_decode_bo(struct intel_winsys *winsys,
{
void *ptr;
+ ptr = intel_bo_map(bo, false);
+ if (!ptr) {
+ debug_printf("failed to map buffer for decoding\n");
+ return;
+ }
+
+ pipe_mutex_lock(winsys->mutex);
+
if (!winsys->decode) {
winsys->decode = drm_intel_decode_context_alloc(winsys->info.devid);
- if (!winsys->decode)
+ if (!winsys->decode) {
+ pipe_mutex_unlock(winsys->mutex);
+ intel_bo_unmap(bo);
return;
+ }
/* debug_printf()/debug_error() uses stderr by default */
drm_intel_decode_set_output_file(winsys->decode, stderr);
}
- ptr = intel_bo_map(bo, false);
- if (!ptr) {
- debug_printf("failed to map buffer for decoding\n");
- return;
- }
-
/* in dwords */
used /= 4;
@@ -439,6 +450,8 @@ intel_winsys_decode_bo(struct intel_winsys *winsys,
drm_intel_decode(winsys->decode);
+ pipe_mutex_unlock(winsys->mutex);
+
intel_bo_unmap(bo);
}