summaryrefslogtreecommitdiff
path: root/shared-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2007-10-22 11:54:41 +1100
committerDave Airlie <airlied@redhat.com>2007-10-22 11:54:41 +1100
commit22883ff26b8a45ab2bec60accc4b822cf6b4f214 (patch)
tree4b1cced67e0c3578b3188e1319ed5884ea7acb3d /shared-core
parent2c5c18fbd394f419a9cf650720a1187440c643cd (diff)
i915: split reloc execution into separate function
Diffstat (limited to 'shared-core')
-rw-r--r--shared-core/i915_dma.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 5a51f6ef..d0d65f8c 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -873,6 +873,43 @@ out:
return ret;
}
+static int i915_exec_reloc(struct drm_file *file_priv, drm_handle_t buf_handle,
+ drm_handle_t buf_reloc_handle,
+ struct drm_buffer_object **buffers,
+ uint32_t buf_count)
+{
+ struct drm_device *dev = file_priv->head->dev;
+ struct i915_relocatee_info relocatee;
+ int ret = 0;
+
+ memset(&relocatee, 0, sizeof(relocatee));
+
+ mutex_lock(&dev->struct_mutex);
+ relocatee.buf = drm_lookup_buffer_object(file_priv, buf_handle, 1);
+ mutex_unlock(&dev->struct_mutex);
+ if (!relocatee.buf) {
+ DRM_DEBUG("relocatee buffer invalid %08x\n", buf_handle);
+ ret = -EINVAL;
+ goto out_err;
+ }
+
+ while (buf_reloc_handle) {
+ ret = i915_process_relocs(file_priv, buf_handle, &buf_reloc_handle, &relocatee, buffers, buf_count);
+ if (ret) {
+ DRM_ERROR("process relocs failed\n");
+ break;
+ }
+ }
+
+ drm_bo_kunmap(&relocatee.kmap);
+ mutex_lock(&dev->struct_mutex);
+ drm_bo_usage_deref_locked(&relocatee.buf);
+ mutex_unlock(&dev->struct_mutex);
+
+out_err:
+ return ret;
+}
+
/*
* Validate, add fence and relocate a block of bos from a userspace list
*/
@@ -889,7 +926,7 @@ int i915_validate_buffer_list(struct drm_file *file_priv,
unsigned buf_count = 0;
struct drm_device *dev = file_priv->head->dev;
uint32_t buf_reloc_handle, buf_handle;
- struct i915_relocatee_info relocatee;
+
do {
if (buf_count >= *num_buffers) {
@@ -950,33 +987,9 @@ int i915_validate_buffer_list(struct drm_file *file_priv,
buf_count++;
if (buf_reloc_handle) {
- memset(&relocatee, 0, sizeof(relocatee));
-
- mutex_lock(&dev->struct_mutex);
- relocatee.buf = drm_lookup_buffer_object(file_priv, buf_handle, 1);
- mutex_unlock(&dev->struct_mutex);
- if (!relocatee.buf) {
- DRM_DEBUG("relocatee buffer invalid %08x\n", buf_handle);
- ret = -EINVAL;
- goto out_err;
- }
-
- while (buf_reloc_handle) {
- ret = i915_process_relocs(file_priv, buf_handle, &buf_reloc_handle, &relocatee, buffers, buf_count);
- if (ret) {
- DRM_ERROR("process relocs failed\n");
- break;
- }
- }
-
- drm_bo_kunmap(&relocatee.kmap);
- mutex_lock(&dev->struct_mutex);
- drm_bo_usage_deref_locked(&relocatee.buf);
- mutex_unlock(&dev->struct_mutex);
-
+ ret = i915_exec_reloc(file_priv, buf_handle, buf_reloc_handle, buffers, buf_count);
if (ret)
goto out_err;
-
}
} while (next != 0);
*num_buffers = buf_count;