freedreno/drm: Get rid of fd_bo_del_locked()
This moves the table_lock into a small critical section in the BO delete path when we are actually removing the entries from the handle/name tables, so finally table_lock isn't the big-bo-lock! Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>
This commit is contained in:
@@ -274,8 +274,6 @@ bo_del_or_recycle(struct fd_bo *bo)
|
||||
{
|
||||
struct fd_device *dev = bo->dev;
|
||||
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
if ((bo->bo_reuse == BO_CACHE) &&
|
||||
(fd_bo_cache_free(&dev->bo_cache, bo) == 0))
|
||||
return 0;
|
||||
@@ -287,21 +285,6 @@ bo_del_or_recycle(struct fd_bo *bo)
|
||||
return bo_del(bo);
|
||||
}
|
||||
|
||||
void
|
||||
fd_bo_del_locked(struct fd_bo *bo)
|
||||
{
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
if (!p_atomic_dec_zero(&bo->refcnt))
|
||||
return;
|
||||
|
||||
struct fd_device *dev = bo->dev;
|
||||
|
||||
uint32_t handle = bo_del_or_recycle(bo);
|
||||
if (handle)
|
||||
close_handles(dev, &handle, 1);
|
||||
}
|
||||
|
||||
void
|
||||
fd_bo_del(struct fd_bo *bo)
|
||||
{
|
||||
@@ -310,11 +293,9 @@ fd_bo_del(struct fd_bo *bo)
|
||||
|
||||
struct fd_device *dev = bo->dev;
|
||||
|
||||
simple_mtx_lock(&table_lock);
|
||||
uint32_t handle = bo_del_or_recycle(bo);
|
||||
if (handle)
|
||||
close_handles(dev, &handle, 1);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -327,7 +308,6 @@ fd_bo_del_array(struct fd_bo **bos, unsigned count)
|
||||
uint32_t handles[64];
|
||||
unsigned cnt = 0;
|
||||
|
||||
simple_mtx_lock(&table_lock);
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
if (!p_atomic_dec_zero(&bos[i]->refcnt))
|
||||
continue;
|
||||
@@ -340,7 +320,6 @@ fd_bo_del_array(struct fd_bo **bos, unsigned count)
|
||||
cnt++;
|
||||
}
|
||||
close_handles(dev, handles, cnt);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,8 +330,6 @@ fd_bo_del_array(struct fd_bo **bos, unsigned count)
|
||||
void
|
||||
fd_bo_del_list_nocache(struct list_head *list)
|
||||
{
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
if (list_is_empty(list))
|
||||
return;
|
||||
|
||||
@@ -376,8 +353,6 @@ fd_bo_del_list_nocache(struct list_head *list)
|
||||
|
||||
/**
|
||||
* The returned handle must be closed via a call to close_handles()
|
||||
*
|
||||
* Called under table_lock
|
||||
*/
|
||||
static uint32_t
|
||||
bo_del(struct fd_bo *bo)
|
||||
@@ -387,8 +362,6 @@ bo_del(struct fd_bo *bo)
|
||||
|
||||
VG_BO_FREE(bo);
|
||||
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
for (int i = 0; i < bo->nr_fences; i++)
|
||||
fd_pipe_del(bo->fences[i].pipe);
|
||||
|
||||
@@ -399,9 +372,11 @@ bo_del(struct fd_bo *bo)
|
||||
os_munmap(bo->map, bo->size);
|
||||
|
||||
if (handle) {
|
||||
simple_mtx_lock(&table_lock);
|
||||
_mesa_hash_table_remove_key(dev->handle_table, &handle);
|
||||
if (bo->name)
|
||||
_mesa_hash_table_remove_key(dev->name_table, &bo->name);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
}
|
||||
|
||||
bo->funcs->destroy(bo);
|
||||
|
||||
@@ -144,8 +144,6 @@ fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time)
|
||||
{
|
||||
int i, cnt = 0;
|
||||
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
if (cache->time == time)
|
||||
return;
|
||||
|
||||
@@ -270,9 +268,7 @@ retry:
|
||||
bucket->misses++;
|
||||
}
|
||||
|
||||
simple_mtx_lock(&table_lock);
|
||||
fd_bo_del_list_nocache(&freelist);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
|
||||
BO_CACHE_LOG(cache, "miss on size=%u, flags=0x%x, bucket=%u", *size, flags,
|
||||
bucket ? bucket->size : 0);
|
||||
@@ -284,8 +280,6 @@ retry:
|
||||
int
|
||||
fd_bo_cache_free(struct fd_bo_cache *cache, struct fd_bo *bo)
|
||||
{
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
|
||||
if (bo->nosync || bo->shared)
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -142,21 +142,20 @@ fd_device_ref(struct fd_device *dev)
|
||||
void
|
||||
fd_device_purge(struct fd_device *dev)
|
||||
{
|
||||
simple_mtx_lock(&table_lock);
|
||||
fd_bo_cache_cleanup(&dev->bo_cache, 0);
|
||||
fd_bo_cache_cleanup(&dev->ring_cache, 0);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
fd_device_del_impl(struct fd_device *dev)
|
||||
void
|
||||
fd_device_del(struct fd_device *dev)
|
||||
{
|
||||
simple_mtx_assert_locked(&table_lock);
|
||||
if (!p_atomic_dec_zero(&dev->refcnt))
|
||||
return;
|
||||
|
||||
assert(list_is_empty(&dev->deferred_submits));
|
||||
|
||||
if (dev->suballoc_bo)
|
||||
fd_bo_del_locked(dev->suballoc_bo);
|
||||
fd_bo_del(dev->suballoc_bo);
|
||||
|
||||
fd_bo_cache_cleanup(&dev->bo_cache, 0);
|
||||
fd_bo_cache_cleanup(&dev->ring_cache, 0);
|
||||
@@ -178,16 +177,6 @@ fd_device_del_impl(struct fd_device *dev)
|
||||
free(dev);
|
||||
}
|
||||
|
||||
void
|
||||
fd_device_del(struct fd_device *dev)
|
||||
{
|
||||
if (!p_atomic_dec_zero(&dev->refcnt))
|
||||
return;
|
||||
simple_mtx_lock(&table_lock);
|
||||
fd_device_del_impl(dev);
|
||||
simple_mtx_unlock(&table_lock);
|
||||
}
|
||||
|
||||
int
|
||||
fd_device_fd(struct fd_device *dev)
|
||||
{
|
||||
|
||||
@@ -207,8 +207,6 @@ struct fd_bo *fd_bo_cache_alloc(struct fd_bo_cache *cache, uint32_t *size,
|
||||
uint32_t flags);
|
||||
int fd_bo_cache_free(struct fd_bo_cache *cache, struct fd_bo *bo);
|
||||
|
||||
/* for where @table_lock is already held: */
|
||||
void fd_bo_del_locked(struct fd_bo *bo);
|
||||
/* for where @fence_lock is already held: */
|
||||
void fd_pipe_del_locked(struct fd_pipe *pipe);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ virtio_device_destroy(struct fd_device *dev)
|
||||
{
|
||||
struct virtio_device *virtio_dev = to_virtio_device(dev);
|
||||
|
||||
fd_bo_del_locked(virtio_dev->shmem_bo);
|
||||
fd_bo_del(virtio_dev->shmem_bo);
|
||||
util_vma_heap_finish(&virtio_dev->address_space);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user