On 04/29/2013 07:15 PM, Kristian Høgsberg wrote:
On Tue, Apr 23, 2013 at 9:54 AM, Ander Conselvan de Oliveira
<ander.conselvan.de.olive...@intel.com> wrote:
Linux kernel 3.8 shipped with a bug in the prime fd passing code that
makes it unreliable. As of this writing, it seems unlikely that 3.9
will contain the fix for the issue.

This patch disable prime support when running on top of those kernels,
in order to prevent unexpected behavior when running a Wayland
compositor.

Commit be8a42ae60addd8b6092535c11b42d099d6470ec in Linus tree introduces
the problem, which can be fixed by the patch below (not upstream yet):
http://lists.freedesktop.org/archives/dri-devel/2013-April/037716.html

What about the idea of using the self-ref test at init time to
determine if the kernel is buggy or not instead of the hard-coded
version check?

The test isn't reliable enough. It depends on the memory allocation for a dma_buf reusing the memory for an old dma_buf.

Ander


Kristian

---
  src/egl/drivers/dri2/egl_dri2.c |   36 +++++++++++++++++++++++++++++++++++-
  1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 06a21d7..13b9107 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -38,6 +38,7 @@
  #include <GL/internal/dri_interface.h>
  #include <sys/types.h>
  #include <sys/stat.h>
+#include <sys/utsname.h>

  #include "egl_dri2.h"

@@ -1557,6 +1558,38 @@ static struct wayland_drm_callbacks wl_drm_callbacks = {
  };

  static EGLBoolean
+kernel_prime_support_not_buggy()
+{
+   struct utsname un;
+
+   /* Linux kernel 3.8 shipped with a bug in the prime fd passing code that
+    * makes it unreliable. As of this writing, it seems unlikely that 3.9
+    * will contain the fix for the issue. Disable prime support when running
+    * on top of those kernels, in order to prevent unexpected behavior when
+    * running a Wayland compositor.
+    *
+    * Commit be8a42ae60addd8b6092535c11b42d099d6470ec in Linus tree introduces
+    * the problem, which can be fixed by the patch below (not upstream yet):
+    * http://lists.freedesktop.org/archives/dri-devel/2013-April/037716.html
+    */
+   if (uname(&un) == -1) {
+      _eglLog(_EGL_INFO,
+              "DRI2: wayland prime support disabled: unknown kernel version");
+      return EGL_FALSE;
+   }
+
+   if (strncmp(un.sysname, "Linux", strlen("Linux")) == 0 &&
+       (strncmp(un.release, "3.8.", strlen("3.8.")) == 0 ||
+        strncmp(un.release, "3.9.", strlen("3.9.")) == 0)) {
+         _eglLog(_EGL_INFO,
+                 "DRI2: wayland prime support disabled: buggy kernel");
+         return EGL_FALSE;
+   }
+
+   return EGL_TRUE;
+}
+
+static EGLBoolean
  dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
                              struct wl_display *wl_dpy)
  {
@@ -1575,7 +1608,8 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay 
*disp,
     ret = drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap);
     if (ret == 0 && cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
         dri2_dpy->image->base.version >= 7 &&
-       dri2_dpy->image->createImageFromFds != NULL)
+       dri2_dpy->image->createImageFromFds != NULL &&
+       kernel_prime_support_not_buggy())
        flags |= WAYLAND_DRM_PRIME;

     dri2_dpy->wl_server_drm =
--
1.7.10.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to