mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
Non-Adreno round 6: PowerVR PRIME on old kernels, thermal, hang-up names, bridge flippable images, Venus Zink variants
- drm.c: PR #570's current PRIME ownership check (F_DUPFD_QUERY, then kcmp, then the F_SETOWN_EX owner marker): on a kernel before 6.10 with kcmp blocked, drmPrimeFDToHandle answered EOPNOTSUPP for every PowerVR import (Pixel 10, Android 17: Zink "failed drmPrimeFDToHandle", Xwayland error 7, gamescope X11 I/O error). The Mali stand-in node is kept. - A /sys/class/thermal the kernel will not list gets an empty directory, so mangoapp no longer aborts on it. - gamescope 0132: a hung-up waitable is named before the abort; 0133: the bridge's flippable images use supported-but-unexportable modifiers instead of asserting. - Venus: when Zink does not start, the loader's view is logged and Zink is retried without ZINK_DEBUG=compact, with ZINK_DESCRIPTORS=auto and without kopper before falling back to llvmpipe.
This commit is contained in:
1 parent
48d2d52d28
commit
72196c3447
7 files changed
+267
-13
No files matched your search
@@ -1184,11 +1184,31 @@ BUSCONF
|
||||
# the client quit ("UpdateUI GL not available"). One probe the way the client asks, with the
|
||||
# loader's reasons in the log; when GL does not start, the client's GL goes to llvmpipe.
|
||||
if [ "${BL_VENUS:-0}" = 1 ] && [ -x /usr/local/bin/droiddeck-glprobe ] && [ "${GALLIUM_DRIVER:-}" = zink ]; then
|
||||
LIBGL_DEBUG=verbose MESA_LOG_LEVEL=debug timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | head -60 | sed 's/^/== glprobe: /'
|
||||
LIBGL_DEBUG=verbose MESA_LOG_LEVEL=debug timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -60 | sed 's/^/== glprobe: /'
|
||||
if [ "${PIPESTATUS[0]}" = 1 ]; then
|
||||
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2
|
||||
echo "== venus: GL through Zink did not start (see glprobe above); the Steam client's GL uses llvmpipe (software)"
|
||||
# Zink failed without a word on a Mali-G615 (instance up, then "failed to load driver").
|
||||
# The loader's view first, then the variants that change what Zink asks of the device;
|
||||
# the first that starts is what the client gets.
|
||||
VK_LOADER_DEBUG=error,warn timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -40 | sed 's/^/== glprobe (loader): /'
|
||||
bl_gl_ok=
|
||||
for bl_variant in "ZINK_DEBUG=" "ZINK_DEBUG= ZINK_DESCRIPTORS=auto" "ZINK_DEBUG= LIBGL_KOPPER_DISABLE=true" "ZINK_DEBUG= DROIDDECK_MALI_COMPAT=0"; do
|
||||
if env $bl_variant timeout 20 /usr/local/bin/droiddeck-glprobe 2>&1 | grep -v drirc | head -20 | sed "s/^/== glprobe ($bl_variant): /"; [ "${PIPESTATUS[0]}" = 0 ]; then
|
||||
bl_gl_ok=$bl_variant
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -n "$bl_gl_ok" ] && [ "$bl_gl_ok" != "ZINK_DEBUG= DROIDDECK_MALI_COMPAT=0" ]; then
|
||||
for bl_kv in $bl_gl_ok; do
|
||||
case $bl_kv in *=) unset "${bl_kv%=}" ;; *) export "$bl_kv" ;; esac
|
||||
done
|
||||
echo "== venus: GL through Zink starts with: $bl_gl_ok (the Steam client gets that)"
|
||||
else
|
||||
[ -n "$bl_gl_ok" ] && echo "== venus: Zink starts only without the Mali compatibility layer (then without nullDescriptor); not used"
|
||||
export GALLIUM_DRIVER=llvmpipe LIBGL_ALWAYS_SOFTWARE=1
|
||||
unset MESA_LOADER_DRIVER_OVERRIDE LIBGL_KOPPER_DRI2
|
||||
echo "== venus: GL through Zink did not start (see glprobe above); the Steam client's GL uses llvmpipe (software)"
|
||||
fi
|
||||
unset bl_gl_ok bl_variant bl_kv
|
||||
fi
|
||||
fi
|
||||
while :; do
|
||||
|
||||
@@ -54,7 +54,7 @@ static int is_kgsl(int fd) {
|
||||
/* KGSL, or the device the Mali bridge's session names as its render node (BL_DRM_STANDIN). */
|
||||
const char *standin = getenv("BL_DRM_STANDIN");
|
||||
kgsl_state = stat("/dev/kgsl-3d0", &st) == 0 || (standin && *standin && stat(standin, &st) == 0) ? 1 : -1;
|
||||
kgsl_dev = st.st_rdev;
|
||||
if (kgsl_state > 0) kgsl_dev = st.st_rdev;
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
return kgsl_state > 0 && fstat(fd, &st) == 0 && S_ISCHR(st.st_mode) && st.st_rdev == kgsl_dev;
|
||||
@@ -110,12 +110,63 @@ static int same_file_description(int a, int b) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Android kernels before 6.10 have no F_DUPFD_QUERY, while the app seccomp policy blocks kcmp.
|
||||
* F_SETOWN_EX updates the open file description, so a duplicate observes a temporary owner marker
|
||||
* and an independent open of the same render node does not. Restore the original owner before
|
||||
* returning; no signal is armed because these DRM descriptors do not have O_ASYNC set.
|
||||
*/
|
||||
static int same_owner_description(int owned, int fd) {
|
||||
struct f_owner_ex original_owned, original_fd, observed;
|
||||
if (fcntl(owned, F_GETOWN_EX, &original_owned) < 0 ||
|
||||
fcntl(fd, F_GETOWN_EX, &original_fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
const struct f_owner_ex candidates[] = {
|
||||
{.type = F_OWNER_TID, .pid = getpid()},
|
||||
{.type = F_OWNER_PID, .pid = getpid()},
|
||||
{.type = F_OWNER_PGRP, .pid = getpgrp()},
|
||||
};
|
||||
const struct f_owner_ex *marker = NULL;
|
||||
for (size_t i = 0; i < sizeof(candidates) / sizeof(candidates[0]); i++) {
|
||||
if (candidates[i].type != original_fd.type || candidates[i].pid != original_fd.pid) {
|
||||
marker = &candidates[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!marker || fcntl(owned, F_SETOWN_EX, marker) < 0) return -1;
|
||||
int observed_result = fcntl(fd, F_GETOWN_EX, &observed);
|
||||
int observed_errno = errno;
|
||||
int restore_result = fcntl(owned, F_SETOWN_EX, &original_owned);
|
||||
int restore_errno = errno;
|
||||
if (restore_result < 0) {
|
||||
errno = restore_errno;
|
||||
return -1;
|
||||
}
|
||||
if (observed_result < 0) {
|
||||
errno = observed_errno;
|
||||
return -1;
|
||||
}
|
||||
return observed.type == marker->type && observed.pid == marker->pid;
|
||||
}
|
||||
|
||||
static int same_owned_description(int owned, int fd) {
|
||||
int saved_errno = errno;
|
||||
int result = fcntl(owned, F_DUPFD_QUERY, fd);
|
||||
if (result >= 0) {
|
||||
errno = saved_errno;
|
||||
return result == 1;
|
||||
}
|
||||
#ifdef SYS_kcmp
|
||||
long compared = syscall(SYS_kcmp, getpid(), getpid(), 0 /* KCMP_FILE */, owned, fd);
|
||||
if (compared >= 0) {
|
||||
errno = saved_errno;
|
||||
return compared == 0;
|
||||
}
|
||||
#endif
|
||||
int owner_match = same_owner_description(owned, fd);
|
||||
errno = saved_errno;
|
||||
if (result >= 0) return result == 1;
|
||||
return same_file_description(owned, fd);
|
||||
return owner_match == 1;
|
||||
}
|
||||
|
||||
static int find_handle_locked(int fd, uint32_t handle) {
|
||||
@@ -176,7 +227,11 @@ int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle) {
|
||||
if (powervr) {
|
||||
owner = fcntl(fd, F_DUPFD_CLOEXEC, 0);
|
||||
if (owner < 0) return -errno;
|
||||
if (!same_owned_description(owner, fd)) {
|
||||
/* The old-kernel owner probe mutates shared OFD state briefly; serialize it with lookups. */
|
||||
pthread_mutex_lock(&lock);
|
||||
int owner_matches = same_owned_description(owner, fd);
|
||||
pthread_mutex_unlock(&lock);
|
||||
if (!owner_matches) {
|
||||
close(owner);
|
||||
errno = EOPNOTSUPP;
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
Reference in new issue
Block a user