- attempt to fix race with udev by just waiting for udev

This commit is contained in:
Dave Airlie 2008-08-10 08:47:25 +00:00
parent 3a58a08db0
commit 072e83d676
2 changed files with 75 additions and 2 deletions

68
libdrm-wait-udev.patch Normal file
View File

@ -0,0 +1,68 @@
diff --git a/configure.ac b/configure.ac
index 1cf877d..0cf0974 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,9 @@ AC_SYS_LARGEFILE
pkgconfigdir=${libdir}/pkgconfig
AC_SUBST(pkgconfigdir)
+AC_ARG_ENABLE(udev, AS_HELP_STRING([--enable-udev],
+ [Enable support for using udev instead of mknod (default: disabled)]),
+ [UDEV=$enableval], [UDEV=no])
dnl ===========================================================================
@@ -101,6 +104,10 @@ AC_CACHE_CHECK([for supported warning flags], libdrm_cv_warn_cflags, [
AC_MSG_CHECKING([which warning flags were supported])])
WARN_CFLAGS="$libdrm_cv_warn_cflags"
+if test "x$UDEV" = xyes; then
+ AC_DEFINE(UDEV, 1, [Have UDEV support])
+fi
+
AC_SUBST(WARN_CFLAGS)
AC_OUTPUT([
Makefile
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index 150dd5f..5d8819a 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -297,6 +297,7 @@ static int drmOpenDevice(long dev, int minor)
group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
}
+#if !defined(UDEV)
if (stat(DRM_DIR_NAME, &st)) {
if (!isroot)
return DRM_ERR_NOT_ROOT;
@@ -317,6 +318,30 @@ static int drmOpenDevice(long dev, int minor)
chown(buf, user, group);
chmod(buf, devmode);
}
+#else
+ /* if we modprobed then wait for udev */
+ {
+ int udev_count = 0;
+wait_for_udev:
+ if (stat(DRM_DIR_NAME, &st)) {
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
+
+ if (stat(buf, &st)) {
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
+ }
+#endif
fd = open(buf, O_RDWR, 0);
drmMsg("drmOpenDevice: open result is %d, (%s)\n",

View File

@ -3,7 +3,7 @@
Summary: Direct Rendering Manager runtime library
Name: libdrm
Version: 2.4.0
Release: 0.16%{?dist}
Release: 0.17%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://dri.sourceforge.net
@ -23,6 +23,7 @@ Patch2: libdrm-2.4.0-no-freaking-mknod.patch
# - funk that just bash it direct for now -
Patch3: libdrm-make-dri-perms-okay.patch
Patch4: libdrm-2.4.0-no-bc.patch
Patch5: libdrm-wait-udev.patch
%description
Direct Rendering Manager runtime library
@ -41,10 +42,11 @@ Direct Rendering Manager development package
#patch2 -p1 -b .mknod
%patch3 -p1 -b .forceperms
%patch4 -p1 -b .no-bc
%patch5 -p1 -b .udev-wait
%build
autoreconf -v --install || exit 1
%configure
%configure --enable-udev
make
%install
@ -90,6 +92,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pkgconfig/libdrm.pc
%changelog
* Sun Aug 10 2008 Dave Airlie <airlied@redhat.com> 2.4.0-0.17
- attempt to fix race with udev by just waiting for udev
* Fri Aug 01 2008 Dave Airlie <airlied@redhat.com> 2.4.0-0.16
- new libdrm snapshot with modesetting for radeon interfaces