From: Eric Anholt Date: Fri, 8 May 2020 18:20:07 +0000 (-0700) Subject: freedreno: Start moving relocs flags into the BOs. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d8d936dfcdab52361b9824cdd1f3ddb41486145;p=mesa.git freedreno: Start moving relocs flags into the BOs. 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: --- diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c index 04f9c1d16b4..de8e128ec3f 100644 --- a/src/freedreno/drm/freedreno_bo.c +++ b/src/freedreno/drm/freedreno_bo.c @@ -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); diff --git a/src/freedreno/drm/freedreno_bo_cache.c b/src/freedreno/drm/freedreno_bo_cache.c index b51e8db35ab..ccb98c1c3cf 100644 --- a/src/freedreno/drm/freedreno_bo_cache.c +++ b/src/freedreno/drm/freedreno_bo_cache.c @@ -181,6 +181,7 @@ retry: } p_atomic_set(&bo->refcnt, 1); fd_device_ref(bo->dev); + bo->flags = FD_RELOC_FLAGS_INIT; return bo; } } diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h index 58d7551f4eb..32ab54fd50c 100644 --- a/src/freedreno/drm/freedreno_priv.h +++ b/src/freedreno/drm/freedreno_priv.h @@ -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; diff --git a/src/freedreno/drm/freedreno_ringbuffer.h b/src/freedreno/drm/freedreno_ringbuffer.h index b484817e6f7..14b2425abbd 100644 --- a/src/freedreno/drm/freedreno_ringbuffer.h +++ b/src/freedreno/drm/freedreno_ringbuffer.h @@ -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 diff --git a/src/freedreno/drm/msm_ringbuffer.c b/src/freedreno/drm/msm_ringbuffer.c index 5e033b3d6ac..8a15c559bb6 100644 --- a/src/freedreno/drm/msm_ringbuffer.c +++ b/src/freedreno/drm/msm_ringbuffer.c @@ -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, }); diff --git a/src/freedreno/drm/msm_ringbuffer_sp.c b/src/freedreno/drm/msm_ringbuffer_sp.c index 5d8e34cc9c1..ef16ccd18e2 100644 --- a/src/freedreno/drm/msm_ringbuffer_sp.c +++ b/src/freedreno/drm/msm_ringbuffer_sp.c @@ -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, }); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h index f9063122bfc..ed1c0003849 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h @@ -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, \