From 603bfa34d982450c7113be7d0c83e691406bdf2a Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 30 Oct 2025 14:36:35 -0400 Subject: [PATCH] panfrost,tu: use util_is_aligned I was hoping this would catch more... Oh well. Via Coccinelle patch: @@ expression x, pot; @@ -align(x, pot) == x +util_is_aligned(x, pot) @@ expression x, pot; @@ -ALIGN(x, pot) == x +util_is_aligned(x, pot) @@ expression x, pot; @@ -ALIGN_POT(x, pot) == x +util_is_aligned(x, pot) Signed-off-by: Alyssa Rosenzweig Reviewed-by: Caio Oliveira Reviewed-by: Mary Guillemard Acked-by: Yonggang Luo Part-of: --- src/freedreno/vulkan/tu_util.cc | 2 +- src/panfrost/genxml/cs_builder.h | 2 +- src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/freedreno/vulkan/tu_util.cc b/src/freedreno/vulkan/tu_util.cc index f61d8d2eaf9..d0df029fd69 100644 --- a/src/freedreno/vulkan/tu_util.cc +++ b/src/freedreno/vulkan/tu_util.cc @@ -274,7 +274,7 @@ tu_tiling_config_update_tile_layout(struct tu_framebuffer *fb, /* Check that we did the math right. */ min_layer_stride = tile_align_h * tile_align_w * pass->min_cpp; - assert(align(min_layer_stride, gmem_align) == min_layer_stride); + assert(util_is_aligned(min_layer_stride, gmem_align)); } /* will force to sysmem, don't bother trying to have a valid tile config diff --git a/src/panfrost/genxml/cs_builder.h b/src/panfrost/genxml/cs_builder.h index 69c55e31dd8..e18efee2f72 100644 --- a/src/panfrost/genxml/cs_builder.h +++ b/src/panfrost/genxml/cs_builder.h @@ -2447,7 +2447,7 @@ static inline void cs_trace_preamble(struct cs_builder *b, const struct cs_tracing_ctx *ctx, struct cs_index scratch_regs, unsigned trace_size) { - assert(trace_size > 0 && ALIGN_POT(trace_size, 64) == trace_size && + assert(trace_size > 0 && util_is_aligned(trace_size, 64) && trace_size < INT16_MAX); assert(scratch_regs.size >= 4 && !(scratch_regs.reg & 1)); diff --git a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c index 387dd940eeb..45c5a6b17ce 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c @@ -929,7 +929,7 @@ cs_render_desc_ringbuf_reserve(struct cs_builder *b, uint32_t size) assert(size <= RENDER_DESC_RINGBUF_SIZE); /* Make sure the allocation is 64-byte aligned. */ - assert(ALIGN_POT(size, 64) == size); + assert(util_is_aligned(size, 64)); struct cs_index ringbuf_sync = cs_scratch_reg64(b, 0); struct cs_index sz_reg = cs_scratch_reg32(b, 2);