From e3fc8dd0018bbba42325a2bdf378fd96bfd67a6c Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 17 Apr 2020 12:34:52 -0700 Subject: [PATCH] freedreno/drm: inline the things The existing structure dates back to when this code was part of libdrm, and we wanted some of this not to be exposed as ABI between libdrm and mesa. Now that this is no longer a constraint, inline things. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_priv.h | 10 ---- src/freedreno/drm/freedreno_ringbuffer.c | 46 --------------- src/freedreno/drm/freedreno_ringbuffer.h | 71 +++++++++++++++++++++--- 3 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h index 98124b72f2b..58d7551f4eb 100644 --- a/src/freedreno/drm/freedreno_priv.h +++ b/src/freedreno/drm/freedreno_priv.h @@ -138,16 +138,6 @@ struct fd_submit { const struct fd_submit_funcs *funcs; }; -struct fd_ringbuffer_funcs { - void (*grow)(struct fd_ringbuffer *ring, uint32_t size); - void (*emit_reloc)(struct fd_ringbuffer *ring, - const struct fd_reloc *reloc); - uint32_t (*emit_reloc_ring)(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx); - uint32_t (*cmd_count)(struct fd_ringbuffer *ring); - void (*destroy)(struct fd_ringbuffer *ring); -}; - struct fd_bo_funcs { int (*offset)(struct fd_bo *bo, uint64_t *offset); int (*cpu_prep)(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op); diff --git a/src/freedreno/drm/freedreno_ringbuffer.c b/src/freedreno/drm/freedreno_ringbuffer.c index d63419a7453..6bf746b1b86 100644 --- a/src/freedreno/drm/freedreno_ringbuffer.c +++ b/src/freedreno/drm/freedreno_ringbuffer.c @@ -66,49 +66,3 @@ fd_ringbuffer_new_object(struct fd_pipe *pipe, uint32_t size) { return pipe->funcs->ringbuffer_new_object(pipe, size); } - -void fd_ringbuffer_del(struct fd_ringbuffer *ring) -{ - if (--ring->refcnt > 0) - return; - - ring->funcs->destroy(ring); -} - -struct fd_ringbuffer * -fd_ringbuffer_ref(struct fd_ringbuffer *ring) -{ - ring->refcnt++; - return ring; -} - -void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) -{ - assert(ring->funcs->grow); /* unsupported on kgsl */ - - /* there is an upper bound on IB size, which appears to be 0x100000 */ - if (ring->size < 0x100000) - ring->size *= 2; - - ring->funcs->grow(ring, ring->size); -} - -void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, - const struct fd_reloc *reloc) -{ - ring->funcs->emit_reloc(ring, reloc); -} - -uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring) -{ - if (!ring->funcs->cmd_count) - return 1; - return ring->funcs->cmd_count(ring); -} - -uint32_t -fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx) -{ - return ring->funcs->emit_reloc_ring(ring, target, cmd_idx); -} diff --git a/src/freedreno/drm/freedreno_ringbuffer.h b/src/freedreno/drm/freedreno_ringbuffer.h index 3ee3e9ba992..3b7078b9747 100644 --- a/src/freedreno/drm/freedreno_ringbuffer.h +++ b/src/freedreno/drm/freedreno_ringbuffer.h @@ -87,7 +87,18 @@ int fd_submit_flush(struct fd_submit *submit, int in_fence_fd, int *out_fence_fd, uint32_t *out_fence); -struct fd_ringbuffer_funcs; +struct fd_ringbuffer; +struct fd_reloc; + +struct fd_ringbuffer_funcs { + void (*grow)(struct fd_ringbuffer *ring, uint32_t size); + void (*emit_reloc)(struct fd_ringbuffer *ring, + const struct fd_reloc *reloc); + uint32_t (*emit_reloc_ring)(struct fd_ringbuffer *ring, + struct fd_ringbuffer *target, uint32_t cmd_idx); + uint32_t (*cmd_count)(struct fd_ringbuffer *ring); + void (*destroy)(struct fd_ringbuffer *ring); +}; /* the ringbuffer object is not opaque so that OUT_RING() type stuff * can be inlined. Note that users should not make assumptions about @@ -109,12 +120,37 @@ struct fd_ringbuffer { struct fd_ringbuffer * fd_ringbuffer_new_object(struct fd_pipe *pipe, uint32_t size); -struct fd_ringbuffer *fd_ringbuffer_ref(struct fd_ringbuffer *ring); -void fd_ringbuffer_del(struct fd_ringbuffer *ring); +static inline void +fd_ringbuffer_del(struct fd_ringbuffer *ring) +{ + if (--ring->refcnt > 0) + return; + + ring->funcs->destroy(ring); +} + +static inline +struct fd_ringbuffer * +fd_ringbuffer_ref(struct fd_ringbuffer *ring) +{ + ring->refcnt++; + return ring; +} + +static inline void +fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords) +{ + assert(ring->funcs->grow); /* unsupported on kgsl */ + + /* there is an upper bound on IB size, which appears to be 0x100000 */ + if (ring->size < 0x100000) + ring->size *= 2; -void fd_ringbuffer_grow(struct fd_ringbuffer *ring, uint32_t ndwords); + ring->funcs->grow(ring, ring->size); +} -static inline void fd_ringbuffer_emit(struct fd_ringbuffer *ring, +static inline void +fd_ringbuffer_emit(struct fd_ringbuffer *ring, uint32_t data) { (*ring->cur++) = data; @@ -134,10 +170,27 @@ struct fd_reloc { /* NOTE: relocs are 2 dwords on a5xx+ */ -void fd_ringbuffer_reloc(struct fd_ringbuffer *ring, const struct fd_reloc *reloc); -uint32_t fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring); -uint32_t fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring, - struct fd_ringbuffer *target, uint32_t cmd_idx); +static inline void +fd_ringbuffer_reloc(struct fd_ringbuffer *ring, + const struct fd_reloc *reloc) +{ + ring->funcs->emit_reloc(ring, reloc); +} + +static inline uint32_t +fd_ringbuffer_cmd_count(struct fd_ringbuffer *ring) +{ + if (!ring->funcs->cmd_count) + return 1; + return ring->funcs->cmd_count(ring); +} + +static inline uint32_t +fd_ringbuffer_emit_reloc_ring_full(struct fd_ringbuffer *ring, + struct fd_ringbuffer *target, uint32_t cmd_idx) +{ + return ring->funcs->emit_reloc_ring(ring, target, cmd_idx); +} static inline uint32_t offset_bytes(void *end, void *start) -- 2.30.2