mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 04:40:09 +01:00
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.
This commit is contained in:
parent
6e93c35ba7
commit
b668d6d905
3 changed files with 13 additions and 3 deletions
|
|
@ -184,7 +184,6 @@ int drm_agp_enable(drm_device_t *dev, drm_agp_mode_t mode)
|
|||
|
||||
dev->agp->mode = mode.mode;
|
||||
agp_enable(dev->agp->agpdev, mode.mode);
|
||||
dev->agp->base = dev->agp->info.ai_aperture_base;
|
||||
dev->agp->enabled = 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -405,6 +404,7 @@ drm_agp_head_t *drm_agp_init(void)
|
|||
return NULL;
|
||||
head->agpdev = agpdev;
|
||||
agp_get_info(agpdev, &head->info);
|
||||
head->base = head->info.ai_aperture_base;
|
||||
head->memory = NULL;
|
||||
DRM_INFO("AGP at 0x%08lx %dMB\n",
|
||||
(long)head->info.ai_aperture_base,
|
||||
|
|
|
|||
|
|
@ -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) &&
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue