From 8609d62e4d7a5112b2426e9c2856d48864f9c2d6 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 4 Aug 2022 15:58:15 -0700 Subject: [PATCH] freedreno/a6xx: Drop "hardpin" support The upstream kernel supported everything needed to stop doing kernel-side relocs before the first things with a6xx were fully supported in upstream kernel. Take advantage to drop some extra overhead in OUT_RELOC() and equiv in the pack macros. Signed-off-by: Rob Clark Part-of: --- src/freedreno/drm/freedreno_ringbuffer.h | 31 ++++++++++++++++------ src/gallium/drivers/freedreno/a6xx/fd6_blend.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_blitter.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_compute.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_const.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_context.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_draw.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_emit.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_gmem.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_image.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_pack.h | 11 +++++--- src/gallium/drivers/freedreno/a6xx/fd6_program.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_query.c | 2 ++ .../drivers/freedreno/a6xx/fd6_rasterizer.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_resource.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_screen.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_texture.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_vsc.c | 2 ++ src/gallium/drivers/freedreno/a6xx/fd6_zsa.c | 2 ++ 19 files changed, 65 insertions(+), 11 deletions(-) diff --git a/src/freedreno/drm/freedreno_ringbuffer.h b/src/freedreno/drm/freedreno_ringbuffer.h index cd8241f..0576834 100644 --- a/src/freedreno/drm/freedreno_ringbuffer.h +++ b/src/freedreno/drm/freedreno_ringbuffer.h @@ -288,6 +288,21 @@ OUT_RING(struct fd_ringbuffer *ring, uint32_t data) fd_ringbuffer_emit(ring, data); } +static inline uint64_t +__reloc_iova(struct fd_bo *bo, uint32_t offset, uint64_t orval, int32_t shift) +{ + uint64_t iova = fd_bo_get_iova(bo) + offset; + + if (shift < 0) + iova >>= -shift; + else + iova <<= shift; + + iova |= orval; + + return iova; +} + /* * NOTE: OUT_RELOC() is 2 dwords (64b) on a5xx+ */ @@ -301,15 +316,14 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t offset, } assert(offset < fd_bo_size(bo)); - uint64_t iova = fd_bo_get_iova(bo) + offset; - - if (shift < 0) - iova >>= -shift; - else - iova <<= shift; - - iova |= orval; + uint64_t iova = __reloc_iova(bo, offset, orval, shift); +#if FD_BO_NO_HARDPIN + uint64_t *cur = (uint64_t *)ring->cur; + *cur = iova; + ring->cur += 2; + fd_ringbuffer_attach_bo(ring, bo); +#else struct fd_reloc reloc = { .bo = bo, .iova = iova, @@ -319,6 +333,7 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo, uint32_t offset, }; fd_ringbuffer_reloc(ring, &reloc); +#endif } static inline void diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c index e62d1a8..6d5c896 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_blend.h" #include "util/u_dual_blend.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 1c01a4a..bc9c758 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "util/format_srgb.h" #include "util/half_float.h" #include "util/u_dump.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c index f8f5648..774e160 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_compute.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_compute.c @@ -24,6 +24,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_dump.h" #include "u_tracepoints.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_const.c b/src/gallium/drivers/freedreno/a6xx/fd6_const.c index 868d226..559a5fd 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_const.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_const.c @@ -22,6 +22,8 @@ * SOFTWARE. */ +#define FD_BO_NO_HARDPIN 1 + #include "fd6_const.h" #include "fd6_pack.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_context.c b/src/gallium/drivers/freedreno/a6xx/fd6_context.c index af001e3..179d799 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_context.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_context.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "freedreno_query_acc.h" #include "freedreno_state.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c index a61af12..fbcddd7 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_draw.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_draw.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_prim.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index 014f1c7..348bb8e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/format/u_format.h" #include "util/u_helpers.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index 74b7dbd..ad82509 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include #include "pipe/p_state.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 64a2ca2..9ffbd83 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "freedreno_resource.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h index ada71da..f6d1fbf 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_pack.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_pack.h @@ -50,6 +50,10 @@ struct fd_reg_pair { } \ } while (0) +#if !FD_BO_NO_HARDPIN +# error 'Hardpin unsupported' +#endif + #define __ONE_REG(i, ...) \ do { \ const struct fd_reg_pair regs[] = {__VA_ARGS__}; \ @@ -57,10 +61,11 @@ struct fd_reg_pair { if (i < ARRAY_SIZE(regs) && (i == 0 || regs[i].reg > 0)) { \ __assert_eq(regs[0].reg + i, regs[i].reg); \ if (regs[i].bo) { \ - ring->cur = p; \ + uint64_t *p64 = (uint64_t *)p; \ + *p64 = __reloc_iova(regs[i].bo, regs[i].bo_offset, regs[i].value, \ + regs[i].bo_shift); \ p += 2; \ - OUT_RELOC(ring, regs[i].bo, regs[i].bo_offset, regs[i].value, \ - regs[i].bo_shift); \ + fd_ringbuffer_attach_bo(ring, regs[i].bo); \ } else { \ *p++ = regs[i].value; \ if (regs[i].is_address) \ diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_program.c b/src/gallium/drivers/freedreno/a6xx/fd6_program.c index c0125ef..dcc3f71 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_program.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_program.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/bitset.h" #include "util/format/u_format.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_query.c b/src/gallium/drivers/freedreno/a6xx/fd6_query.c index 5343690..15af1a5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_query.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_query.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + /* NOTE: see https://gitlab.freedesktop.org/freedreno/freedreno/-/wikis/A5xx-Queries */ #include "freedreno_query_acc.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c b/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c index 6f42dad..80c6e9e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_string.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index f13ef13..34eab33 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "drm-uapi/drm_fourcc.h" #include "fd6_resource.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c index 86f9ad4..94b3a5e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_screen.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_screen.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "drm-uapi/drm_fourcc.h" #include "pipe/p_screen.h" #include "util/format/u_format.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index 7255151..ce80d50 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/format/u_format.h" #include "util/hash_table.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c b/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c index f419b93..caa8f8b 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_vsc.c @@ -21,6 +21,8 @@ * SOFTWARE. */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_prim.h" diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c b/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c index a00ad61..5f99822 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_zsa.c @@ -25,6 +25,8 @@ * Rob Clark */ +#define FD_BO_NO_HARDPIN 1 + #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_string.h" -- 2.7.4