summaryrefslogtreecommitdiff
path: root/bsd
diff options
context:
space:
mode:
Diffstat (limited to 'bsd')
-rw-r--r--bsd/drmP.h4
-rw-r--r--bsd/drm_bufs.h39
-rw-r--r--bsd/drm_drv.h28
-rw-r--r--bsd/drm_sysctl.h2
4 files changed, 33 insertions, 40 deletions
diff --git a/bsd/drmP.h b/bsd/drmP.h
index 82a226a9..d7e73f08 100644
--- a/bsd/drmP.h
+++ b/bsd/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/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";