Module Name:    src
Committed By:   mrg
Date:           Mon Mar 30 01:47:36 UTC 2009

Modified Files:
        src/sys/external/bsd/drm/dist/bsd-core: drm_drv.c

Log Message:
- set dev->device to the device_t
- fix a DEBUG message
- apply from sys/dev:
revision 1.20
date: 2009/01/18 10:04:35;  author: mrg;  state: Exp;  lines: +6 -2
Don't attempt to unload a DRM device that's in use.  (Note:
Unloading doesn't work right in any case -- it doesn't clean up the
sysctl tree, among other things.  This code needs Work, but at least
this prevents it crashing randomly due to autounload while X is
running.)  Also, fix the dependency list for radeondrm.

contributed anonymously.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c
diff -u src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.10 src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.11
--- src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.10	Mon Jul 21 07:18:11 2008
+++ src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c	Mon Mar 30 01:47:36 2009
@@ -395,6 +395,7 @@
 		return;
 
 	dev = drm_units[unit] = device_private(kdev);
+	dev->device = kdev;
 	dev->unit = unit;
 	for (unit = 0; unit < DRM_MAX_PCI_RESOURCE; unit++)
 	{
@@ -434,9 +435,13 @@
 
 int drm_detach(struct device *self, int flags)
 {
-	drm_device_t *dev = (drm_device_t*)self;
+	drm_device_t *dev = device_private(self);
 
-	drm_unload((struct drm_device *)self);
+	/* XXX locking */
+	if (dev->open_count)
+		return EBUSY;
+
+	drm_unload(dev);
 	drm_units[dev->unit] = NULL;
 	return 0;
 }
@@ -903,7 +908,10 @@
 #ifdef __FreeBSD__
 	DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
 		   DRM_CURRENTPID, (long)dev->device, dev->open_count );
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
+#elif defined(__NetBSD__)
+	DRM_DEBUG( "pid = %d, device = 0x%p, open_count = %d\n",
+		   DRM_CURRENTPID, dev->device, dev->open_count);
+#elif defined(__OpenBSD__)
 	DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
 		   DRM_CURRENTPID, (long)&dev->device, dev->open_count);
 #endif

Reply via email to