brcm2708-gpu-fw: update to latest version
[lede.git] / target / linux / brcm2708 / patches-4.4 / 0197-drm-vc4-Return-an-ERR_PTR-from-BO-creation-instead-o.patch
1 From d6211c47e6671faf74389dbcbe29454c5997defb 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 197/232] drm/vc4: Return an ERR_PTR from BO creation instead
5  of NULL.
6
7 Fixes igt vc4_create_bo/create-bo-0 by returning -EINVAL from the
8 ioctl instead of -ENOMEM.
9
10 Signed-off-by: Eric Anholt <eric@anholt.net>
11 ---
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(-)
18
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;
25 -       int pass;
26 +       int pass, ret;
27  
28         if (size == 0)
29 -               return NULL;
30 +               return ERR_PTR(-EINVAL);
31  
32         /* First, try to get a vc4_bo from the kernel BO cache. */
33         if (from_cache) {
34 @@ -247,14 +247,17 @@ struct vc4_bo *vc4_bo_create(struct drm_
35                          * unreferenced BOs to the cache, and then
36                          * free the cache.
37                          */
38 -                       vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull, true);
39 +                       ret = vc4_wait_for_seqno(dev, vc4->emit_seqno, ~0ull,
40 +                                                true);
41 +                       if (ret)
42 +                               return ERR_PTR(ret);
43                         vc4_job_handle_completed(vc4);
44                         vc4_bo_cache_purge(dev);
45                         break;
46                 case 3:
47                         DRM_ERROR("Failed to allocate from CMA:\n");
48                         vc4_bo_stats_dump(vc4);
49 -                       return NULL;
50 +                       return ERR_PTR(-ENOMEM);
51                 }
52         }
53  
54 @@ -276,8 +279,8 @@ int vc4_dumb_create(struct drm_file *fil
55                 args->size = args->pitch * args->height;
56  
57         bo = vc4_bo_create(dev, args->size, false);
58 -       if (!bo)
59 -               return -ENOMEM;
60 +       if (IS_ERR(bo))
61 +               return PTR_ERR(bo);
62  
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.
67          */
68         bo = vc4_bo_create(dev, args->size, false);
69 -       if (!bo)
70 -               return -ENOMEM;
71 +       if (IS_ERR(bo))
72 +               return PTR_ERR(bo);
73  
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
77         }
78  
79         bo = vc4_bo_create(dev, args->size, true);
80 -       if (!bo)
81 -               return -ENOMEM;
82 +       if (IS_ERR(bo))
83 +               return PTR_ERR(bo);
84  
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
90         }
91  
92         bo = vc4_bo_create(dev, exec_size, true);
93 -       if (!bo) {
94 +       if (IS_ERR(bo)) {
95                 DRM_ERROR("Couldn't allocate BO for binning\n");
96 -               ret = PTR_ERR(exec->exec_bo);
97 +               ret = PTR_ERR(bo);
98                 goto fail;
99         }
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
104         struct vc4_bo *bo;
105  
106         bo = vc4_bo_create(dev, 256 * 1024, true);
107 -       if (!bo) {
108 +       if (IS_ERR(bo)) {
109                 DRM_ERROR("Couldn't allocate binner overflow mem\n");
110                 return;
111         }
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;
116  
117         setup->rcl = &vc4_bo_create(dev, size, true)->base;
118 -       if (!setup->rcl)
119 -               return -ENOMEM;
120 +       if (IS_ERR(setup->rcl))
121 +               return PTR_ERR(setup->rcl);
122         list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head,
123                       &exec->unref_list);
124  
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,
129                                 true);
130         exec->tile_bo = &tile_bo->base;
131 -       if (!exec->tile_bo)
132 -               return -ENOMEM;
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);
136  
137         /* tile alloc address. */