summaryrefslogtreecommitdiff
path: root/bsd-core/drm_bufs.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-08-15 14:29:31 -0700
committerEric Anholt <eric@anholt.net>2007-08-15 14:29:31 -0700
commitb668d6d9050106bebfb704e4ed32d2924bb26371 (patch)
treeefdc06fab9804aebb52312ef72de029e2821aaf8 /bsd-core/drm_bufs.c
parent6e93c35ba7c5001e756d0c9d1a4f534384652a5a (diff)
Fix dev->agp->base initialization on BSD, and fix addmap range check on Linux.
With the previous linux commit, an AGP aperture at the end of the address space would have wrapped to 0 and the test would have failed.
Diffstat (limited to 'bsd-core/drm_bufs.c')
-rw-r--r--bsd-core/drm_bufs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 65d8c82b..9b58c593 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -191,7 +191,17 @@ int drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
break;
case _DRM_AGP:
/*valid = 0;*/
- map->offset += dev->agp->base;
+ /* In some cases (i810 driver), user space may have already
+ * added the AGP base itself, because dev->agp->base previously
+ * only got set during AGP enable. So, only add the base
+ * address if the map's offset isn't already within the
+ * aperture.
+ */
+ if (map->offset < dev->agp->base ||
+ map->offset > dev->agp->base +
+ dev->agp->info.ai_aperture_size - 1) {
+ map->offset += dev->agp->base;
+ }
map->mtrr = dev->agp->mtrr; /* for getmap */
/*for (entry = dev->agp->memory; entry; entry = entry->next) {
if ((map->offset >= entry->bound) &&