diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-12-16 08:57:08 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-12-16 08:57:08 +0000 |
commit | 9fb6986e83a84f6b958e8aba2c20b5988676bd55 (patch) | |
tree | 466fa7fd9089d1b7aa4e1257096e177a2c6034c0 | |
parent | 5285b029876a4d3122ae72cc3d81ca8d184ed9ca (diff) |
Don't ioremap the framebuffer area. The ioremapped area wasn't used by
anything, and took up valuable KVA. While I'm in the area, clean up BSD
MTRR stuff some more.
Suggested by: jonsmirl
-rw-r--r-- | bsd-core/drmP.h | 4 | ||||
-rw-r--r-- | bsd-core/drm_bufs.c | 39 | ||||
-rw-r--r-- | bsd-core/drm_drv.c | 28 | ||||
-rw-r--r-- | bsd-core/drm_sysctl.c | 2 | ||||
-rw-r--r-- | bsd/drmP.h | 4 | ||||
-rw-r--r-- | bsd/drm_bufs.h | 39 | ||||
-rw-r--r-- | bsd/drm_drv.h | 28 | ||||
-rw-r--r-- | bsd/drm_sysctl.h | 2 | ||||
-rw-r--r-- | linux-core/drm_bufs.c | 4 | ||||
-rw-r--r-- | linux/drm_bufs.h | 4 | ||||
-rw-r--r-- | shared-core/mga_dma.c | 8 | ||||
-rw-r--r-- | shared-core/mga_drv.h | 1 | ||||
-rw-r--r-- | shared-core/r128_cce.c | 7 | ||||
-rw-r--r-- | shared-core/r128_drv.h | 1 | ||||
-rw-r--r-- | shared-core/radeon_cp.c | 7 | ||||
-rw-r--r-- | shared-core/radeon_drv.h | 1 | ||||
-rw-r--r-- | shared/mga_dma.c | 8 | ||||
-rw-r--r-- | shared/mga_drv.h | 1 | ||||
-rw-r--r-- | shared/r128_cce.c | 7 | ||||
-rw-r--r-- | shared/r128_drv.h | 1 | ||||
-rw-r--r-- | shared/radeon_cp.c | 7 | ||||
-rw-r--r-- | shared/radeon_drv.h | 1 |
22 files changed, 72 insertions, 132 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 82a226a9..d7e73f08 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -267,7 +267,7 @@ typedef struct drm_agp_head { int enabled; int acquired; unsigned long base; - int agp_mtrr; + int mtrr; int cant_use_aperture; unsigned long page_mask; } drm_agp_head_t; @@ -287,7 +287,7 @@ typedef struct drm_local_map { drm_map_flags_t flags; /* Flags */ void *handle; /* User-space: "Handle" to pass to mmap */ /* Kernel-space: kernel-virtual address */ - int mtrr; /* MTRR slot used */ + int mtrr; /* Boolean: MTRR used */ /* Private data */ bus_space_tag_t iot; bus_space_handle_t ioh; diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c index 15d4a3b1..4bcd012a 100644 --- a/bsd-core/drm_bufs.c +++ b/bsd-core/drm_bufs.c @@ -87,7 +87,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) map->size = request.size; map->type = request.type; map->flags = request.flags; - map->mtrr = -1; + map->mtrr = 0; map->handle = 0; /* Only allow shared memory to be removable since we only keep enough @@ -104,28 +104,23 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); return DRM_ERR(EINVAL); } + if (map->offset + map->size < map->offset) { + DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + return DRM_ERR(EINVAL); + } switch ( map->type ) { case _DRM_REGISTERS: + DRM_IOREMAP(map, dev); + if (!(map->flags & _DRM_WRITE_COMBINING)) + break; + /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: - if ( map->offset + map->size < map->offset ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - return DRM_ERR(EINVAL); - } #if __REALLY_HAVE_MTRR - if ( map->type == _DRM_FRAME_BUFFER || - (map->flags & _DRM_WRITE_COMBINING) ) { - int mtrr; - - mtrr = DRM(mtrr_add)(map->offset, map->size, - DRM_MTRR_WC); - if (mtrr == 0) - map->mtrr = 1; - } -#endif /* __REALLY_HAVE_MTRR */ - DRM_IOREMAP(map, dev); + if (DRM(mtrr_add)(map->offset, map->size, DRM_MTRR_WC) == 0) + map->mtrr = 1; +#endif break; - case _DRM_SHM: map->handle = (void *)DRM(alloc)(map->size, DRM_MEM_SAREA); DRM_DEBUG( "%lu %d %p\n", @@ -152,7 +147,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) #if __REALLY_HAVE_AGP case _DRM_AGP: map->offset += dev->agp->base; - map->mtrr = dev->agp->agp_mtrr; /* for getmap */ + map->mtrr = dev->agp->mtrr; /* for getmap */ break; #endif case _DRM_SCATTER_GATHER: @@ -231,12 +226,12 @@ int DRM(rmmap)( DRM_IOCTL_ARGS ) case _DRM_REGISTERS: case _DRM_FRAME_BUFFER: #if __REALLY_HAVE_MTRR - if (map->mtrr >= 0) { - int __unused mtrr; + if (map->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(map->offset, map->size, + retcode = DRM(mtrr_del)(map->offset, map->size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del = %d\n", mtrr); + DRM_DEBUG("mtrr_del = %d\n", retcode); } #endif DRM(ioremapfree)(map); diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index bf1e2ac4..7184e3d9 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -565,17 +565,18 @@ static int DRM(takedown)( drm_device_t *dev ) map = list->map; switch ( map->type ) { case _DRM_REGISTERS: + DRM(ioremapfree)(map); + /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: #if __REALLY_HAVE_MTRR - if ( map->mtrr >= 0 ) { - int __unused mtrr; + if (map->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(map->offset, + retcode = DRM(mtrr_del)(map->offset, map->size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del=%d\n", mtrr); + DRM_DEBUG("mtrr_del = %d", retcode); } #endif - DRM(ioremapfree)( map ); break; case _DRM_SHM: DRM(free)(map->handle, @@ -679,12 +680,9 @@ static int DRM(init)( device_t nbdev ) #endif /* __MUST_HAVE_AGP */ #if __REALLY_HAVE_MTRR if (dev->agp) { - int retcode; - - retcode = DRM(mtrr_add)(dev->agp->info.ai_aperture_base, - dev->agp->info.ai_aperture_size, DRM_MTRR_WC); - if (retcode == 0) - dev->agp->agp_mtrr=1; + if (DRM(mtrr_add)(dev->agp->info.ai_aperture_base, + dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0) + dev->agp->mtrr = 1; } #endif /* __REALLY_HAVE_MTRR */ #endif /* __REALLY_HAVE_AGP */ @@ -742,12 +740,12 @@ static void DRM(cleanup)(drm_device_t *dev) #endif #if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR - if ( dev->agp && dev->agp->agp_mtrr >= 0) { - int __unused mtrr; + if (dev->agp && dev->agp->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(dev->agp->info.ai_aperture_base, + retcode = DRM(mtrr_del)(dev->agp->info.ai_aperture_base, dev->agp->info.ai_aperture_size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del=%d\n", mtrr); + DRM_DEBUG("mtrr_del = %d", retcode); } #endif diff --git a/bsd-core/drm_sysctl.c b/bsd-core/drm_sysctl.c index 4bb603f4..0897c359 100644 --- a/bsd-core/drm_sysctl.c +++ b/bsd-core/drm_sysctl.c @@ -192,7 +192,7 @@ static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS else type = types[map->type]; - if (map->mtrr <= 0) + if (!map->mtrr) yesno = "no"; else yesno = "yes"; @@ -267,7 +267,7 @@ typedef struct drm_agp_head { int enabled; int acquired; unsigned long base; - int agp_mtrr; + int mtrr; int cant_use_aperture; unsigned long page_mask; } drm_agp_head_t; @@ -287,7 +287,7 @@ typedef struct drm_local_map { drm_map_flags_t flags; /* Flags */ void *handle; /* User-space: "Handle" to pass to mmap */ /* Kernel-space: kernel-virtual address */ - int mtrr; /* MTRR slot used */ + int mtrr; /* Boolean: MTRR used */ /* Private data */ bus_space_tag_t iot; bus_space_handle_t ioh; diff --git a/bsd/drm_bufs.h b/bsd/drm_bufs.h index 15d4a3b1..4bcd012a 100644 --- a/bsd/drm_bufs.h +++ b/bsd/drm_bufs.h @@ -87,7 +87,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) map->size = request.size; map->type = request.type; map->flags = request.flags; - map->mtrr = -1; + map->mtrr = 0; map->handle = 0; /* Only allow shared memory to be removable since we only keep enough @@ -104,28 +104,23 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); return DRM_ERR(EINVAL); } + if (map->offset + map->size < map->offset) { + DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); + return DRM_ERR(EINVAL); + } switch ( map->type ) { case _DRM_REGISTERS: + DRM_IOREMAP(map, dev); + if (!(map->flags & _DRM_WRITE_COMBINING)) + break; + /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: - if ( map->offset + map->size < map->offset ) { - DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - return DRM_ERR(EINVAL); - } #if __REALLY_HAVE_MTRR - if ( map->type == _DRM_FRAME_BUFFER || - (map->flags & _DRM_WRITE_COMBINING) ) { - int mtrr; - - mtrr = DRM(mtrr_add)(map->offset, map->size, - DRM_MTRR_WC); - if (mtrr == 0) - map->mtrr = 1; - } -#endif /* __REALLY_HAVE_MTRR */ - DRM_IOREMAP(map, dev); + if (DRM(mtrr_add)(map->offset, map->size, DRM_MTRR_WC) == 0) + map->mtrr = 1; +#endif break; - case _DRM_SHM: map->handle = (void *)DRM(alloc)(map->size, DRM_MEM_SAREA); DRM_DEBUG( "%lu %d %p\n", @@ -152,7 +147,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS ) #if __REALLY_HAVE_AGP case _DRM_AGP: map->offset += dev->agp->base; - map->mtrr = dev->agp->agp_mtrr; /* for getmap */ + map->mtrr = dev->agp->mtrr; /* for getmap */ break; #endif case _DRM_SCATTER_GATHER: @@ -231,12 +226,12 @@ int DRM(rmmap)( DRM_IOCTL_ARGS ) case _DRM_REGISTERS: case _DRM_FRAME_BUFFER: #if __REALLY_HAVE_MTRR - if (map->mtrr >= 0) { - int __unused mtrr; + if (map->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(map->offset, map->size, + retcode = DRM(mtrr_del)(map->offset, map->size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del = %d\n", mtrr); + DRM_DEBUG("mtrr_del = %d\n", retcode); } #endif DRM(ioremapfree)(map); diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index bf1e2ac4..7184e3d9 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -565,17 +565,18 @@ static int DRM(takedown)( drm_device_t *dev ) map = list->map; switch ( map->type ) { case _DRM_REGISTERS: + DRM(ioremapfree)(map); + /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: #if __REALLY_HAVE_MTRR - if ( map->mtrr >= 0 ) { - int __unused mtrr; + if (map->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(map->offset, + retcode = DRM(mtrr_del)(map->offset, map->size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del=%d\n", mtrr); + DRM_DEBUG("mtrr_del = %d", retcode); } #endif - DRM(ioremapfree)( map ); break; case _DRM_SHM: DRM(free)(map->handle, @@ -679,12 +680,9 @@ static int DRM(init)( device_t nbdev ) #endif /* __MUST_HAVE_AGP */ #if __REALLY_HAVE_MTRR if (dev->agp) { - int retcode; - - retcode = DRM(mtrr_add)(dev->agp->info.ai_aperture_base, - dev->agp->info.ai_aperture_size, DRM_MTRR_WC); - if (retcode == 0) - dev->agp->agp_mtrr=1; + if (DRM(mtrr_add)(dev->agp->info.ai_aperture_base, + dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0) + dev->agp->mtrr = 1; } #endif /* __REALLY_HAVE_MTRR */ #endif /* __REALLY_HAVE_AGP */ @@ -742,12 +740,12 @@ static void DRM(cleanup)(drm_device_t *dev) #endif #if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR - if ( dev->agp && dev->agp->agp_mtrr >= 0) { - int __unused mtrr; + if (dev->agp && dev->agp->mtrr) { + int __unused retcode; - mtrr = DRM(mtrr_del)(dev->agp->info.ai_aperture_base, + retcode = DRM(mtrr_del)(dev->agp->info.ai_aperture_base, dev->agp->info.ai_aperture_size, DRM_MTRR_WC); - DRM_DEBUG("mtrr_del=%d\n", mtrr); + DRM_DEBUG("mtrr_del = %d", retcode); } #endif diff --git a/bsd/drm_sysctl.h b/bsd/drm_sysctl.h index 4bb603f4..0897c359 100644 --- a/bsd/drm_sysctl.h +++ b/bsd/drm_sysctl.h @@ -192,7 +192,7 @@ static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS else type = types[map->type]; - if (map->mtrr <= 0) + if (!map->mtrr) yesno = "no"; else yesno = "yes"; diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index e30e6de8..577a1c99 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -148,7 +148,9 @@ int DRM(addmap)( struct inode *inode, struct file *filp, MTRR_TYPE_WRCOMB, 1 ); } #endif - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + if (map->type == _DRM_REGISTERS) + map->handle = DRM(ioremap)( map->offset, map->size, + dev ); break; case _DRM_SHM: diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h index e30e6de8..577a1c99 100644 --- a/linux/drm_bufs.h +++ b/linux/drm_bufs.h @@ -148,7 +148,9 @@ int DRM(addmap)( struct inode *inode, struct file *filp, MTRR_TYPE_WRCOMB, 1 ); } #endif - map->handle = DRM(ioremap)( map->offset, map->size, dev ); + if (map->type == _DRM_REGISTERS) + map->handle = DRM(ioremap)( map->offset, map->size, + dev ); break; case _DRM_SHM: diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c index 19bc9e32..5e5c407d 100644 --- a/shared-core/mga_dma.c +++ b/shared-core/mga_dma.c @@ -500,14 +500,6 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init ) return DRM_ERR(EINVAL); } - DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); - if(!dev_priv->fb) { - DRM_ERROR( "failed to find framebuffer!\n" ); - /* Assign dev_private so we can do cleanup. */ - dev->dev_private = (void *)dev_priv; - mga_do_cleanup_dma( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR( "failed to find mmio region!\n" ); diff --git a/shared-core/mga_drv.h b/shared-core/mga_drv.h index 9396ae92..65847165 100644 --- a/shared-core/mga_drv.h +++ b/shared-core/mga_drv.h @@ -91,7 +91,6 @@ typedef struct drm_mga_private { unsigned int texture_size; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *status; drm_local_map_t *warp; diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c index abf05c17..bf4b4d95 100644 --- a/shared-core/r128_cce.c +++ b/shared-core/r128_cce.c @@ -467,13 +467,6 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) return DRM_ERR(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; - r128_do_cleanup_cce( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h index 10569f46..9df32e56 100644 --- a/shared-core/r128_drv.h +++ b/shared-core/r128_drv.h @@ -97,7 +97,6 @@ typedef struct drm_r128_private { u32 span_pitch_offset_c; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cce_ring; drm_local_map_t *ring_rptr; diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c index 4cacef5c..e145c78e 100644 --- a/shared-core/radeon_cp.c +++ b/shared-core/radeon_cp.c @@ -1118,13 +1118,6 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) return DRM_ERR(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 DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h index 1569caa7..afa516e8 100644 --- a/shared-core/radeon_drv.h +++ b/shared-core/radeon_drv.h @@ -135,7 +135,6 @@ typedef struct drm_radeon_private { unsigned long gart_textures_offset; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cp_ring; drm_local_map_t *ring_rptr; diff --git a/shared/mga_dma.c b/shared/mga_dma.c index 19bc9e32..5e5c407d 100644 --- a/shared/mga_dma.c +++ b/shared/mga_dma.c @@ -500,14 +500,6 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init ) return DRM_ERR(EINVAL); } - DRM_FIND_MAP( dev_priv->fb, init->fb_offset ); - if(!dev_priv->fb) { - DRM_ERROR( "failed to find framebuffer!\n" ); - /* Assign dev_private so we can do cleanup. */ - dev->dev_private = (void *)dev_priv; - mga_do_cleanup_dma( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR( "failed to find mmio region!\n" ); diff --git a/shared/mga_drv.h b/shared/mga_drv.h index 9396ae92..65847165 100644 --- a/shared/mga_drv.h +++ b/shared/mga_drv.h @@ -91,7 +91,6 @@ typedef struct drm_mga_private { unsigned int texture_size; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *status; drm_local_map_t *warp; diff --git a/shared/r128_cce.c b/shared/r128_cce.c index abf05c17..bf4b4d95 100644 --- a/shared/r128_cce.c +++ b/shared/r128_cce.c @@ -467,13 +467,6 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ) return DRM_ERR(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; - r128_do_cleanup_cce( dev ); - return DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); diff --git a/shared/r128_drv.h b/shared/r128_drv.h index 10569f46..9df32e56 100644 --- a/shared/r128_drv.h +++ b/shared/r128_drv.h @@ -97,7 +97,6 @@ typedef struct drm_r128_private { u32 span_pitch_offset_c; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cce_ring; drm_local_map_t *ring_rptr; diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c index 4cacef5c..e145c78e 100644 --- a/shared/radeon_cp.c +++ b/shared/radeon_cp.c @@ -1118,13 +1118,6 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init ) return DRM_ERR(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 DRM_ERR(EINVAL); - } DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset ); if(!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h index 1569caa7..afa516e8 100644 --- a/shared/radeon_drv.h +++ b/shared/radeon_drv.h @@ -135,7 +135,6 @@ typedef struct drm_radeon_private { unsigned long gart_textures_offset; drm_local_map_t *sarea; - drm_local_map_t *fb; drm_local_map_t *mmio; drm_local_map_t *cp_ring; drm_local_map_t *ring_rptr; |