From 05abdda27ba21f9b8783870630004f17cbef7673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Fri, 18 Oct 2024 13:51:55 -0400 Subject: [PATCH] panfrost: properly align CRC buffer size for prefetching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRC values are prefetched in 32x32 regions so we need to round up the framebuffer size to account for that. Signed-off-by: Louis-Francis Ratté-Boulianne Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_layout.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index 6862057d81a..58e87166a6f 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -341,20 +341,28 @@ format_minimum_alignment(unsigned arch, enum pipe_format format, uint64_t mod) } } -/* Computes sizes for checksumming, which is 8 bytes per 16x16 tile. +/* + * Computes sizes for checksumming, which is 8 bytes per 16x16 tile. * Checksumming is believed to be a CRC variant (CRC64 based on the size?). - * This feature is also known as "transaction elimination". */ + * This feature is also known as "transaction elimination". + * CRC values are prefetched by 32x32 regions so size needs to be aligned. + */ -#define CHECKSUM_TILE_WIDTH 16 -#define CHECKSUM_TILE_HEIGHT 16 -#define CHECKSUM_BYTES_PER_TILE 8 +#define CHECKSUM_TILE_WIDTH 16 +#define CHECKSUM_TILE_HEIGHT 16 +#define CHECKSUM_REGION_SIZE 32 +#define CHECKSUM_X_TILE_PER_REGION (CHECKSUM_REGION_SIZE / CHECKSUM_TILE_WIDTH) +#define CHECKSUM_Y_TILE_PER_REGION (CHECKSUM_REGION_SIZE / CHECKSUM_TILE_HEIGHT) +#define CHECKSUM_BYTES_PER_TILE 8 unsigned panfrost_compute_checksum_size(struct pan_image_slice_layout *slice, unsigned width, unsigned height) { - unsigned tile_count_x = DIV_ROUND_UP(width, CHECKSUM_TILE_WIDTH); - unsigned tile_count_y = DIV_ROUND_UP(height, CHECKSUM_TILE_HEIGHT); + unsigned tile_count_x = + CHECKSUM_X_TILE_PER_REGION * DIV_ROUND_UP(width, CHECKSUM_REGION_SIZE); + unsigned tile_count_y = + CHECKSUM_Y_TILE_PER_REGION * DIV_ROUND_UP(height, CHECKSUM_REGION_SIZE); slice->crc.stride = tile_count_x * CHECKSUM_BYTES_PER_TILE;