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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4967>
This commit is contained in:
Eric Anholt
2020-05-08 11:20:07 -07:00
committed by Marge Bot
parent 4235624b6a
commit 9d8d936dfc
7 changed files with 16 additions and 17 deletions
+1
View 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);
+1
View 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;
}
}
+1
View 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;
+5 -3
View 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
+4 -8
View 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,
});
+3 -3
View 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,
});
@@ -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, \