1 From f832d2e9a9b142e2bf7ab5de8154aa6f992651a0 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 25 Jan 2016 14:13:12 -0800
4 Subject: [PATCH 196/304] drm/vc4: Return an ERR_PTR from BO creation instead
7 Fixes igt vc4_create_bo/create-bo-0 by returning -EINVAL from the
8 ioctl instead of -ENOMEM.
10 Signed-off-by: Eric Anholt <eric@anholt.net>
12 drivers/gpu/drm/vc4/vc4_bo.c | 23 +++++++++++++----------
13 drivers/gpu/drm/vc4/vc4_gem.c | 4 ++--
14 drivers/gpu/drm/vc4/vc4_irq.c | 2 +-
15 drivers/gpu/drm/vc4/vc4_render_cl.c | 4 ++--
16 drivers/gpu/drm/vc4/vc4_validate.c | 4 ++--
17 5 files changed, 20 insertions(+), 17 deletions(-)
19 --- a/drivers/gpu/drm/vc4/vc4_bo.c
20 +++ b/drivers/gpu/drm/vc4/vc4_bo.c
21 @@ -213,10 +213,10 @@ struct vc4_bo *vc4_bo_create(struct drm_
22 size_t size = roundup(unaligned_size, PAGE_SIZE);
23 struct vc4_dev *vc4 = to_vc4_dev(dev);
24 struct drm_gem_cma_object *cma_obj;
30 + return ERR_PTR(-EINVAL);
32 /* First, try to get a vc4_bo from the kernel BO cache. */
34 @@ -247,14 +247,17 @@ struct vc4_bo *vc4_bo_create(struct drm_
35 * unreferenced BOs to the cache, and then
38 - vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull, true);
39 + ret = vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull,
42 + return ERR_PTR(ret);
43 vc4_job_handle_completed(vc4);
44 vc4_bo_cache_purge(dev);
47 DRM_ERROR("Failed to allocate from CMA:\n");
48 vc4_bo_stats_dump(vc4);
50 + return ERR_PTR(-ENOMEM);
54 @@ -276,8 +279,8 @@ int vc4_dumb_create(struct drm_file *fil
55 args->size = args->pitch * args->height;
57 bo = vc4_bo_create(dev, args->size, false);
63 ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
64 drm_gem_object_unreference_unlocked(&bo->base.base);
65 @@ -460,8 +463,8 @@ int vc4_create_bo_ioctl(struct drm_devic
66 * get zeroed, and that might leak data between users.
68 bo = vc4_bo_create(dev, args->size, false);
74 ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
75 drm_gem_object_unreference_unlocked(&bo->base.base);
76 @@ -513,8 +516,8 @@ vc4_create_shader_bo_ioctl(struct drm_de
79 bo = vc4_bo_create(dev, args->size, true);
85 ret = copy_from_user(bo->base.vaddr,
86 (void __user *)(uintptr_t)args->data,
87 --- a/drivers/gpu/drm/vc4/vc4_gem.c
88 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
89 @@ -593,9 +593,9 @@ vc4_get_bcl(struct drm_device *dev, stru
92 bo = vc4_bo_create(dev, exec_size, true);
95 DRM_ERROR("Couldn't allocate BO for binning\n");
96 - ret = PTR_ERR(exec->exec_bo);
100 exec->exec_bo = &bo->base;
101 --- a/drivers/gpu/drm/vc4/vc4_irq.c
102 +++ b/drivers/gpu/drm/vc4/vc4_irq.c
103 @@ -57,7 +57,7 @@ vc4_overflow_mem_work(struct work_struct
106 bo = vc4_bo_create(dev, 256 * 1024, true);
109 DRM_ERROR("Couldn't allocate binner overflow mem\n");
112 --- a/drivers/gpu/drm/vc4/vc4_render_cl.c
113 +++ b/drivers/gpu/drm/vc4/vc4_render_cl.c
114 @@ -316,8 +316,8 @@ static int vc4_create_rcl_bo(struct drm_
115 size += xtiles * ytiles * loop_body_size;
117 setup->rcl = &vc4_bo_create(dev, size, true)->base;
120 + if (IS_ERR(setup->rcl))
121 + return PTR_ERR(setup->rcl);
122 list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head,
125 --- a/drivers/gpu/drm/vc4/vc4_validate.c
126 +++ b/drivers/gpu/drm/vc4/vc4_validate.c
127 @@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_AR
128 tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size,
130 exec->tile_bo = &tile_bo->base;
131 - if (!exec->tile_bo)
133 + if (IS_ERR(exec->tile_bo))
134 + return PTR_ERR(exec->tile_bo);
135 list_add_tail(&tile_bo->unref_head, &exec->unref_list);
137 /* tile alloc address. */