aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-01-08 05:56:59 -0500
committerDave Airlie <airlied@linux.ie>2007-02-07 21:24:26 -0500
commit004a7727421fd202bbdfcc0231a3359085199a52 (patch)
tree74da2f5eb50095cf7b5388ee05a26328a5519e1b /drivers
parentb9094d3aaa9550e740b6fd12b68f485d9979ce27 (diff)
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: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/drm/drmP.h26
-rw-r--r--drivers/char/drm/drm_bufs.c8
-rw-r--r--drivers/char/drm/drm_memory.c94
-rw-r--r--drivers/char/drm/drm_memory.h20
-rw-r--r--drivers/char/drm/drm_memory_debug.h70
-rw-r--r--drivers/char/drm/drm_vm.c2
6 files changed, 25 insertions, 195 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 6dcdceb81203..63042ca9fffe 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -843,9 +843,6 @@ extern void drm_mem_init(void);
843extern int drm_mem_info(char *buf, char **start, off_t offset, 843extern int drm_mem_info(char *buf, char **start, off_t offset,
844 int request, int *eof, void *data); 844 int request, int *eof, void *data);
845extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); 845extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
846extern void *drm_ioremap(unsigned long offset, unsigned long size,
847 drm_device_t * dev);
848extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev);
849 846
850extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type); 847extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type);
851extern int drm_free_agp(DRM_AGP_MEM * handle, int pages); 848extern 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,
1059extern int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size); 1056extern int drm_mm_init(drm_mm_t *mm, unsigned long start, unsigned long size);
1060extern void drm_mm_takedown(drm_mm_t *mm); 1057extern void drm_mm_takedown(drm_mm_t *mm);
1061 1058
1062/* Inline replacements for DRM_IOREMAP macros */ 1059extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
1063static __inline__ void drm_core_ioremap(struct drm_map *map, 1060extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
1064 struct drm_device *dev)
1065{
1066 map->handle = drm_ioremap(map->offset, map->size, dev);
1067}
1068
1069#if 0
1070static __inline__ void drm_core_ioremap_nocache(struct drm_map *map,
1071 struct drm_device *dev)
1072{
1073 map->handle = drm_ioremap_nocache(map->offset, map->size, dev);
1074}
1075#endif /* 0 */
1076
1077static __inline__ void drm_core_ioremapfree(struct drm_map *map,
1078 struct drm_device *dev)
1079{
1080 if (map->handle && map->size)
1081 drm_ioremapfree(map->handle, map->size, dev);
1082}
1083 1061
1084static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, 1062static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
1085 unsigned int token) 1063 unsigned int token)
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 1f74fb49fa78..d917c8cb8a36 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -178,7 +178,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
178 } 178 }
179 } 179 }
180 if (map->type == _DRM_REGISTERS) 180 if (map->type == _DRM_REGISTERS)
181 map->handle = drm_ioremap(map->offset, map->size, dev); 181 map->handle = ioremap(map->offset, map->size);
182 break; 182 break;
183 183
184 case _DRM_SHM: 184 case _DRM_SHM:
@@ -238,7 +238,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); 238 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
239 if (!list) { 239 if (!list) {
240 if (map->type == _DRM_REGISTERS) 240 if (map->type == _DRM_REGISTERS)
241 drm_ioremapfree(map->handle, map->size, dev); 241 iounmap(map->handle);
242 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 242 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
243 return -EINVAL; 243 return -EINVAL;
244 } 244 }
@@ -255,7 +255,7 @@ static int drm_addmap_core(drm_device_t * dev, unsigned int offset,
255 ret = drm_map_handle(dev, &list->hash, user_token, 0); 255 ret = drm_map_handle(dev, &list->hash, user_token, 0);
256 if (ret) { 256 if (ret) {
257 if (map->type == _DRM_REGISTERS) 257 if (map->type == _DRM_REGISTERS)
258 drm_ioremapfree(map->handle, map->size, dev); 258 iounmap(map->handle);
259 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 259 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
260 drm_free(list, sizeof(*list), DRM_MEM_MAPS); 260 drm_free(list, sizeof(*list), DRM_MEM_MAPS);
261 mutex_unlock(&dev->struct_mutex); 261 mutex_unlock(&dev->struct_mutex);
@@ -362,7 +362,7 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map)
362 362
363 switch (map->type) { 363 switch (map->type) {
364 case _DRM_REGISTERS: 364 case _DRM_REGISTERS:
365 drm_ioremapfree(map->handle, map->size, dev); 365 iounmap(map->handle);
366 /* FALLTHROUGH */ 366 /* FALLTHROUGH */
367 case _DRM_FRAME_BUFFER: 367 case _DRM_FRAME_BUFFER:
368 if (drm_core_has_MTRR(dev) && map->mtrr >= 0) { 368 if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c
index 5681cae1d404..92a867082376 100644
--- a/drivers/char/drm/drm_memory.c
+++ b/drivers/char/drm/drm_memory.c
@@ -79,28 +79,6 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
79} 79}
80 80
81#if __OS_HAS_AGP 81#if __OS_HAS_AGP
82/*
83 * Find the drm_map that covers the range [offset, offset+size).
84 */
85static drm_map_t *drm_lookup_map(unsigned long offset,
86 unsigned long size, drm_device_t * dev)
87{
88 struct list_head *list;
89 drm_map_list_t *r_list;
90 drm_map_t *map;
91
92 list_for_each(list, &dev->maplist->head) {
93 r_list = (drm_map_list_t *) list;
94 map = r_list->map;
95 if (!map)
96 continue;
97 if (map->offset <= offset
98 && (offset + size) <= (map->offset + map->size))
99 return map;
100 }
101 return NULL;
102}
103
104static void *agp_remap(unsigned long offset, unsigned long size, 82static void *agp_remap(unsigned long offset, unsigned long size,
105 drm_device_t * dev) 83 drm_device_t * dev)
106{ 84{
@@ -169,13 +147,6 @@ int drm_unbind_agp(DRM_AGP_MEM * handle)
169} 147}
170 148
171#else /* __OS_HAS_AGP */ 149#else /* __OS_HAS_AGP */
172
173static inline drm_map_t *drm_lookup_map(unsigned long offset,
174 unsigned long size, drm_device_t * dev)
175{
176 return NULL;
177}
178
179static inline void *agp_remap(unsigned long offset, unsigned long size, 150static inline void *agp_remap(unsigned long offset, unsigned long size,
180 drm_device_t * dev) 151 drm_device_t * dev)
181{ 152{
@@ -184,57 +155,28 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
184 155
185#endif /* agp */ 156#endif /* agp */
186 157
187void *drm_ioremap(unsigned long offset, unsigned long size, 158#endif /* debug_memory */
188 drm_device_t * dev)
189{
190 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) {
191 drm_map_t *map = drm_lookup_map(offset, size, dev);
192
193 if (map && map->type == _DRM_AGP)
194 return agp_remap(offset, size, dev);
195 }
196 return ioremap(offset, size);
197}
198EXPORT_SYMBOL(drm_ioremap);
199 159
200#if 0 160void drm_core_ioremap(struct drm_map *map, struct drm_device *dev)
201void *drm_ioremap_nocache(unsigned long offset,
202 unsigned long size, drm_device_t * dev)
203{ 161{
204 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { 162 if (drm_core_has_AGP(dev) &&
205 drm_map_t *map = drm_lookup_map(offset, size, dev); 163 dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
206 164 map->handle = agp_remap(map->offset, map->size, dev);
207 if (map && map->type == _DRM_AGP) 165 else
208 return agp_remap(offset, size, dev); 166 map->handle = ioremap(map->offset, map->size);
209 }
210 return ioremap_nocache(offset, size);
211} 167}
212#endif /* 0 */ 168EXPORT_SYMBOL(drm_core_ioremap);
213 169
214void drm_ioremapfree(void *pt, unsigned long size, 170void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
215 drm_device_t * dev)
216{ 171{
217 /* 172 if (!map->handle || !map->size)
218 * This is a bit ugly. It would be much cleaner if the DRM API would use separate 173 return;
219 * routines for handling mappings in the AGP space. Hopefully this can be done in 174
220 * a future revision of the interface... 175 if (drm_core_has_AGP(dev) &&
221 */ 176 dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
222 if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture 177 vunmap(map->handle);
223 && ((unsigned long)pt >= VMALLOC_START 178 else
224 && (unsigned long)pt < VMALLOC_END)) { 179 iounmap(map->handle);
225 unsigned long offset;
226 drm_map_t *map;
227
228 offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK);
229 map = drm_lookup_map(offset, size, dev);
230 if (map && map->type == _DRM_AGP) {
231 vunmap(pt);
232 return;
233 }
234 }
235
236 iounmap(pt);
237} 180}
238EXPORT_SYMBOL(drm_ioremapfree); 181EXPORT_SYMBOL(drm_core_ioremapfree);
239 182
240#endif /* debug_memory */
diff --git a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h
index f1b97aff10cf..63e425b5ea82 100644
--- a/drivers/char/drm/drm_memory.h
+++ b/drivers/char/drm/drm_memory.h
@@ -56,26 +56,6 @@
56# endif 56# endif
57#endif 57#endif
58 58
59static inline unsigned long drm_follow_page(void *vaddr)
60{
61 pgd_t *pgd = pgd_offset_k((unsigned long)vaddr);
62 pud_t *pud = pud_offset(pgd, (unsigned long)vaddr);
63 pmd_t *pmd = pmd_offset(pud, (unsigned long)vaddr);
64 pte_t *ptep = pte_offset_kernel(pmd, (unsigned long)vaddr);
65 return pte_pfn(*ptep) << PAGE_SHIFT;
66}
67
68#else /* __OS_HAS_AGP */ 59#else /* __OS_HAS_AGP */
69 60
70static inline unsigned long drm_follow_page(void *vaddr)
71{
72 return 0;
73}
74
75#endif 61#endif
76
77void *drm_ioremap(unsigned long offset, unsigned long size,
78 drm_device_t * dev);
79
80void drm_ioremapfree(void *pt, unsigned long size,
81 drm_device_t * dev);
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
index 74581af806e1..6463271deea8 100644
--- a/drivers/char/drm/drm_memory_debug.h
+++ b/drivers/char/drm/drm_memory_debug.h
@@ -205,76 +205,6 @@ void drm_free (void *pt, size_t size, int area) {
205 } 205 }
206} 206}
207 207
208void *drm_ioremap (unsigned long offset, unsigned long size,
209 drm_device_t * dev) {
210 void *pt;
211
212 if (!size) {
213 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
214 "Mapping 0 bytes at 0x%08lx\n", offset);
215 return NULL;
216 }
217
218 if (!(pt = drm_ioremap(offset, size, dev))) {
219 spin_lock(&drm_mem_lock);
220 ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count;
221 spin_unlock(&drm_mem_lock);
222 return NULL;
223 }
224 spin_lock(&drm_mem_lock);
225 ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
226 drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size;
227 spin_unlock(&drm_mem_lock);
228 return pt;
229}
230
231#if 0
232void *drm_ioremap_nocache (unsigned long offset, unsigned long size,
233 drm_device_t * dev) {
234 void *pt;
235
236 if (!size) {
237 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
238 "Mapping 0 bytes at 0x%08lx\n", offset);
239 return NULL;
240 }
241
242 if (!(pt = drm_ioremap_nocache(offset, size, dev))) {
243 spin_lock(&drm_mem_lock);
244 ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count;
245 spin_unlock(&drm_mem_lock);
246 return NULL;
247 }
248 spin_lock(&drm_mem_lock);
249 ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
250 drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size;
251 spin_unlock(&drm_mem_lock);
252 return pt;
253}
254#endif /* 0 */
255
256void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) {
257 int alloc_count;
258 int free_count;
259
260 if (!pt)
261 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
262 "Attempt to free NULL pointer\n");
263 else
264 drm_ioremapfree(pt, size, dev);
265
266 spin_lock(&drm_mem_lock);
267 drm_mem_stats[DRM_MEM_MAPPINGS].bytes_freed += size;
268 free_count = ++drm_mem_stats[DRM_MEM_MAPPINGS].free_count;
269 alloc_count = drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
270 spin_unlock(&drm_mem_lock);
271 if (free_count > alloc_count) {
272 DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
273 "Excess frees: %d frees, %d allocs\n",
274 free_count, alloc_count);
275 }
276}
277
278#if __OS_HAS_AGP 208#if __OS_HAS_AGP
279 209
280DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) { 210DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) {
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index b9cfc077f6bc..4e480583a27f 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
227 map->size); 227 map->size);
228 DRM_DEBUG("mtrr_del = %d\n", retcode); 228 DRM_DEBUG("mtrr_del = %d\n", retcode);
229 } 229 }
230 drm_ioremapfree(map->handle, map->size, dev); 230 iounmap(map->handle);
231 break; 231 break;
232 case _DRM_SHM: 232 case _DRM_SHM:
233 vfree(map->handle); 233 vfree(map->handle);