From 828ae3f6b88b5a69a56b2961307e40ed95edea29 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Mon, 8 Sep 2008 16:40:52 -0400 Subject: [FreeBSD] We need to call drm_detach before we free dev->driver. The driver is in control of the show, so when you try and unload a module the driver detach routine is called first. It is what drives the whole unload process and so lots of panics occur if dev->driver is already free. --- bsd-core/i915_drv.c | 5 ++++- bsd-core/mach64_drv.c | 5 ++++- bsd-core/mga_drv.c | 5 ++++- bsd-core/r128_drv.c | 5 ++++- bsd-core/radeon_drv.c | 5 ++++- bsd-core/savage_drv.c | 5 ++++- bsd-core/sis_drv.c | 5 ++++- bsd-core/tdfx_drv.c | 5 ++++- bsd-core/via_drv.c | 5 ++++- 9 files changed, 36 insertions(+), 9 deletions(-) diff --git a/bsd-core/i915_drv.c b/bsd-core/i915_drv.c index 71a8d64d..7e745190 100644 --- a/bsd-core/i915_drv.c +++ b/bsd-core/i915_drv.c @@ -122,10 +122,13 @@ static int i915_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t i915_methods[] = { diff --git a/bsd-core/mach64_drv.c b/bsd-core/mach64_drv.c index f940e90f..36f3cec7 100644 --- a/bsd-core/mach64_drv.c +++ b/bsd-core/mach64_drv.c @@ -96,10 +96,13 @@ static int mach64_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t mach64_methods[] = { diff --git a/bsd-core/mga_drv.c b/bsd-core/mga_drv.c index 7abf2b03..85809609 100644 --- a/bsd-core/mga_drv.c +++ b/bsd-core/mga_drv.c @@ -142,10 +142,13 @@ static int mga_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t mga_methods[] = { diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c index 03a97da0..5d4dfed9 100644 --- a/bsd-core/r128_drv.c +++ b/bsd-core/r128_drv.c @@ -95,10 +95,13 @@ static int r128_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t r128_methods[] = { diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c index 019f705c..50a2f6b5 100644 --- a/bsd-core/radeon_drv.c +++ b/bsd-core/radeon_drv.c @@ -100,10 +100,13 @@ static int radeon_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t radeon_methods[] = { diff --git a/bsd-core/savage_drv.c b/bsd-core/savage_drv.c index f0c6c06e..36dd34a7 100644 --- a/bsd-core/savage_drv.c +++ b/bsd-core/savage_drv.c @@ -86,10 +86,13 @@ static int savage_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t savage_methods[] = { diff --git a/bsd-core/sis_drv.c b/bsd-core/sis_drv.c index 8ad6414d..bcf4ffd6 100644 --- a/bsd-core/sis_drv.c +++ b/bsd-core/sis_drv.c @@ -80,10 +80,13 @@ static int sis_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t sis_methods[] = { diff --git a/bsd-core/tdfx_drv.c b/bsd-core/tdfx_drv.c index 8fafe0fe..8d9e272f 100644 --- a/bsd-core/tdfx_drv.c +++ b/bsd-core/tdfx_drv.c @@ -82,10 +82,13 @@ static int tdfx_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t tdfx_methods[] = { diff --git a/bsd-core/via_drv.c b/bsd-core/via_drv.c index cdd78d19..402b374b 100644 --- a/bsd-core/via_drv.c +++ b/bsd-core/via_drv.c @@ -93,10 +93,13 @@ static int via_detach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); + int ret; + + ret = drm_detach(nbdev); free(dev->driver, M_DRM); - return drm_detach(nbdev); + return ret; } static device_method_t via_methods[] = { -- cgit v1.2.3