This is what I am testing on FreeBSD right now, to install the irq
handlers at load time.  The linux side could do something like this
also.  This approach doesn't change the assumptions of the drivers and
so doesn't require touching driver code.

robert.
-- 
Robert Noland <[EMAIL PROTECTED]>
2Hip Networks
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 326b220..e65b7e0 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -933,6 +933,7 @@ int	drm_vblank_get(struct drm_device *dev, int crtc);
 void	drm_vblank_put(struct drm_device *dev, int crtc);
 int	drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
 int	drm_vblank_init(struct drm_device *dev, int num_crtcs);
+void	drm_vblank_cleanup(struct drm_device *dev);
 void	drm_vbl_send_signals(struct drm_device *dev, int crtc);
 int 	drm_modeset_ctl(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 9bd6079..57d293c 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -580,6 +580,14 @@ static int drm_load(struct drm_device *dev)
 		goto error;
 	}
 
+	if (dev->driver.use_irq) {
+		retcode = drm_irq_install(dev);
+		if (retcode != 0) {
+			DRM_ERROR("Couldn't setup irq\n");
+			goto error;
+		}
+	}
+
 	DRM_INFO("Initialized %s %d.%d.%d %s\n",
 	  	dev->driver.name,
 	  	dev->driver.major,
@@ -651,9 +659,14 @@ static void drm_unload(struct drm_device *dev)
 		dev->agp = NULL;
 	}
 
+	if (dev->driver.use_irq)
+	    drm_irq_uninstall(dev);
+
 	if (dev->driver.unload != NULL)
 		dev->driver.unload(dev);
 
+	drm_vblank_cleanup(dev);
+
 	delete_unrhdr(dev->drw_unrhdr);
 
 	drm_mem_uninit();
diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c
index 6e21d41..8febf5a 100644
--- a/bsd-core/drm_irq.c
+++ b/bsd-core/drm_irq.c
@@ -96,7 +96,7 @@ static void vblank_disable_fn(void *arg)
 	}
 }
 
-static void drm_vblank_cleanup(struct drm_device *dev)
+void drm_vblank_cleanup(struct drm_device *dev)
 {
 	unsigned long irqflags;
 
@@ -295,7 +295,6 @@ int drm_irq_uninstall(struct drm_device *dev)
 #elif defined(__NetBSD__) || defined(__OpenBSD__)
 	pci_intr_disestablish(&dev->pa.pa_pc, dev->irqh);
 #endif
-	drm_vblank_cleanup(dev);
 
 	return 0;
 }
@@ -303,26 +302,15 @@ int drm_irq_uninstall(struct drm_device *dev)
 int drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	drm_control_t *ctl = data;
-	int err;
 
 	switch ( ctl->func ) {
 	case DRM_INST_HANDLER:
-		/* Handle drivers whose DRM used to require IRQ setup but the
-		 * no longer does.
-		 */
-		if (!dev->driver.use_irq)
-			return 0;
 		if (dev->if_version < DRM_IF_VERSION(1, 2) &&
 		    ctl->irq != dev->irq)
 			return EINVAL;
-		return drm_irq_install(dev);
+		return 0;
 	case DRM_UNINST_HANDLER:
-		if (!dev->driver.use_irq)
-			return 0;
-		DRM_LOCK();
-		err = drm_irq_uninstall(dev);
-		DRM_UNLOCK();
-		return err;
+		return 0;
 	default:
 		return EINVAL;
 	}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to