From de811ee8ebc66db4be01aa7bf8c560dc0eec28cb Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 29 Jun 2021 00:37:39 +0200 Subject: [PATCH] nouveau: wrap nouveau_pushbuf_validate This makes it easier to insert locking code around libdrm. Signed-off-by: Karol Herbst Reviewed-by: M Henning Part-of: --- src/gallium/drivers/nouveau/nouveau_video.c | 2 +- src/gallium/drivers/nouveau/nouveau_winsys.h | 6 ++++++ .../drivers/nouveau/nv30/nv30_state_validate.c | 2 +- src/gallium/drivers/nouveau/nv50/nv50_compute.c | 2 +- .../drivers/nouveau/nv50/nv50_state_validate.c | 2 +- src/gallium/drivers/nouveau/nv50/nv50_surface.c | 6 +++--- src/gallium/drivers/nouveau/nv50/nv50_transfer.c | 8 ++++---- .../drivers/nouveau/nvc0/nvc0_state_validate.c | 2 +- src/gallium/drivers/nouveau/nvc0/nvc0_surface.c | 10 +++++----- src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c | 12 ++++++------ .../drivers/nouveau/nvc0/nvc0_vbo_translate.c | 4 ++-- 11 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c index db594416348..9637f39c8e2 100644 --- a/src/gallium/drivers/nouveau/nouveau_video.c +++ b/src/gallium/drivers/nouveau/nouveau_video.c @@ -88,7 +88,7 @@ nouveau_vpe_fini(struct nouveau_decoder *dec) { #undef BCTX_ARGS - if (unlikely(nouveau_pushbuf_validate(dec->push))) + if (unlikely(PUSH_VAL(dec->push))) return; BEGIN_NV04(push, NV31_MPEG(EXEC), 1); diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h index f1b655cb973..8365f3d8812 100644 --- a/src/gallium/drivers/nouveau/nouveau_winsys.h +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h @@ -75,6 +75,12 @@ PUSH_KICK(struct nouveau_pushbuf *push) nouveau_pushbuf_kick(push, push->channel); } +static inline int +PUSH_VAL(struct nouveau_pushbuf *push) +{ + return nouveau_pushbuf_validate(push); +} + static inline int BO_MAP(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) { diff --git a/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c b/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c index 26c77595c2a..248c399dd89 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c @@ -499,7 +499,7 @@ nv30_state_validate(struct nv30_context *nv30, uint32_t mask, bool hwtnl) } nouveau_pushbuf_bufctx(push, bctx); - if (nouveau_pushbuf_validate(push)) { + if (PUSH_VAL(push)) { nouveau_pushbuf_bufctx(push, NULL); return false; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_compute.c b/src/gallium/drivers/nouveau/nv50/nv50_compute.c index 1fdd5a41e61..cf406089eae 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_compute.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_compute.c @@ -545,7 +545,7 @@ nv50_compute_upload_input(struct nv50_context *nv50, const uint32_t *input) nouveau_bufctx_refn(nv50->bufctx, 0, bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD); nouveau_pushbuf_bufctx(push, nv50->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); PUSH_SPACE_EX(push, 0, 0, 1); diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c index d465cf633cf..02cf0b72e7e 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c @@ -559,7 +559,7 @@ nv50_state_validate(struct nv50_context *nv50, uint32_t mask, nv50_bufctx_fence(bufctx, false); } nouveau_pushbuf_bufctx(nv50->base.pushbuf, bufctx); - ret = nouveau_pushbuf_validate(nv50->base.pushbuf); + ret = PUSH_VAL(nv50->base.pushbuf); return !ret; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_surface.c b/src/gallium/drivers/nouveau/nv50/nv50_surface.c index f457ac46258..84c9bac414d 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_surface.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_surface.c @@ -257,7 +257,7 @@ nv50_resource_copy_region(struct pipe_context *pipe, BCTX_REFN(nv50->bufctx, 2D, nv04_resource(src), RD); BCTX_REFN(nv50->bufctx, 2D, nv04_resource(dst), WR); nouveau_pushbuf_bufctx(nv50->base.pushbuf, nv50->bufctx); - nouveau_pushbuf_validate(nv50->base.pushbuf); + PUSH_VAL(nv50->base.pushbuf); for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { ret = nv50_2d_texture_do_copy(nv50->base.pushbuf, @@ -653,7 +653,7 @@ nv50_clear_buffer_push(struct pipe_context *pipe, nouveau_bufctx_refn(nv50->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nv50->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); offset &= ~0xff; @@ -1639,7 +1639,7 @@ nv50_blit_eng2d(struct nv50_context *nv50, const struct pipe_blit_info *info) BCTX_REFN(nv50->bufctx, 2D, &dst->base, WR); BCTX_REFN(nv50->bufctx, 2D, &src->base, RD); nouveau_pushbuf_bufctx(nv50->base.pushbuf, nv50->bufctx); - if (nouveau_pushbuf_validate(nv50->base.pushbuf)) + if (PUSH_VAL(nv50->base.pushbuf)) return; for (i = 0; i < info->dst.box.depth; ++i) { diff --git a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c index d84a6763a46..143d920552f 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c @@ -67,7 +67,7 @@ nv50_2d_transfer_rect(struct nv50_context *nv50, nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); uint32_t format; switch (cpp) { @@ -197,7 +197,7 @@ nv50_m2mf_transfer_rect(struct nv50_context *nv50, nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); if (nouveau_bo_memtype(src->bo)) { BEGIN_NV04(push, NV50_M2MF(LINEAR_IN), 6); @@ -284,7 +284,7 @@ nv50_sifc_linear_u8(struct nouveau_context *nv, nouveau_bufctx_refn(nv50->bufctx, 0, dst, domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nv50->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); offset &= ~0xff; @@ -337,7 +337,7 @@ nv50_m2mf_copy_linear(struct nouveau_context *nv, nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); BEGIN_NV04(push, NV50_M2MF(LINEAR_IN), 1); PUSH_DATA (push, 1); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c index ab9a4717727..39c518efdef 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c @@ -985,7 +985,7 @@ nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask, } nouveau_pushbuf_bufctx(nvc0->base.pushbuf, bufctx); - ret = nouveau_pushbuf_validate(nvc0->base.pushbuf); + ret = PUSH_VAL(nvc0->base.pushbuf); return !ret; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c index a1c568b0e8f..24e2a2963d4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c @@ -267,7 +267,7 @@ nvc0_resource_copy_region(struct pipe_context *pipe, BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(src), RD); BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(dst), WR); nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx); - nouveau_pushbuf_validate(nvc0->base.pushbuf); + PUSH_VAL(nvc0->base.pushbuf); for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { ret = nvc0_2d_texture_do_copy(nvc0->base.pushbuf, @@ -379,7 +379,7 @@ nvc0_clear_buffer_push_nvc0(struct pipe_context *pipe, nouveau_bufctx_refn(nvc0->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nvc0->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); unsigned count = (size + 3) / 4; unsigned data_words = data_size / 4; @@ -428,7 +428,7 @@ nvc0_clear_buffer_push_nve4(struct pipe_context *pipe, nouveau_bufctx_refn(nvc0->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nvc0->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); unsigned count = (size + 3) / 4; unsigned data_words = data_size / 4; @@ -1327,7 +1327,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) NOUVEAU_BO_GART | NOUVEAU_BO_RD, vtxbuf_bo); BCTX_REFN_bo(nvc0->bufctx_3d, 3D_TEXT, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD, screen->text); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); BEGIN_NVC0(push, NVC0_3D(VERTEX_ARRAY_FETCH(0)), 4); PUSH_DATA (push, NVC0_3D_VERTEX_ARRAY_FETCH_ENABLE | stride << @@ -1549,7 +1549,7 @@ nvc0_blit_eng2d(struct nvc0_context *nvc0, const struct pipe_blit_info *info) BCTX_REFN(nvc0->bufctx, 2D, &dst->base, WR); BCTX_REFN(nvc0->bufctx, 2D, &src->base, RD); nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx); - if (nouveau_pushbuf_validate(nvc0->base.pushbuf)) + if (PUSH_VAL(nvc0->base.pushbuf)) return; for (i = 0; i < info->dst.box.depth; ++i) { diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c index 1e57d889289..1da61c0370a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c @@ -32,7 +32,7 @@ nvc0_m2mf_transfer_rect(struct nvc0_context *nvc0, nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); if (nouveau_bo_memtype(src->bo)) { BEGIN_NVC0(push, NVC0_M2MF(TILING_MODE_IN), 5); @@ -138,7 +138,7 @@ nve4_m2mf_transfer_rect(struct nvc0_context *nvc0, nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); exec = NVE4_COPY_EXEC_SWIZZLE_ENABLE | NVE4_COPY_EXEC_2D_ENABLE | NVE4_COPY_EXEC_FLUSH | NVE4_COPY_EXEC_COPY_MODE_NON_PIPELINED; @@ -207,7 +207,7 @@ nvc0_m2mf_push_linear(struct nouveau_context *nv, nouveau_bufctx_refn(nvc0->bufctx, 0, dst, domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nvc0->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); while (count) { unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN); @@ -249,7 +249,7 @@ nve4_p2mf_push_linear(struct nouveau_context *nv, nouveau_bufctx_refn(nvc0->bufctx, 0, dst, domain | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, nvc0->bufctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); while (count) { unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1)); @@ -289,7 +289,7 @@ nvc0_m2mf_copy_linear(struct nouveau_context *nv, nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); while (size) { unsigned bytes = MIN2(size, 1 << 17); @@ -327,7 +327,7 @@ nve4_m2mf_copy_linear(struct nouveau_context *nv, nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); nouveau_pushbuf_bufctx(push, bctx); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); BEGIN_NVC0(push, NVE4_COPY(SRC_ADDRESS_HIGH), 4); PUSH_DATAh(push, src->offset + srcoff); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c index 30dae5a1265..c7ae3fb3f9b 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c @@ -239,7 +239,7 @@ nvc0_push_setup_vertex_array(struct nvc0_context *nvc0, const unsigned count) BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, NOUVEAU_BO_GART | NOUVEAU_BO_RD, bo); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); return dest; } @@ -731,7 +731,7 @@ nvc0_push_upload_vertex_ids(struct push_context *ctx, BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, NOUVEAU_BO_GART | NOUVEAU_BO_RD, bo); - nouveau_pushbuf_validate(push); + PUSH_VAL(push); if (info->index_size) { if (!draw->index_bias) {