From 877f9049c3e87e5d64820bcdf62c8fbfe2a33206 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Mon, 14 Mar 2022 16:31:00 -0700 Subject: [PATCH] freedreno/drm: Move bo idx to base The virtio backend will want this too, and it will make it easier to share most of the submit/ringbuffer implementation with the virtio backend. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_priv.h | 5 +++++ src/freedreno/drm/msm/msm_priv.h | 1 - src/freedreno/drm/msm/msm_ringbuffer.c | 5 ++--- src/freedreno/drm/msm/msm_ringbuffer_sp.c | 5 ++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h index 97c233fd0d4..155535dc58a 100644 --- a/src/freedreno/drm/freedreno_priv.h +++ b/src/freedreno/drm/freedreno_priv.h @@ -351,6 +351,11 @@ struct fd_bo { */ bool nosync : 1; + /* Most recent index in submit's bo table, used to optimize the common + * case where a bo is used many times in the same submit. + */ + uint32_t idx; + struct list_head list; /* bucket-list entry */ time_t free_time; /* time when added to bucket-list */ diff --git a/src/freedreno/drm/msm/msm_priv.h b/src/freedreno/drm/msm/msm_priv.h index 4727cbca15f..828ee03ef9a 100644 --- a/src/freedreno/drm/msm/msm_priv.h +++ b/src/freedreno/drm/msm/msm_priv.h @@ -83,7 +83,6 @@ void msm_pipe_sp_ringpool_fini(struct msm_pipe *msm_pipe); struct msm_bo { struct fd_bo base; uint64_t offset; - uint32_t idx; }; FD_DEFINE_CAST(fd_bo, msm_bo); diff --git a/src/freedreno/drm/msm/msm_ringbuffer.c b/src/freedreno/drm/msm/msm_ringbuffer.c index 43bd83937e5..f750e1e5bf4 100644 --- a/src/freedreno/drm/msm/msm_ringbuffer.c +++ b/src/freedreno/drm/msm/msm_ringbuffer.c @@ -127,14 +127,13 @@ msm_ringbuffer_init(struct msm_ringbuffer *msm_ring, uint32_t size, static uint32_t append_bo(struct msm_submit *submit, struct fd_bo *bo) { - struct msm_bo *msm_bo = to_msm_bo(bo); uint32_t idx; /* NOTE: it is legal to use the same bo on different threads for * different submits. But it is not legal to use the same submit * from given threads. */ - idx = READ_ONCE(msm_bo->idx); + idx = READ_ONCE(bo->idx); if (unlikely((idx >= submit->nr_submit_bos) || (submit->submit_bos[idx].handle != bo->handle))) { @@ -158,7 +157,7 @@ append_bo(struct msm_submit *submit, struct fd_bo *bo) _mesa_hash_table_insert_pre_hashed(submit->bo_table, hash, bo, (void *)(uintptr_t)idx); } - msm_bo->idx = idx; + bo->idx = idx; } return idx; diff --git a/src/freedreno/drm/msm/msm_ringbuffer_sp.c b/src/freedreno/drm/msm/msm_ringbuffer_sp.c index d46bcc42dd5..c87399ccae2 100644 --- a/src/freedreno/drm/msm/msm_ringbuffer_sp.c +++ b/src/freedreno/drm/msm/msm_ringbuffer_sp.c @@ -128,14 +128,13 @@ msm_ringbuffer_sp_init(struct msm_ringbuffer_sp *msm_ring, uint32_t size, static uint32_t msm_submit_append_bo(struct msm_submit_sp *submit, struct fd_bo *bo) { - struct msm_bo *msm_bo = to_msm_bo(bo); uint32_t idx; /* NOTE: it is legal to use the same bo on different threads for * different submits. But it is not legal to use the same submit * from different threads. */ - idx = READ_ONCE(msm_bo->idx); + idx = READ_ONCE(bo->idx); if (unlikely((idx >= submit->nr_bos) || (submit->bos[idx] != bo))) { uint32_t hash = _mesa_hash_pointer(bo); @@ -151,7 +150,7 @@ msm_submit_append_bo(struct msm_submit_sp *submit, struct fd_bo *bo) _mesa_hash_table_insert_pre_hashed(submit->bo_table, hash, bo, (void *)(uintptr_t)idx); } - msm_bo->idx = idx; + bo->idx = idx; } return idx;