diff options
author | Jeff Hartmann <jhartmann@valinux.com> | 2001-08-07 18:15:10 +0000 |
---|---|---|
committer | Jeff Hartmann <jhartmann@valinux.com> | 2001-08-07 18:15:10 +0000 |
commit | 51e38d96ead5700c25c4fddd8017dc7992e96f5a (patch) | |
tree | 0f0372afa73a701c1be0e9f9b6b65106817d14a6 /linux/radeon_cp.c | |
parent | 56bd9c207770d41a497f3e8237a1099dd9d4cd91 (diff) |
Lots of DRM fixes: added new pieces of template code so the ffb driver can
be ported, rolled back r128 and i810 version bumps so 4.1.0 works with
cvs kernel modules, added Config.in and updated Makefile.kernel,
incorporated lots of drm fixes inspired by patches sent by Redhat, made
DRM(realloc) usage check for NULL allocations, restructure driver init
routines to export dev_priv only when initialized and to check for all
error conditions.
Diffstat (limited to 'linux/radeon_cp.c')
-rw-r--r-- | linux/radeon_cp.c | 86 |
1 files changed, 68 insertions, 18 deletions
diff --git a/linux/radeon_cp.c b/linux/radeon_cp.c index d8b85949..a7127b2b 100644 --- a/linux/radeon_cp.c +++ b/linux/radeon_cp.c @@ -574,12 +574,11 @@ static int radeon_do_engine_reset( drm_device_t *dev ) return 0; } -static void radeon_cp_init_ring_buffer( drm_device_t *dev ) +static void radeon_cp_init_ring_buffer( drm_device_t *dev, + drm_radeon_private_t *dev_priv ) { - drm_radeon_private_t *dev_priv = dev->dev_private; u32 ring_start, cur_read_ptr; u32 tmp; - DRM_DEBUG( "%s\n", __FUNCTION__ ); /* Initialize the memory controller */ RADEON_WRITE( RADEON_MC_FB_LOCATION, @@ -659,7 +658,6 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER ); if ( dev_priv == NULL ) return -ENOMEM; - dev->dev_private = (void *)dev_priv; memset( dev_priv, 0, sizeof(drm_radeon_private_t) ); @@ -670,16 +668,16 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) */ if ( dev_priv->is_pci ) { DRM_ERROR( "PCI GART not yet supported for Radeon!\n" ); - DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); - dev->dev_private = NULL; + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); return -EINVAL; } #endif if ( dev_priv->is_pci && !dev->sg ) { DRM_ERROR( "PCI GART memory not allocated!\n" ); - DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); - dev->dev_private = NULL; + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); return -EINVAL; } @@ -687,8 +685,8 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) if ( dev_priv->usec_timeout < 1 || dev_priv->usec_timeout > RADEON_MAX_USEC_TIMEOUT ) { DRM_DEBUG( "TIMEOUT problem!\n" ); - DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); - dev->dev_private = NULL; + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); return -EINVAL; } @@ -705,8 +703,8 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) if ( ( init->cp_mode != RADEON_CSQ_PRIBM_INDDIS ) && ( init->cp_mode != RADEON_CSQ_PRIBM_INDBM ) ) { DRM_DEBUG( "BAD cp_mode (%x)!\n", init->cp_mode ); - DRM(free)( dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER ); - dev->dev_private = NULL; + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); return -EINVAL; } @@ -782,16 +780,58 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) break; } } + if(!dev_priv->sarea) { + DRM_ERROR("could not find sarea!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); + if(!dev_priv->fb) { + DRM_ERROR("could not find framebuffer!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); + if(!dev_priv->mmio) { + DRM_ERROR("could not find mmio region!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } DRM_FIND_MAP( dev_priv->cp_ring, init->ring_offset ); + if(!dev_priv->cp_ring) { + DRM_ERROR("could not find cp ring region!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset ); + if(!dev_priv->ring_rptr) { + DRM_ERROR("could not find ring read pointer!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset ); + if(!dev_priv->buffers) { + DRM_ERROR("could not find dma buffer region!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } if ( !dev_priv->is_pci ) { DRM_FIND_MAP( dev_priv->agp_textures, init->agp_textures_offset ); + if(!dev_priv->agp_textures) { + DRM_ERROR("could not find agp texture region!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } } dev_priv->sarea_priv = @@ -802,6 +842,14 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) DRM_IOREMAP( dev_priv->cp_ring ); DRM_IOREMAP( dev_priv->ring_rptr ); DRM_IOREMAP( dev_priv->buffers ); + if(!dev_priv->cp_ring->handle || + !dev_priv->ring_rptr->handle || + !dev_priv->buffers->handle) { + DRM_ERROR("could not find ioremap agp regions!\n"); + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -EINVAL; + } } else { dev_priv->cp_ring->handle = (void *)dev_priv->cp_ring->offset; @@ -884,10 +932,9 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) dev_priv->phys_pci_gart = DRM(ati_pcigart_init)( dev ); if ( !dev_priv->phys_pci_gart ) { DRM_ERROR( "failed to init PCI GART!\n" ); - DRM(free)( dev_priv, sizeof(*dev_priv), - DRM_MEM_DRIVER ); - dev->dev_private = NULL; - return -EINVAL; + dev->dev_private = (void *)dev_priv; + radeon_do_cleanup_cp(dev); + return -ENOMEM; } /* Turn on PCI GART */ @@ -919,13 +966,16 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) } radeon_cp_load_microcode( dev_priv ); - radeon_cp_init_ring_buffer( dev ); - radeon_do_engine_reset( dev ); + radeon_cp_init_ring_buffer( dev, dev_priv ); #if ROTATE_BUFS dev_priv->last_buf = 0; #endif + dev->dev_private = (void *)dev_priv; + + radeon_do_engine_reset( dev ); + return 0; } |