From aade60ef2e3968fe35a47715edd19fa075d32816 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Mon, 24 Nov 2008 23:00:34 +0000 Subject: Work around the stupidity of radeondrm by double checking that things are running before we play with things. Lots more cleanup needed, but now you can shut X without it crashing. --- sys/dev/pci/drm/ati_pcigart.c | 9 +++-- sys/dev/pci/drm/radeon_cp.c | 81 ++++++++++++++---------------------------- sys/dev/pci/drm/radeon_drv.c | 2 +- sys/dev/pci/drm/radeon_state.c | 3 +- 4 files changed, 34 insertions(+), 61 deletions(-) (limited to 'sys') diff --git a/sys/dev/pci/drm/ati_pcigart.c b/sys/dev/pci/drm/ati_pcigart.c index 2de7d9ea041..0bcf23b1bd2 100644 --- a/sys/dev/pci/drm/ati_pcigart.c +++ b/sys/dev/pci/drm/ati_pcigart.c @@ -75,11 +75,10 @@ drm_ati_pcigart_cleanup(struct drm_device *dev, } if (gart_info->bus_addr) { - if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { - gart_info->bus_addr = 0; - if (dev->sg->dmah) - drm_ati_free_pcigart_table(dev, gart_info); - } + gart_info->bus_addr = 0; + if (gart_info->gart_table_location == DRM_ATI_GART_MAIN && + dev->sg->dmah != NULL) + drm_ati_free_pcigart_table(dev, gart_info); } return 1; diff --git a/sys/dev/pci/drm/radeon_cp.c b/sys/dev/pci/drm/radeon_cp.c index d993d79151d..0ebf75e429d 100644 --- a/sys/dev/pci/drm/radeon_cp.c +++ b/sys/dev/pci/drm/radeon_cp.c @@ -1300,18 +1300,12 @@ radeon_do_cleanup_cp(struct drm_device *dev) #if __OS_HAS_AGP if (dev_priv->flags & RADEON_IS_AGP) { - if (dev_priv->cp_ring != NULL) { + if (dev_priv->cp_ring != NULL) drm_core_ioremapfree(dev_priv->cp_ring); - dev_priv->cp_ring = NULL; - } - if (dev_priv->ring_rptr != NULL) { + if (dev_priv->ring_rptr != NULL) drm_core_ioremapfree(dev_priv->ring_rptr); - dev_priv->ring_rptr = NULL; - } - if (dev->agp_buffer_map != NULL) { + if (dev->agp_buffer_map != NULL) drm_core_ioremapfree(dev->agp_buffer_map); - dev->agp_buffer_map = NULL; - } } else #endif { @@ -1327,8 +1321,12 @@ radeon_do_cleanup_cp(struct drm_device *dev) { drm_core_ioremapfree(&dev_priv->gart_info.mapping); dev_priv->gart_info.addr = 0; + dev_priv->gart_info.gart_table_location = 0; } } + dev_priv->cp_ring = NULL; + dev_priv->ring_rptr = NULL; + dev->agp_buffer_map = NULL; return 0; } @@ -1469,45 +1467,32 @@ radeon_do_release(struct drm_device *dev) drm_radeon_private_t *dev_priv = dev->dev_private; int i, ret; - if (dev_priv) { - if (dev_priv->cp_running) { - /* Stop the cp */ - while ((ret = radeon_do_cp_idle(dev_priv)) != 0) { - DRM_DEBUG("radeon_do_cp_idle %d\n", ret); -#ifdef __linux__ - schedule(); -#else -#if defined(__FreeBSD__) && __FreeBSD_version > 500000 - mtx_sleep(&ret, &dev->dev_lock, PZERO, "rdnrel", - 1); -#else + if (dev_priv->cp_running) { + /* Stop the cp */ + while ((ret = radeon_do_cp_idle(dev_priv)) != 0) { + DRM_DEBUG("radeon_do_cp_idle %d\n", ret); tsleep(&ret, PZERO, "rdnrel", 1); -#endif -#endif - } - radeon_do_cp_stop(dev_priv); - radeon_do_engine_reset(dev); } + radeon_do_cp_stop(dev_priv); + radeon_do_engine_reset(dev); + } - /* Disable *all* interrupts */ - RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); + /* Disable *all* interrupts */ + RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); - /* remove all surfaces */ - for (i = 0; i < RADEON_MAX_SURFACES; i++) { - RADEON_WRITE(RADEON_SURFACE0_INFO + 16 * i, 0); - RADEON_WRITE(RADEON_SURFACE0_LOWER_BOUND + - 16 * i, 0); - RADEON_WRITE(RADEON_SURFACE0_UPPER_BOUND + - 16 * i, 0); - } + /* remove all surfaces */ + for (i = 0; i < RADEON_MAX_SURFACES; i++) { + RADEON_WRITE(RADEON_SURFACE0_INFO + 16 * i, 0); + RADEON_WRITE(RADEON_SURFACE0_LOWER_BOUND + 16 * i, 0); + RADEON_WRITE(RADEON_SURFACE0_UPPER_BOUND + 16 * i, 0); + } - /* Free memory heap structures */ - radeon_mem_takedown(&(dev_priv->gart_heap)); - radeon_mem_takedown(&(dev_priv->fb_heap)); + /* Free memory heap structures */ + radeon_mem_takedown(&(dev_priv->gart_heap)); + radeon_mem_takedown(&(dev_priv->fb_heap)); - /* deallocate kernel resources */ - radeon_do_cleanup_cp(dev); - } + /* deallocate kernel resources */ + radeon_do_cleanup_cp(dev); } /* Just reset the CP ring. Called as part of an X Server engine reset. @@ -1564,18 +1549,6 @@ radeon_engine_reset(struct drm_device *dev, void *data, return radeon_do_engine_reset(dev); } -/* ================================================================ - * Fullscreen mode - */ - -/* KW: Deprecated to say the least: - */ -int -radeon_fullscreen(struct drm_device *dev, void *data, - struct drm_file *file_priv) -{ - return 0; -} /* ================================================================ * Freelist management diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c index cae9dac5488..2a334c46643 100644 --- a/sys/dev/pci/drm/radeon_drv.c +++ b/sys/dev/pci/drm/radeon_drv.c @@ -629,7 +629,7 @@ radeondrm_ioctl(struct drm_device *dev, u_long cmd, caddr_t data, case DRM_IOCTL_RADEON_RESET: return (radeon_engine_reset(dev, data, file_priv)); case DRM_IOCTL_RADEON_FULLSCREEN: - return (radeon_fullscreen(dev, data, file_priv)); + return (0); /* oh so deprecated */ case DRM_IOCTL_RADEON_SWAP: return (radeon_cp_swap(dev, data, file_priv)); case DRM_IOCTL_RADEON_CLEAR: diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c index 678c9316bc7..44e9408e646 100644 --- a/sys/dev/pci/drm/radeon_state.c +++ b/sys/dev/pci/drm/radeon_state.c @@ -3234,7 +3234,8 @@ void radeon_driver_close(struct drm_device *dev, dev_priv->page_flipping = 0; radeon_mem_release(file_priv, dev_priv->gart_heap); radeon_mem_release(file_priv, dev_priv->fb_heap); - radeon_surfaces_release(file_priv, dev_priv); + if (dev_priv->cp_running) + radeon_surfaces_release(file_priv, dev_priv); } void radeon_driver_lastclose(struct drm_device *dev) -- cgit v1.2.3