i915: split reloc execution into separate function
parent
2c5c18fbd3
commit
22883ff26b
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue