freedreno/drm: Convert to simple_mtx

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7342>
This commit is contained in:
Rob Clark 2020-11-07 11:50:18 -08:00 committed by Marge Bot
parent 57a2a5db81
commit 78b3f58c99
4 changed files with 23 additions and 23 deletions

View file

@ -29,7 +29,7 @@
#include "freedreno_drmif.h"
#include "freedreno_priv.h"
pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER;
simple_mtx_t table_lock = _SIMPLE_MTX_INITIALIZER_NP;
void bo_del(struct fd_bo *bo);
/* set buffer name, and add to table, call w/ table_lock held: */
@ -98,9 +98,9 @@ bo_new(struct fd_device *dev, uint32_t size, uint32_t flags,
if (ret)
return NULL;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
bo = bo_from_handle(dev, size, handle);
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
VG_BO_ALLOC(bo);
@ -145,7 +145,7 @@ fd_bo_from_handle(struct fd_device *dev, uint32_t handle, uint32_t size)
{
struct fd_bo *bo = NULL;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
bo = lookup_bo(dev->handle_table, handle);
if (bo)
@ -156,7 +156,7 @@ fd_bo_from_handle(struct fd_device *dev, uint32_t handle, uint32_t size)
VG_BO_ALLOC(bo);
out_unlock:
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
return bo;
}
@ -168,10 +168,10 @@ fd_bo_from_dmabuf(struct fd_device *dev, int fd)
uint32_t handle;
struct fd_bo *bo;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
return NULL;
}
@ -188,7 +188,7 @@ fd_bo_from_dmabuf(struct fd_device *dev, int fd)
VG_BO_ALLOC(bo);
out_unlock:
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
return bo;
}
@ -200,7 +200,7 @@ struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name)
};
struct fd_bo *bo;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
/* check name table first, to see if bo is already open: */
bo = lookup_bo(dev->name_table, name);
@ -223,7 +223,7 @@ struct fd_bo * fd_bo_from_name(struct fd_device *dev, uint32_t name)
}
out_unlock:
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
return bo;
}
@ -254,7 +254,7 @@ void fd_bo_del(struct fd_bo *bo)
if (!atomic_dec_and_test(&bo->refcnt))
return;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
if ((bo->bo_reuse == BO_CACHE) && (fd_bo_cache_free(&dev->bo_cache, bo) == 0))
goto out;
@ -264,7 +264,7 @@ void fd_bo_del(struct fd_bo *bo)
bo_del(bo);
out:
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
}
/* Called under table_lock */
@ -305,9 +305,9 @@ int fd_bo_get_name(struct fd_bo *bo, uint32_t *name)
return ret;
}
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
set_name(bo, req.name);
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
bo->bo_reuse = NO_CACHE;
}

View file

@ -28,7 +28,7 @@
#include "freedreno_priv.h"
void bo_del(struct fd_bo *bo);
extern pthread_mutex_t table_lock;
extern simple_mtx_t table_lock;
static void
add_bucket(struct fd_bo_cache *cache, int size)
@ -140,7 +140,7 @@ static struct fd_bo *find_in_bucket(struct fd_bo_bucket *bucket, uint32_t flags)
* NOTE that intel takes ALLOC_FOR_RENDER bo's from the list tail
* (MRU, since likely to be in GPU cache), rather than head (LRU)..
*/
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
if (!list_is_empty(&bucket->list)) {
bo = LIST_ENTRY(struct fd_bo, bucket->list.next, list);
/* TODO check for compatible flags? */
@ -150,7 +150,7 @@ static struct fd_bo *find_in_bucket(struct fd_bo_bucket *bucket, uint32_t flags)
bo = NULL;
}
}
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
return bo;
}
@ -174,9 +174,9 @@ retry:
VG_BO_OBTAIN(bo);
if (bo->funcs->madvise(bo, true) <= 0) {
/* we've lost the backing pages, delete and try again: */
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
bo_del(bo);
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
goto retry;
}
p_atomic_set(&bo->refcnt, 1);

View file

@ -33,7 +33,7 @@
#include "freedreno_drmif.h"
#include "freedreno_priv.h"
static pthread_mutex_t table_lock = PTHREAD_MUTEX_INITIALIZER;
static simple_mtx_t table_lock = _SIMPLE_MTX_INITIALIZER_NP;
struct fd_device * kgsl_device_new(int fd);
struct fd_device * msm_device_new(int fd);
@ -130,9 +130,9 @@ void fd_device_del(struct fd_device *dev)
{
if (!atomic_dec_and_test(&dev->refcnt))
return;
pthread_mutex_lock(&table_lock);
simple_mtx_lock(&table_lock);
fd_device_del_impl(dev);
pthread_mutex_unlock(&table_lock);
simple_mtx_unlock(&table_lock);
}
int fd_device_fd(struct fd_device *dev)

View file

@ -35,13 +35,13 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <pthread.h>
#include <stdio.h>
#include <xf86drm.h>
#include "util/hash_table.h"
#include "util/list.h"
#include "util/simple_mtx.h"
#include "util/u_debug.h"
#include "util/u_atomic.h"
#include "util/u_math.h"