summaryrefslogtreecommitdiff
path: root/shared-core/savage_bci.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2005-06-28 20:58:34 +0000
committerEric Anholt <anholt@freebsd.org>2005-06-28 20:58:34 +0000
commit5d96c74ff1fe9b2d37e22dbea9882791aae389bf (patch)
tree598019eecfc3d9c964a79d7b9841a1c86829d14b /shared-core/savage_bci.c
parent6397722f1990856a9ee268cadd65d78b44b24835 (diff)
- Remove drm_initmap and replace its usage with drm_addmap. This reduces
code duplication, and it also hands you the map pointer so you don't need to re-find it. - Remove the permanent maps flag. Instead, for register and framebuffer maps, we always check whether there's already a map of that type and offset around. Move the Radeon map initialization into presetup (first open) so it happens again after every takedown. - Remove the split cleanup of maps between driver takedown (last close) and cleanup (module unload). Instead, always tear down maps on takedown, and drivers can recreate them on first open. - Make MGA always use addmap, instead of allocating consistent memory in the PCI case and then faking up a map for it, which accomplished nearly the same thing, in a different order. Note that the maps are exposed to the user again: we may want to expose a flag to avoid this, but it's not a security concern, and saves us a lot of code. - Remove rmmaps in the MGA driver. Since the function is only called during takedown anyway, we can let them die a natural death. - Make removal of maps happen in one function, which is called by both drm_takedown and drm_rmmap_ioctl. Reviewed by: idr (previous revision) Tested on: mga (old/new/pci dma), radeon, savage
Diffstat (limited to 'shared-core/savage_bci.c')
-rw-r--r--shared-core/savage_bci.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/shared-core/savage_bci.c b/shared-core/savage_bci.c
index 150f74b4..bfd760ea 100644
--- a/shared-core/savage_bci.c
+++ b/shared-core/savage_bci.c
@@ -537,18 +537,20 @@ static void savage_fake_dma_flush(drm_savage_private_t *dev_priv)
}
/*
- * Initalize permanent mappings. On Savage4 and SavageIX the alignment
+ * Initalize mappings. On Savage4 and SavageIX the alignment
* and size of the aperture is not suitable for automatic MTRR setup
- * in drm_initmap. Therefore we do it manually before the maps are
+ * in drm_addmap. Therefore we do it manually before the maps are
* initialized. We also need to take care of deleting the MTRRs in
* postcleanup.
- *
- * FIXME: this is linux-specific
*/
int savage_preinit(drm_device_t *dev, unsigned long chipset)
{
drm_savage_private_t *dev_priv;
unsigned long mmio_base, fb_base, fb_size, aperture_base;
+ /* fb_rsrc and aper_rsrc aren't really used currently, but still exist
+ * in case we decide we need information on the BAR for BSD in the
+ * future.
+ */
unsigned int fb_rsrc, aper_rsrc;
int ret = 0;
@@ -623,24 +625,21 @@ int savage_preinit(drm_device_t *dev, unsigned long chipset)
/* Automatic MTRR setup will do the right thing. */
}
- if ((ret = drm_initmap(dev, mmio_base, SAVAGE_MMIO_SIZE, 0,
- _DRM_REGISTERS, _DRM_READ_ONLY)))
+ ret = drm_addmap(dev, mmio_base, SAVAGE_MMIO_SIZE, _DRM_REGISTERS,
+ _DRM_READ_ONLY, &dev_priv->mmio);
+ if (ret)
return ret;
- if (!(dev_priv->mmio = drm_core_findmap (dev, mmio_base)))
- return DRM_ERR(ENOMEM);
- if ((ret = drm_initmap(dev, fb_base, fb_size, fb_rsrc,
- _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING)))
+ ret = drm_addmap(dev, fb_base, fb_size, _DRM_FRAME_BUFFER,
+ _DRM_WRITE_COMBINING, &dev_priv->fb);
+ if (ret)
return ret;
- if (!(dev_priv->fb = drm_core_findmap (dev, fb_base)))
- return DRM_ERR(ENOMEM);
- if ((ret = drm_initmap(dev, aperture_base, SAVAGE_APERTURE_SIZE,
- aper_rsrc,
- _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING)))
+ ret = drm_addmap(dev, aperture_base, SAVAGE_APERTURE_SIZE,
+ _DRM_FRAME_BUFFER, _DRM_WRITE_COMBINING,
+ &dev_priv->aperture);
+ if (ret)
return ret;
- if (!(dev_priv->aperture = drm_core_findmap (dev, aperture_base)))
- return DRM_ERR(ENOMEM);
return ret;
}