[Mesa-dev] [PATCH mesa] wayland: Disable prime support on buggy kernels

Jonas Ådahl jadahl at gmail.com
Wed May 8 13:50:14 PDT 2013


On Tue, Apr 23, 2013 at 3:54 PM, Ander Conselvan de Oliveira
<ander.conselvan.de.oliveira at 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
> ---
>  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)) {

I think if we should test against kernel releases we can disable for
anything older than the first release that has the fix as it doesn't
seem to work on older versions either. At least in my case I get what
looks like the same issue when prime support enabled when running
kernel version 3.5.

Jonas

> +         _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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list