drm: remove drm_ioremap and drm_ioremapfree
authorChristoph Hellwig <hch@lst.de>
Mon, 8 Jan 2007 10:56:59 +0000 (21:56 +1100)
committerDave Airlie <airlied@linux.ie>
Thu, 8 Feb 2007 02:24:26 +0000 (13:24 +1100)
hch originally submitted this for paravirt ops work, airlied took it
and cleaned up a lot of unused code caused by using this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drmP.h
drivers/char/drm/drm_bufs.c
drivers/char/drm/drm_memory.c
drivers/char/drm/drm_memory.h
drivers/char/drm/drm_memory_debug.h
drivers/char/drm/drm_vm.c

index 6dcdceb812033aeb05693fdd3dbb76fcd767a9ff..63042ca9fffe650c4ec3657ba8886d7abc240245 100644 (file)
@@ -843,9 +843,6 @@ extern void drm_mem_init(void);
 extern int drm_mem_info(char *buf, char **start, off_t offset,
                        int request, int *eof, void *data);
 extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
-extern void *drm_ioremap(unsigned long offset, unsigned long size,
-                        drm_device_t * dev);
-extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev);
 
 extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type);
 extern int drm_free_agp(DRM_AGP_MEM * handle, int pages);
@@ -1059,27 +1056,8 @@ extern drm_mm_node_t *drm_mm_search_free(const drm_mm_t *mm, unsigned long size,
 extern int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size);
 extern void drm_mm_takedown(drm_mm_t *mm);
 
-/* Inline replacements for DRM_IOREMAP macros */
-static __inline__ void drm_core_ioremap(struct drm_map *map,
-                                       struct drm_device *dev)
-{
-       map->handle = drm_ioremap(map->offset, map->size, dev);
-}
-
-#if 0
-static __inline__ void drm_core_ioremap_nocache(struct drm_map *map,
-                                               struct drm_device *dev)
-{
-       map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
-}
-#endif  /*  0  */
-
-static __inline__ void drm_core_ioremapfree(struct drm_map *map,
-                                           struct drm_device *dev)
-{
-       if (map->handle && map->size)
-               drm_ioremapfree(map->handle, map->size, dev);
-}
+extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
+extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
 
 static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
                                                   unsigned int token)
index 1f74fb49fa78167d5c856f927444bf685468b40d..d917c8cb8a36226cc492ec50f2794e57d7fa3820 100644 (file)
@@ -178,7 +178,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
                        }
                }
                if (map->type == _DRM_REGISTERS)
-                       map->handle = drm_ioremap(map->offset, map->size, dev);
+                       map->handle = ioremap(map->offset, map->size);
                break;
 
        case _DRM_SHM:
@@ -238,7 +238,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
        list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
        if (!list) {
                if (map->type == _DRM_REGISTERS)
-                       drm_ioremapfree(map->handle, map->size, dev);
+                       iounmap(map->handle);
                drm_free(map, sizeof(*map), DRM_MEM_MAPS);
                return -EINVAL;
        }
@@ -255,7 +255,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
        ret = drm_map_handle(dev, &list->hash, user_token, 0);
        if (ret) {
                if (map->type == _DRM_REGISTERS)
-                       drm_ioremapfree(map->handle, map->size, dev);
+                       iounmap(map->handle);
                drm_free(map, sizeof(*map), DRM_MEM_MAPS);
                drm_free(list, sizeof(*list), DRM_MEM_MAPS);
                mutex_unlock(&dev->struct_mutex);
@@ -362,7 +362,7 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
 
        switch (map->type) {
        case _DRM_REGISTERS:
-               drm_ioremapfree(map->handle, map->size, dev);
+               iounmap(map->handle);
                /* FALLTHROUGH */
        case _DRM_FRAME_BUFFER:
                if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
index 5681cae1d404980fb9a2c123912e6d836778a5ee..92a867082376cead936dbb818eaaba212e0f18e5 100644 (file)
@@ -79,28 +79,6 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
 }
 
 #if __OS_HAS_AGP
-/*
- * Find the drm_map that covers the range [offset, offset+size).
- */
-static drm_map_t *drm_lookup_map(unsigned long offset,
-                                unsigned long size, drm_device_t * dev)
-{
-       struct list_head *list;
-       drm_map_list_t *r_list;
-       drm_map_t *map;
-
-       list_for_each(list, &dev->maplist->head) {
-               r_list = (drm_map_list_t *) list;
-               map = r_list->map;
-               if (!map)
-                       continue;
-               if (map->offset <= offset
-                   && (offset + size) <= (map->offset + map->size))
-                       return map;
-       }
-       return NULL;
-}
-
 static void *agp_remap(unsigned long offset, unsigned long size,
                       drm_device_t * dev)
 {
@@ -169,13 +147,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle)
 }
 
 #else  /*  __OS_HAS_AGP  */
-
-static inline drm_map_t *drm_lookup_map(unsigned long offset,
-                                       unsigned long size, drm_device_t * dev)
-{
-       return NULL;
-}
-
 static inline void *agp_remap(unsigned long offset, unsigned long size,
                              drm_device_t * dev)
 {
@@ -184,57 +155,28 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
 
 #endif                         /* agp */
 
-void *drm_ioremap(unsigned long offset, unsigned long size,
-                               drm_device_t * dev)
-{
-       if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
-               drm_map_t *map = drm_lookup_map(offset, size, dev);
-
-               if (map && map->type == _DRM_AGP)
-                       return agp_remap(offset, size, dev);
-       }
-       return ioremap(offset, size);
-}
-EXPORT_SYMBOL(drm_ioremap);
+#endif                         /* debug_memory */
 
-#if 0
-void *drm_ioremap_nocache(unsigned long offset,
-                                       unsigned long size, drm_device_t * dev)
+void drm_core_ioremap(struct drm_map *map, struct drm_device *dev)
 {
-       if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
-               drm_map_t *map = drm_lookup_map(offset, size, dev);
-
-               if (map && map->type == _DRM_AGP)
-                       return agp_remap(offset, size, dev);
-       }
-       return ioremap_nocache(offset, size);
+       if (drm_core_has_AGP(dev) &&
+           dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
+               map->handle = agp_remap(map->offset, map->size, dev);
+       else
+               map->handle = ioremap(map->offset, map->size);
 }
-#endif  /*  0  */
+EXPORT_SYMBOL(drm_core_ioremap);
 
-void drm_ioremapfree(void *pt, unsigned long size,
-                                  drm_device_t * dev)
+void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
 {
-       /*
-        * This is a bit ugly.  It would be much cleaner if the DRM API would use separate
-        * routines for handling mappings in the AGP space.  Hopefully this can be done in
-        * a future revision of the interface...
-        */
-       if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture
-           && ((unsigned long)pt >= VMALLOC_START
-               && (unsigned long)pt < VMALLOC_END)) {
-               unsigned long offset;
-               drm_map_t *map;
-
-               offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK);
-               map = drm_lookup_map(offset, size, dev);
-               if (map && map->type == _DRM_AGP) {
-                       vunmap(pt);
-                       return;
-               }
-       }
-
-       iounmap(pt);
+       if (!map->handle || !map->size)
+               return;
+
+       if (drm_core_has_AGP(dev) &&
+           dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
+               vunmap(map->handle);
+       else
+               iounmap(map->handle);
 }
-EXPORT_SYMBOL(drm_ioremapfree);
+EXPORT_SYMBOL(drm_core_ioremapfree);
 
-#endif                         /* debug_memory */
index f1b97aff10cf65eb8304651dc776ccd3693271e9..63e425b5ea82aca841b2997934bd191b1903deff 100644 (file)
 # endif
 #endif
 
-static inline unsigned long drm_follow_page(void *vaddr)
-{
-       pgd_t *pgd = pgd_offset_k((unsigned long)vaddr);
-       pud_t *pud = pud_offset(pgd, (unsigned long)vaddr);
-       pmd_t *pmd = pmd_offset(pud, (unsigned long)vaddr);
-       pte_t *ptep = pte_offset_kernel(pmd, (unsigned long)vaddr);
-       return pte_pfn(*ptep) << PAGE_SHIFT;
-}
-
 #else                          /* __OS_HAS_AGP */
 
-static inline unsigned long drm_follow_page(void *vaddr)
-{
-       return 0;
-}
-
 #endif
-
-void *drm_ioremap(unsigned long offset, unsigned long size,
-                               drm_device_t * dev);
-
-void drm_ioremapfree(void *pt, unsigned long size,
-                                  drm_device_t * dev);
index 74581af806e11d073e8b1ac6b5d29c6bdb0cea31..6463271deea899f7274eac92acf28c7943cbe35a 100644 (file)
@@ -205,76 +205,6 @@ void drm_free (void *pt, size_t size, int area) {
        }
 }
 
-void *drm_ioremap (unsigned long offset, unsigned long size,
-                   drm_device_t * dev) {
-       void *pt;
-
-       if (!size) {
-               DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-                             "Mapping 0 bytes at 0x%08lx\n", offset);
-               return NULL;
-       }
-
-       if (!(pt = drm_ioremap(offset, size, dev))) {
-               spin_lock(&drm_mem_lock);
-               ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count;
-               spin_unlock(&drm_mem_lock);
-               return NULL;
-       }
-       spin_lock(&drm_mem_lock);
-       ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
-       drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size;
-       spin_unlock(&drm_mem_lock);
-       return pt;
-}
-
-#if 0
-void *drm_ioremap_nocache (unsigned long offset, unsigned long size,
-                           drm_device_t * dev) {
-       void *pt;
-
-       if (!size) {
-               DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-                             "Mapping 0 bytes at 0x%08lx\n", offset);
-               return NULL;
-       }
-
-       if (!(pt = drm_ioremap_nocache(offset, size, dev))) {
-               spin_lock(&drm_mem_lock);
-               ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count;
-               spin_unlock(&drm_mem_lock);
-               return NULL;
-       }
-       spin_lock(&drm_mem_lock);
-       ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
-       drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size;
-       spin_unlock(&drm_mem_lock);
-       return pt;
-}
-#endif  /*  0  */
-
-void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) {
-       int alloc_count;
-       int free_count;
-
-       if (!pt)
-               DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-                             "Attempt to free NULL pointer\n");
-       else
-               drm_ioremapfree(pt, size, dev);
-
-       spin_lock(&drm_mem_lock);
-       drm_mem_stats[DRM_MEM_MAPPINGS].bytes_freed += size;
-       free_count = ++drm_mem_stats[DRM_MEM_MAPPINGS].free_count;
-       alloc_count = drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
-       spin_unlock(&drm_mem_lock);
-       if (free_count > alloc_count) {
-               DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
-                             "Excess frees: %d frees, %d allocs\n",
-                             free_count, alloc_count);
-       }
-}
-
 #if __OS_HAS_AGP
 
 DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) {
index b9cfc077f6bc845633328aef6965b292fe83871f..4e480583a27fb6bbe912ef929de53ceca8ce8089 100644 (file)
@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
                                                           map->size);
                                        DRM_DEBUG("mtrr_del = %d\n", retcode);
                                }
-                               drm_ioremapfree(map->handle, map->size, dev);
+                               iounmap(map->handle);
                                break;
                        case _DRM_SHM:
                                vfree(map->handle);