[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libdrm: Changes to 'upstream-unstable'



 bsd-core/Makefile                |    2 
 bsd-core/drmP.h                  |   81 -
 bsd-core/drm_bufs.c              |   11 
 bsd-core/drm_drv.c               |  151 ++-
 bsd-core/drm_irq.c               |  100 --
 bsd-core/drm_linux_list.h        |    4 
 bsd-core/drm_lock.c              |    9 
 bsd-core/drm_pci.c               |    8 
 bsd-core/drm_scatter.c           |  111 ++
 bsd-core/drm_sysctl.c            |    6 
 bsd-core/drm_vm.c                |    7 
 bsd-core/i915_drv.c              |   30 
 bsd-core/i915_reg.h              |    1 
 bsd-core/mach64_drv.c            |   23 
 bsd-core/mga_drv.c               |   16 
 bsd-core/nouveau/@               |    1 
 bsd-core/nouveau/Makefile        |   33 
 bsd-core/nouveau/machine         |    1 
 bsd-core/nouveau_dma.c           |    1 
 bsd-core/nouveau_dma.h           |    1 
 bsd-core/nouveau_drm.h           |    1 
 bsd-core/nouveau_drv.c           |  148 +++
 bsd-core/nouveau_drv.h           |    1 
 bsd-core/nouveau_fifo.c          |    1 
 bsd-core/nouveau_irq.c           |    1 
 bsd-core/nouveau_mem.c           |    1 
 bsd-core/nouveau_notifier.c      |    1 
 bsd-core/nouveau_object.c        |    1 
 bsd-core/nouveau_reg.h           |    1 
 bsd-core/nouveau_sgdma.c         |  357 ++++++++
 bsd-core/nouveau_state.c         |    1 
 bsd-core/nouveau_swmthd.c        |    1 
 bsd-core/nouveau_swmthd.h        |    1 
 bsd-core/nv04_fb.c               |    1 
 bsd-core/nv04_fifo.c             |    1 
 bsd-core/nv04_graph.c            |    1 
 bsd-core/nv04_instmem.c          |    1 
 bsd-core/nv04_mc.c               |    1 
 bsd-core/nv04_timer.c            |    1 
 bsd-core/nv10_fb.c               |    1 
 bsd-core/nv10_fifo.c             |    1 
 bsd-core/nv10_graph.c            |    1 
 bsd-core/nv20_graph.c            |    1 
 bsd-core/nv40_fb.c               |    1 
 bsd-core/nv40_fifo.c             |    1 
 bsd-core/nv40_graph.c            |    1 
 bsd-core/nv40_mc.c               |    1 
 bsd-core/nv50_fifo.c             |    1 
 bsd-core/nv50_graph.c            |    1 
 bsd-core/nv50_grctx.h            |    1 
 bsd-core/nv50_instmem.c          |    1 
 bsd-core/nv50_mc.c               |    1 
 bsd-core/r128_drv.c              |   22 
 bsd-core/radeon_drv.c            |   16 
 bsd-core/savage_drv.c            |   16 
 bsd-core/sis_drv.c               |   16 
 bsd-core/tdfx_drv.c              |   16 
 bsd-core/via_drv.c               |   16 
 configure.ac                     |    9 
 libdrm/intel/intel_bufmgr.h      |    1 
 libdrm/intel/intel_bufmgr_fake.c |   19 
 libdrm/intel/intel_bufmgr_gem.c  |   72 +
 libdrm/nouveau/Makefile.am       |    4 
 libdrm/nouveau/nouveau_bo.c      |   25 
 libdrm/nouveau/nouveau_device.c  |   18 
 libdrm/nouveau/nouveau_drmif.h   |    3 
 libdrm/nouveau/nouveau_fence.c   |   16 
 libdrm/nouveau/nouveau_private.h |    2 
 linux-core/ati_pcigart.c         |    4 
 linux-core/drmP.h                |   10 
 linux-core/drm_agpsupport.c      |   37 
 linux-core/drm_bo.c              |   66 -
 linux-core/drm_bo_move.c         |   16 
 linux-core/drm_compat.c          |  579 -------------
 linux-core/drm_compat.h          |  172 ----
 linux-core/drm_drv.c             |    5 
 linux-core/drm_irq.c             |    4 
 linux-core/drm_memory.c          |    7 
 linux-core/drm_memory_debug.c    |    4 
 linux-core/drm_objects.h         |   11 
 linux-core/drm_os_linux.h        |   22 
 linux-core/drm_proc.c            |    4 
 linux-core/drm_ttm.c             |    6 
 linux-core/drm_vm.c              |   24 
 linux-core/mga_drv.c             |    2 
 linux-core/nouveau_drv.c         |    2 
 linux-core/r128_drv.c            |    2 
 linux-core/radeon_drv.c          |    2 
 linux-core/via_dmablit.c         |   12 
 linux-core/xgi_drv.c             |    2 
 shared-core/i915_dma.c           |  696 +++++-----------
 shared-core/i915_drv.h           | 1632 ++-------------------------------------
 shared-core/i915_irq.c           |  910 +++++----------------
 shared-core/i915_reg.h           | 1422 +++++++++++++++++++++++++++++++++
 shared-core/mach64_drv.h         |    1 
 shared-core/mach64_irq.c         |    2 
 shared-core/mga_dma.c            |    8 
 shared-core/mga_irq.c            |    5 
 shared-core/nouveau_dma.c        |    1 
 shared-core/nouveau_mem.c        |   85 +-
 shared-core/nouveau_reg.h        |    8 
 shared-core/nv04_instmem.c       |    3 
 shared-core/nv40_mc.c            |    2 
 shared-core/r128_drv.h           |    1 
 shared-core/r128_irq.c           |    2 
 shared-core/radeon_cp.c          |   13 
 shared-core/radeon_irq.c         |   33 
 shared-core/via_irq.c            |    1 
 shared-core/via_map.c            |   12 
 tests/Makefile.am                |   47 -
 tests/drmtest.c                  |  117 +-
 tests/drmtest.h                  |    3 
 tests/gem_basic.c                |    6 
 tests/gem_flink.c                |    6 
 tests/gem_mmap.c                 |    6 
 tests/gem_readwrite.c            |    6 
 tests/getversion.c               |    3 
 tests/setversion.c               |    5 
 tests/updatedraw.c               |    5 
 119 files changed, 3305 insertions(+), 4132 deletions(-)

New commits:
commit 07646002c6835537c6ae44ef9b3f8480762279b8
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Fri Apr 10 15:34:24 2009 -0700

    Bump version to 2.4.9
    
    Who needs 2.4.8 anyway?

diff --git a/configure.ac b/configure.ac
index 5c82dcf..19d9c9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,8 +18,8 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-AC_PREREQ(2.58)
-AC_INIT([libdrm], 2.4.7, [dri-devel@lists.sourceforge.net], libdrm)
+AC_PREREQ(2.57)
+AC_INIT([libdrm], 2.4.9, [dri-devel@lists.sourceforge.net], libdrm)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 

commit 4d5e82e7d3cf9f94c1c74bd5067e3ea1fb9d0981
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Fri Apr 10 15:24:41 2009 -0700

    Bump version to 2.4.8

diff --git a/configure.ac b/configure.ac
index c3e76e0..5c82dcf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-AC_PREREQ(2.57)
+AC_PREREQ(2.58)
 AC_INIT([libdrm], 2.4.7, [dri-devel@lists.sourceforge.net], libdrm)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])

commit 3637dcc66d707aa9ababf0b12cd4a299559522f5
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Fri Apr 10 15:24:10 2009 -0700

    Revert "libdrm: speed up connector & mode fetching"
    
    This reverts commit cd5c66c659168cbe2e3229ebf8be79f764ed0ee1.  It broke too
    many kernel assumptions about the double ioctl (connector status, mode
    fetching, etc.)

diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index e2aba81..872604f 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -357,45 +357,21 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
 {
 	struct drm_mode_get_connector conn;
 	drmModeConnectorPtr r = NULL;
-	int pre_props = 8, pre_modes = 16, pre_encoders = 4;
 
 	conn.connector_id = connector_id;
 	conn.connector_type_id = 0;
 	conn.connector_type  = 0;
-	conn.count_modes  = pre_modes;
-	conn.count_props  = pre_props;
-	conn.count_encoders  = pre_encoders;
-
-	/*
-	 * Pre-allocate space for some modes, properties, and encoders.  If
-	 * we're lucky we won't need to call into the kernel twice.
-	 */
-	conn.props_ptr = VOID2U64(drmMalloc(pre_props * sizeof(uint32_t)));
-	conn.prop_values_ptr = VOID2U64(drmMalloc(pre_props *
-						  sizeof(uint64_t)));
-	conn.modes_ptr = VOID2U64(drmMalloc(pre_modes *
-					    sizeof(struct drm_mode_modeinfo)));
-	conn.encoders_ptr = VOID2U64(drmMalloc(pre_encoders *
-					       sizeof(uint32_t)));
+	conn.count_modes  = 0;
+	conn.modes_ptr    = 0;
+	conn.count_props  = 0;
+	conn.props_ptr    = 0;
+	conn.prop_values_ptr = 0;
+	conn.count_encoders  = 0;
+	conn.encoders_ptr = 0;
 
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
 		return 0;
 
-	if (conn.count_props <= pre_props &&
-	    conn.count_modes <= pre_modes &&
-	    conn.count_encoders <= pre_encoders)
-		goto done;
-
-	/* Oh well, free & reallocate everything and ask again... */
-	drmFree(U642VOID(conn.prop_values_ptr));
-	drmFree(U642VOID(conn.props_ptr));
-	drmFree(U642VOID(conn.modes_ptr));
-	drmFree(U642VOID(conn.encoders_ptr));
-	conn.prop_values_ptr = 0;
-	conn.props_ptr = 0;
-	conn.modes_ptr = 0;
-	conn.encoders_ptr = 0;
-
 	if (conn.count_props) {
 		conn.props_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint32_t)));
 		conn.prop_values_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint64_t)));
@@ -410,7 +386,6 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
 		goto err_allocs;
 
-done:
 	if(!(r = drmMalloc(sizeof(*r)))) {
 		goto err_allocs;
 	}

commit fef29358bb407f35b90e8c6ee913e4979786cfd5
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Apr 9 15:19:10 2009 -0400

    Bump version to 2.4.7

diff --git a/configure.ac b/configure.ac
index 2e32c84..c3e76e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libdrm], 2.4.6, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.7, [dri-devel@lists.sourceforge.net], libdrm)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 

commit ec9b7b320a724e49d61375b4ad53e2c88fa30f66
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Apr 9 15:17:51 2009 -0400

    test: Avoid recursive dependency in makefile

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b1dad7e..98c106b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,7 +21,7 @@ libdrmtest_la_SOURCES = \
 	drmtest.h
 
 libdrmtest_la_LIBADD = \
-	$(LDADD) \
+	$(top_builddir)/libdrm/libdrm.la \
 	$(LIBUDEV_LIBS)
 
 LDADD += libdrmtest.la

commit a85e07b9031c819f3cdf54b66c90ac0c450e3e75
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Apr 9 15:02:40 2009 -0400

    test: Makefile.am grammar nazi

diff --git a/tests/Makefile.am b/tests/Makefile.am
index e5e9fc4..b1dad7e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,8 @@
-AM_CFLAGS = \
+AM_CPPFLAGS = \
 	-I $(top_srcdir)/shared-core \
 	-I $(top_srcdir)/libdrm
 
-AM_LDFLAGS = $(top_builddir)/libdrm/libdrm.la
+LDADD = $(top_builddir)/libdrm/libdrm.la
 
 noinst_PROGRAMS = \
 	dristat \
@@ -15,14 +15,16 @@ SUBDIRS = \
 if HAVE_LIBUDEV
 
 EXTRA_LTLIBRARIES = libdrmtest.la
+
 libdrmtest_la_SOURCES = \
 	drmtest.c \
 	drmtest.h
+
 libdrmtest_la_LIBADD = \
-	$(top_builddir)/libdrm/libdrm.la \
+	$(LDADD) \
 	$(LIBUDEV_LIBS)
 
-LDADD = libdrmtest.la
+LDADD += libdrmtest.la
 
 XFAIL_TESTS =					\
 	auth					\

commit 1faab66cfd1a854925da6ff7109aa614292dea90
Author: Dave Airlie <airlied@linux.ie>
Date:   Tue Apr 7 09:26:32 2009 +1000

    drm: fix test makefile
    
    no idea if this is correct but it works so meh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc99447..e5e9fc4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,8 @@ AM_CFLAGS = \
 	-I $(top_srcdir)/shared-core \
 	-I $(top_srcdir)/libdrm
 
+AM_LDFLAGS = $(top_builddir)/libdrm/libdrm.la
+
 noinst_PROGRAMS = \
 	dristat \
 	drmstat

commit 751db3fe27d5e51925c28ceecadb828784d46028
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Mon Apr 6 17:22:10 2009 -0400

    Skip tests that require root
    
    This lets us do make distcheck as non-root.

diff --git a/tests/setversion.c b/tests/setversion.c
index f4bfbfb..3aaf7cc 100644
--- a/tests/setversion.c
+++ b/tests/setversion.c
@@ -40,6 +40,11 @@ int main(int argc, char **argv)
 	int fd, ret;
 	drm_set_version_t sv, version;
 
+	if (getuid() != 0) {
+		fprintf(stderr, "setversion test requires root, skipping\n");
+		return 0;
+	}
+
 	fd = drm_open_any_master();
 
 	/* First, check that we can get the DD/DI versions. */
diff --git a/tests/updatedraw.c b/tests/updatedraw.c
index 2f22fef..a61eb15 100644
--- a/tests/updatedraw.c
+++ b/tests/updatedraw.c
@@ -123,6 +123,11 @@ int main(int argc, char **argv)
 {
 	int fd, ret, d1, d2;
 
+	if (getuid() != 0) {
+		fprintf(stderr, "updatedraw test requires root, skipping\n");
+		return 0;
+	}
+
 	fd = drm_open_any_master();
 
 	d1 = add_drawable(fd);

commit 8a5c4d567fafffbda57cbe5e4ed8c419193cada5
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Mon Apr 6 17:18:17 2009 -0400

    XFAIL auth and lock test cases
    
    They're writing to the read end of a pipe and failing.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 123c547..bc99447 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,17 +22,20 @@ libdrmtest_la_LIBADD = \
 
 LDADD = libdrmtest.la
 
-TESTS = auth \
-	openclose \
-	getversion \
-	getclient \
-	getstats \
-	lock \
-	setversion \
-	updatedraw \
-	gem_basic \
-	gem_flink \
-	gem_readwrite \
+XFAIL_TESTS =					\
+	auth					\
+	lock
+
+TESTS =						\
+	openclose				\
+	getversion				\
+	getclient				\
+	getstats				\
+	setversion				\
+	updatedraw				\
+	gem_basic				\
+	gem_flink				\
+	gem_readwrite				\
 	gem_mmap
 
 EXTRA_PROGRAMS = $(TESTS)
diff --git a/tests/getversion.c b/tests/getversion.c
index 3de90de..711d376 100644
--- a/tests/getversion.c
+++ b/tests/getversion.c
@@ -40,7 +40,8 @@ int main(int argc, char **argv)
 	assert(strlen(v->name) != 0);
 	assert(strlen(v->date) != 0);
 	assert(strlen(v->desc) != 0);
-	assert(v->version_major >= 1);
+	if (strcmp(v->name, "i915") == 0)
+		assert(v->version_major >= 1);
 	drmFree(v);
 	close(fd);
 	return 0;

commit e9d6116e5bd30639d6333ef95462fe300f47ccd5
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Mon Apr 6 17:13:01 2009 -0400

    Use libudev in test case to only run gem tests for intel devices.

diff --git a/configure.ac b/configure.ac
index 8be1e2a..2e32c84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,13 @@ if test "x$HAVE_CAIRO" = xyes; then
 fi
 AM_CONDITIONAL(HAVE_CAIRO, [test "x$HAVE_CAIRO" = xyes])
 
+# For enumerating devices in test case
+PKG_CHECK_MODULES(LIBUDEV, libudev, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
+if test "x$HAVE_LIBUDEV" = xyes; then
+   	AC_DEFINE(HAVE_LIBUDEV, 1, [Have libudev support])
+fi
+AM_CONDITIONAL(HAVE_LIBUDEV, [test "x$HAVE_LIBUDEV" = xyes])
+
 
 AC_SUBST(WARN_CFLAGS)
 AC_OUTPUT([
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e66d1c8..123c547 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,19 +6,22 @@ noinst_PROGRAMS = \
 	dristat \
 	drmstat
 
+SUBDIRS = \
+	modeprint \
+	modetest
+
+if HAVE_LIBUDEV
+
 EXTRA_LTLIBRARIES = libdrmtest.la
 libdrmtest_la_SOURCES = \
 	drmtest.c \
 	drmtest.h
 libdrmtest_la_LIBADD = \
-	$(top_builddir)/libdrm/libdrm.la
+	$(top_builddir)/libdrm/libdrm.la \
+	$(LIBUDEV_LIBS)
 
 LDADD = libdrmtest.la
 
-SUBDIRS = \
-	modeprint \
-	modetest
-
 TESTS = auth \
 	openclose \
 	getversion \
@@ -33,5 +36,8 @@ TESTS = auth \
 	gem_mmap
 
 EXTRA_PROGRAMS = $(TESTS)
+
+endif
+
 CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES)
 
diff --git a/tests/drmtest.c b/tests/drmtest.c
index 5453b10..15e5c4a 100644
--- a/tests/drmtest.c
+++ b/tests/drmtest.c
@@ -26,58 +26,103 @@
  */
 
 #include <fcntl.h>
+#include <fnmatch.h>
 #include <sys/stat.h>
 #include "drmtest.h"
 
-/** Open the first DRM device we can find, searching up to 16 device nodes */
-int drm_open_any(void)
+#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
+#include <libudev.h>
+
+static int is_master(int fd)
 {
-	char name[20];
+	drm_client_t client;
+	int ret;
+
+	/* Check that we're the only opener and authed. */
+	client.idx = 0;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	assert (ret == 0);
+	if (!client.auth)
+		return 0;
+	client.idx = 1;
+	ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
+	if (ret != -1 || errno != EINVAL)
+		return 0;
+
+	return 1;
+}
+
+/** Open the first DRM device matching the criteria */
+int drm_open_matching(const char *pci_glob, int flags)
+{
+	struct udev *udev;
+	struct udev_enumerate *e;
+	struct udev_device *device, *parent;
+        struct udev_list_entry *entry;
+	const char *pci_id, *path;
 	int i, fd;
 
-	for (i = 0; i < 16; i++) {
-		sprintf(name, "/dev/dri/card%d", i);
-		fd = open(name, O_RDWR);
-		if (fd != -1)
-			return fd;
+	udev = udev_new();
+	if (udev == NULL) {
+		fprintf(stderr, "failed to initialize udev context\n");
+		abort();
 	}
-	abort();
+
+	fd = -1;
+	e = udev_enumerate_new(udev);
+	udev_enumerate_add_match_subsystem(e, "drm");
+        udev_enumerate_scan_devices(e);
+        udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
+		path = udev_list_entry_get_name(entry);
+		device = udev_device_new_from_syspath(udev, path);
+		parent = udev_device_get_parent(device);
+		/* Filter out KMS output devices. */
+		if (strcmp(udev_device_get_subsystem(parent), "pci") != 0)
+			continue;
+		pci_id = udev_device_get_property_value(parent, "PCI_ID");
+		if (fnmatch(pci_glob, pci_id, 0) != 0)
+			continue;
+		fd = open(udev_device_get_devnode(device), O_RDWR);
+		if (fd < 0)
+			continue;
+		if ((flags & DRM_TEST_MASTER) && !is_master(fd)) {
+			close(fd);
+			fd = -1;
+			continue;
+		}
+
+		break;
+	}
+        udev_enumerate_unref(e);
+	udev_unref(udev);
+
+	return fd;
 }
 
+int drm_open_any(void)
+{
+	int fd = drm_open_matching("*:*", 0);
+
+	if (fd < 0) {
+		fprintf(stderr, "failed to open any drm device\n");
+		abort();
+	}
+
+	return fd;
+}
 
 /**
  * Open the first DRM device we can find where we end up being the master.
  */
 int drm_open_any_master(void)
 {
-	char name[20];
-	int i, fd;
+	int fd = drm_open_matching("*:*", DRM_TEST_MASTER);
 
-	for (i = 0; i < 16; i++) {
-		drm_client_t client;
-		int ret;
+	if (fd < 0) {
+		fprintf(stderr, "failed to open any drm device\n");
+		abort();
+	}
 
-		sprintf(name, "/dev/dri/card%d", i);
-		fd = open(name, O_RDWR);
-		if (fd == -1)
-			continue;
+	return fd;
 
-		/* Check that we're the only opener and authed. */
-		client.idx = 0;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		assert (ret == 0);
-		if (!client.auth) {
-			close(fd);
-			continue;
-		}
-		client.idx = 1;
-		ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
-		if (ret != -1 || errno != EINVAL) {
-			close(fd);
-			continue;
-		}
-		return fd;
-	}
-	fprintf(stderr, "Couldn't find an un-controlled DRM device\n");
-	abort();
 }
diff --git a/tests/drmtest.h b/tests/drmtest.h
index afa0df4..55bb446 100644
--- a/tests/drmtest.h
+++ b/tests/drmtest.h
@@ -33,5 +33,8 @@
 
 #include "xf86drm.h"
 
+#define DRM_TEST_MASTER 0x01
+
 int drm_open_any(void);
 int drm_open_any_master(void);
+int drm_open_matching(const char *pci_glob, int flags);
diff --git a/tests/gem_basic.c b/tests/gem_basic.c
index b2176fb..4e4b6cb 100644
--- a/tests/gem_basic.c
+++ b/tests/gem_basic.c
@@ -88,7 +88,11 @@ int main(int argc, char **argv)
 {
 	int fd;
 
-	fd = drm_open_any();
+	fd = drm_open_matching("8086:*", 0);
+	if (fd < 0) {
+		fprintf(stderr, "failed to open intel drm device\n");
+		return 0;
+	}
 
 	test_bad_close(fd);
 	test_create_close(fd);
diff --git a/tests/gem_flink.c b/tests/gem_flink.c
index d2e062f..ff999d2 100644
--- a/tests/gem_flink.c
+++ b/tests/gem_flink.c
@@ -117,7 +117,11 @@ int main(int argc, char **argv)
 {
 	int fd;
 
-	fd = drm_open_any();
+	fd = drm_open_matching("8086:*", 0);
+	if (fd < 0) {
+		fprintf(stderr, "failed to open intel drm device, skipping\n");
+		return 0;
+	}
 
 	test_flink(fd);
 	test_double_flink(fd);
diff --git a/tests/gem_mmap.c b/tests/gem_mmap.c
index b5c1546..d24005b 100644
--- a/tests/gem_mmap.c
+++ b/tests/gem_mmap.c
@@ -81,7 +81,11 @@ int main(int argc, char **argv)
 	int ret;
 	int handle;
 
-	fd = drm_open_any();
+	fd = drm_open_matching("8086:*", 0);
+	if (fd < 0) {
+		fprintf(stderr, "failed to open intel drm device, skipping\n");
+		return 0;
+	}
 
 	memset(&mmap, 0, sizeof(mmap));
 	mmap.handle = 0x10101010;
diff --git a/tests/gem_readwrite.c b/tests/gem_readwrite.c
index bd1d232..4f5cde6 100644
--- a/tests/gem_readwrite.c
+++ b/tests/gem_readwrite.c
@@ -78,7 +78,11 @@ int main(int argc, char **argv)
 	int ret;
 	int handle;
 
-	fd = drm_open_any();
+	fd = drm_open_matching("8086:*", 0);
+	if (fd < 0) {
+		fprintf(stderr, "failed to open intel drm device, skipping\n");
+		return 0;
+	}
 
 	memset(&create, 0, sizeof(create));
 	create.size = OBJECT_SIZE;

commit 51d6346f9f3c425f49e57d185530c6bcaeb94f5e
Author: Robert Noland <rnoland@2hip.net>
Date:   Tue Mar 31 13:33:18 2009 -0500

    Move drm_vblank_cleanup() after lastclose.
    
    This may prevent a possible panic on shutdown.

diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index a9165a4..ce683a6 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -524,12 +524,12 @@ static void drm_unload(struct drm_device *dev)
 		DRM_DEBUG("mtrr_del = %d", retcode);
 	}
 
-	drm_vblank_cleanup(dev);
-
 	DRM_LOCK();
 	drm_lastclose(dev);
 	DRM_UNLOCK();
 
+	drm_vblank_cleanup(dev);
+
 	/* Clean up PCI resources allocated by drm_bufs.c.  We're not really
 	 * worried about resource consumption while the DRM is inactive (between
 	 * lastclose and firstopen or unload) because these aren't actually
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index c68e237..72f0e98 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -397,11 +397,11 @@ static void drm_cleanup(struct drm_device * dev)
 		return;
 	}
 
-	drm_vblank_cleanup(dev);
-
 	drm_lastclose(dev);
 	drm_fence_manager_takedown(dev);
 
+	drm_vblank_cleanup(dev);
+
 	if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp
 	    && dev->agp->agp_mtrr >= 0) {
 		int retval;

commit cd5c66c659168cbe2e3229ebf8be79f764ed0ee1
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Mon Mar 30 14:35:30 2009 -0700

    libdrm: speed up connector & mode fetching
    
    This patch speeds up drmModeGetConnector by pre-allocating mode &
    property info space before calling into the kernel.  In many cases this
    pre-allocation will be sufficient to hold the returned values (it's easy
    enough to tweak if the common case becomes larger), which means we don't
    have to make the second call, which saves a lot of time.
    
    Acked-by: Jakob Bornecrantz <wallbraker@gmail.com>
    Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index 872604f..e2aba81 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -357,21 +357,45 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
 {
 	struct drm_mode_get_connector conn;
 	drmModeConnectorPtr r = NULL;
+	int pre_props = 8, pre_modes = 16, pre_encoders = 4;
 
 	conn.connector_id = connector_id;
 	conn.connector_type_id = 0;
 	conn.connector_type  = 0;
-	conn.count_modes  = 0;
-	conn.modes_ptr    = 0;
-	conn.count_props  = 0;
-	conn.props_ptr    = 0;
-	conn.prop_values_ptr = 0;
-	conn.count_encoders  = 0;
-	conn.encoders_ptr = 0;
+	conn.count_modes  = pre_modes;
+	conn.count_props  = pre_props;
+	conn.count_encoders  = pre_encoders;
+
+	/*
+	 * Pre-allocate space for some modes, properties, and encoders.  If
+	 * we're lucky we won't need to call into the kernel twice.
+	 */
+	conn.props_ptr = VOID2U64(drmMalloc(pre_props * sizeof(uint32_t)));
+	conn.prop_values_ptr = VOID2U64(drmMalloc(pre_props *
+						  sizeof(uint64_t)));
+	conn.modes_ptr = VOID2U64(drmMalloc(pre_modes *
+					    sizeof(struct drm_mode_modeinfo)));
+	conn.encoders_ptr = VOID2U64(drmMalloc(pre_encoders *
+					       sizeof(uint32_t)));
 
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
 		return 0;
 
+	if (conn.count_props <= pre_props &&
+	    conn.count_modes <= pre_modes &&
+	    conn.count_encoders <= pre_encoders)
+		goto done;
+
+	/* Oh well, free & reallocate everything and ask again... */
+	drmFree(U642VOID(conn.prop_values_ptr));
+	drmFree(U642VOID(conn.props_ptr));
+	drmFree(U642VOID(conn.modes_ptr));
+	drmFree(U642VOID(conn.encoders_ptr));
+	conn.prop_values_ptr = 0;
+	conn.props_ptr = 0;
+	conn.modes_ptr = 0;
+	conn.encoders_ptr = 0;
+
 	if (conn.count_props) {
 		conn.props_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint32_t)));
 		conn.prop_values_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint64_t)));
@@ -386,6 +410,7 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
 		goto err_allocs;
 
+done:
 	if(!(r = drmMalloc(sizeof(*r)))) {
 		goto err_allocs;
 	}

commit 93e65271601e6a1c7c90453f2f13157ae24b35c2
Author: Stuart Bennett <stuart@freedesktop.org>
Date:   Mon Mar 30 20:38:49 2009 +0100

    nouveau: nForce 1/2 IGP memory sanity check from DDX

diff --git a/shared-core/nouveau_mem.c b/shared-core/nouveau_mem.c
index af23214..627b917 100644
--- a/shared-core/nouveau_mem.c
+++ b/shared-core/nouveau_mem.c
@@ -237,7 +237,7 @@ void nouveau_mem_close(struct drm_device *dev)
  * and a small inline to do	*val = pci_read_config(pdev->device, where, 4);
  * might work
  */
-static uint32_t nforce_pci_fn_read_config_dword(int devfn, int where, uint32_t *val)
+static int nforce_pci_fn_read_config_dword(int devfn, int where, uint32_t *val)
 {
 #ifdef __linux__
 	DRM_PCI_DEV *pdev;
@@ -255,6 +255,29 @@ static uint32_t nforce_pci_fn_read_config_dword(int devfn, int where, uint32_t *
 #endif
 }
 
+static void nouveau_mem_check_nforce_dimms(struct drm_device *dev)
+{
+	uint32_t mem_ctrlr_pciid;
+
+	nforce_pci_fn_read_config_dword(3, 0x00, &mem_ctrlr_pciid);
+	mem_ctrlr_pciid >>= 16;
+
+	if (mem_ctrlr_pciid == 0x01a9 || mem_ctrlr_pciid == 0x01ab ||
+	    mem_ctrlr_pciid == 0x01ed) {
+		uint32_t dimm[3];
+		int i;
+
+		for (i = 0; i < 3; i++) {
+			nforce_pci_fn_read_config_dword(2, 0x40 + i * 4, &dimm[i]);
+			dimm[i] = (dimm[i] >> 8) & 0x4f;
+		}
+
+		if (dimm[0] + dimm[1] != dimm[2])
+			DRM_INFO("Your nForce DIMMs are not arranged in "
+				 "optimal banks!\n");
+	}
+}
+
 static uint32_t
 nouveau_mem_fb_amount_igp(struct drm_device *dev)
 {
@@ -484,6 +507,9 @@ int nouveau_mem_init(struct drm_device *dev)
 	dev_priv->fb_phys = 0;
 	dev_priv->gart_info.type = NOUVEAU_GART_NONE;
 
+	if (dev_priv->flags & (NV_NFORCE | NV_NFORCE2))
+		nouveau_mem_check_nforce_dimms(dev);
+
 	/* setup a mtrr over the FB */
 	dev_priv->fb_mtrr = drm_mtrr_add(drm_get_resource_start(dev, 1),
 					 nouveau_mem_fb_amount(dev),

commit 2ada85502242a3d5328b8f392d7843ef58a78780
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Mon Mar 30 11:25:09 2009 -0700

    libdrm: bump version to 2.4.6
    
    This version includes GTT unmap support for the Intel bufmgr.

diff --git a/configure.ac b/configure.ac
index 04933c3..8be1e2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,7 @@
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libdrm], 2.4.5, [dri-devel@lists.sourceforge.net], libdrm)
+AC_INIT([libdrm], 2.4.6, [dri-devel@lists.sourceforge.net], libdrm)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 

commit e2d7dfb61ad7a97367f050150160c205614d152e
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Thu Mar 26 16:43:00 2009 -0700

    libdrm/intel: support GTT maps correctly
    
    libdrm has some support for GTT mapping already, but there are bugs
    with it (no surprise since it hasn't been used much).
    
    In fixing 20803, I found that sharing bo_gem->virtual was a bad idea,
    since a previously mapped object might not end up getting GTT mapped,
    leading to corruption.  So this patch splits the fields according to
    use, taking care to unmap both at free time (but preserving the map
    caching).
    
    There's still a risk we might run out of mappings (there's a sysctl
    tunable for max number of mappings per process, defaulted to 64k or so
    it looks like) but at least GTT maps will work with these changes (and
    some others for fixing PAT breakage in the kernel).
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h
index 111d2af..542dc06 100644
--- a/libdrm/intel/intel_bufmgr.h
+++ b/libdrm/intel/intel_bufmgr.h
@@ -115,6 +115,7 @@ drm_intel_bo *drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
 						unsigned int handle);
 void drm_intel_bufmgr_gem_enable_reuse(drm_intel_bufmgr *bufmgr);
 int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo);
+int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo);
 void drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable);
 
 /* drm_intel_bufmgr_fake.c */
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 9e49d7c..e48778c 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -145,7 +145,9 @@ struct _drm_intel_bo_gem {
     /** Number of entries in relocs */
     int reloc_count;
     /** Mapped address for the buffer, saved across map/unmap cycles */
-    void *virtual;
+    void *mem_virtual;
+    /** GTT virtual address for the buffer, saved across map/unmap cycles */
+    void *gtt_virtual;
 
     /** BO cache list */
     drmMMListHead head;
@@ -524,8 +526,10 @@ drm_intel_gem_bo_free(drm_intel_bo *bo)
     struct drm_gem_close close;
     int ret;
 
-    if (bo_gem->virtual)


Reply to: