opnsense-ports/graphics/mesa-devel/files/patch-userptr
Franco Fichtner 7581d1f204 */*: sync with upstream
Taken from: FreeBSD
2022-09-27 13:44:40 +02:00

100 lines
3.4 KiB
Text

Try unsynchronized userptr if regular one fails.
https://github.com/FreeBSDDesktop/kms-drm/issues/197
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13162
--- src/gallium/drivers/crocus/crocus_bufmgr.c.orig 2021-06-30 22:34:42 UTC
+++ src/gallium/drivers/crocus/crocus_bufmgr.c
@@ -493,8 +493,20 @@ crocus_bo_create_userptr(struct crocus_bufmgr *bufmgr,
.user_ptr = (uintptr_t)ptr,
.user_size = size,
};
- if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
+
+ int ret;
+retry:
+ ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg);
+ if (ret) {
+ if (errno == ENODEV && arg.flags == 0) {
+ arg.flags = I915_USERPTR_UNSYNCHRONIZED;
+ goto retry;
+ }
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s", "ioctl(I915_GEM_USERPTR) failed. Try running as root but expect poor stability.\n");
+ }
goto err_free;
+ }
bo->gem_handle = arg.handle;
/* Check the buffer for validity before we try and use it in a batch */
--- src/gallium/drivers/iris/iris_bufmgr.c.orig 2021-03-10 22:23:51 UTC
+++ src/gallium/drivers/iris/iris_bufmgr.c
@@ -624,8 +624,20 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, con
.user_ptr = (uintptr_t)ptr,
.user_size = size,
};
- if (intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg))
+
+ int ret;
+retry:
+ ret = intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_USERPTR, &arg);
+ if (ret) {
+ if (errno == ENODEV && arg.flags == 0) {
+ arg.flags = I915_USERPTR_UNSYNCHRONIZED;
+ goto retry;
+ }
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s", "ioctl(I915_GEM_USERPTR) failed. Try running as root but expect poor stability.\n");
+ }
goto err_free;
+ }
bo->gem_handle = arg.handle;
/* Check the buffer for validity before we try and use it in a batch */
--- src/intel/vulkan/anv_gem.c.orig 2021-03-10 22:23:51 UTC
+++ src/intel/vulkan/anv_gem.c
@@ -146,9 +146,19 @@ anv_gem_userptr(struct anv_device *device, void *mem,
.flags = 0,
};
- int ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
- if (ret == -1)
+ int ret;
+retry:
+ ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
+ if (ret == -1) {
+ if (errno == ENODEV && userptr.flags == 0) {
+ userptr.flags = I915_USERPTR_UNSYNCHRONIZED;
+ goto retry;
+ }
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s", "ioctl(I915_GEM_USERPTR) failed. Try running as root but expect poor stability.\n");
+ }
return 0;
+ }
return userptr.handle;
}
--- src/intel/vulkan_hasvk/anv_gem.c.orig 2022-09-03 20:27:51 UTC
+++ src/intel/vulkan_hasvk/anv_gem.c
@@ -179,9 +179,19 @@ anv_gem_userptr(struct anv_device *device, void *mem,
if (device->physical->has_userptr_probe)
userptr.flags |= I915_USERPTR_PROBE;
- int ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
- if (ret == -1)
+ int ret;
+retry:
+ ret = intel_ioctl(device->fd, DRM_IOCTL_I915_GEM_USERPTR, &userptr);
+ if (ret == -1) {
+ if (errno == ENODEV && userptr.flags == 0) {
+ userptr.flags = I915_USERPTR_UNSYNCHRONIZED;
+ goto retry;
+ }
+ if (geteuid() != 0) {
+ fprintf(stderr, "%s", "ioctl(I915_GEM_USERPTR) failed. Try running as root but expect poor stability.\n");
+ }
return 0;
+ }
return userptr.handle;
}