aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2010-10-20 15:50:24 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-12-03 00:11:07 -0500
commit382d62e524db528cdf53563ad9a018adc170dfde (patch)
tree84a7268a64ce58a4dfe533b4e3a5cef79b883053 /drivers
parent5f80198e43cf96542923269ccb607052e5f144cc (diff)
drm/nouveau: fix annoying nouveau_fence type issue
nouveau_fence_* functions are not type safe, which could lead to bugs. Additionally every use of nouveau_fence_unref had to cast struct nouveau_fence to void **. Fix it by renaming old functions and creating static inline functions with new prototypes. We still need old functions, because we pass function pointers to ttm. As we are wrapping functions, drop unused "void *arg" parameter where possible. Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Francisco Jerez <currojerez@riseup.net> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c12
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h33
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fence.c22
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c4
7 files changed, 53 insertions, 30 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 8442bfbf5d42..c09928322eb9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -487,7 +487,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
487 487
488 ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, NULL, evict, 488 ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, NULL, evict,
489 no_wait_reserve, no_wait_gpu, new_mem); 489 no_wait_reserve, no_wait_gpu, new_mem);
490 nouveau_fence_unref((void *)&fence); 490 nouveau_fence_unref(&fence);
491 return ret; 491 return ret;
492} 492}
493 493
@@ -949,11 +949,11 @@ struct ttm_bo_driver nouveau_bo_driver = {
949 .evict_flags = nouveau_bo_evict_flags, 949 .evict_flags = nouveau_bo_evict_flags,
950 .move = nouveau_bo_move, 950 .move = nouveau_bo_move,
951 .verify_access = nouveau_bo_verify_access, 951 .verify_access = nouveau_bo_verify_access,
952 .sync_obj_signaled = nouveau_fence_signalled, 952 .sync_obj_signaled = __nouveau_fence_signalled,
953 .sync_obj_wait = nouveau_fence_wait, 953 .sync_obj_wait = __nouveau_fence_wait,
954 .sync_obj_flush = nouveau_fence_flush, 954 .sync_obj_flush = __nouveau_fence_flush,
955 .sync_obj_unref = nouveau_fence_unref, 955 .sync_obj_unref = __nouveau_fence_unref,
956 .sync_obj_ref = nouveau_fence_ref, 956 .sync_obj_ref = __nouveau_fence_ref,
957 .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify, 957 .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify,
958 .io_mem_reserve = &nouveau_ttm_io_mem_reserve, 958 .io_mem_reserve = &nouveau_ttm_io_mem_reserve,
959 .io_mem_free = &nouveau_ttm_io_mem_free, 959 .io_mem_free = &nouveau_ttm_io_mem_free,
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index f2d674202369..c9cdbd786dae 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -303,8 +303,8 @@ nouveau_channel_put_unlocked(struct nouveau_channel **pchan)
303 303
304 ret = nouveau_fence_new(chan, &fence, true); 304 ret = nouveau_fence_new(chan, &fence, true);
305 if (ret == 0) { 305 if (ret == 0) {
306 ret = nouveau_fence_wait(fence, NULL, false, false); 306 ret = nouveau_fence_wait(fence, false, false);
307 nouveau_fence_unref((void *)&fence); 307 nouveau_fence_unref(&fence);
308 } 308 }
309 309
310 if (ret) 310 if (ret)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index db926ecf5b6f..15f48493d0d8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -205,8 +205,8 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
205 205
206 ret = nouveau_fence_new(chan, &fence, true); 206 ret = nouveau_fence_new(chan, &fence, true);
207 if (ret == 0) { 207 if (ret == 0) {
208 ret = nouveau_fence_wait(fence, NULL, false, false); 208 ret = nouveau_fence_wait(fence, false, false);
209 nouveau_fence_unref((void *)&fence); 209 nouveau_fence_unref(&fence);
210 } 210 }
211 211
212 if (ret) { 212 if (ret) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 9ab7dc8ede4e..a356d894a2ee 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -1264,12 +1264,35 @@ extern void nouveau_fence_work(struct nouveau_fence *fence,
1264 void (*work)(void *priv, bool signalled), 1264 void (*work)(void *priv, bool signalled),
1265 void *priv); 1265 void *priv);
1266struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *); 1266struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *);
1267extern bool nouveau_fence_signalled(void *obj, void *arg); 1267
1268extern int nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr); 1268extern bool __nouveau_fence_signalled(void *obj, void *arg);
1269extern int __nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);
1270extern int __nouveau_fence_flush(void *obj, void *arg);
1271extern void __nouveau_fence_unref(void **obj);
1272extern void *__nouveau_fence_ref(void *obj);
1273
1274static inline bool nouveau_fence_signalled(struct nouveau_fence *obj)
1275{
1276 return __nouveau_fence_signalled(obj, NULL);
1277}
1278static inline int
1279nouveau_fence_wait(struct nouveau_fence *obj, bool lazy, bool intr)
1280{
1281 return __nouveau_fence_wait(obj, NULL, lazy, intr);
1282}
1269extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *); 1283extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);
1270extern int nouveau_fence_flush(void *obj, void *arg); 1284static inline int nouveau_fence_flush(struct nouveau_fence *obj)
1271extern void nouveau_fence_unref(void **obj); 1285{
1272extern void *nouveau_fence_ref(void *obj); 1286 return __nouveau_fence_flush(obj, NULL);
1287}
1288static inline void nouveau_fence_unref(struct nouveau_fence **obj)
1289{
1290 __nouveau_fence_unref((void **)obj);
1291}
1292static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj)
1293{
1294 return __nouveau_fence_ref(obj);
1295}
1273 1296
1274/* nouveau_gem.c */ 1297/* nouveau_gem.c */
1275extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *, 1298extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,
diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index 75ce1b45d8a4..91aa6c54cc96 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -120,7 +120,7 @@ nouveau_fence_new(struct nouveau_channel *chan, struct nouveau_fence **pfence,
120 ret = nouveau_fence_emit(fence); 120 ret = nouveau_fence_emit(fence);
121 121
122 if (ret) 122 if (ret)
123 nouveau_fence_unref((void *)&fence); 123 nouveau_fence_unref(&fence);
124 *pfence = fence; 124 *pfence = fence;
125 return ret; 125 return ret;
126} 126}
@@ -183,7 +183,7 @@ nouveau_fence_work(struct nouveau_fence *fence,
183} 183}
184 184
185void 185void
186nouveau_fence_unref(void **sync_obj) 186__nouveau_fence_unref(void **sync_obj)
187{ 187{
188 struct nouveau_fence *fence = nouveau_fence(*sync_obj); 188 struct nouveau_fence *fence = nouveau_fence(*sync_obj);
189 189
@@ -193,7 +193,7 @@ nouveau_fence_unref(void **sync_obj)
193} 193}
194 194
195void * 195void *
196nouveau_fence_ref(void *sync_obj) 196__nouveau_fence_ref(void *sync_obj)
197{ 197{
198 struct nouveau_fence *fence = nouveau_fence(sync_obj); 198 struct nouveau_fence *fence = nouveau_fence(sync_obj);
199 199
@@ -202,7 +202,7 @@ nouveau_fence_ref(void *sync_obj)
202} 202}
203 203
204bool 204bool
205nouveau_fence_signalled(void *sync_obj, void *sync_arg) 205__nouveau_fence_signalled(void *sync_obj, void *sync_arg)
206{ 206{
207 struct nouveau_fence *fence = nouveau_fence(sync_obj); 207 struct nouveau_fence *fence = nouveau_fence(sync_obj);
208 struct nouveau_channel *chan = fence->channel; 208 struct nouveau_channel *chan = fence->channel;
@@ -215,13 +215,13 @@ nouveau_fence_signalled(void *sync_obj, void *sync_arg)
215} 215}
216 216
217int 217int
218nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr) 218__nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
219{ 219{
220 unsigned long timeout = jiffies + (3 * DRM_HZ); 220 unsigned long timeout = jiffies + (3 * DRM_HZ);
221 int ret = 0; 221 int ret = 0;
222 222
223 while (1) { 223 while (1) {
224 if (nouveau_fence_signalled(sync_obj, sync_arg)) 224 if (__nouveau_fence_signalled(sync_obj, sync_arg))
225 break; 225 break;
226 226
227 if (time_after_eq(jiffies, timeout)) { 227 if (time_after_eq(jiffies, timeout)) {
@@ -369,7 +369,7 @@ emit_semaphore(struct nouveau_channel *chan, int method,
369 369
370 kref_get(&sema->ref); 370 kref_get(&sema->ref);
371 nouveau_fence_work(fence, semaphore_work, sema); 371 nouveau_fence_work(fence, semaphore_work, sema);
372 nouveau_fence_unref((void *)&fence); 372 nouveau_fence_unref(&fence);
373 373
374 return 0; 374 return 0;
375} 375}
@@ -384,14 +384,14 @@ nouveau_fence_sync(struct nouveau_fence *fence,
384 int ret = 0; 384 int ret = 0;
385 385
386 if (likely(!chan || chan == wchan || 386 if (likely(!chan || chan == wchan ||
387 nouveau_fence_signalled(fence, NULL))) 387 nouveau_fence_signalled(fence)))
388 goto out; 388 goto out;
389 389
390 sema = alloc_semaphore(dev); 390 sema = alloc_semaphore(dev);
391 if (!sema) { 391 if (!sema) {
392 /* Early card or broken userspace, fall back to 392 /* Early card or broken userspace, fall back to
393 * software sync. */ 393 * software sync. */
394 ret = nouveau_fence_wait(fence, NULL, true, false); 394 ret = nouveau_fence_wait(fence, true, false);
395 goto out; 395 goto out;
396 } 396 }
397 397
@@ -400,7 +400,7 @@ nouveau_fence_sync(struct nouveau_fence *fence,
400 * order issues 400 * order issues
401 */ 401 */
402 if (!mutex_trylock(&chan->mutex)) { 402 if (!mutex_trylock(&chan->mutex)) {
403 ret = nouveau_fence_wait(fence, NULL, true, false); 403 ret = nouveau_fence_wait(fence, true, false);
404 goto out_unref; 404 goto out_unref;
405 } 405 }
406 406
@@ -423,7 +423,7 @@ out:
423} 423}
424 424
425int 425int
426nouveau_fence_flush(void *sync_obj, void *sync_arg) 426__nouveau_fence_flush(void *sync_obj, void *sync_arg)
427{ 427{
428 return 0; 428 return 0;
429} 429}
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 23b521ea8e04..de8535b58710 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -238,7 +238,7 @@ validate_fini_list(struct list_head *list, struct nouveau_fence *fence)
238 prev_fence = nvbo->bo.sync_obj; 238 prev_fence = nvbo->bo.sync_obj;
239 nvbo->bo.sync_obj = nouveau_fence_ref(fence); 239 nvbo->bo.sync_obj = nouveau_fence_ref(fence);
240 spin_unlock(&nvbo->bo.bdev->fence_lock); 240 spin_unlock(&nvbo->bo.bdev->fence_lock);
241 nouveau_fence_unref((void *)&prev_fence); 241 nouveau_fence_unref(&prev_fence);
242 } 242 }
243 243
244 if (unlikely(nvbo->validate_mapped)) { 244 if (unlikely(nvbo->validate_mapped)) {
@@ -728,7 +728,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
728 728
729out: 729out:
730 validate_fini(&op, fence); 730 validate_fini(&op, fence);
731 nouveau_fence_unref((void**)&fence); 731 nouveau_fence_unref(&fence);
732 kfree(bo); 732 kfree(bo);
733 kfree(push); 733 kfree(push);
734 734
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index fe4a30dc4b42..a7c3e08aa7b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -54,7 +54,7 @@ nv10_mem_set_region_tiling(struct drm_device *dev, int i, uint32_t addr,
54 tile->addr = addr; 54 tile->addr = addr;
55 tile->size = size; 55 tile->size = size;
56 tile->used = !!pitch; 56 tile->used = !!pitch;
57 nouveau_fence_unref((void **)&tile->fence); 57 nouveau_fence_unref(&tile->fence);
58 58
59 pfifo->reassign(dev, false); 59 pfifo->reassign(dev, false);
60 pfifo->cache_pull(dev, false); 60 pfifo->cache_pull(dev, false);
@@ -87,7 +87,7 @@ nv10_mem_set_tiling(struct drm_device *dev, uint32_t addr, uint32_t size,
87 continue; 87 continue;
88 88
89 if (tile->fence && 89 if (tile->fence &&
90 !nouveau_fence_signalled(tile->fence, NULL)) 90 !nouveau_fence_signalled(tile->fence))
91 /* Pending tile region. */ 91 /* Pending tile region. */
92 continue; 92 continue;
93 93