From 2b742dd9c8bcb2d699fbb49b759a876adcdbe093 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Tue, 19 Nov 2024 15:18:07 +0100 Subject: [PATCH] panfrost: use 64-bits for layout calculations On modern Mali GPUs, we can have 16 bits for the X and Y sizes, already overflowing 32-bit barrier even with a single layer of byte-sized formats. So let's make sure we have enough bits to avoid overflows here. Fixes: d5ed77800e0 ("panvk: Fix GetPhysicalDeviceProperties2() to report accurate info") Reviewed-by: Boris Brezillon Part-of: (cherry picked from commit 00b25ec7693e81c23619369551b0d1fd0cb9c440) --- .pick_status.json | 2 +- src/panfrost/lib/pan_layout.c | 8 ++++---- src/panfrost/lib/pan_texture.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3f776b145f3..ce387c10ee1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1154,7 +1154,7 @@ "description": "panfrost: use 64-bits for layout calculations", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "d5ed77800e04fee670dbc1091d98490e4fa470ce", "notes": null diff --git a/src/panfrost/lib/pan_layout.c b/src/panfrost/lib/pan_layout.c index 58e87166a6f..e8d7de31030 100644 --- a/src/panfrost/lib/pan_layout.c +++ b/src/panfrost/lib/pan_layout.c @@ -485,7 +485,7 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout, bool linear = layout->modifier == DRM_FORMAT_MOD_LINEAR; bool is_3d = layout->dim == MALI_TEXTURE_DIMENSION_3D; - unsigned offset = explicit_layout ? explicit_layout->offset : 0; + uint64_t offset = explicit_layout ? explicit_layout->offset : 0; struct pan_block_size block_size = panfrost_block_size(layout->modifier, layout->format); @@ -543,8 +543,8 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout, row_stride = ALIGN_POT(row_stride, 64); } - unsigned slice_one_size = - row_stride * (effective_height / block_size.height); + uint64_t slice_one_size = + (uint64_t)row_stride * (effective_height / block_size.height); /* Compute AFBC sizes if necessary */ if (afbc) { @@ -583,7 +583,7 @@ pan_image_layout_init(unsigned arch, struct pan_image_layout *layout, slice->row_stride = row_stride; } - unsigned slice_full_size = slice_one_size * depth * layout->nr_samples; + uint64_t slice_full_size = slice_one_size * depth * layout->nr_samples; slice->surface_stride = slice_one_size; diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h index 13235b06990..9f382fdf1f7 100644 --- a/src/panfrost/lib/pan_texture.h +++ b/src/panfrost/lib/pan_texture.h @@ -112,7 +112,7 @@ struct pan_image_layout { struct pan_image_slice_layout slices[MAX_MIP_LEVELS]; uint64_t data_size; - unsigned array_stride; + uint64_t array_stride; }; struct pan_image_mem {