freedreno: Start moving relocs flags into the BOs.
authorEric Anholt <eric@anholt.net>
Fri, 8 May 2020 18:20:07 +0000 (11:20 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 12 May 2020 16:30:57 +0000 (16:30 +0000)
It's silly to have all the reloc emitters passing around FD_RELOC_READ
when you have to have it set on all relocs (that don't include WRITE,
which implies read) for the kernel to actually track the fences on the BO.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4967>

src/freedreno/drm/freedreno_bo.c
src/freedreno/drm/freedreno_bo_cache.c
src/freedreno/drm/freedreno_priv.h
src/freedreno/drm/freedreno_ringbuffer.h
src/freedreno/drm/msm_ringbuffer.c
src/freedreno/drm/msm_ringbuffer_sp.c
src/gallium/drivers/freedreno/a6xx/fd6_pack.h

index 04f9c1d16b4f65bcc5d0ecb82caab46125df7459..de8e128ec3f35be5685b82c6e5348603d1b3b1b6 100644 (file)
@@ -73,6 +73,7 @@ static struct fd_bo * bo_from_handle(struct fd_device *dev,
        bo->size = size;
        bo->handle = handle;
        bo->iova = bo->funcs->iova(bo);
+       bo->flags = FD_RELOC_FLAGS_INIT;
 
        p_atomic_set(&bo->refcnt, 1);
        list_inithead(&bo->list);
index b51e8db35ab9534633a544e56005f0bcaa880b2b..ccb98c1c3cfa35c32198a22caba6908dbaef295b 100644 (file)
@@ -181,6 +181,7 @@ retry:
                        }
                        p_atomic_set(&bo->refcnt, 1);
                        fd_device_ref(bo->dev);
+                       bo->flags = FD_RELOC_FLAGS_INIT;
                        return bo;
                }
        }
index 58d7551f4eb5eb96a95a2f4d548799dd94d5fac5..32ab54fd50c7ee067126a5c273171f29953489c1 100644 (file)
@@ -154,6 +154,7 @@ struct fd_bo {
        uint32_t handle;
        uint32_t name;
        int32_t refcnt;
+       uint32_t flags; /* flags like FD_RELOC_DUMP to use for relocs to this BO */
        uint64_t iova;
        void *map;
        const struct fd_bo_funcs *funcs;
index b484817e6f7376a408573ead6018ad6fde8bd0bd..14b2425abbdd93791bf26f391e1b2a9d3fa58c39 100644 (file)
@@ -172,6 +172,8 @@ struct fd_reloc {
        uint32_t orhi;      /* used for a5xx+ */
 };
 
+#define FD_RELOC_FLAGS_INIT FD_RELOC_READ
+
 /* NOTE: relocs are 2 dwords on a5xx+ */
 
 static inline void
@@ -252,21 +254,21 @@ static inline void
 OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
                uint32_t offset, uint64_t or, int32_t shift)
 {
-       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ);
+       __out_reloc(ring, bo, offset, or, shift, 0);
 }
 
 static inline void
 OUT_RELOCW(struct fd_ringbuffer *ring, struct fd_bo *bo,
                uint32_t offset, uint64_t or, int32_t shift)
 {
-       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ | FD_RELOC_WRITE);
+       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_WRITE);
 }
 
 static inline void
 OUT_RELOCD(struct fd_ringbuffer *ring, struct fd_bo *bo,
                uint32_t offset, uint64_t or, int32_t shift)
 {
-       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ | FD_RELOC_DUMP);
+       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_DUMP);
 }
 
 static inline void
index 5e033b3d6ac16646edba792d79e24015293878ea..8a15c559bb6b4560e5f7b194a3d5191db04d3f54 100644 (file)
@@ -162,7 +162,7 @@ append_bo(struct msm_submit *submit, struct fd_bo *bo, uint32_t flags)
                        idx = APPEND(submit, submit_bos);
                        idx = APPEND(submit, bos);
 
-                       submit->submit_bos[idx].flags = 0;
+                       submit->submit_bos[idx].flags = bo->flags;
                        submit->submit_bos[idx].handle = bo->handle;
                        submit->submit_bos[idx].presumed = 0;
 
@@ -174,8 +174,6 @@ append_bo(struct msm_submit *submit, struct fd_bo *bo, uint32_t flags)
                msm_bo->idx = idx;
        }
 
-       if (flags & FD_RELOC_READ)
-               submit->submit_bos[idx].flags |= MSM_SUBMIT_BO_READ;
        if (flags & FD_RELOC_WRITE)
                submit->submit_bos[idx].flags |= MSM_SUBMIT_BO_WRITE;
 
@@ -283,8 +281,6 @@ handle_stateobj_relocs(struct msm_submit *submit, struct msm_ringbuffer *ring)
                struct fd_bo *bo = ring->u.reloc_bos[idx].bo;
                unsigned flags = 0;
 
-               if (ring->u.reloc_bos[idx].flags & MSM_SUBMIT_BO_READ)
-                       flags |= FD_RELOC_READ;
                if (ring->u.reloc_bos[idx].flags & MSM_SUBMIT_BO_WRITE)
                        flags |= FD_RELOC_WRITE;
 
@@ -347,7 +343,7 @@ msm_submit_flush(struct fd_submit *submit, int in_fence_fd,
 
                        cmds[i].type = MSM_SUBMIT_CMD_IB_TARGET_BUF;
                        cmds[i].submit_idx =
-                               append_bo(msm_submit, msm_ring->ring_bo, FD_RELOC_READ);
+                               append_bo(msm_submit, msm_ring->ring_bo, 0);
                        cmds[i].submit_offset = msm_ring->offset;
                        cmds[i].size = offset_bytes(ring->cur, ring->start);
                        cmds[i].pad = 0;
@@ -363,7 +359,7 @@ msm_submit_flush(struct fd_submit *submit, int in_fence_fd,
                                        cmds[i].type = MSM_SUBMIT_CMD_IB_TARGET_BUF;
                                }
                                cmds[i].submit_idx = append_bo(msm_submit,
-                                               msm_ring->u.cmds[j]->ring_bo, FD_RELOC_READ);
+                                               msm_ring->u.cmds[j]->ring_bo, 0);
                                cmds[i].submit_offset = msm_ring->offset;
                                cmds[i].size = msm_ring->u.cmds[j]->size;
                                cmds[i].pad = 0;
@@ -607,7 +603,7 @@ msm_ringbuffer_emit_reloc_ring(struct fd_ringbuffer *ring,
 
        msm_ringbuffer_emit_reloc(ring, &(struct fd_reloc){
                .bo     = bo,
-               .flags  = FD_RELOC_READ,
+               .flags  = 0,
                .offset = msm_target->offset,
        });
 
index 5d8e34cc9c12f37a4e0afb4d96ce0f9f71aad7ea..ef16ccd18e20fa18fe9f3ff0a89ad19335cffd85 100644 (file)
@@ -140,7 +140,7 @@ msm_submit_append_bo(struct msm_submit_sp *submit, struct fd_bo *bo, uint32_t fl
                        idx = APPEND(submit, submit_bos);
                        idx = APPEND(submit, bos);
 
-                       submit->submit_bos[idx].flags = 0;
+                       submit->submit_bos[idx].flags = bo->flags;
                        submit->submit_bos[idx].handle = bo->handle;
                        submit->submit_bos[idx].presumed = 0;
 
@@ -259,7 +259,7 @@ msm_submit_sp_flush(struct fd_submit *submit, int in_fence_fd,
        for (unsigned i = 0; i < primary->u.nr_cmds; i++) {
                cmds[i].type = MSM_SUBMIT_CMD_BUF;
                cmds[i].submit_idx = msm_submit_append_bo(msm_submit,
-                               primary->u.cmds[i].ring_bo, FD_RELOC_READ | FD_RELOC_DUMP);
+                               primary->u.cmds[i].ring_bo, FD_RELOC_DUMP);
                cmds[i].submit_offset = primary->offset;
                cmds[i].size = primary->u.cmds[i].size;
                cmds[i].pad = 0;
@@ -453,7 +453,7 @@ msm_ringbuffer_sp_emit_reloc_ring(struct fd_ringbuffer *ring,
 
        msm_ringbuffer_sp_emit_reloc(ring, &(struct fd_reloc){
                .bo     = bo,
-               .flags  = FD_RELOC_READ | FD_RELOC_DUMP,
+               .flags  = FD_RELOC_DUMP,
                .offset = msm_target->offset,
        });
 
index f9063122bfc33f9cb6973acd23dbbc6bf8e1f253..ed1c00038490a2360db84308bdfab988e158d77d 100644 (file)
@@ -58,9 +58,7 @@ struct fd_reg_pair {
                        if (regs[i].bo) {                                                                               \
                                struct fd_reloc reloc = {                                                       \
                                        .bo = regs[i].bo,                                                               \
-                                       .flags = FD_RELOC_READ |                                                \
-                                               (regs[i].bo_write ? FD_RELOC_WRITE : 0),        \
-                                                                                                                                       \
+                                       .flags = (regs[i].bo_write ? FD_RELOC_WRITE : 0),       \
                                        .offset = regs[i].bo_offset,                                    \
                                        .or = regs[i].value,                                                    \
                                        .shift = regs[i].bo_shift,                                              \