etnaviv: drm: Use mesa's atomic definitions
authorGuido Günther <agx@sigxcpu.org>
Fri, 31 May 2019 12:35:06 +0000 (14:35 +0200)
committerGuido Günther <agx@sigxcpu.org>
Wed, 5 Jun 2019 08:58:05 +0000 (08:58 +0000)
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/etnaviv/drm/etnaviv_bo.c
src/etnaviv/drm/etnaviv_bo_cache.c
src/etnaviv/drm/etnaviv_device.c
src/etnaviv/drm/etnaviv_priv.h

index be88241d61b70fae33aeba7832a37a61c3de2a7e..31ad484da4f13f2151ceed6e08c1336acaf650be 100644 (file)
@@ -95,7 +95,7 @@ static struct etna_bo *bo_from_handle(struct etna_device *dev,
        bo->size = size;
        bo->handle = handle;
        bo->flags = flags;
-       atomic_set(&bo->refcnt, 1);
+       p_atomic_set(&bo->refcnt, 1);
        list_inithead(&bo->list);
        /* add ourselves to the handle table: */
        drmHashInsert(dev->handle_table, handle, bo);
@@ -133,7 +133,7 @@ struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
 
 struct etna_bo *etna_bo_ref(struct etna_bo *bo)
 {
-       atomic_inc(&bo->refcnt);
+       p_atomic_inc(&bo->refcnt);
 
        return bo;
 }
@@ -239,7 +239,7 @@ void etna_bo_del(struct etna_bo *bo)
        if (!bo)
                return;
 
-       if (!atomic_dec_and_test(&bo->refcnt))
+       if (!p_atomic_dec_zero(&bo->refcnt))
                return;
 
        pthread_mutex_lock(&table_lock);
index 6da847c724ce3ffed2b6b1935e0da6841ec3bc27..fa0d2a28451e7a1e48ff8f4b6f02664fd8b98725 100644 (file)
@@ -169,7 +169,7 @@ struct etna_bo *etna_bo_cache_alloc(struct etna_bo_cache *cache, uint32_t *size,
                *size = bucket->size;
                bo = find_in_bucket(bucket, flags);
                if (bo) {
-                       atomic_set(&bo->refcnt, 1);
+                       p_atomic_set(&bo->refcnt, 1);
                        etna_device_ref(bo->dev);
                        return bo;
                }
index c1833da5a9f160fc4ebfc2f948dbac4b35343ec4..921ff4d37f744f37aa5cea8ab83f3d6a88e2e8be 100644 (file)
@@ -34,7 +34,6 @@
 #include <pthread.h>
 
 #include <xf86drm.h>
-#include <xf86atomic.h>
 
 #include "etnaviv_priv.h"
 #include "etnaviv_drmif.h"
@@ -48,7 +47,7 @@ struct etna_device *etna_device_new(int fd)
        if (!dev)
                return NULL;
 
-       atomic_set(&dev->refcnt, 1);
+       p_atomic_set(&dev->refcnt, 1);
        dev->fd = fd;
        dev->handle_table = drmHashCreate();
        dev->name_table = drmHashCreate();
@@ -74,7 +73,7 @@ struct etna_device *etna_device_new_dup(int fd)
 
 struct etna_device *etna_device_ref(struct etna_device *dev)
 {
-       atomic_inc(&dev->refcnt);
+       p_atomic_inc(&dev->refcnt);
 
        return dev;
 }
@@ -93,7 +92,7 @@ static void etna_device_del_impl(struct etna_device *dev)
 
 void etna_device_del_locked(struct etna_device *dev)
 {
-       if (!atomic_dec_and_test(&dev->refcnt))
+       if (!p_atomic_dec_zero(&dev->refcnt))
                return;
 
        etna_device_del_impl(dev);
@@ -101,7 +100,7 @@ void etna_device_del_locked(struct etna_device *dev)
 
 void etna_device_del(struct etna_device *dev)
 {
-       if (!atomic_dec_and_test(&dev->refcnt))
+       if (!p_atomic_dec_zero(&dev->refcnt))
                return;
 
        pthread_mutex_lock(&table_lock);
index aabace03f2b51bbbee9e5cb0fcccb1d4747207ca..d13cfe73686aa31d6b23d18f229f2159e8c8f5db 100644 (file)
@@ -40,6 +40,9 @@
 
 #include <xf86drm.h>
 
+#include "util/list.h"
+#include "util/u_atomic.h"
+
 #include "etnaviv_drmif.h"
 #include "etnaviv_drm.h"
 
@@ -56,7 +59,7 @@ struct etna_bo_cache {
 
 struct etna_device {
        int fd;
-       atomic_t refcnt;
+       int refcnt;
 
        /* tables to keep track of bo's, to avoid "evil-twin" etna_bo objects:
         *
@@ -92,7 +95,7 @@ struct etna_bo {
        uint32_t        flags;
        uint32_t        name;           /* flink global handle (DRI2 name) */
        uint64_t        offset;         /* offset to mmap() */
-       atomic_t        refcnt;
+       int             refcnt;
 
        /* in the common case, a bo won't be referenced by more than a single
         * command stream.  So to avoid looping over all the bo's in the