aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-11-08 18:21:27 -0500
committerBen Skeggs <bskeggs@redhat.com>2016-01-10 20:17:40 -0500
commitf01c4e682c941ba70e0ebec44db754844a1b9b82 (patch)
tree4b79c3e1b8afeaaae0143565a8ad0320fa9751dc
parent13db6d6ea7190a377af31246016af66803766588 (diff)
drm/nouveau/nvif: modify nvif_unvers/nvif_unpack macros to be more obvious
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/include/nvif/unpack.h34
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_usif.c25
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/client.c8
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/core/ioctl.c56
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c12
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/device/user.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c8
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c8
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c8
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c16
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c9
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c28
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c4
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c4
45 files changed, 186 insertions, 171 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvif/unpack.h b/drivers/gpu/drm/nouveau/include/nvif/unpack.h
index 5933188b4a77..751bcf4930a7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/unpack.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/unpack.h
@@ -1,24 +1,28 @@
1#ifndef __NVIF_UNPACK_H__ 1#ifndef __NVIF_UNPACK_H__
2#define __NVIF_UNPACK_H__ 2#define __NVIF_UNPACK_H__
3 3
4#define nvif_unvers(d) ({ \ 4#define nvif_unvers(r,d,s,m) ({ \
5 ret = (size == sizeof(d)) ? 0 : -ENOSYS; \ 5 void **_data = (d); __u32 *_size = (s); int _ret = (r); \
6 (ret == 0); \ 6 if (_ret == -ENOSYS && *_size == sizeof(m)) { \
7 *_data = NULL; \
8 *_size = _ret = 0; \
9 } \
10 _ret; \
7}) 11})
8 12
9#define nvif_unpack(d,vl,vh,m) ({ \ 13#define nvif_unpack(r,d,s,m,vl,vh,x) ({ \
10 if ((vl) == 0 || ret == -ENOSYS) { \ 14 void **_data = (d); __u32 *_size = (s); \
11 int _size = sizeof(d); \ 15 int _ret = (r), _vl = (vl), _vh = (vh); \
12 if (_size <= size && (d).version >= (vl) && \ 16 if (_ret == -ENOSYS && *_size >= sizeof(m) && \
13 (d).version <= (vh)) { \ 17 (m).version >= _vl && (m).version <= _vh) { \
14 data = (u8 *)data + _size; \ 18 *_data = (__u8 *)*_data + sizeof(m); \
15 size = size - _size; \ 19 *_size = *_size - sizeof(m); \
16 ret = ((m) || !size) ? 0 : -E2BIG; \ 20 if (_ret = 0, !(x)) { \
17 } else { \ 21 _ret = *_size ? -E2BIG : 0; \
18 ret = -ENOSYS; \ 22 *_data = NULL; \
23 *_size = 0; \
19 } \ 24 } \
20 } \ 25 } \
21 (ret == 0); \ 26 _ret; \
22}) 27})
23
24#endif 28#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 054ef97df411..50f52ffe5b0c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -357,9 +357,9 @@ nouveau_abi16_usif(struct drm_file *file_priv, void *data, u32 size)
357 } *args = data; 357 } *args = data;
358 struct nouveau_abi16_chan *chan; 358 struct nouveau_abi16_chan *chan;
359 struct nouveau_abi16 *abi16; 359 struct nouveau_abi16 *abi16;
360 int ret; 360 int ret = -ENOSYS;
361 361
362 if (nvif_unpack(args->v0, 0, 0, true)) { 362 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
363 switch (args->v0.type) { 363 switch (args->v0.type) {
364 case NVIF_IOCTL_V0_NEW: 364 case NVIF_IOCTL_V0_NEW:
365 case NVIF_IOCTL_V0_MTHD: 365 case NVIF_IOCTL_V0_MTHD:
diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
index 6ae1b3494bcd..e9f52ef0be83 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -130,20 +130,21 @@ usif_notify_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
130 struct nvif_notify_req_v0 v0; 130 struct nvif_notify_req_v0 v0;
131 } *req; 131 } *req;
132 struct usif_notify *ntfy; 132 struct usif_notify *ntfy;
133 int ret; 133 int ret = -ENOSYS;
134 134
135 if (nvif_unpack(args->v0, 0, 0, true)) { 135 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
136 if (usif_notify_find(f, args->v0.index)) 136 if (usif_notify_find(f, args->v0.index))
137 return -EEXIST; 137 return -EEXIST;
138 } else 138 } else
139 return ret; 139 return ret;
140 req = data; 140 req = data;
141 ret = -ENOSYS;
141 142
142 if (!(ntfy = kmalloc(sizeof(*ntfy), GFP_KERNEL))) 143 if (!(ntfy = kmalloc(sizeof(*ntfy), GFP_KERNEL)))
143 return -ENOMEM; 144 return -ENOMEM;
144 atomic_set(&ntfy->enabled, 0); 145 atomic_set(&ntfy->enabled, 0);
145 146
146 if (nvif_unpack(req->v0, 0, 0, true)) { 147 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, true))) {
147 ntfy->reply = sizeof(struct nvif_notify_rep_v0) + req->v0.reply; 148 ntfy->reply = sizeof(struct nvif_notify_rep_v0) + req->v0.reply;
148 ntfy->route = req->v0.route; 149 ntfy->route = req->v0.route;
149 ntfy->token = req->v0.token; 150 ntfy->token = req->v0.token;
@@ -171,9 +172,9 @@ usif_notify_del(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
171 struct nvif_ioctl_ntfy_del_v0 v0; 172 struct nvif_ioctl_ntfy_del_v0 v0;
172 } *args = data; 173 } *args = data;
173 struct usif_notify *ntfy; 174 struct usif_notify *ntfy;
174 int ret; 175 int ret = -ENOSYS;
175 176
176 if (nvif_unpack(args->v0, 0, 0, true)) { 177 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
177 if (!(ntfy = usif_notify_find(f, args->v0.index))) 178 if (!(ntfy = usif_notify_find(f, args->v0.index)))
178 return -ENOENT; 179 return -ENOENT;
179 } else 180 } else
@@ -194,9 +195,9 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
194 struct nvif_ioctl_ntfy_del_v0 v0; 195 struct nvif_ioctl_ntfy_del_v0 v0;
195 } *args = data; 196 } *args = data;
196 struct usif_notify *ntfy; 197 struct usif_notify *ntfy;
197 int ret; 198 int ret = -ENOSYS;
198 199
199 if (nvif_unpack(args->v0, 0, 0, true)) { 200 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
200 if (!(ntfy = usif_notify_find(f, args->v0.index))) 201 if (!(ntfy = usif_notify_find(f, args->v0.index)))
201 return -ENOENT; 202 return -ENOENT;
202 } else 203 } else
@@ -233,9 +234,9 @@ usif_notify_put(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
233 struct nvif_ioctl_ntfy_put_v0 v0; 234 struct nvif_ioctl_ntfy_put_v0 v0;
234 } *args = data; 235 } *args = data;
235 struct usif_notify *ntfy; 236 struct usif_notify *ntfy;
236 int ret; 237 int ret = -ENOSYS;
237 238
238 if (nvif_unpack(args->v0, 0, 0, true)) { 239 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
239 if (!(ntfy = usif_notify_find(f, args->v0.index))) 240 if (!(ntfy = usif_notify_find(f, args->v0.index)))
240 return -ENOENT; 241 return -ENOENT;
241 } else 242 } else
@@ -270,13 +271,13 @@ usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
270 struct nvif_ioctl_new_v0 v0; 271 struct nvif_ioctl_new_v0 v0;
271 } *args = data; 272 } *args = data;
272 struct usif_object *object; 273 struct usif_object *object;
273 int ret; 274 int ret = -ENOSYS;
274 275
275 if (!(object = kmalloc(sizeof(*object), GFP_KERNEL))) 276 if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
276 return -ENOMEM; 277 return -ENOMEM;
277 list_add(&object->head, &cli->objects); 278 list_add(&object->head, &cli->objects);
278 279
279 if (nvif_unpack(args->v0, 0, 0, true)) { 280 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
280 object->route = args->v0.route; 281 object->route = args->v0.route;
281 object->token = args->v0.token; 282 object->token = args->v0.token;
282 args->v0.route = NVDRM_OBJECT_USIF; 283 args->v0.route = NVDRM_OBJECT_USIF;
@@ -310,7 +311,7 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 argc)
310 if (ret = -EFAULT, copy_from_user(argv, user, size)) 311 if (ret = -EFAULT, copy_from_user(argv, user, size))
311 goto done; 312 goto done;
312 313
313 if (nvif_unpack(argv->v0, 0, 0, true)) { 314 if (!(ret = nvif_unpack(-ENOSYS, &data, &size, argv->v0, 0, 0, true))) {
314 /* block access to objects not created via this interface */ 315 /* block access to objects not created via this interface */
315 owner = argv->v0.owner; 316 owner = argv->v0.owner;
316 if (argv->v0.object == 0ULL) 317 if (argv->v0.object == 0ULL)
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/client.c b/drivers/gpu/drm/nouveau/nvkm/core/client.c
index 98e694179ace..e1943910858e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/client.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/client.c
@@ -97,7 +97,7 @@ nvkm_client_notify_new(struct nvkm_object *object,
97 struct nvif_notify_req_v0 v0; 97 struct nvif_notify_req_v0 v0;
98 } *req = data; 98 } *req = data;
99 u8 index, reply; 99 u8 index, reply;
100 int ret; 100 int ret = -ENOSYS;
101 101
102 for (index = 0; index < ARRAY_SIZE(client->notify); index++) { 102 for (index = 0; index < ARRAY_SIZE(client->notify); index++) {
103 if (!client->notify[index]) 103 if (!client->notify[index])
@@ -112,7 +112,7 @@ nvkm_client_notify_new(struct nvkm_object *object,
112 return -ENOMEM; 112 return -ENOMEM;
113 113
114 nvif_ioctl(object, "notify new size %d\n", size); 114 nvif_ioctl(object, "notify new size %d\n", size);
115 if (nvif_unpack(req->v0, 0, 0, true)) { 115 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, true))) {
116 nvif_ioctl(object, "notify new vers %d reply %d route %02x " 116 nvif_ioctl(object, "notify new vers %d reply %d route %02x "
117 "token %llx\n", req->v0.version, 117 "token %llx\n", req->v0.version,
118 req->v0.reply, req->v0.route, req->v0.token); 118 req->v0.reply, req->v0.route, req->v0.token);
@@ -144,10 +144,10 @@ nvkm_client_mthd_devlist(struct nvkm_object *object, void *data, u32 size)
144 union { 144 union {
145 struct nv_client_devlist_v0 v0; 145 struct nv_client_devlist_v0 v0;
146 } *args = data; 146 } *args = data;
147 int ret; 147 int ret = -ENOSYS;
148 148
149 nvif_ioctl(object, "client devlist size %d\n", size); 149 nvif_ioctl(object, "client devlist size %d\n", size);
150 if (nvif_unpack(args->v0, 0, 0, true)) { 150 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
151 nvif_ioctl(object, "client devlist vers %d count %d\n", 151 nvif_ioctl(object, "client devlist vers %d count %d\n",
152 args->v0.version, args->v0.count); 152 args->v0.version, args->v0.count);
153 if (size == sizeof(args->v0.device[0]) * args->v0.count) { 153 if (size == sizeof(args->v0.device[0]) * args->v0.count) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
index d87d6ab03cc7..b0db51847c36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/ioctl.c
@@ -34,10 +34,10 @@ nvkm_ioctl_nop(struct nvkm_object *object, void *data, u32 size)
34 union { 34 union {
35 struct nvif_ioctl_nop_v0 v0; 35 struct nvif_ioctl_nop_v0 v0;
36 } *args = data; 36 } *args = data;
37 int ret; 37 int ret = -ENOSYS;
38 38
39 nvif_ioctl(object, "nop size %d\n", size); 39 nvif_ioctl(object, "nop size %d\n", size);
40 if (nvif_unpack(args->v0, 0, 0, false)) { 40 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
41 nvif_ioctl(object, "nop vers %lld\n", args->v0.version); 41 nvif_ioctl(object, "nop vers %lld\n", args->v0.version);
42 args->v0.version = NVIF_VERSION_LATEST; 42 args->v0.version = NVIF_VERSION_LATEST;
43 } 43 }
@@ -52,10 +52,10 @@ nvkm_ioctl_sclass(struct nvkm_object *object, void *data, u32 size)
52 struct nvif_ioctl_sclass_v0 v0; 52 struct nvif_ioctl_sclass_v0 v0;
53 } *args = data; 53 } *args = data;
54 struct nvkm_oclass oclass; 54 struct nvkm_oclass oclass;
55 int ret, i = 0; 55 int ret = -ENOSYS, i = 0;
56 56
57 nvif_ioctl(object, "sclass size %d\n", size); 57 nvif_ioctl(object, "sclass size %d\n", size);
58 if (nvif_unpack(args->v0, 0, 0, true)) { 58 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
59 nvif_ioctl(object, "sclass vers %d count %d\n", 59 nvif_ioctl(object, "sclass vers %d count %d\n",
60 args->v0.version, args->v0.count); 60 args->v0.version, args->v0.count);
61 if (size != args->v0.count * sizeof(args->v0.oclass[0])) 61 if (size != args->v0.count * sizeof(args->v0.oclass[0]))
@@ -86,10 +86,10 @@ nvkm_ioctl_new(struct nvkm_object *parent, void *data, u32 size)
86 struct nvkm_client *client = parent->client; 86 struct nvkm_client *client = parent->client;
87 struct nvkm_object *object = NULL; 87 struct nvkm_object *object = NULL;
88 struct nvkm_oclass oclass; 88 struct nvkm_oclass oclass;
89 int ret, i = 0; 89 int ret = -ENOSYS, i = 0;
90 90
91 nvif_ioctl(parent, "new size %d\n", size); 91 nvif_ioctl(parent, "new size %d\n", size);
92 if (nvif_unpack(args->v0, 0, 0, true)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
93 nvif_ioctl(parent, "new vers %d handle %08x class %08x " 93 nvif_ioctl(parent, "new vers %d handle %08x class %08x "
94 "route %02x token %llx object %016llx\n", 94 "route %02x token %llx object %016llx\n",
95 args->v0.version, args->v0.handle, args->v0.oclass, 95 args->v0.version, args->v0.handle, args->v0.oclass,
@@ -147,10 +147,10 @@ nvkm_ioctl_del(struct nvkm_object *object, void *data, u32 size)
147 union { 147 union {
148 struct nvif_ioctl_del none; 148 struct nvif_ioctl_del none;
149 } *args = data; 149 } *args = data;
150 int ret; 150 int ret = -ENOSYS;
151 151
152 nvif_ioctl(object, "delete size %d\n", size); 152 nvif_ioctl(object, "delete size %d\n", size);
153 if (nvif_unvers(args->none)) { 153 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
154 nvif_ioctl(object, "delete\n"); 154 nvif_ioctl(object, "delete\n");
155 nvkm_object_fini(object, false); 155 nvkm_object_fini(object, false);
156 nvkm_object_del(&object); 156 nvkm_object_del(&object);
@@ -165,10 +165,10 @@ nvkm_ioctl_mthd(struct nvkm_object *object, void *data, u32 size)
165 union { 165 union {
166 struct nvif_ioctl_mthd_v0 v0; 166 struct nvif_ioctl_mthd_v0 v0;
167 } *args = data; 167 } *args = data;
168 int ret; 168 int ret = -ENOSYS;
169 169
170 nvif_ioctl(object, "mthd size %d\n", size); 170 nvif_ioctl(object, "mthd size %d\n", size);
171 if (nvif_unpack(args->v0, 0, 0, true)) { 171 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
172 nvif_ioctl(object, "mthd vers %d mthd %02x\n", 172 nvif_ioctl(object, "mthd vers %d mthd %02x\n",
173 args->v0.version, args->v0.method); 173 args->v0.version, args->v0.method);
174 ret = nvkm_object_mthd(object, args->v0.method, data, size); 174 ret = nvkm_object_mthd(object, args->v0.method, data, size);
@@ -189,10 +189,10 @@ nvkm_ioctl_rd(struct nvkm_object *object, void *data, u32 size)
189 u16 b16; 189 u16 b16;
190 u32 b32; 190 u32 b32;
191 } v; 191 } v;
192 int ret; 192 int ret = -ENOSYS;
193 193
194 nvif_ioctl(object, "rd size %d\n", size); 194 nvif_ioctl(object, "rd size %d\n", size);
195 if (nvif_unpack(args->v0, 0, 0, false)) { 195 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
196 nvif_ioctl(object, "rd vers %d size %d addr %016llx\n", 196 nvif_ioctl(object, "rd vers %d size %d addr %016llx\n",
197 args->v0.version, args->v0.size, args->v0.addr); 197 args->v0.version, args->v0.size, args->v0.addr);
198 switch (args->v0.size) { 198 switch (args->v0.size) {
@@ -223,10 +223,10 @@ nvkm_ioctl_wr(struct nvkm_object *object, void *data, u32 size)
223 union { 223 union {
224 struct nvif_ioctl_wr_v0 v0; 224 struct nvif_ioctl_wr_v0 v0;
225 } *args = data; 225 } *args = data;
226 int ret; 226 int ret = -ENOSYS;
227 227
228 nvif_ioctl(object, "wr size %d\n", size); 228 nvif_ioctl(object, "wr size %d\n", size);
229 if (nvif_unpack(args->v0, 0, 0, false)) { 229 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
230 nvif_ioctl(object, 230 nvif_ioctl(object,
231 "wr vers %d size %d addr %016llx data %08x\n", 231 "wr vers %d size %d addr %016llx data %08x\n",
232 args->v0.version, args->v0.size, args->v0.addr, 232 args->v0.version, args->v0.size, args->v0.addr,
@@ -251,10 +251,10 @@ nvkm_ioctl_map(struct nvkm_object *object, void *data, u32 size)
251 union { 251 union {
252 struct nvif_ioctl_map_v0 v0; 252 struct nvif_ioctl_map_v0 v0;
253 } *args = data; 253 } *args = data;
254 int ret; 254 int ret = -ENOSYS;
255 255
256 nvif_ioctl(object, "map size %d\n", size); 256 nvif_ioctl(object, "map size %d\n", size);
257 if (nvif_unpack(args->v0, 0, 0, false)) { 257 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
258 nvif_ioctl(object, "map vers %d\n", args->v0.version); 258 nvif_ioctl(object, "map vers %d\n", args->v0.version);
259 ret = nvkm_object_map(object, &args->v0.handle, 259 ret = nvkm_object_map(object, &args->v0.handle,
260 &args->v0.length); 260 &args->v0.length);
@@ -269,10 +269,10 @@ nvkm_ioctl_unmap(struct nvkm_object *object, void *data, u32 size)
269 union { 269 union {
270 struct nvif_ioctl_unmap none; 270 struct nvif_ioctl_unmap none;
271 } *args = data; 271 } *args = data;
272 int ret; 272 int ret = -ENOSYS;
273 273
274 nvif_ioctl(object, "unmap size %d\n", size); 274 nvif_ioctl(object, "unmap size %d\n", size);
275 if (nvif_unvers(args->none)) { 275 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
276 nvif_ioctl(object, "unmap\n"); 276 nvif_ioctl(object, "unmap\n");
277 } 277 }
278 278
@@ -286,10 +286,10 @@ nvkm_ioctl_ntfy_new(struct nvkm_object *object, void *data, u32 size)
286 struct nvif_ioctl_ntfy_new_v0 v0; 286 struct nvif_ioctl_ntfy_new_v0 v0;
287 } *args = data; 287 } *args = data;
288 struct nvkm_event *event; 288 struct nvkm_event *event;
289 int ret; 289 int ret = -ENOSYS;
290 290
291 nvif_ioctl(object, "ntfy new size %d\n", size); 291 nvif_ioctl(object, "ntfy new size %d\n", size);
292 if (nvif_unpack(args->v0, 0, 0, true)) { 292 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
293 nvif_ioctl(object, "ntfy new vers %d event %02x\n", 293 nvif_ioctl(object, "ntfy new vers %d event %02x\n",
294 args->v0.version, args->v0.event); 294 args->v0.version, args->v0.event);
295 ret = nvkm_object_ntfy(object, args->v0.event, &event); 295 ret = nvkm_object_ntfy(object, args->v0.event, &event);
@@ -312,10 +312,10 @@ nvkm_ioctl_ntfy_del(struct nvkm_object *object, void *data, u32 size)
312 union { 312 union {
313 struct nvif_ioctl_ntfy_del_v0 v0; 313 struct nvif_ioctl_ntfy_del_v0 v0;
314 } *args = data; 314 } *args = data;
315 int ret; 315 int ret = -ENOSYS;
316 316
317 nvif_ioctl(object, "ntfy del size %d\n", size); 317 nvif_ioctl(object, "ntfy del size %d\n", size);
318 if (nvif_unpack(args->v0, 0, 0, false)) { 318 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
319 nvif_ioctl(object, "ntfy del vers %d index %d\n", 319 nvif_ioctl(object, "ntfy del vers %d index %d\n",
320 args->v0.version, args->v0.index); 320 args->v0.version, args->v0.index);
321 ret = nvkm_client_notify_del(client, args->v0.index); 321 ret = nvkm_client_notify_del(client, args->v0.index);
@@ -331,10 +331,10 @@ nvkm_ioctl_ntfy_get(struct nvkm_object *object, void *data, u32 size)
331 union { 331 union {
332 struct nvif_ioctl_ntfy_get_v0 v0; 332 struct nvif_ioctl_ntfy_get_v0 v0;
333 } *args = data; 333 } *args = data;
334 int ret; 334 int ret = -ENOSYS;
335 335
336 nvif_ioctl(object, "ntfy get size %d\n", size); 336 nvif_ioctl(object, "ntfy get size %d\n", size);
337 if (nvif_unpack(args->v0, 0, 0, false)) { 337 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
338 nvif_ioctl(object, "ntfy get vers %d index %d\n", 338 nvif_ioctl(object, "ntfy get vers %d index %d\n",
339 args->v0.version, args->v0.index); 339 args->v0.version, args->v0.index);
340 ret = nvkm_client_notify_get(client, args->v0.index); 340 ret = nvkm_client_notify_get(client, args->v0.index);
@@ -350,10 +350,10 @@ nvkm_ioctl_ntfy_put(struct nvkm_object *object, void *data, u32 size)
350 union { 350 union {
351 struct nvif_ioctl_ntfy_put_v0 v0; 351 struct nvif_ioctl_ntfy_put_v0 v0;
352 } *args = data; 352 } *args = data;
353 int ret; 353 int ret = -ENOSYS;
354 354
355 nvif_ioctl(object, "ntfy put size %d\n", size); 355 nvif_ioctl(object, "ntfy put size %d\n", size);
356 if (nvif_unpack(args->v0, 0, 0, false)) { 356 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
357 nvif_ioctl(object, "ntfy put vers %d index %d\n", 357 nvif_ioctl(object, "ntfy put vers %d index %d\n",
358 args->v0.version, args->v0.index); 358 args->v0.version, args->v0.index);
359 ret = nvkm_client_notify_put(client, args->v0.index); 359 ret = nvkm_client_notify_put(client, args->v0.index);
@@ -421,12 +421,12 @@ nvkm_ioctl(struct nvkm_client *client, bool supervisor,
421 union { 421 union {
422 struct nvif_ioctl_v0 v0; 422 struct nvif_ioctl_v0 v0;
423 } *args = data; 423 } *args = data;
424 int ret; 424 int ret = -ENOSYS;
425 425
426 client->super = supervisor; 426 client->super = supervisor;
427 nvif_ioctl(object, "size %d\n", size); 427 nvif_ioctl(object, "size %d\n", size);
428 428
429 if (nvif_unpack(args->v0, 0, 0, true)) { 429 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
430 nvif_ioctl(object, 430 nvif_ioctl(object,
431 "vers %d type %02x object %016llx owner %02x\n", 431 "vers %d type %02x object %016llx owner %02x\n",
432 args->v0.version, args->v0.type, args->v0.object, 432 args->v0.version, args->v0.type, args->v0.object,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
index 5e84b2f9f32a..b0ece71aefde 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
@@ -38,10 +38,10 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)
38 struct nvif_control_pstate_info_v0 v0; 38 struct nvif_control_pstate_info_v0 v0;
39 } *args = data; 39 } *args = data;
40 struct nvkm_clk *clk = ctrl->device->clk; 40 struct nvkm_clk *clk = ctrl->device->clk;
41 int ret; 41 int ret = -ENOSYS;
42 42
43 nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size); 43 nvif_ioctl(&ctrl->object, "control pstate info size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
45 nvif_ioctl(&ctrl->object, "control pstate info vers %d\n", 45 nvif_ioctl(&ctrl->object, "control pstate info vers %d\n",
46 args->v0.version); 46 args->v0.version);
47 } else 47 } else
@@ -76,10 +76,10 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
76 struct nvkm_cstate *cstate; 76 struct nvkm_cstate *cstate;
77 int i = 0, j = -1; 77 int i = 0, j = -1;
78 u32 lo, hi; 78 u32 lo, hi;
79 int ret; 79 int ret = -ENOSYS;
80 80
81 nvif_ioctl(&ctrl->object, "control pstate attr size %d\n", size); 81 nvif_ioctl(&ctrl->object, "control pstate attr size %d\n", size);
82 if (nvif_unpack(args->v0, 0, 0, false)) { 82 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
83 nvif_ioctl(&ctrl->object, 83 nvif_ioctl(&ctrl->object,
84 "control pstate attr vers %d state %d index %d\n", 84 "control pstate attr vers %d state %d index %d\n",
85 args->v0.version, args->v0.state, args->v0.index); 85 args->v0.version, args->v0.state, args->v0.index);
@@ -144,10 +144,10 @@ nvkm_control_mthd_pstate_user(struct nvkm_control *ctrl, void *data, u32 size)
144 struct nvif_control_pstate_user_v0 v0; 144 struct nvif_control_pstate_user_v0 v0;
145 } *args = data; 145 } *args = data;
146 struct nvkm_clk *clk = ctrl->device->clk; 146 struct nvkm_clk *clk = ctrl->device->clk;
147 int ret; 147 int ret = -ENOSYS;
148 148
149 nvif_ioctl(&ctrl->object, "control pstate user size %d\n", size); 149 nvif_ioctl(&ctrl->object, "control pstate user size %d\n", size);
150 if (nvif_unpack(args->v0, 0, 0, false)) { 150 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
151 nvif_ioctl(&ctrl->object, 151 nvif_ioctl(&ctrl->object,
152 "control pstate user vers %d ustate %d pwrsrc %d\n", 152 "control pstate user vers %d ustate %d pwrsrc %d\n",
153 args->v0.version, args->v0.ustate, args->v0.pwrsrc); 153 args->v0.version, args->v0.ustate, args->v0.pwrsrc);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
index 22a2d7632d49..137066426ed7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
@@ -49,10 +49,10 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
49 union { 49 union {
50 struct nv_device_info_v0 v0; 50 struct nv_device_info_v0 v0;
51 } *args = data; 51 } *args = data;
52 int ret; 52 int ret = -ENOSYS;
53 53
54 nvif_ioctl(object, "device info size %d\n", size); 54 nvif_ioctl(object, "device info size %d\n", size);
55 if (nvif_unpack(args->v0, 0, 0, false)) { 55 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
56 nvif_ioctl(object, "device info vers %d\n", args->v0.version); 56 nvif_ioctl(object, "device info vers %d\n", args->v0.version);
57 } else 57 } else
58 return ret; 58 return ret;
@@ -124,13 +124,16 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size)
124static int 124static int
125nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size) 125nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
126{ 126{
127 struct nvkm_object *object = &udev->object;
127 struct nvkm_device *device = udev->device; 128 struct nvkm_device *device = udev->device;
128 union { 129 union {
129 struct nv_device_time_v0 v0; 130 struct nv_device_time_v0 v0;
130 } *args = data; 131 } *args = data;
131 int ret; 132 int ret = -ENOSYS;
132 133
133 if (nvif_unpack(args->v0, 0, 0, false)) { 134 nvif_ioctl(object, "device time size %d\n", size);
135 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
136 nvif_ioctl(object, "device time vers %d\n", args->v0.version);
134 args->v0.time = nvkm_timer_read(device->timer); 137 args->v0.time = nvkm_timer_read(device->timer);
135 } 138 }
136 139
@@ -141,6 +144,7 @@ static int
141nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 144nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
142{ 145{
143 struct nvkm_udevice *udev = nvkm_udevice(object); 146 struct nvkm_udevice *udev = nvkm_udevice(object);
147 nvif_ioctl(object, "device mthd %08x\n", mthd);
144 switch (mthd) { 148 switch (mthd) {
145 case NV_DEVICE_V0_INFO: 149 case NV_DEVICE_V0_INFO:
146 return nvkm_udevice_info(udev, data, size); 150 return nvkm_udevice_info(udev, data, size);
@@ -332,10 +336,10 @@ nvkm_udevice_new(const struct nvkm_oclass *oclass, void *data, u32 size,
332 struct nvkm_object *parent = &client->object; 336 struct nvkm_object *parent = &client->object;
333 const struct nvkm_object_func *func; 337 const struct nvkm_object_func *func;
334 struct nvkm_udevice *udev; 338 struct nvkm_udevice *udev;
335 int ret; 339 int ret = -ENOSYS;
336 340
337 nvif_ioctl(parent, "create device size %d\n", size); 341 nvif_ioctl(parent, "create device size %d\n", size);
338 if (nvif_unpack(args->v0, 0, 0, false)) { 342 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
339 nvif_ioctl(parent, "create device v%d device %016llx\n", 343 nvif_ioctl(parent, "create device v%d device %016llx\n",
340 args->v0.version, args->v0.device); 344 args->v0.version, args->v0.device);
341 } else 345 } else
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
index 9ac1638ae0ce..785fa76d0fbf 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/base.c
@@ -59,9 +59,9 @@ nvkm_disp_vblank_ctor(struct nvkm_object *object, void *data, u32 size,
59 union { 59 union {
60 struct nvif_notify_head_req_v0 v0; 60 struct nvif_notify_head_req_v0 v0;
61 } *req = data; 61 } *req = data;
62 int ret; 62 int ret = -ENOSYS;
63 63
64 if (nvif_unpack(req->v0, 0, 0, false)) { 64 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, false))) {
65 notify->size = sizeof(struct nvif_notify_head_rep_v0); 65 notify->size = sizeof(struct nvif_notify_head_rep_v0);
66 if (ret = -ENXIO, req->v0.head <= disp->vblank.index_nr) { 66 if (ret = -ENXIO, req->v0.head <= disp->vblank.index_nr) {
67 notify->types = 1; 67 notify->types = 1;
@@ -97,9 +97,9 @@ nvkm_disp_hpd_ctor(struct nvkm_object *object, void *data, u32 size,
97 struct nvif_notify_conn_req_v0 v0; 97 struct nvif_notify_conn_req_v0 v0;
98 } *req = data; 98 } *req = data;
99 struct nvkm_output *outp; 99 struct nvkm_output *outp;
100 int ret; 100 int ret = -ENOSYS;
101 101
102 if (nvif_unpack(req->v0, 0, 0, false)) { 102 if (!(ret = nvif_unpack(ret, &data, &size, req->v0, 0, 0, false))) {
103 notify->size = sizeof(struct nvif_notify_conn_rep_v0); 103 notify->size = sizeof(struct nvif_notify_conn_rep_v0);
104 list_for_each_entry(outp, &disp->outp, head) { 104 list_for_each_entry(outp, &disp->outp, head) {
105 if (ret = -ENXIO, outp->conn->index == req->v0.conn) { 105 if (ret = -ENXIO, outp->conn->index == req->v0.conn) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
index 23e3d43e50a0..83f152300ec0 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/basenv50.c
@@ -42,11 +42,11 @@ nv50_disp_base_new(const struct nv50_disp_dmac_func *func,
42 } *args = data; 42 } *args = data;
43 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
44 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
45 int head, ret; 45 int head, ret = -ENOSYS;
46 u64 push; 46 u64 push;
47 47
48 nvif_ioctl(parent, "create disp base channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp base channel dma size %d\n", size);
49 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
50 nvif_ioctl(parent, "create disp base channel dma vers %d " 50 nvif_ioctl(parent, "create disp base channel dma vers %d "
51 "pushbuf %016llx head %d\n", 51 "pushbuf %016llx head %d\n",
52 args->v0.version, args->v0.pushbuf, args->v0.head); 52 args->v0.version, args->v0.pushbuf, args->v0.head);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
index 41d0ad2646a4..dd2953bc9264 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
@@ -134,9 +134,9 @@ nv50_disp_chan_uevent_ctor(struct nvkm_object *object, void *data, u32 size,
134 union { 134 union {
135 struct nvif_notify_uevent_req none; 135 struct nvif_notify_uevent_req none;
136 } *args = data; 136 } *args = data;
137 int ret; 137 int ret = -ENOSYS;
138 138
139 if (nvif_unvers(args->none)) { 139 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
140 notify->size = sizeof(struct nvif_notify_uevent_rep); 140 notify->size = sizeof(struct nvif_notify_uevent_rep);
141 notify->types = 1; 141 notify->types = 1;
142 notify->index = chan->chid; 142 notify->index = chan->chid;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
index 6901b712da3f..b547c8b833ca 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
@@ -43,10 +43,10 @@ nv50_disp_core_new(const struct nv50_disp_dmac_func *func,
43 } *args = data; 43 } *args = data;
44 struct nvkm_object *parent = oclass->parent; 44 struct nvkm_object *parent = oclass->parent;
45 u64 push; 45 u64 push;
46 int ret; 46 int ret = -ENOSYS;
47 47
48 nvif_ioctl(parent, "create disp core channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp core channel dma size %d\n", size);
49 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
50 nvif_ioctl(parent, "create disp core channel dma vers %d " 50 nvif_ioctl(parent, "create disp core channel dma vers %d "
51 "pushbuf %016llx\n", 51 "pushbuf %016llx\n",
52 args->v0.version, args->v0.pushbuf); 52 args->v0.version, args->v0.pushbuf);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
index 3e9d27ea41a2..8b1320499a0f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/cursnv50.c
@@ -42,10 +42,10 @@ nv50_disp_curs_new(const struct nv50_disp_chan_func *func,
42 } *args = data; 42 } *args = data;
43 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
44 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
45 int head, ret; 45 int head, ret = -ENOSYS;
46 46
47 nvif_ioctl(parent, "create disp cursor size %d\n", size); 47 nvif_ioctl(parent, "create disp cursor size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(parent, "create disp cursor vers %d head %d\n", 49 nvif_ioctl(parent, "create disp cursor vers %d head %d\n",
50 args->v0.version, args->v0.head); 50 args->v0.version, args->v0.head);
51 if (args->v0.head > disp->base.head.nr) 51 if (args->v0.head > disp->base.head.nr)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
index 4a3e0f113ea0..c9b78b8f9c87 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacnv50.c
@@ -39,10 +39,10 @@ nv50_dac_power(NV50_DISP_MTHD_V1)
39 struct nv50_disp_dac_pwr_v0 v0; 39 struct nv50_disp_dac_pwr_v0 v0;
40 } *args = data; 40 } *args = data;
41 u32 stat; 41 u32 stat;
42 int ret; 42 int ret = -ENOSYS;
43 43
44 nvif_ioctl(object, "disp dac pwr size %d\n", size); 44 nvif_ioctl(object, "disp dac pwr size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 45 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(object, "disp dac pwr vers %d state %d data %d " 46 nvif_ioctl(object, "disp dac pwr vers %d state %d data %d "
47 "vsync %d hsync %d\n", 47 "vsync %d hsync %d\n",
48 args->v0.version, args->v0.state, args->v0.data, 48 args->v0.version, args->v0.state, args->v0.data,
@@ -76,10 +76,10 @@ nv50_dac_sense(NV50_DISP_MTHD_V1)
76 } *args = data; 76 } *args = data;
77 const u32 doff = outp->or * 0x800; 77 const u32 doff = outp->or * 0x800;
78 u32 loadval; 78 u32 loadval;
79 int ret; 79 int ret = -ENOSYS;
80 80
81 nvif_ioctl(object, "disp dac load size %d\n", size); 81 nvif_ioctl(object, "disp dac load size %d\n", size);
82 if (nvif_unpack(args->v0, 0, 0, false)) { 82 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
83 nvif_ioctl(object, "disp dac load vers %d data %08x\n", 83 nvif_ioctl(object, "disp dac load vers %d data %08x\n",
84 args->v0.version, args->v0.data); 84 args->v0.version, args->v0.data);
85 if (args->v0.data & 0xfff00000) 85 if (args->v0.data & 0xfff00000)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
index ae7343dda04e..da6129b2b78f 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagf119.c
@@ -41,10 +41,10 @@ gf119_hda_eld(NV50_DISP_MTHD_V1)
41 } *args = data; 41 } *args = data;
42 const u32 soff = outp->or * 0x030; 42 const u32 soff = outp->or * 0x030;
43 const u32 hoff = head * 0x800; 43 const u32 hoff = head * 0x800;
44 int ret, i; 44 int ret = -ENOSYS, i;
45 45
46 nvif_ioctl(object, "disp sor hda eld size %d\n", size); 46 nvif_ioctl(object, "disp sor hda eld size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, true)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
48 nvif_ioctl(object, "disp sor hda eld vers %d\n", 48 nvif_ioctl(object, "disp sor hda eld vers %d\n",
49 args->v0.version); 49 args->v0.version);
50 if (size > 0x60) 50 if (size > 0x60)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
index e6390e974061..6f0436df0219 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdagt215.c
@@ -38,10 +38,10 @@ gt215_hda_eld(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hda_eld_v0 v0; 38 struct nv50_disp_sor_hda_eld_v0 v0;
39 } *args = data; 39 } *args = data;
40 const u32 soff = outp->or * 0x800; 40 const u32 soff = outp->or * 0x800;
41 int ret, i; 41 int ret = -ENOSYS, i;
42 42
43 nvif_ioctl(object, "disp sor hda eld size %d\n", size); 43 nvif_ioctl(object, "disp sor hda eld size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, true)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
45 nvif_ioctl(object, "disp sor hda eld vers %d\n", 45 nvif_ioctl(object, "disp sor hda eld vers %d\n",
46 args->v0.version); 46 args->v0.version);
47 if (size > 0x60) 47 if (size > 0x60)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
index 3eca62a29909..1c4256e8cbd6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmig84.c
@@ -37,10 +37,10 @@ g84_hdmi_ctrl(NV50_DISP_MTHD_V1)
37 struct nv50_disp_sor_hdmi_pwr_v0 v0; 37 struct nv50_disp_sor_hdmi_pwr_v0 v0;
38 } *args = data; 38 } *args = data;
39 u32 ctrl; 39 u32 ctrl;
40 int ret; 40 int ret = -ENOSYS;
41 41
42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
43 if (nvif_unpack(args->v0, 0, 0, false)) { 43 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
45 "max_ac_packet %d rekey %d\n", 45 "max_ac_packet %d rekey %d\n",
46 args->v0.version, args->v0.state, 46 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
index 62ca1feaff66..632f02da1382 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigf119.c
@@ -37,10 +37,10 @@ gf119_hdmi_ctrl(NV50_DISP_MTHD_V1)
37 struct nv50_disp_sor_hdmi_pwr_v0 v0; 37 struct nv50_disp_sor_hdmi_pwr_v0 v0;
38 } *args = data; 38 } *args = data;
39 u32 ctrl; 39 u32 ctrl;
40 int ret; 40 int ret = -ENOSYS;
41 41
42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 42 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
43 if (nvif_unpack(args->v0, 0, 0, false)) { 43 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 44 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
45 "max_ac_packet %d rekey %d\n", 45 "max_ac_packet %d rekey %d\n",
46 args->v0.version, args->v0.state, 46 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
index efba0e12ff1c..4e8067d511d7 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigk104.c
@@ -38,10 +38,10 @@ gk104_hdmi_ctrl(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hdmi_pwr_v0 v0; 38 struct nv50_disp_sor_hdmi_pwr_v0 v0;
39 } *args = data; 39 } *args = data;
40 u32 ctrl; 40 u32 ctrl;
41 int ret; 41 int ret = -ENOSYS;
42 42
43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
46 "max_ac_packet %d rekey %d\n", 46 "max_ac_packet %d rekey %d\n",
47 args->v0.version, args->v0.state, 47 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
index 472444c837bf..f1afc16494b6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/hdmigt215.c
@@ -38,10 +38,10 @@ gt215_hdmi_ctrl(NV50_DISP_MTHD_V1)
38 struct nv50_disp_sor_hdmi_pwr_v0 v0; 38 struct nv50_disp_sor_hdmi_pwr_v0 v0;
39 } *args = data; 39 } *args = data;
40 u32 ctrl; 40 u32 ctrl;
41 int ret; 41 int ret = -ENOSYS;
42 42
43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size); 43 nvif_ioctl(object, "disp sor hdmi ctrl size %d\n", size);
44 if (nvif_unpack(args->v0, 0, 0, false)) { 44 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d " 45 nvif_ioctl(object, "disp sor hdmi ctrl vers %d state %d "
46 "max_ac_packet %d rekey %d\n", 46 "max_ac_packet %d rekey %d\n",
47 args->v0.version, args->v0.state, 47 args->v0.version, args->v0.state,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
index 8e9a06487d14..3940b9c966ec 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/oimmnv50.c
@@ -42,10 +42,10 @@ nv50_disp_oimm_new(const struct nv50_disp_chan_func *func,
42 } *args = data; 42 } *args = data;
43 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
44 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
45 int head, ret; 45 int head, ret = -ENOSYS;
46 46
47 nvif_ioctl(parent, "create disp overlay size %d\n", size); 47 nvif_ioctl(parent, "create disp overlay size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(parent, "create disp overlay vers %d head %d\n", 49 nvif_ioctl(parent, "create disp overlay vers %d head %d\n",
50 args->v0.version, args->v0.head); 50 args->v0.version, args->v0.head);
51 if (args->v0.head > disp->base.head.nr) 51 if (args->v0.head > disp->base.head.nr)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
index 503e9b5761c1..2a49c46425cd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/ovlynv50.c
@@ -42,11 +42,11 @@ nv50_disp_ovly_new(const struct nv50_disp_dmac_func *func,
42 } *args = data; 42 } *args = data;
43 struct nvkm_object *parent = oclass->parent; 43 struct nvkm_object *parent = oclass->parent;
44 struct nv50_disp *disp = root->disp; 44 struct nv50_disp *disp = root->disp;
45 int head, ret; 45 int head, ret = -ENOSYS;
46 u64 push; 46 u64 push;
47 47
48 nvif_ioctl(parent, "create disp overlay channel dma size %d\n", size); 48 nvif_ioctl(parent, "create disp overlay channel dma size %d\n", size);
49 if (nvif_unpack(args->v0, 0, 0, false)) { 49 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
50 nvif_ioctl(parent, "create disp overlay channel dma vers %d " 50 nvif_ioctl(parent, "create disp overlay channel dma vers %d "
51 "pushbuf %016llx head %d\n", 51 "pushbuf %016llx head %d\n",
52 args->v0.version, args->v0.pushbuf, args->v0.head); 52 args->v0.version, args->v0.pushbuf, args->v0.head);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
index dcd1836800bf..6c532eadba17 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/piornv50.c
@@ -40,10 +40,10 @@ nv50_pior_power(NV50_DISP_MTHD_V1)
40 struct nv50_disp_pior_pwr_v0 v0; 40 struct nv50_disp_pior_pwr_v0 v0;
41 } *args = data; 41 } *args = data;
42 u32 ctrl, type; 42 u32 ctrl, type;
43 int ret; 43 int ret = -ENOSYS;
44 44
45 nvif_ioctl(object, "disp pior pwr size %d\n", size); 45 nvif_ioctl(object, "disp pior pwr size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n", 47 nvif_ioctl(object, "disp pior pwr vers %d state %d type %x\n",
48 args->v0.version, args->v0.state, args->v0.type); 48 args->v0.version, args->v0.state, args->v0.type);
49 if (args->v0.type > 0x0f) 49 if (args->v0.type > 0x0f)
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
index 09d12067b1bb..335d88823c22 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgf119.c
@@ -42,10 +42,10 @@ gf119_disp_root_scanoutpos(NV50_DISP_MTHD_V0)
42 union { 42 union {
43 struct nv50_disp_scanoutpos_v0 v0; 43 struct nv50_disp_scanoutpos_v0 v0;
44 } *args = data; 44 } *args = data;
45 int ret; 45 int ret = -ENOSYS;
46 46
47 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 47 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(object, "disp scanoutpos vers %d\n", 49 nvif_ioctl(object, "disp scanoutpos vers %d\n",
50 args->v0.version); 50 args->v0.version);
51 args->v0.vblanke = (blanke & 0xffff0000) >> 16; 51 args->v0.vblanke = (blanke & 0xffff0000) >> 16;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
index d73f1c6e3254..f535f43231e2 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv04.c
@@ -46,10 +46,10 @@ nv04_disp_scanoutpos(struct nv04_disp_root *root,
46 struct nv04_disp_scanoutpos_v0 v0; 46 struct nv04_disp_scanoutpos_v0 v0;
47 } *args = data; 47 } *args = data;
48 u32 line; 48 u32 line;
49 int ret; 49 int ret = -ENOSYS;
50 50
51 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 51 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
52 if (nvif_unpack(args->v0, 0, 0, false)) { 52 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
53 nvif_ioctl(object, "disp scanoutpos vers %d\n", 53 nvif_ioctl(object, "disp scanoutpos vers %d\n",
54 args->v0.version); 54 args->v0.version);
55 args->v0.vblanks = nvkm_rd32(device, 0x680800 + hoff) & 0xffff; 55 args->v0.vblanks = nvkm_rd32(device, 0x680800 + hoff) & 0xffff;
@@ -86,10 +86,10 @@ nv04_disp_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
86 union { 86 union {
87 struct nv04_disp_mthd_v0 v0; 87 struct nv04_disp_mthd_v0 v0;
88 } *args = data; 88 } *args = data;
89 int head, ret; 89 int head, ret = -ENOSYS;
90 90
91 nvif_ioctl(object, "disp mthd size %d\n", size); 91 nvif_ioctl(object, "disp mthd size %d\n", size);
92 if (nvif_unpack(args->v0, 0, 0, true)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
93 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n", 93 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n",
94 args->v0.version, args->v0.method, args->v0.head); 94 args->v0.version, args->v0.method, args->v0.head);
95 mthd = args->v0.method; 95 mthd = args->v0.method;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
index 2aba84d51b1e..2f9cecd81d04 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.c
@@ -42,10 +42,10 @@ nv50_disp_root_scanoutpos(NV50_DISP_MTHD_V0)
42 union { 42 union {
43 struct nv50_disp_scanoutpos_v0 v0; 43 struct nv50_disp_scanoutpos_v0 v0;
44 } *args = data; 44 } *args = data;
45 int ret; 45 int ret = -ENOSYS;
46 46
47 nvif_ioctl(object, "disp scanoutpos size %d\n", size); 47 nvif_ioctl(object, "disp scanoutpos size %d\n", size);
48 if (nvif_unpack(args->v0, 0, 0, false)) { 48 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
49 nvif_ioctl(object, "disp scanoutpos vers %d\n", 49 nvif_ioctl(object, "disp scanoutpos vers %d\n",
50 args->v0.version); 50 args->v0.version);
51 args->v0.vblanke = (blanke & 0xffff0000) >> 16; 51 args->v0.vblanke = (blanke & 0xffff0000) >> 16;
@@ -79,19 +79,19 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
79 struct nvkm_output *outp = NULL; 79 struct nvkm_output *outp = NULL;
80 struct nvkm_output *temp; 80 struct nvkm_output *temp;
81 u16 type, mask = 0; 81 u16 type, mask = 0;
82 int head, ret; 82 int head, ret = -ENOSYS;
83 83
84 if (mthd != NV50_DISP_MTHD) 84 if (mthd != NV50_DISP_MTHD)
85 return -EINVAL; 85 return -EINVAL;
86 86
87 nvif_ioctl(object, "disp mthd size %d\n", size); 87 nvif_ioctl(object, "disp mthd size %d\n", size);
88 if (nvif_unpack(args->v0, 0, 0, true)) { 88 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
89 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n", 89 nvif_ioctl(object, "disp mthd vers %d mthd %02x head %d\n",
90 args->v0.version, args->v0.method, args->v0.head); 90 args->v0.version, args->v0.method, args->v0.head);
91 mthd = args->v0.method; 91 mthd = args->v0.method;
92 head = args->v0.head; 92 head = args->v0.head;
93 } else 93 } else
94 if (nvif_unpack(args->v1, 1, 1, true)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v1, 1, 1, true))) {
95 nvif_ioctl(object, "disp mthd vers %d mthd %02x " 95 nvif_ioctl(object, "disp mthd vers %d mthd %02x "
96 "type %04x mask %04x\n", 96 "type %04x mask %04x\n",
97 args->v1.version, args->v1.method, 97 args->v1.version, args->v1.method,
@@ -144,8 +144,9 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
144 union { 144 union {
145 struct nv50_disp_sor_lvds_script_v0 v0; 145 struct nv50_disp_sor_lvds_script_v0 v0;
146 } *args = data; 146 } *args = data;
147 int ret = -ENOSYS;
147 nvif_ioctl(object, "disp sor lvds script size %d\n", size); 148 nvif_ioctl(object, "disp sor lvds script size %d\n", size);
148 if (nvif_unpack(args->v0, 0, 0, false)) { 149 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
149 nvif_ioctl(object, "disp sor lvds script " 150 nvif_ioctl(object, "disp sor lvds script "
150 "vers %d name %04x\n", 151 "vers %d name %04x\n",
151 args->v0.version, args->v0.script); 152 args->v0.version, args->v0.script);
@@ -160,8 +161,9 @@ nv50_disp_root_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
160 union { 161 union {
161 struct nv50_disp_sor_dp_pwr_v0 v0; 162 struct nv50_disp_sor_dp_pwr_v0 v0;
162 } *args = data; 163 } *args = data;
164 int ret = -ENOSYS;
163 nvif_ioctl(object, "disp sor dp pwr size %d\n", size); 165 nvif_ioctl(object, "disp sor dp pwr size %d\n", size);
164 if (nvif_unpack(args->v0, 0, 0, false)) { 166 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
165 nvif_ioctl(object, "disp sor dp pwr vers %d state %d\n", 167 nvif_ioctl(object, "disp sor dp pwr vers %d state %d\n",
166 args->v0.version, args->v0.state); 168 args->v0.version, args->v0.state);
167 if (args->v0.state == 0) { 169 if (args->v0.state == 0) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
index 6e8c954518d8..53596bed3c36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sornv50.c
@@ -39,10 +39,10 @@ nv50_sor_power(NV50_DISP_MTHD_V1)
39 } *args = data; 39 } *args = data;
40 const u32 soff = outp->or * 0x800; 40 const u32 soff = outp->or * 0x800;
41 u32 stat; 41 u32 stat;
42 int ret; 42 int ret = -ENOSYS;
43 43
44 nvif_ioctl(object, "disp sor pwr size %d\n", size); 44 nvif_ioctl(object, "disp sor pwr size %d\n", size);
45 if (nvif_unpack(args->v0, 0, 0, false)) { 45 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
46 nvif_ioctl(object, "disp sor pwr vers %d state %d\n", 46 nvif_ioctl(object, "disp sor pwr vers %d state %d\n",
47 args->v0.version, args->v0.state); 47 args->v0.version, args->v0.state);
48 stat = !!args->v0.state; 48 stat = !!args->v0.state;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
index 4a4e3b13d6b1..13c661b1ef14 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/user.c
@@ -69,7 +69,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
69 struct nvkm_fb *fb = device->fb; 69 struct nvkm_fb *fb = device->fb;
70 void *data = *pdata; 70 void *data = *pdata;
71 u32 size = *psize; 71 u32 size = *psize;
72 int ret; 72 int ret = -ENOSYS;
73 73
74 nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object); 74 nvkm_object_ctor(&nvkm_dmaobj_func, oclass, &dmaobj->object);
75 dmaobj->func = func; 75 dmaobj->func = func;
@@ -77,7 +77,7 @@ nvkm_dmaobj_ctor(const struct nvkm_dmaobj_func *func, struct nvkm_dma *dma,
77 RB_CLEAR_NODE(&dmaobj->rb); 77 RB_CLEAR_NODE(&dmaobj->rb);
78 78
79 nvif_ioctl(parent, "create dma size %d\n", *psize); 79 nvif_ioctl(parent, "create dma size %d\n", *psize);
80 if (nvif_unpack(args->v0, 0, 0, true)) { 80 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, true))) {
81 nvif_ioctl(parent, "create dma vers %d target %d access %d " 81 nvif_ioctl(parent, "create dma vers %d target %d access %d "
82 "start %016llx limit %016llx\n", 82 "start %016llx limit %016llx\n",
83 args->v0.version, args->v0.target, args->v0.access, 83 args->v0.version, args->v0.target, args->v0.access,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
index 93435a4a6df9..ef7ac360101e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf100.c
@@ -87,10 +87,11 @@ gf100_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
87 if (ret) 87 if (ret)
88 return ret; 88 return ret;
89 89
90 ret = -ENOSYS;
90 args = data; 91 args = data;
91 92
92 nvif_ioctl(parent, "create gf100 dma size %d\n", size); 93 nvif_ioctl(parent, "create gf100 dma size %d\n", size);
93 if (nvif_unpack(args->v0, 0, 0, false)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
94 nvif_ioctl(parent, 95 nvif_ioctl(parent,
95 "create gf100 dma vers %d priv %d kind %02x\n", 96 "create gf100 dma vers %d priv %d kind %02x\n",
96 args->v0.version, args->v0.priv, args->v0.kind); 97 args->v0.version, args->v0.priv, args->v0.kind);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
index fc7c97eaf970..c068cee34588 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usergf119.c
@@ -85,10 +85,11 @@ gf119_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
85 if (ret) 85 if (ret)
86 return ret; 86 return ret;
87 87
88 ret = -ENOSYS;
88 args = data; 89 args = data;
89 90
90 nvif_ioctl(parent, "create gf119 dma size %d\n", size); 91 nvif_ioctl(parent, "create gf119 dma size %d\n", size);
91 if (nvif_unpack(args->v0, 0, 0, false)) { 92 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
92 nvif_ioctl(parent, 93 nvif_ioctl(parent,
93 "create gf100 dma vers %d page %d kind %02x\n", 94 "create gf100 dma vers %d page %d kind %02x\n",
94 args->v0.version, args->v0.page, args->v0.kind); 95 args->v0.version, args->v0.page, args->v0.kind);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
index f3ec8df1dd8c..6a85b5dea643 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/dma/usernv50.c
@@ -87,10 +87,11 @@ nv50_dmaobj_new(struct nvkm_dma *dma, const struct nvkm_oclass *oclass,
87 if (ret) 87 if (ret)
88 return ret; 88 return ret;
89 89
90 ret = -ENOSYS;
90 args = data; 91 args = data;
91 92
92 nvif_ioctl(parent, "create nv50 dma size %d\n", size); 93 nvif_ioctl(parent, "create nv50 dma size %d\n", size);
93 if (nvif_unpack(args->v0, 0, 0, false)) { 94 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
94 nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d " 95 nvif_ioctl(parent, "create nv50 dma vers %d priv %d part %d "
95 "comp %d kind %02x\n", args->v0.version, 96 "comp %d kind %02x\n", args->v0.version,
96 args->v0.priv, args->v0.part, args->v0.comp, 97 args->v0.priv, args->v0.part, args->v0.comp,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
index 1fbbfbe6ca9c..cfc7d5725a61 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/base.c
@@ -129,9 +129,9 @@ nvkm_fifo_uevent_ctor(struct nvkm_object *object, void *data, u32 size,
129 union { 129 union {
130 struct nvif_notify_uevent_req none; 130 struct nvif_notify_uevent_req none;
131 } *req = data; 131 } *req = data;
132 int ret; 132 int ret = -ENOSYS;
133 133
134 if (nvif_unvers(req->none)) { 134 if (!(ret = nvif_unvers(ret, &data, &size, req->none))) {
135 notify->size = sizeof(struct nvif_notify_uevent_rep); 135 notify->size = sizeof(struct nvif_notify_uevent_rep);
136 notify->types = 1; 136 notify->types = 1;
137 notify->index = 0; 137 notify->index = 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
index 4091727d07ed..caa914074752 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmag84.c
@@ -40,10 +40,10 @@ g84_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
40 } *args = data; 40 } *args = data;
41 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
42 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
43 int ret; 43 int ret = -ENOSYS;
44 44
45 nvif_ioctl(parent, "create channel dma size %d\n", size); 45 nvif_ioctl(parent, "create channel dma size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(parent, "create channel dma vers %d vm %llx " 47 nvif_ioctl(parent, "create channel dma vers %d vm %llx "
48 "pushbuf %llx offset %016llx\n", 48 "pushbuf %llx offset %016llx\n",
49 args->v0.version, args->v0.vm, args->v0.pushbuf, 49 args->v0.version, args->v0.vm, args->v0.pushbuf,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
index 51af281a0b14..edec30fd3ecd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv04.c
@@ -168,10 +168,10 @@ nv04_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
168 struct nv04_fifo_chan *chan = NULL; 168 struct nv04_fifo_chan *chan = NULL;
169 struct nvkm_device *device = fifo->base.engine.subdev.device; 169 struct nvkm_device *device = fifo->base.engine.subdev.device;
170 struct nvkm_instmem *imem = device->imem; 170 struct nvkm_instmem *imem = device->imem;
171 int ret; 171 int ret = -ENOSYS;
172 172
173 nvif_ioctl(parent, "create channel dma size %d\n", size); 173 nvif_ioctl(parent, "create channel dma size %d\n", size);
174 if (nvif_unpack(args->v0, 0, 0, false)) { 174 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
175 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 175 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
176 "offset %08x\n", args->v0.version, 176 "offset %08x\n", args->v0.version,
177 args->v0.pushbuf, args->v0.offset); 177 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
index e676af4504c2..f5f355ff005d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv10.c
@@ -44,10 +44,10 @@ nv10_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
44 struct nv04_fifo_chan *chan = NULL; 44 struct nv04_fifo_chan *chan = NULL;
45 struct nvkm_device *device = fifo->base.engine.subdev.device; 45 struct nvkm_device *device = fifo->base.engine.subdev.device;
46 struct nvkm_instmem *imem = device->imem; 46 struct nvkm_instmem *imem = device->imem;
47 int ret; 47 int ret = -ENOSYS;
48 48
49 nvif_ioctl(parent, "create channel dma size %d\n", size); 49 nvif_ioctl(parent, "create channel dma size %d\n", size);
50 if (nvif_unpack(args->v0, 0, 0, false)) { 50 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
52 "offset %08x\n", args->v0.version, 52 "offset %08x\n", args->v0.version,
53 args->v0.pushbuf, args->v0.offset); 53 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
index ee364e287d0a..7edc6a564b5d 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv17.c
@@ -44,10 +44,10 @@ nv17_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
44 struct nv04_fifo_chan *chan = NULL; 44 struct nv04_fifo_chan *chan = NULL;
45 struct nvkm_device *device = fifo->base.engine.subdev.device; 45 struct nvkm_device *device = fifo->base.engine.subdev.device;
46 struct nvkm_instmem *imem = device->imem; 46 struct nvkm_instmem *imem = device->imem;
47 int ret; 47 int ret = -ENOSYS;
48 48
49 nvif_ioctl(parent, "create channel dma size %d\n", size); 49 nvif_ioctl(parent, "create channel dma size %d\n", size);
50 if (nvif_unpack(args->v0, 0, 0, false)) { 50 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 51 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
52 "offset %08x\n", args->v0.version, 52 "offset %08x\n", args->v0.version,
53 args->v0.pushbuf, args->v0.offset); 53 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
index c75a41eaaa24..0ec179fc40a1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv40.c
@@ -189,10 +189,10 @@ nv40_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
189 struct nv04_fifo_chan *chan = NULL; 189 struct nv04_fifo_chan *chan = NULL;
190 struct nvkm_device *device = fifo->base.engine.subdev.device; 190 struct nvkm_device *device = fifo->base.engine.subdev.device;
191 struct nvkm_instmem *imem = device->imem; 191 struct nvkm_instmem *imem = device->imem;
192 int ret; 192 int ret = -ENOSYS;
193 193
194 nvif_ioctl(parent, "create channel dma size %d\n", size); 194 nvif_ioctl(parent, "create channel dma size %d\n", size);
195 if (nvif_unpack(args->v0, 0, 0, false)) { 195 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
196 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx " 196 nvif_ioctl(parent, "create channel dma vers %d pushbuf %llx "
197 "offset %08x\n", args->v0.version, 197 "offset %08x\n", args->v0.version,
198 args->v0.pushbuf, args->v0.offset); 198 args->v0.pushbuf, args->v0.offset);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
index 982bed04c6a4..480bc3777be5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/dmanv50.c
@@ -40,10 +40,10 @@ nv50_fifo_dma_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
40 } *args = data; 40 } *args = data;
41 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
42 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
43 int ret; 43 int ret = -ENOSYS;
44 44
45 nvif_ioctl(parent, "create channel dma size %d\n", size); 45 nvif_ioctl(parent, "create channel dma size %d\n", size);
46 if (nvif_unpack(args->v0, 0, 0, false)) { 46 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
47 nvif_ioctl(parent, "create channel dma vers %d vm %llx " 47 nvif_ioctl(parent, "create channel dma vers %d vm %llx "
48 "pushbuf %llx offset %016llx\n", 48 "pushbuf %llx offset %016llx\n",
49 args->v0.version, args->v0.vm, args->v0.pushbuf, 49 args->v0.version, args->v0.vm, args->v0.pushbuf,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
index e463100f74da..77c2f2a28bf3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifog84.c
@@ -41,10 +41,10 @@ g84_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
41 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
42 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
43 u64 ioffset, ilength; 43 u64 ioffset, ilength;
44 int ret; 44 int ret = -ENOSYS;
45 45
46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
49 "pushbuf %llx ioffset %016llx " 49 "pushbuf %llx ioffset %016llx "
50 "ilength %08x\n", 50 "ilength %08x\n",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
index 8db9cf018c89..cbc67f262322 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogf100.c
@@ -200,10 +200,10 @@ gf100_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
200 struct nvkm_object *parent = oclass->parent; 200 struct nvkm_object *parent = oclass->parent;
201 struct gf100_fifo_chan *chan; 201 struct gf100_fifo_chan *chan;
202 u64 usermem, ioffset, ilength; 202 u64 usermem, ioffset, ilength;
203 int ret, i; 203 int ret = -ENOSYS, i;
204 204
205 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 205 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
206 if (nvif_unpack(args->v0, 0, 0, false)) { 206 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
207 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 207 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
208 "ioffset %016llx ilength %08x\n", 208 "ioffset %016llx ilength %08x\n",
209 args->v0.version, args->v0.vm, args->v0.ioffset, 209 args->v0.version, args->v0.vm, args->v0.ioffset,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
index ba2bfe59c041..2e1df01bd928 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
@@ -214,10 +214,10 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
214 struct gk104_fifo_chan *chan; 214 struct gk104_fifo_chan *chan;
215 u64 usermem, ioffset, ilength; 215 u64 usermem, ioffset, ilength;
216 u32 engines; 216 u32 engines;
217 int ret, i; 217 int ret = -ENOSYS, i;
218 218
219 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 219 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
220 if (nvif_unpack(args->v0, 0, 0, false)) { 220 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
221 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 221 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
222 "ioffset %016llx ilength %08x engine %08x\n", 222 "ioffset %016llx ilength %08x engine %08x\n",
223 args->v0.version, args->v0.vm, args->v0.ioffset, 223 args->v0.version, args->v0.vm, args->v0.ioffset,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
index 94456cad3ef0..c5a7de9db259 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifonv50.c
@@ -41,10 +41,10 @@ nv50_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
41 struct nv50_fifo *fifo = nv50_fifo(base); 41 struct nv50_fifo *fifo = nv50_fifo(base);
42 struct nv50_fifo_chan *chan; 42 struct nv50_fifo_chan *chan;
43 u64 ioffset, ilength; 43 u64 ioffset, ilength;
44 int ret; 44 int ret = -ENOSYS;
45 45
46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size); 46 nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
47 if (nvif_unpack(args->v0, 0, 0, false)) { 47 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx " 48 nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
49 "pushbuf %llx ioffset %016llx " 49 "pushbuf %llx ioffset %016llx "
50 "ilength %08x\n", 50 "ilength %08x\n",
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
index d423a0686a31..3c6effbf19d6 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
@@ -148,9 +148,9 @@ gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size)
148 union { 148 union {
149 struct fermi_a_zbc_color_v0 v0; 149 struct fermi_a_zbc_color_v0 v0;
150 } *args = data; 150 } *args = data;
151 int ret; 151 int ret = -ENOSYS;
152 152
153 if (nvif_unpack(args->v0, 0, 0, false)) { 153 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
154 switch (args->v0.format) { 154 switch (args->v0.format) {
155 case FERMI_A_ZBC_COLOR_V0_FMT_ZERO: 155 case FERMI_A_ZBC_COLOR_V0_FMT_ZERO:
156 case FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE: 156 case FERMI_A_ZBC_COLOR_V0_FMT_UNORM_ONE:
@@ -194,9 +194,9 @@ gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
194 union { 194 union {
195 struct fermi_a_zbc_depth_v0 v0; 195 struct fermi_a_zbc_depth_v0 v0;
196 } *args = data; 196 } *args = data;
197 int ret; 197 int ret = -ENOSYS;
198 198
199 if (nvif_unpack(args->v0, 0, 0, false)) { 199 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
200 switch (args->v0.format) { 200 switch (args->v0.format) {
201 case FERMI_A_ZBC_DEPTH_V0_FMT_FP32: 201 case FERMI_A_ZBC_DEPTH_V0_FMT_FP32:
202 ret = gf100_gr_zbc_depth_get(gr, args->v0.format, 202 ret = gf100_gr_zbc_depth_get(gr, args->v0.format,
@@ -214,6 +214,7 @@ gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
214static int 214static int
215gf100_fermi_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size) 215gf100_fermi_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
216{ 216{
217 nvif_ioctl(object, "fermi mthd %08x\n", mthd);
217 switch (mthd) { 218 switch (mthd) {
218 case FERMI_A_ZBC_COLOR: 219 case FERMI_A_ZBC_COLOR:
219 return gf100_fermi_mthd_zbc_color(object, data, size); 220 return gf100_fermi_mthd_zbc_color(object, data, size);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
index 344b1e5d7f85..f19fabef8d73 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/pm/base.c
@@ -212,10 +212,10 @@ nvkm_perfdom_init(struct nvkm_perfdom *dom, void *data, u32 size)
212 } *args = data; 212 } *args = data;
213 struct nvkm_object *object = &dom->object; 213 struct nvkm_object *object = &dom->object;
214 struct nvkm_pm *pm = dom->perfmon->pm; 214 struct nvkm_pm *pm = dom->perfmon->pm;
215 int ret, i; 215 int ret = -ENOSYS, i;
216 216
217 nvif_ioctl(object, "perfdom init size %d\n", size); 217 nvif_ioctl(object, "perfdom init size %d\n", size);
218 if (nvif_unvers(args->none)) { 218 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
219 nvif_ioctl(object, "perfdom init\n"); 219 nvif_ioctl(object, "perfdom init\n");
220 } else 220 } else
221 return ret; 221 return ret;
@@ -242,10 +242,10 @@ nvkm_perfdom_sample(struct nvkm_perfdom *dom, void *data, u32 size)
242 } *args = data; 242 } *args = data;
243 struct nvkm_object *object = &dom->object; 243 struct nvkm_object *object = &dom->object;
244 struct nvkm_pm *pm = dom->perfmon->pm; 244 struct nvkm_pm *pm = dom->perfmon->pm;
245 int ret; 245 int ret = -ENOSYS;
246 246
247 nvif_ioctl(object, "perfdom sample size %d\n", size); 247 nvif_ioctl(object, "perfdom sample size %d\n", size);
248 if (nvif_unvers(args->none)) { 248 if (!(ret = nvif_unvers(ret, &data, &size, args->none))) {
249 nvif_ioctl(object, "perfdom sample\n"); 249 nvif_ioctl(object, "perfdom sample\n");
250 } else 250 } else
251 return ret; 251 return ret;
@@ -266,10 +266,10 @@ nvkm_perfdom_read(struct nvkm_perfdom *dom, void *data, u32 size)
266 } *args = data; 266 } *args = data;
267 struct nvkm_object *object = &dom->object; 267 struct nvkm_object *object = &dom->object;
268 struct nvkm_pm *pm = dom->perfmon->pm; 268 struct nvkm_pm *pm = dom->perfmon->pm;
269 int ret, i; 269 int ret = -ENOSYS, i;
270 270
271 nvif_ioctl(object, "perfdom read size %d\n", size); 271 nvif_ioctl(object, "perfdom read size %d\n", size);
272 if (nvif_unpack(args->v0, 0, 0, false)) { 272 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
273 nvif_ioctl(object, "perfdom read vers %d\n", args->v0.version); 273 nvif_ioctl(object, "perfdom read vers %d\n", args->v0.version);
274 } else 274 } else
275 return ret; 275 return ret;
@@ -376,10 +376,10 @@ nvkm_perfdom_new_(struct nvkm_perfmon *perfmon,
376 struct nvkm_perfctr *ctr[4] = {}; 376 struct nvkm_perfctr *ctr[4] = {};
377 struct nvkm_perfdom *dom; 377 struct nvkm_perfdom *dom;
378 int c, s, m; 378 int c, s, m;
379 int ret; 379 int ret = -ENOSYS;
380 380
381 nvif_ioctl(parent, "create perfdom size %d\n", size); 381 nvif_ioctl(parent, "create perfdom size %d\n", size);
382 if (nvif_unpack(args->v0, 0, 0, false)) { 382 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
383 nvif_ioctl(parent, "create perfdom vers %d dom %d mode %02x\n", 383 nvif_ioctl(parent, "create perfdom vers %d dom %d mode %02x\n",
384 args->v0.version, args->v0.domain, args->v0.mode); 384 args->v0.version, args->v0.domain, args->v0.mode);
385 } else 385 } else
@@ -441,10 +441,10 @@ nvkm_perfmon_mthd_query_domain(struct nvkm_perfmon *perfmon,
441 struct nvkm_pm *pm = perfmon->pm; 441 struct nvkm_pm *pm = perfmon->pm;
442 struct nvkm_perfdom *dom; 442 struct nvkm_perfdom *dom;
443 u8 domain_nr; 443 u8 domain_nr;
444 int di, ret; 444 int di, ret = -ENOSYS;
445 445
446 nvif_ioctl(object, "perfmon query domain size %d\n", size); 446 nvif_ioctl(object, "perfmon query domain size %d\n", size);
447 if (nvif_unpack(args->v0, 0, 0, false)) { 447 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
448 nvif_ioctl(object, "perfmon domain vers %d iter %02x\n", 448 nvif_ioctl(object, "perfmon domain vers %d iter %02x\n",
449 args->v0.version, args->v0.iter); 449 args->v0.version, args->v0.iter);
450 di = (args->v0.iter & 0xff) - 1; 450 di = (args->v0.iter & 0xff) - 1;
@@ -492,10 +492,10 @@ nvkm_perfmon_mthd_query_signal(struct nvkm_perfmon *perfmon,
492 struct nvkm_perfsig *sig; 492 struct nvkm_perfsig *sig;
493 const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false); 493 const bool all = nvkm_boolopt(device->cfgopt, "NvPmShowAll", false);
494 const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all); 494 const bool raw = nvkm_boolopt(device->cfgopt, "NvPmUnnamed", all);
495 int ret, si; 495 int ret = -ENOSYS, si;
496 496
497 nvif_ioctl(object, "perfmon query signal size %d\n", size); 497 nvif_ioctl(object, "perfmon query signal size %d\n", size);
498 if (nvif_unpack(args->v0, 0, 0, false)) { 498 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
499 nvif_ioctl(object, 499 nvif_ioctl(object,
500 "perfmon query signal vers %d dom %d iter %04x\n", 500 "perfmon query signal vers %d dom %d iter %04x\n",
501 args->v0.version, args->v0.domain, args->v0.iter); 501 args->v0.version, args->v0.domain, args->v0.iter);
@@ -545,10 +545,10 @@ nvkm_perfmon_mthd_query_source(struct nvkm_perfmon *perfmon,
545 struct nvkm_perfsig *sig; 545 struct nvkm_perfsig *sig;
546 struct nvkm_perfsrc *src; 546 struct nvkm_perfsrc *src;
547 u8 source_nr = 0; 547 u8 source_nr = 0;
548 int si, ret; 548 int si, ret = -ENOSYS;
549 549
550 nvif_ioctl(object, "perfmon query source size %d\n", size); 550 nvif_ioctl(object, "perfmon query source size %d\n", size);
551 if (nvif_unpack(args->v0, 0, 0, false)) { 551 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
552 nvif_ioctl(object, 552 nvif_ioctl(object,
553 "perfmon source vers %d dom %d sig %02x iter %02x\n", 553 "perfmon source vers %d dom %d sig %02x iter %02x\n",
554 args->v0.version, args->v0.domain, args->v0.signal, 554 args->v0.version, args->v0.domain, args->v0.signal,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
index d082f4f73a80..f28967065639 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/chan.c
@@ -53,9 +53,9 @@ nvkm_sw_chan_event_ctor(struct nvkm_object *object, void *data, u32 size,
53 union { 53 union {
54 struct nvif_notify_uevent_req none; 54 struct nvif_notify_uevent_req none;
55 } *req = data; 55 } *req = data;
56 int ret; 56 int ret = -ENOSYS;
57 57
58 if (nvif_unvers(req->none)) { 58 if (!(ret = nvif_unvers(ret, &data, &size, req->none))) {
59 notify->size = sizeof(struct nvif_notify_uevent_rep); 59 notify->size = sizeof(struct nvif_notify_uevent_rep);
60 notify->types = 1; 60 notify->types = 1;
61 notify->index = 0; 61 notify->index = 0;
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
index 648caac3841a..b6675fe1b0ce 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/sw/nv04.c
@@ -47,9 +47,9 @@ nv04_nvsw_mthd_get_ref(struct nvkm_nvsw *nvsw, void *data, u32 size)
47 union { 47 union {
48 struct nv04_nvsw_get_ref_v0 v0; 48 struct nv04_nvsw_get_ref_v0 v0;
49 } *args = data; 49 } *args = data;
50 int ret; 50 int ret = -ENOSYS;
51 51
52 if (nvif_unpack(args->v0, 0, 0, false)) { 52 if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
53 args->v0.ref = atomic_read(&chan->ref); 53 args->v0.ref = atomic_read(&chan->ref);
54 } 54 }
55 55