From da32849ac235a0b5f5a81eb1defc6bb30f0d9d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 20 Dec 2022 15:14:23 +0000 Subject: [PATCH] libdrm/lima: move sync fd handling into DRM object Converting from the sync-fd to the actual handle is internal implementation detail. Issue #4760. --- repos/libports/src/lib/libdrm/ioctl_lima.cc | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/repos/libports/src/lib/libdrm/ioctl_lima.cc b/repos/libports/src/lib/libdrm/ioctl_lima.cc index a4255a83a8..8c010021e8 100644 --- a/repos/libports/src/lib/libdrm/ioctl_lima.cc +++ b/repos/libports/src/lib/libdrm/ioctl_lima.cc @@ -436,8 +436,14 @@ class Lima::Call } while (true); } - void _wait_for_syncobj(unsigned int handle) + int _wait_for_syncobj(int fd) { + if (fd < SYNC_FD) { + Genode::warning("ignore invalid sync fd: ", fd); + return -1; + } + + unsigned const handle = fd - SYNC_FD; Syncobj::Id_space::Id syncobj_id { .value = handle }; try { @@ -453,7 +459,12 @@ class Lima::Call } while (true); }; _syncobj_space.apply(syncobj_id, wait); - } catch (Genode::Id_space::Unknown_id) { } + } catch (Genode::Id_space::Unknown_id) { + Genode::warning("ignore unknown sync fd: ", fd); + return -1; + } + + return 0; } template @@ -807,6 +818,11 @@ class Lima::Call : _generic_ioctl(command_number(request), arg); } + int wait_for_syncobj(int fd) + { + return _wait_for_syncobj(fd); + } + void *mmap(unsigned long offset, unsigned long /* size */) { /* @@ -907,8 +923,8 @@ int lima_drm_poll(int fd) return -1; } - int const handle = fd - Lima::Call::SYNC_FD; - _drm->wait_for_syncobj((unsigned)handle); + int const ret = _drm->wait_for_syncobj(fd); + pthread_mutex_unlock(&poll_mutex); - return 0; + return ret; }