Commit 004a7727 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Airlie

drm: remove drm_ioremap and drm_ioremapfree

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent b9094d3a
...@@ -843,9 +843,6 @@ extern void drm_mem_init(void); ...@@ -843,9 +843,6 @@ extern void drm_mem_init(void);
extern int drm_mem_info(char *buf, char **start, off_t offset, extern int drm_mem_info(char *buf, char **start, off_t offset,
int request, int *eof, void *data); int request, int *eof, void *data);
extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); 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 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); 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, ...@@ -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 int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size);
extern void drm_mm_takedown(drm_mm_t *mm); extern void drm_mm_takedown(drm_mm_t *mm);
/* Inline replacements for DRM_IOREMAP macros */ extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
static __inline__ void drm_core_ioremap(struct drm_map *map, extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
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);
}
static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
unsigned int token) unsigned int token)
......
...@@ -178,7 +178,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, ...@@ -178,7 +178,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
} }
} }
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
map->handle = drm_ioremap(map->offset, map->size, dev); map->handle = ioremap(map->offset, map->size);
break; break;
case _DRM_SHM: case _DRM_SHM:
...@@ -238,7 +238,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, ...@@ -238,7 +238,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
if (!list) { if (!list) {
if (map->type == _DRM_REGISTERS) 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(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL; return -EINVAL;
} }
...@@ -255,7 +255,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset, ...@@ -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); ret = drm_map_handle(dev, &list->hash, user_token, 0);
if (ret) { if (ret) {
if (map->type == _DRM_REGISTERS) 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(map, sizeof(*map), DRM_MEM_MAPS);
drm_free(list, sizeof(*list), DRM_MEM_MAPS); drm_free(list, sizeof(*list), DRM_MEM_MAPS);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
...@@ -362,7 +362,7 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) ...@@ -362,7 +362,7 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
drm_ioremapfree(map->handle, map->size, dev); iounmap(map->handle);
/* FALLTHROUGH */ /* FALLTHROUGH */
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
if (drm_core_has_MTRR(dev) && map->mtrr >= 0) { if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
......
...@@ -79,28 +79,6 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) ...@@ -79,28 +79,6 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
} }
#if __OS_HAS_AGP #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, static void *agp_remap(unsigned long offset, unsigned long size,
drm_device_t * dev) drm_device_t * dev)
{ {
...@@ -169,13 +147,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) ...@@ -169,13 +147,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle)
} }
#else /* __OS_HAS_AGP */ #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, static inline void *agp_remap(unsigned long offset, unsigned long size,
drm_device_t * dev) drm_device_t * dev)
{ {
...@@ -184,57 +155,28 @@ static inline void *agp_remap(unsigned long offset, unsigned long size, ...@@ -184,57 +155,28 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
#endif /* agp */ #endif /* agp */
void *drm_ioremap(unsigned long offset, unsigned long size, #endif /* debug_memory */
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);
#if 0 void drm_core_ioremap(struct drm_map *map, struct drm_device *dev)
void *drm_ioremap_nocache(unsigned long offset,
unsigned long size, drm_device_t * dev)
{ {
if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { if (drm_core_has_AGP(dev) &&
drm_map_t *map = drm_lookup_map(offset, size, dev); dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
map->handle = agp_remap(map->offset, map->size, dev);
if (map && map->type == _DRM_AGP) else
return agp_remap(offset, size, dev); map->handle = ioremap(map->offset, map->size);
}
return ioremap_nocache(offset, size);
} }
#endif /* 0 */ EXPORT_SYMBOL(drm_core_ioremap);
void drm_ioremapfree(void *pt, unsigned long size, void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
drm_device_t * dev)
{ {
/* if (!map->handle || !map->size)
* This is a bit ugly. It would be much cleaner if the DRM API would use separate return;
* 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 && map->type == _DRM_AGP)
if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture vunmap(map->handle);
&& ((unsigned long)pt >= VMALLOC_START else
&& (unsigned long)pt < VMALLOC_END)) { iounmap(map->handle);
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);
} }
EXPORT_SYMBOL(drm_ioremapfree); EXPORT_SYMBOL(drm_core_ioremapfree);
#endif /* debug_memory */
...@@ -56,26 +56,6 @@ ...@@ -56,26 +56,6 @@
# endif # endif
#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 */ #else /* __OS_HAS_AGP */
static inline unsigned long drm_follow_page(void *vaddr)
{
return 0;
}
#endif #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);
...@@ -205,76 +205,6 @@ void drm_free (void *pt, size_t size, int area) { ...@@ -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 #if __OS_HAS_AGP
DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) { DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) {
......
...@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
map->size); map->size);
DRM_DEBUG("mtrr_del = %d\n", retcode); DRM_DEBUG("mtrr_del = %d\n", retcode);
} }
drm_ioremapfree(map->handle, map->size, dev); iounmap(map->handle);
break; break;
case _DRM_SHM: case _DRM_SHM:
vfree(map->handle); vfree(map->handle);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment