diff options
author | Leif Delgass <ldelgass@users.sourceforge.net> | 2003-04-26 22:28:56 +0000 |
---|---|---|
committer | Leif Delgass <ldelgass@users.sourceforge.net> | 2003-04-26 22:28:56 +0000 |
commit | f2a0c5438dc83171de1007a68e4f98e35b5a8fbe (patch) | |
tree | f886e31d758dda4c3460465d0f6be13921efbe58 /shared | |
parent | a79adaab72bde726ce4c08184997f34b31014d9e (diff) |
Ensure driver has been initialized (dev_private != NULL) before installing
irq handler in DRM(irq_install). Modify all drivers to ensure irq
handler is removed before cleanup and cleanup is called at takedown.
Remove unused buffer private struct fields in i810, i830. Check for
lock on init/cleanup in all drivers except i810/i830. The current DDX
for i810 and i830 doesn't hold the lock on kernel init (FIXME?).
Diffstat (limited to 'shared')
-rw-r--r-- | shared/mga.h | 2 | ||||
-rw-r--r-- | shared/mga_dma.c | 10 | ||||
-rw-r--r-- | shared/mga_irq.c | 9 | ||||
-rw-r--r-- | shared/r128.h | 2 | ||||
-rw-r--r-- | shared/r128_cce.c | 11 | ||||
-rw-r--r-- | shared/r128_irq.c | 9 | ||||
-rw-r--r-- | shared/radeon_cp.c | 10 | ||||
-rw-r--r-- | shared/radeon_irq.c | 9 |
8 files changed, 48 insertions, 14 deletions
diff --git a/shared/mga.h b/shared/mga.h index 49530442..96179627 100644 --- a/shared/mga.h +++ b/shared/mga.h @@ -72,7 +72,7 @@ /* Driver customization: */ #define DRIVER_PRETAKEDOWN() do { \ - if ( dev->dev_private ) mga_do_cleanup_dma( dev ); \ + mga_do_cleanup_dma( dev ); \ } while (0) /* DMA customization: diff --git a/shared/mga_dma.c b/shared/mga_dma.c index 96fd97ff..71b9f3a3 100644 --- a/shared/mga_dma.c +++ b/shared/mga_dma.c @@ -639,6 +639,14 @@ int mga_do_cleanup_dma( drm_device_t *dev ) { DRM_DEBUG( "\n" ); +#if _HAVE_DMA_IRQ + /* Make sure interrupts are disabled here because the uninstall ioctl + * may not have been called from userspace and after dev_private + * is freed, it's too late. + */ + if ( dev->irq ) DRM(irq_uninstall)(dev); +#endif + if ( dev->dev_private ) { drm_mga_private_t *dev_priv = dev->dev_private; @@ -666,6 +674,8 @@ int mga_dma_init( DRM_IOCTL_ARGS ) DRM_DEVICE; drm_mga_init_t init; + LOCK_TEST_WITH_RETURN( dev, filp ); + DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) ); switch ( init.func ) { diff --git a/shared/mga_irq.c b/shared/mga_irq.c index 28e9a262..a2a4db53 100644 --- a/shared/mga_irq.c +++ b/shared/mga_irq.c @@ -93,8 +93,9 @@ void mga_driver_irq_postinstall( drm_device_t *dev ) { void mga_driver_irq_uninstall( drm_device_t *dev ) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - if ( dev_priv ) { - /* Disable *all* interrupts */ - MGA_WRITE( MGA_IEN, 0 ); - } + if (!dev_priv) + return; + + /* Disable *all* interrupts */ + MGA_WRITE( MGA_IEN, 0 ); } diff --git a/shared/r128.h b/shared/r128.h index 29b26cd2..f23f46ee 100644 --- a/shared/r128.h +++ b/shared/r128.h @@ -85,7 +85,7 @@ } while (0) #define DRIVER_PRETAKEDOWN() do { \ - if ( dev->dev_private ) r128_do_cleanup_cce( dev ); \ + r128_do_cleanup_cce( dev ); \ } while (0) /* DMA customization: diff --git a/shared/r128_cce.c b/shared/r128_cce.c index ad03f4f9..608b7da6 100644 --- a/shared/r128_cce.c +++ b/shared/r128_cce.c @@ -613,6 +613,15 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) int r128_do_cleanup_cce( drm_device_t *dev ) { + +#if _HAVE_DMA_IRQ + /* Make sure interrupts are disabled here because the uninstall ioctl + * may not have been called from userspace and after dev_private + * is freed, it's too late. + */ + if ( dev->irq ) DRM(irq_uninstall)(dev); +#endif + if ( dev->dev_private ) { drm_r128_private_t *dev_priv = dev->dev_private; @@ -649,6 +658,8 @@ int r128_cce_init( DRM_IOCTL_ARGS ) DRM_DEBUG( "\n" ); + LOCK_TEST_WITH_RETURN( dev, filp ); + DRM_COPY_FROM_USER_IOCTL( init, (drm_r128_init_t *)data, sizeof(init) ); switch ( init.func ) { diff --git a/shared/r128_irq.c b/shared/r128_irq.c index bfc30405..f3f84d8c 100644 --- a/shared/r128_irq.c +++ b/shared/r128_irq.c @@ -93,8 +93,9 @@ void r128_driver_irq_postinstall( drm_device_t *dev ) { void r128_driver_irq_uninstall( drm_device_t *dev ) { drm_r128_private_t *dev_priv = (drm_r128_private_t *)dev->dev_private; - if ( dev_priv ) { - /* Disable *all* interrupts */ - R128_WRITE( R128_GEN_INT_CNTL, 0 ); - } + if (!dev_priv) + return; + + /* Disable *all* interrupts */ + R128_WRITE( R128_GEN_INT_CNTL, 0 ); } diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c index fce148a0..281b0cf0 100644 --- a/shared/radeon_cp.c +++ b/shared/radeon_cp.c @@ -1266,6 +1266,14 @@ int radeon_do_cleanup_cp( drm_device_t *dev ) { DRM_DEBUG( "\n" ); +#if _HAVE_DMA_IRQ + /* Make sure interrupts are disabled here because the uninstall ioctl + * may not have been called from userspace and after dev_private + * is freed, it's too late. + */ + if ( dev->irq ) DRM(irq_uninstall)(dev); +#endif + if ( dev->dev_private ) { drm_radeon_private_t *dev_priv = dev->dev_private; @@ -1298,6 +1306,8 @@ int radeon_cp_init( DRM_IOCTL_ARGS ) DRM_DEVICE; drm_radeon_init_t init; + LOCK_TEST_WITH_RETURN( dev, filp ); + DRM_COPY_FROM_USER_IOCTL( init, (drm_radeon_init_t *)data, sizeof(init) ); switch ( init.func ) { diff --git a/shared/radeon_irq.c b/shared/radeon_irq.c index 9199fbbf..c6bd90e5 100644 --- a/shared/radeon_irq.c +++ b/shared/radeon_irq.c @@ -249,8 +249,9 @@ void DRM(driver_irq_postinstall)( drm_device_t *dev ) { void DRM(driver_irq_uninstall)( drm_device_t *dev ) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)dev->dev_private; - if ( dev_priv ) { - /* Disable *all* interrupts */ - RADEON_WRITE( RADEON_GEN_INT_CNTL, 0 ); - } + if (!dev_priv) + return; + + /* Disable *all* interrupts */ + RADEON_WRITE( RADEON_GEN_INT_CNTL, 0 ); } |