etnaviv/drm: convert to simple_mtx

We do not need a full blown pthread mutex.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7832>
This commit is contained in:
Christian Gmeiner 2020-11-30 09:39:35 +01:00 committed by Marge Bot
parent aad0c7c6b8
commit 034dd948df
5 changed files with 21 additions and 21 deletions

View File

@ -30,7 +30,7 @@
#include "etnaviv_priv.h"
#include "etnaviv_drmif.h"
pthread_mutex_t etna_drm_table_lock = PTHREAD_MUTEX_INITIALIZER;
simple_mtx_t etna_drm_table_lock = _SIMPLE_MTX_INITIALIZER_NP;
void _etna_bo_del(struct etna_bo *bo);
/* set buffer name, and add to table, call w/ etna_drm_table_lock held: */
@ -135,10 +135,10 @@ struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
if (ret)
return NULL;
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
bo = bo_from_handle(dev, size, req.handle, flags);
bo->reuse = 1;
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
VG_BO_ALLOC(bo);
@ -181,7 +181,7 @@ struct etna_bo *etna_bo_from_name(struct etna_device *dev,
.name = name,
};
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
/* check name table first, to see if bo is already open: */
bo = lookup_bo(dev->name_table, name);
@ -204,7 +204,7 @@ struct etna_bo *etna_bo_from_name(struct etna_device *dev,
}
out_unlock:
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
return bo;
}
@ -223,11 +223,11 @@ struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
* racing against etna_bo_del, which might invalidate the
* returned handle.
*/
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
return NULL;
}
@ -244,7 +244,7 @@ struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
VG_BO_ALLOC(bo);
out_unlock:
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
return bo;
}
@ -257,7 +257,7 @@ void etna_bo_del(struct etna_bo *bo)
struct etna_device *dev = bo->dev;
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
/* Must test under table lock to avoid racing with the from_dmabuf/name
* paths, which rely on the BO refcount to be stable over the lookup, so
@ -272,7 +272,7 @@ void etna_bo_del(struct etna_bo *bo)
_etna_bo_del(bo);
etna_device_del_locked(dev);
out:
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
}
/* get the global flink/DRI2 buffer name */
@ -289,9 +289,9 @@ int etna_bo_get_name(struct etna_bo *bo, uint32_t *name)
return ret;
}
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
set_name(bo, req.name);
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
bo->reuse = 0;
}

View File

@ -122,7 +122,7 @@ static struct etna_bo *find_in_bucket(struct etna_bo_bucket *bucket, uint32_t fl
{
struct etna_bo *bo = NULL, *tmp;
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
if (list_is_empty(&bucket->list))
goto out_unlock;
@ -146,7 +146,7 @@ static struct etna_bo *find_in_bucket(struct etna_bo_bucket *bucket, uint32_t fl
bo = NULL;
out_unlock:
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
return bo;
}

View File

@ -30,7 +30,7 @@
#include "etnaviv_drmif.h"
#include "etnaviv_priv.h"
static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER;
static simple_mtx_t idx_lock = _SIMPLE_MTX_INITIALIZER_NP;
static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
{
@ -173,7 +173,7 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo,
struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream);
uint32_t idx;
pthread_mutex_lock(&idx_lock);
simple_mtx_lock(&idx_lock);
if (bo->current_stream == stream) {
idx = bo->idx;
@ -195,7 +195,7 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo,
bo->current_stream = stream;
bo->idx = idx;
}
pthread_mutex_unlock(&idx_lock);
simple_mtx_unlock(&idx_lock);
if (flags & ETNA_RELOC_READ)
priv->submit.bos[idx].flags |= ETNA_SUBMIT_BO_READ;

View File

@ -109,9 +109,9 @@ void etna_device_del(struct etna_device *dev)
if (!p_atomic_dec_zero(&dev->refcnt))
return;
pthread_mutex_lock(&etna_drm_table_lock);
simple_mtx_lock(&etna_drm_table_lock);
etna_device_del_impl(dev);
pthread_mutex_unlock(&etna_drm_table_lock);
simple_mtx_unlock(&etna_drm_table_lock);
}
int etna_device_fd(struct etna_device *dev)

View File

@ -34,7 +34,6 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <pthread.h>
#include <stdio.h>
#include <assert.h>
@ -42,6 +41,7 @@
#include "util/list.h"
#include "util/macros.h"
#include "util/simple_mtx.h"
#include "util/timespec.h"
#include "util/u_atomic.h"
#include "util/u_debug.h"
@ -50,7 +50,7 @@
#include "etnaviv_drmif.h"
#include "drm-uapi/etnaviv_drm.h"
extern pthread_mutex_t etna_drm_table_lock;
extern simple_mtx_t etna_drm_table_lock;
struct etna_bo_bucket {
uint32_t size;