freedreno/drm: Move bo idx to base
authorRob Clark <robdclark@chromium.org>
Mon, 14 Mar 2022 23:31:00 +0000 (16:31 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 02:03:30 +0000 (02:03 +0000)
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>

src/freedreno/drm/freedreno_priv.h
src/freedreno/drm/msm/msm_priv.h
src/freedreno/drm/msm/msm_ringbuffer.c
src/freedreno/drm/msm/msm_ringbuffer_sp.c

index 97c233f..155535d 100644 (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 */
 
index 4727cbc..828ee03 100644 (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);
 
index 43bd839..f750e1e 100644 (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;
index d46bcc4..c87399c 100644 (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;