From 3ee211f4f7435792752c1dbcd3a60e2e7abfba09 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 13 Aug 2007 16:29:24 -0700 Subject: Bug #11895: Only add the AGP base to map offset if the caller didn't. The i830 and newer intel 2D code adds the AGP base to map offsets already, because it wasn't doing the AGP enable which used to set dev->agp->base. Credit goes to Zhenyu for finding the issue. --- linux-core/drm_bufs.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index f9987ca6..f0b28fa1 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -223,11 +223,17 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset, #ifdef __alpha__ map->offset += dev->hose->mem_space->start; #endif - /* Note: dev->agp->base may actually be 0 when the DRM - * is not in control of AGP space. But if user space is - * it should already have added the AGP base itself. + /* 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. */ - map->offset += dev->agp->base; + if (map->offset < dev->agp->base || + map->offset > dev->agp->base + + dev->agp->agp_info.aper_size * 1024 * 1024) { + map->offset += dev->agp->base; + } map->mtrr = dev->agp->agp_mtrr; /* for getmap */ /* This assumes the DRM is in total control of AGP space. -- cgit v1.2.3 From b668d6d9050106bebfb704e4ed32d2924bb26371 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 15 Aug 2007 14:29:31 -0700 Subject: 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. --- linux-core/drm_bufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux-core/drm_bufs.c') diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index f0b28fa1..60eca60c 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -231,7 +231,7 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset, */ if (map->offset < dev->agp->base || map->offset > dev->agp->base + - dev->agp->agp_info.aper_size * 1024 * 1024) { + dev->agp->agp_info.aper_size * 1024 * 1024 - 1) { map->offset += dev->agp->base; } map->mtrr = dev->agp->agp_mtrr; /* for getmap */ -- cgit v1.2.3