brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0196-drm-vc4-Return-an-ERR_PTR-from-BO-creation-instead-o.patch
1 From 96cfc336eb33c0152c4aff462bd6a21cd75cc731 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] drm/vc4: Return an ERR_PTR from BO creation instead of NULL.
5
6 Fixes igt vc4_create_bo/create-bo-0 by returning -EINVAL from the
7 ioctl instead of -ENOMEM.
8
9 Signed-off-by: Eric Anholt <eric@anholt.net>
10 ---
11 drivers/gpu/drm/vc4/vc4_bo.c | 23 +++++++++++++----------
12 drivers/gpu/drm/vc4/vc4_gem.c | 4 ++--
13 drivers/gpu/drm/vc4/vc4_irq.c | 2 +-
14 drivers/gpu/drm/vc4/vc4_render_cl.c | 4 ++--
15 drivers/gpu/drm/vc4/vc4_validate.c | 4 ++--
16 5 files changed, 20 insertions(+), 17 deletions(-)
17
18 --- a/drivers/gpu/drm/vc4/vc4_bo.c
19 +++ b/drivers/gpu/drm/vc4/vc4_bo.c
20 @@ -213,10 +213,10 @@ struct vc4_bo *vc4_bo_create(struct drm_
21 size_t size = roundup(unaligned_size, PAGE_SIZE);
22 struct vc4_dev *vc4 = to_vc4_dev(dev);
23 struct drm_gem_cma_object *cma_obj;
24 - int pass;
25 + int pass, ret;
26
27 if (size == 0)
28 - return NULL;
29 + return ERR_PTR(-EINVAL);
30
31 /* First, try to get a vc4_bo from the kernel BO cache. */
32 if (from_cache) {
33 @@ -247,14 +247,17 @@ struct vc4_bo *vc4_bo_create(struct drm_
34 * unreferenced BOs to the cache, and then
35 * free the cache.
36 */
37 - vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull, true);
38 + ret = vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull,
39 + true);
40 + if (ret)
41 + return ERR_PTR(ret);
42 vc4_job_handle_completed(vc4);
43 vc4_bo_cache_purge(dev);
44 break;
45 case 3:
46 DRM_ERROR("Failed to allocate from CMA:\n");
47 vc4_bo_stats_dump(vc4);
48 - return NULL;
49 + return ERR_PTR(-ENOMEM);
50 }
51 }
52
53 @@ -276,8 +279,8 @@ int vc4_dumb_create(struct drm_file *fil
54 args->size = args->pitch * args->height;
55
56 bo = vc4_bo_create(dev, args->size, false);
57 - if (!bo)
58 - return -ENOMEM;
59 + if (IS_ERR(bo))
60 + return PTR_ERR(bo);
61
62 ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
63 drm_gem_object_unreference_unlocked(&bo->base.base);
64 @@ -460,8 +463,8 @@ int vc4_create_bo_ioctl(struct drm_devic
65 * get zeroed, and that might leak data between users.
66 */
67 bo = vc4_bo_create(dev, args->size, false);
68 - if (!bo)
69 - return -ENOMEM;
70 + if (IS_ERR(bo))
71 + return PTR_ERR(bo);
72
73 ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
74 drm_gem_object_unreference_unlocked(&bo->base.base);
75 @@ -513,8 +516,8 @@ vc4_create_shader_bo_ioctl(struct drm_de
76 }
77
78 bo = vc4_bo_create(dev, args->size, true);
79 - if (!bo)
80 - return -ENOMEM;
81 + if (IS_ERR(bo))
82 + return PTR_ERR(bo);
83
84 ret = copy_from_user(bo->base.vaddr,
85 (void __user *)(uintptr_t)args->data,
86 --- a/drivers/gpu/drm/vc4/vc4_gem.c
87 +++ b/drivers/gpu/drm/vc4/vc4_gem.c
88 @@ -593,9 +593,9 @@ vc4_get_bcl(struct drm_device *dev, stru
89 }
90
91 bo = vc4_bo_create(dev, exec_size, true);
92 - if (!bo) {
93 + if (IS_ERR(bo)) {
94 DRM_ERROR("Couldn't allocate BO for binning\n");
95 - ret = PTR_ERR(exec->exec_bo);
96 + ret = PTR_ERR(bo);
97 goto fail;
98 }
99 exec->exec_bo = &bo->base;
100 --- a/drivers/gpu/drm/vc4/vc4_irq.c
101 +++ b/drivers/gpu/drm/vc4/vc4_irq.c
102 @@ -57,7 +57,7 @@ vc4_overflow_mem_work(struct work_struct
103 struct vc4_bo *bo;
104
105 bo = vc4_bo_create(dev, 256 * 1024, true);
106 - if (!bo) {
107 + if (IS_ERR(bo)) {
108 DRM_ERROR("Couldn't allocate binner overflow mem\n");
109 return;
110 }
111 --- a/drivers/gpu/drm/vc4/vc4_render_cl.c
112 +++ b/drivers/gpu/drm/vc4/vc4_render_cl.c
113 @@ -316,8 +316,8 @@ static int vc4_create_rcl_bo(struct drm_
114 size += xtiles * ytiles * loop_body_size;
115
116 setup->rcl = &vc4_bo_create(dev, size, true)->base;
117 - if (!setup->rcl)
118 - return -ENOMEM;
119 + if (IS_ERR(setup->rcl))
120 + return PTR_ERR(setup->rcl);
121 list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head,
122 &exec->unref_list);
123
124 --- a/drivers/gpu/drm/vc4/vc4_validate.c
125 +++ b/drivers/gpu/drm/vc4/vc4_validate.c
126 @@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_AR
127 tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size,
128 true);
129 exec->tile_bo = &tile_bo->base;
130 - if (!exec->tile_bo)
131 - return -ENOMEM;
132 + if (IS_ERR(exec->tile_bo))
133 + return PTR_ERR(exec->tile_bo);
134 list_add_tail(&tile_bo->unref_head, &exec->unref_list);
135
136 /* tile alloc address. */