Commit 2c68f1fc authored by Eric Anholt's avatar Eric Anholt

drm/vc4: Return an ERR_PTR from BO creation instead of NULL.

Fixes igt vc4_create_bo/create-bo-0 by returning -EINVAL from the
ioctl instead of -ENOMEM.
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent 54aec44a
...@@ -215,7 +215,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size, ...@@ -215,7 +215,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
struct drm_gem_cma_object *cma_obj; struct drm_gem_cma_object *cma_obj;
if (size == 0) if (size == 0)
return NULL; return ERR_PTR(-EINVAL);
/* First, try to get a vc4_bo from the kernel BO cache. */ /* First, try to get a vc4_bo from the kernel BO cache. */
if (from_cache) { if (from_cache) {
...@@ -237,7 +237,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size, ...@@ -237,7 +237,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
if (IS_ERR(cma_obj)) { if (IS_ERR(cma_obj)) {
DRM_ERROR("Failed to allocate from CMA:\n"); DRM_ERROR("Failed to allocate from CMA:\n");
vc4_bo_stats_dump(vc4); vc4_bo_stats_dump(vc4);
return NULL; return ERR_PTR(-ENOMEM);
} }
} }
...@@ -259,8 +259,8 @@ int vc4_dumb_create(struct drm_file *file_priv, ...@@ -259,8 +259,8 @@ int vc4_dumb_create(struct drm_file *file_priv,
args->size = args->pitch * args->height; args->size = args->pitch * args->height;
bo = vc4_bo_create(dev, args->size, false); bo = vc4_bo_create(dev, args->size, false);
if (!bo) if (IS_ERR(bo))
return -ENOMEM; return PTR_ERR(bo);
ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
drm_gem_object_unreference_unlocked(&bo->base.base); drm_gem_object_unreference_unlocked(&bo->base.base);
...@@ -443,8 +443,8 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data, ...@@ -443,8 +443,8 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
* get zeroed, and that might leak data between users. * get zeroed, and that might leak data between users.
*/ */
bo = vc4_bo_create(dev, args->size, false); bo = vc4_bo_create(dev, args->size, false);
if (!bo) if (IS_ERR(bo))
return -ENOMEM; return PTR_ERR(bo);
ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle); ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
drm_gem_object_unreference_unlocked(&bo->base.base); drm_gem_object_unreference_unlocked(&bo->base.base);
...@@ -496,8 +496,8 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data, ...@@ -496,8 +496,8 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
} }
bo = vc4_bo_create(dev, args->size, true); bo = vc4_bo_create(dev, args->size, true);
if (!bo) if (IS_ERR(bo))
return -ENOMEM; return PTR_ERR(bo);
ret = copy_from_user(bo->base.vaddr, ret = copy_from_user(bo->base.vaddr,
(void __user *)(uintptr_t)args->data, (void __user *)(uintptr_t)args->data,
......
...@@ -578,9 +578,9 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec) ...@@ -578,9 +578,9 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
} }
bo = vc4_bo_create(dev, exec_size, true); bo = vc4_bo_create(dev, exec_size, true);
if (!bo) { if (IS_ERR(bo)) {
DRM_ERROR("Couldn't allocate BO for binning\n"); DRM_ERROR("Couldn't allocate BO for binning\n");
ret = -ENOMEM; ret = PTR_ERR(bo);
goto fail; goto fail;
} }
exec->exec_bo = &bo->base; exec->exec_bo = &bo->base;
......
...@@ -57,7 +57,7 @@ vc4_overflow_mem_work(struct work_struct *work) ...@@ -57,7 +57,7 @@ vc4_overflow_mem_work(struct work_struct *work)
struct vc4_bo *bo; struct vc4_bo *bo;
bo = vc4_bo_create(dev, 256 * 1024, true); bo = vc4_bo_create(dev, 256 * 1024, true);
if (!bo) { if (IS_ERR(bo)) {
DRM_ERROR("Couldn't allocate binner overflow mem\n"); DRM_ERROR("Couldn't allocate binner overflow mem\n");
return; return;
} }
......
...@@ -316,8 +316,8 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec, ...@@ -316,8 +316,8 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec,
size += xtiles * ytiles * loop_body_size; size += xtiles * ytiles * loop_body_size;
setup->rcl = &vc4_bo_create(dev, size, true)->base; setup->rcl = &vc4_bo_create(dev, size, true)->base;
if (!setup->rcl) if (IS_ERR(setup->rcl))
return -ENOMEM; return PTR_ERR(setup->rcl);
list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head, list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head,
&exec->unref_list); &exec->unref_list);
......
...@@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_ARGS) ...@@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_ARGS)
tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size, tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size,
true); true);
exec->tile_bo = &tile_bo->base; exec->tile_bo = &tile_bo->base;
if (!exec->tile_bo) if (IS_ERR(exec->tile_bo))
return -ENOMEM; return PTR_ERR(exec->tile_bo);
list_add_tail(&tile_bo->unref_head, &exec->unref_list); list_add_tail(&tile_bo->unref_head, &exec->unref_list);
/* tile alloc address. */ /* tile alloc address. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment