]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
drm/nouveau: fix annoying nouveau_fence type issue
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Wed, 20 Oct 2010 19:50:24 +0000 (21:50 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 3 Dec 2010 05:11:07 +0000 (15:11 +1000)
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>
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_channel.c
drivers/gpu/drm/nouveau/nouveau_drv.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_mem.c

index 8442bfbf5d4240c9715f66601b72222c4647bbac..c09928322eb9dffc110df2cb38b912e9c768fedf 100644 (file)
@@ -487,7 +487,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
 
        ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, NULL, evict,
                                        no_wait_reserve, no_wait_gpu, new_mem);
-       nouveau_fence_unref((void *)&fence);
+       nouveau_fence_unref(&fence);
        return ret;
 }
 
@@ -949,11 +949,11 @@ struct ttm_bo_driver nouveau_bo_driver = {
        .evict_flags = nouveau_bo_evict_flags,
        .move = nouveau_bo_move,
        .verify_access = nouveau_bo_verify_access,
-       .sync_obj_signaled = nouveau_fence_signalled,
-       .sync_obj_wait = nouveau_fence_wait,
-       .sync_obj_flush = nouveau_fence_flush,
-       .sync_obj_unref = nouveau_fence_unref,
-       .sync_obj_ref = nouveau_fence_ref,
+       .sync_obj_signaled = __nouveau_fence_signalled,
+       .sync_obj_wait = __nouveau_fence_wait,
+       .sync_obj_flush = __nouveau_fence_flush,
+       .sync_obj_unref = __nouveau_fence_unref,
+       .sync_obj_ref = __nouveau_fence_ref,
        .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify,
        .io_mem_reserve = &nouveau_ttm_io_mem_reserve,
        .io_mem_free = &nouveau_ttm_io_mem_free,
index f2d674202369bfdac2d9c705e7577add4d7afeda..c9cdbd786dae7adda06460f90ae8af015aca4065 100644 (file)
@@ -303,8 +303,8 @@ nouveau_channel_put_unlocked(struct nouveau_channel **pchan)
 
                ret = nouveau_fence_new(chan, &fence, true);
                if (ret == 0) {
-                       ret = nouveau_fence_wait(fence, NULL, false, false);
-                       nouveau_fence_unref((void *)&fence);
+                       ret = nouveau_fence_wait(fence, false, false);
+                       nouveau_fence_unref(&fence);
                }
 
                if (ret)
index db926ecf5b6f406e150f096c11ea24ff36389e6f..15f48493d0d8835a20a706b2115f1bdc75bd1b1d 100644 (file)
@@ -205,8 +205,8 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
 
                ret = nouveau_fence_new(chan, &fence, true);
                if (ret == 0) {
-                       ret = nouveau_fence_wait(fence, NULL, false, false);
-                       nouveau_fence_unref((void *)&fence);
+                       ret = nouveau_fence_wait(fence, false, false);
+                       nouveau_fence_unref(&fence);
                }
 
                if (ret) {
index 9ab7dc8ede4e4e579bdd550ce0808e74d2ac7090..a356d894a2eebb3909c6c41895c45ff0a2d56452 100644 (file)
@@ -1264,12 +1264,35 @@ extern void nouveau_fence_work(struct nouveau_fence *fence,
                               void (*work)(void *priv, bool signalled),
                               void *priv);
 struct nouveau_channel *nouveau_fence_channel(struct nouveau_fence *);
-extern bool nouveau_fence_signalled(void *obj, void *arg);
-extern int nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);
+
+extern bool __nouveau_fence_signalled(void *obj, void *arg);
+extern int __nouveau_fence_wait(void *obj, void *arg, bool lazy, bool intr);
+extern int __nouveau_fence_flush(void *obj, void *arg);
+extern void __nouveau_fence_unref(void **obj);
+extern void *__nouveau_fence_ref(void *obj);
+
+static inline bool nouveau_fence_signalled(struct nouveau_fence *obj)
+{
+       return __nouveau_fence_signalled(obj, NULL);
+}
+static inline int
+nouveau_fence_wait(struct nouveau_fence *obj, bool lazy, bool intr)
+{
+       return __nouveau_fence_wait(obj, NULL, lazy, intr);
+}
 extern int nouveau_fence_sync(struct nouveau_fence *, struct nouveau_channel *);
-extern int nouveau_fence_flush(void *obj, void *arg);
-extern void nouveau_fence_unref(void **obj);
-extern void *nouveau_fence_ref(void *obj);
+static inline int nouveau_fence_flush(struct nouveau_fence *obj)
+{
+       return __nouveau_fence_flush(obj, NULL);
+}
+static inline void nouveau_fence_unref(struct nouveau_fence **obj)
+{
+       __nouveau_fence_unref((void **)obj);
+}
+static inline struct nouveau_fence *nouveau_fence_ref(struct nouveau_fence *obj)
+{
+       return __nouveau_fence_ref(obj);
+}
 
 /* nouveau_gem.c */
 extern int nouveau_gem_new(struct drm_device *, struct nouveau_channel *,
index 75ce1b45d8a473b8f7a901d730a73c06475934db..91aa6c54cc9654196b39096b452b3855eb75074b 100644 (file)
@@ -120,7 +120,7 @@ nouveau_fence_new(struct nouveau_channel *chan, struct nouveau_fence **pfence,
                ret = nouveau_fence_emit(fence);
 
        if (ret)
-               nouveau_fence_unref((void *)&fence);
+               nouveau_fence_unref(&fence);
        *pfence = fence;
        return ret;
 }
@@ -183,7 +183,7 @@ nouveau_fence_work(struct nouveau_fence *fence,
 }
 
 void
-nouveau_fence_unref(void **sync_obj)
+__nouveau_fence_unref(void **sync_obj)
 {
        struct nouveau_fence *fence = nouveau_fence(*sync_obj);
 
@@ -193,7 +193,7 @@ nouveau_fence_unref(void **sync_obj)
 }
 
 void *
-nouveau_fence_ref(void *sync_obj)
+__nouveau_fence_ref(void *sync_obj)
 {
        struct nouveau_fence *fence = nouveau_fence(sync_obj);
 
@@ -202,7 +202,7 @@ nouveau_fence_ref(void *sync_obj)
 }
 
 bool
-nouveau_fence_signalled(void *sync_obj, void *sync_arg)
+__nouveau_fence_signalled(void *sync_obj, void *sync_arg)
 {
        struct nouveau_fence *fence = nouveau_fence(sync_obj);
        struct nouveau_channel *chan = fence->channel;
@@ -215,13 +215,13 @@ nouveau_fence_signalled(void *sync_obj, void *sync_arg)
 }
 
 int
-nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
+__nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
 {
        unsigned long timeout = jiffies + (3 * DRM_HZ);
        int ret = 0;
 
        while (1) {
-               if (nouveau_fence_signalled(sync_obj, sync_arg))
+               if (__nouveau_fence_signalled(sync_obj, sync_arg))
                        break;
 
                if (time_after_eq(jiffies, timeout)) {
@@ -369,7 +369,7 @@ emit_semaphore(struct nouveau_channel *chan, int method,
 
        kref_get(&sema->ref);
        nouveau_fence_work(fence, semaphore_work, sema);
-       nouveau_fence_unref((void *)&fence);
+       nouveau_fence_unref(&fence);
 
        return 0;
 }
@@ -384,14 +384,14 @@ nouveau_fence_sync(struct nouveau_fence *fence,
        int ret = 0;
 
        if (likely(!chan || chan == wchan ||
-                  nouveau_fence_signalled(fence, NULL)))
+                  nouveau_fence_signalled(fence)))
                goto out;
 
        sema = alloc_semaphore(dev);
        if (!sema) {
                /* Early card or broken userspace, fall back to
                 * software sync. */
-               ret = nouveau_fence_wait(fence, NULL, true, false);
+               ret = nouveau_fence_wait(fence, true, false);
                goto out;
        }
 
@@ -400,7 +400,7 @@ nouveau_fence_sync(struct nouveau_fence *fence,
         * order issues
         */
        if (!mutex_trylock(&chan->mutex)) {
-               ret = nouveau_fence_wait(fence, NULL, true, false);
+               ret = nouveau_fence_wait(fence, true, false);
                goto out_unref;
        }
 
@@ -423,7 +423,7 @@ out:
 }
 
 int
-nouveau_fence_flush(void *sync_obj, void *sync_arg)
+__nouveau_fence_flush(void *sync_obj, void *sync_arg)
 {
        return 0;
 }
index 23b521ea8e040dbfb421e4f1c3fba8d860e87d17..de8535b58710dc1b43a1814f69ffa0fb9ce335b6 100644 (file)
@@ -238,7 +238,7 @@ validate_fini_list(struct list_head *list, struct nouveau_fence *fence)
                        prev_fence = nvbo->bo.sync_obj;
                        nvbo->bo.sync_obj = nouveau_fence_ref(fence);
                        spin_unlock(&nvbo->bo.bdev->fence_lock);
-                       nouveau_fence_unref((void *)&prev_fence);
+                       nouveau_fence_unref(&prev_fence);
                }
 
                if (unlikely(nvbo->validate_mapped)) {
@@ -728,7 +728,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 
 out:
        validate_fini(&op, fence);
-       nouveau_fence_unref((void**)&fence);
+       nouveau_fence_unref(&fence);
        kfree(bo);
        kfree(push);
 
index fe4a30dc4b42e929f283d35e1094b26a422f4f2e..a7c3e08aa7b5320b071fb73a292424bce575ea2c 100644 (file)
@@ -54,7 +54,7 @@ nv10_mem_set_region_tiling(struct drm_device *dev, int i, uint32_t addr,
        tile->addr = addr;
        tile->size = size;
        tile->used = !!pitch;
-       nouveau_fence_unref((void **)&tile->fence);
+       nouveau_fence_unref(&tile->fence);
 
        pfifo->reassign(dev, false);
        pfifo->cache_pull(dev, false);
@@ -87,7 +87,7 @@ nv10_mem_set_tiling(struct drm_device *dev, uint32_t addr, uint32_t size,
                        continue;
 
                if (tile->fence &&
-                   !nouveau_fence_signalled(tile->fence, NULL))
+                   !nouveau_fence_signalled(tile->fence))
                        /* Pending tile region. */
                        continue;