panfrost: Require 64-byte alignment on imports
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 7 Nov 2022 18:49:51 +0000 (13:49 -0500)
committerEric Engestrom <eric@engestrom.ch>
Thu, 17 Nov 2022 14:05:02 +0000 (14:05 +0000)
commit57e8d21ffffde3895b596c08df1db3dc46c8e4c4
tree75df11e52a341642e04f91342078dacfd79fe9c9
parent5f5821232a0688d78f6c1a8d249cd7cac4cd2f8c
panfrost: Require 64-byte alignment on imports

While Panfrost allocates linear images with strides that are a multiple of 64
bytes, other dma-buf producers on the system may not satisfy this requirement.
However, at least on v7 and newer, any image with a regular format must have a
stride that is a multiple of 64 bytes.

This fixes a real bug in an application that created a linear R8_UNORM image
with stride 480 bytes, imported it as an EGL_image, and then tried to texture
from it with the GPU. Previously, the driver allowed this situation but it
resulted in an imprecise fault from the GPU. This patch corrects the driver to
reject the import as invalid due to the unaligned stride, ensuring we never
attempt to texture from such a resource.

To implement, we add some new layout queries to centralize knowledge about the
stride alignment requirements, and we sprinkle in asserts to show how the
invariant is upheld throughout the lifecycle of image creation to texturing.

Cc: mesa-stable
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19620>
(cherry picked from commit 811f8a19469722bea32f3c539b8cf0939fe3b057)
.pick_status.json
src/panfrost/lib/pan_layout.c
src/panfrost/lib/pan_texture.c
src/panfrost/lib/pan_texture.h