return bo;
}
-void
-fd_bo_del(struct fd_bo *bo)
+static void
+bo_del_or_recycle(struct fd_bo *bo)
{
struct fd_device *dev = bo->dev;
- if (!p_atomic_dec_zero(&bo->refcnt))
- return;
-
- simple_mtx_lock(&table_lock);
+ simple_mtx_assert_locked(&table_lock);
if ((bo->bo_reuse == BO_CACHE) &&
(fd_bo_cache_free(&dev->bo_cache, bo) == 0))
- goto out;
+ return;
+
if ((bo->bo_reuse == RING_CACHE) &&
(fd_bo_cache_free(&dev->ring_cache, bo) == 0))
- goto out;
+ 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;
+
+ bo_del_or_recycle(bo);
+}
-out:
+void
+fd_bo_del(struct fd_bo *bo)
+{
+ if (!p_atomic_dec_zero(&bo->refcnt))
+ return;
+
+ simple_mtx_lock(&table_lock);
+ bo_del_or_recycle(bo);
simple_mtx_unlock(&table_lock);
}
pipe->funcs->destroy(pipe);
}
+void
+fd_pipe_del_locked(struct fd_pipe *pipe)
+{
+ simple_mtx_assert_locked(&table_lock);
+ if (!p_atomic_dec_zero(&pipe->refcnt))
+ return;
+ pipe->funcs->destroy(pipe);
+}
+
int
fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param, uint64_t *value)
{
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);
void fd_device_del_locked(struct fd_device *dev);
+void fd_pipe_del_locked(struct fd_pipe *pipe);
struct fd_pipe_funcs {
struct fd_ringbuffer *(*ringbuffer_new_object)(struct fd_pipe *pipe,