summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-10-22 18:59:37 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-10-22 18:59:37 +0200
commit919c886b2b7728768720aac93e0f6fd1acb8b2df (patch)
treebaa2598b79f5133f91acb30374def4eea9c0e0df
parentd4ce4be0dad516caa43fddcd8a56c28f264c9c2a (diff)
A cmdbuf mutex to implement validate-submit-fence atomicity in the absence
of a hardware lock.
-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;