Commit Graph

5 Commits

Author SHA1 Message Date
Rob Clark d2e498b6a5 egl+libsync: Add helper to complain about invalid fence fd's
Debugging fd lifetime issues can be hard.  Add a helper for debug builds
to print out an error if an fd is not a fence fd, and sprinkle it around

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15094>
2022-03-04 22:16:20 +00:00
Jesse Natalie df92a13a27 util/libsync: Fix timeout handling if poll() wakes up early
Check how long poll waited, and use a smaller timeout on the next
iteration through the loop.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12268>
2021-11-09 04:05:55 +00:00
Rob Clark 964efdfba9 egl+libsync: Add check for valid fence-fd
Debugging fd mix-ups (ie. where, possibly via close()ing the original
fd, etc, you end up with something that is a valid fd but not a valid
*fence* fd) can be difficult.  Fortunately we can use the FILE_INFO
ioctl, which will return an error if the fd is not a fence fd.

For android, we instead use the libsync API, which does a similar thing
on modern kernels, but has a fallback path for older android kernels.

Note that the FILE_INFO ioctl has existed upstream since at least prior
to destaging of sync_file.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11202>
2021-06-07 20:14:25 +00:00
Eric Anholt 27b8887946 android: Add pre-4.7 Android kernel compatibility to our libsync header.
The downstream Android kernels had a different API than was merged
upstream, and libsync on Android abstracts over that for us.  Use their
sync_merge() and sync_wait(), at the cost of linking against libsync
(which Android.mk and meson both do).

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6821>
2020-10-19 18:41:50 +00:00
Eric Anholt e8c89a9bcb util: Import a copy of drm's libsync.h
libsync.h is one of the common dependencies on libdrm from drivers that
otherwise don't want libdrm.  Given that it's header-only code, just
import it to Mesa instead of forcing library dependencies on our users.

Copied from libdrm commit a84caff71be9 (" intel: Add PCI ID support to RKL
platform")

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6821>
2020-10-19 18:41:50 +00:00