From 25536c7d4d65032189a89242939f4045f9600756 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Mon, 14 Apr 2025 19:03:34 +0200 Subject: [PATCH] pan/kmod: Explicitly set the user MMIO offset when the KMD supports it FEX is a 64-bit process potentially running x86 (32-bit) binary, in which case the automatic user MMIO offset detection doesn't work, so let's explicitly set the user MMIO offset when we can. Signed-off-by: Boris Brezillon Acked-by: Mary Guillemard Reviewed-by: Erik Faye-Lund Part-of: --- src/panfrost/lib/kmod/panthor_kmod.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/panfrost/lib/kmod/panthor_kmod.c b/src/panfrost/lib/kmod/panthor_kmod.c index 43c8b4c1ee5..e43622c5972 100644 --- a/src/panfrost/lib/kmod/panthor_kmod.c +++ b/src/panfrost/lib/kmod/panthor_kmod.c @@ -153,6 +153,18 @@ panthor_kmod_dev_create(int fd, uint32_t flags, drmVersionPtr version, } /* Map the LATEST_FLUSH_ID register at device creation time. */ + if (version->version_major > 1 || version->version_minor >= 5) { + struct drm_panthor_set_user_mmio_offset user_mmio_offset = { + .offset = DRM_PANTHOR_USER_MMIO_OFFSET, + }; + + ret = drmIoctl(fd, DRM_IOCTL_PANTHOR_SET_USER_MMIO_OFFSET, &user_mmio_offset); + if (ret) { + mesa_loge("DRM_IOCTL_PANTHOR_SET_USER_MMIO_OFFSET, failed (err=%d)", errno); + goto err_free_dev; + } + } + panthor_dev->flush_id = os_mmap(0, getpagesize(), PROT_READ, MAP_SHARED, fd, DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET); if (panthor_dev->flush_id == MAP_FAILED) {