From 88a10c621689b801e46aad82c38b2ed7ee1a560c Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 10 Feb 2022 09:31:16 -0800 Subject: [PATCH] freedreno/drm: Avoid CPU_PREP ioctl if bo is idle With userspace fences, if we know definitely that the buffer is idle (which implies that it is not shared with other processes, etc), then skip the ioctl. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_bo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c index 386e77749e8..fe41b251539 100644 --- a/src/freedreno/drm/freedreno_bo.c +++ b/src/freedreno/drm/freedreno_bo.c @@ -503,14 +503,14 @@ fd_bo_upload(struct fd_bo *bo, void *src, unsigned len) int fd_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op) { + simple_mtx_lock(&table_lock); + enum fd_bo_state state = fd_bo_state(bo); + simple_mtx_unlock(&table_lock); + + if (state == FD_BO_STATE_IDLE) + return 0; + if (op & (FD_BO_PREP_NOSYNC | FD_BO_PREP_FLUSH)) { - simple_mtx_lock(&table_lock); - enum fd_bo_state state = fd_bo_state(bo); - simple_mtx_unlock(&table_lock); - - if (state == FD_BO_STATE_IDLE) - return 0; - if (op & FD_BO_PREP_FLUSH) bo_flush(bo);