aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared-core/i915_dma.c15
-rw-r--r--shared-core/i915_drv.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 14a91f36..d07be6e0 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -213,6 +213,7 @@ static int i915_initialize(struct drm_device * dev,
}
DRM_DEBUG("Enabled hardware status page\n");
dev->dev_private = (void *)dev_priv;
+ mutex_init(&dev_priv->cmdbuf_mutex);
return 0;
}
@@ -1023,11 +1024,23 @@ static int i915_execbuffer(struct drm_device *dev, void *data,
if (ret)
return ret;
+ /*
+ * The cmdbuf_mutex makes sure the validate-submit-fence
+ * operation is atomic.
+ */
+
+ ret = mutex_lock_interruptible(&dev_priv->cmdbuf_mutex);
+ if (ret) {
+ drm_bo_read_unlock(&dev->bm.bm_lock);
+ return -EAGAIN;
+ }
+
num_buffers = exec_buf->num_buffers;
buffers = drm_calloc(num_buffers, sizeof(struct drm_buffer_object *), DRM_MEM_DRIVER);
if (!buffers) {
drm_bo_read_unlock(&dev->bm.bm_lock);
+ mutex_unlock(&dev_priv->cmdbuf_mutex);
return -ENOMEM;
}
@@ -1073,6 +1086,8 @@ out_err0:
out_free:
drm_free(buffers, (exec_buf->num_buffers * sizeof(struct drm_buffer_object *)), DRM_MEM_DRIVER);
+
+ mutex_unlock(&dev_priv->cmdbuf_mutex);
drm_bo_read_unlock(&dev->bm.bm_lock);
return ret;
}
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index e8f18798..817288b6 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -139,6 +139,7 @@ typedef struct drm_i915_private {
#ifdef I915_HAVE_BUFFER
void *agp_iomap;
unsigned int max_validate_buffers;
+ struct mutex cmdbuf_mutex;
#endif
DRM_SPINTYPE swaps_lock;