radeonsi: set proper drm_amdgpu_cs_chunk_fence alignment

The 'struct drm_amdgpu_cs_chunk_fence' is processed as
'struct drm_amdgpu_cs_chunk_data' which is a union.
This change ensures the proper alignment for this structure
to be processed as 'struct drm_amdgpu_cs_chunk_data'.

The presence of __u64 as one member of
'struct drm_amdgpu_cs_chunk_data' makes the
whole structure expected to be 64-bit aligned.

This is a minor issue detected by the gcc sanitizer (ubsan), for instance at the libdrm library:
../amdgpu/amdgpu_cs.c:937:26: runtime error: member access within misaligned address 0x63100001484c for type 'struct drm_amdgpu_cs_chunk_data', which requires 8 byte alignment
0x63100001484c: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                ^

Fixes: ae7e4d7619 ("amd: rename ring_type --> amd_ip_type and match the kernel enum values")
Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22920>
(cherry picked from commit acdd6a2a6c)
This commit is contained in:
Patrick Lerda 2023-04-25 16:47:23 +02:00 committed by Dylan Baker
parent 649c2f5bd0
commit 99cb7a1705
2 changed files with 6 additions and 2 deletions

View File

@ -4254,7 +4254,7 @@
"description": "radeonsi: set proper drm_amdgpu_cs_chunk_fence alignment",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "ae7e4d7619e0f9aad41aac5424b051f8826afba1",
"notes": null

View File

@ -131,8 +131,12 @@ struct amdgpu_cs {
struct amdgpu_ib main; /* must be first because this is inherited */
struct amdgpu_winsys *ws;
struct amdgpu_ctx *ctx;
enum amd_ip_type ip_type;
/*
* Ensure a 64-bit alignment for drm_amdgpu_cs_chunk_fence.
*/
struct drm_amdgpu_cs_chunk_fence fence_chunk;
enum amd_ip_type ip_type;
/* We flip between these two CS. While one is being consumed
* by the kernel in another thread, the other one is being filled