From 8de279f8dbc3403708e28dbdcde95005e697fa2a Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 11 Nov 2020 11:21:05 -0800 Subject: [PATCH] freedreno/drm: Add some locking asserts Also fix evil-twin table_lock which they turned up. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_bo.c | 4 ++++ src/freedreno/drm/freedreno_device.c | 5 +++-- src/freedreno/drm/freedreno_priv.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c index 315a3bbc361..887a3155965 100644 --- a/src/freedreno/drm/freedreno_bo.c +++ b/src/freedreno/drm/freedreno_bo.c @@ -61,6 +61,8 @@ static struct fd_bo * bo_from_handle(struct fd_device *dev, { struct fd_bo *bo; + simple_mtx_assert_locked(&table_lock); + bo = dev->funcs->bo_from_handle(dev, size, handle); if (!bo) { struct drm_gem_close req = { @@ -272,6 +274,8 @@ void bo_del(struct fd_bo *bo) { VG_BO_FREE(bo); + simple_mtx_assert_locked(&table_lock); + if (bo->map) os_munmap(bo->map, bo->size); diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c index 2accf5ce67f..69e40f08d9d 100644 --- a/src/freedreno/drm/freedreno_device.c +++ b/src/freedreno/drm/freedreno_device.c @@ -33,8 +33,6 @@ #include "freedreno_drmif.h" #include "freedreno_priv.h" -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); @@ -110,6 +108,9 @@ struct fd_device * fd_device_ref(struct fd_device *dev) static void fd_device_del_impl(struct fd_device *dev) { int close_fd = dev->closefd ? dev->fd : -1; + + simple_mtx_assert_locked(&table_lock); + fd_bo_cache_cleanup(&dev->bo_cache, 0); fd_bo_cache_cleanup(&dev->ring_cache, 0); _mesa_hash_table_destroy(dev->handle_table, NULL); diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h index 0c7915f761c..982122fa027 100644 --- a/src/freedreno/drm/freedreno_priv.h +++ b/src/freedreno/drm/freedreno_priv.h @@ -51,6 +51,8 @@ #include "freedreno_drmif.h" #include "freedreno_ringbuffer.h" +extern simple_mtx_t table_lock; + struct fd_device_funcs { int (*bo_new_handle)(struct fd_device *dev, uint32_t size, uint32_t flags, uint32_t *handle);