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 <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14900>
This commit is contained in:
Rob Clark 2022-03-14 16:31:00 -07:00 committed by Marge Bot
parent 2ac9b23f78
commit 877f9049c3
4 changed files with 9 additions and 7 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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;

View file

@ -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;