From aee0ce980bed9f7daa16f54a747c3d8b3b7cbd65 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 17 Oct 2024 18:26:38 -0500 Subject: [PATCH] nak/bindings: Use an enum for IOCTL numbers This should be more robust against weird bindgen shenanigans because it forces LLVM to constant-fold and give us an actual thing we can generate bindings for. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12008 Fixes: cd7128c2e305 ("nak: Add a bare HW shader runner") Part-of: --- src/nouveau/compiler/nak/hw_runner.rs | 4 ++-- src/nouveau/compiler/nak_bindings.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nouveau/compiler/nak/hw_runner.rs b/src/nouveau/compiler/nak/hw_runner.rs index d139a83a886..d36851661bb 100644 --- a/src/nouveau/compiler/nak/hw_runner.rs +++ b/src/nouveau/compiler/nak/hw_runner.rs @@ -190,7 +190,7 @@ impl<'a> Runner { }; let err = drmIoctl( self.dev.as_ref().fd, - DRM_RS_IOCTL_NOUVEAU_EXEC, + DRM_RS_IOCTL_NOUVEAU_EXEC.into(), &exec as *const _ as *mut std::os::raw::c_void, ); if err != 0 { @@ -226,7 +226,7 @@ impl<'a> Runner { }; let err = drmIoctl( self.dev.as_ref().fd, - DRM_RS_IOCTL_NOUVEAU_EXEC, + DRM_RS_IOCTL_NOUVEAU_EXEC.into(), ptr::from_mut(&mut exec).cast(), ); if err != 0 { diff --git a/src/nouveau/compiler/nak_bindings.h b/src/nouveau/compiler/nak_bindings.h index 9af1aecef3c..e766da19f98 100644 --- a/src/nouveau/compiler/nak_bindings.h +++ b/src/nouveau/compiler/nak_bindings.h @@ -13,6 +13,8 @@ #include "drm-uapi/nouveau_drm.h" #define DRM_RS_IOCTL(FOO) \ - static const unsigned long DRM_RS_IOCTL_##FOO = DRM_IOCTL_##FOO + DRM_RS_IOCTL_##FOO = DRM_IOCTL_##FOO -DRM_RS_IOCTL(NOUVEAU_EXEC); +enum ENUM_PACKED drm_rs_ioctls { + DRM_RS_IOCTL(NOUVEAU_EXEC), +};