aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-03-24 15:23:04 -0400
committerEric Anholt <eric@anholt.net>2009-06-18 16:00:33 -0400
commit9a298b2acd771d8a5c0004d8f8e4156c65b11f6b (patch)
treef8bf6cfe675492cb881abb50d9aa9aa8f38733d6 /drivers/gpu
parent52dc7d32b88156248167864f77a9026abe27b432 (diff)
drm: Remove memory debugging infrastructure.
It hasn't been used in ages, and having the user tell your how much memory is being freed at free time is a recipe for disaster even if it was ever used. Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_agpsupport.c12
-rw-r--r--drivers/gpu/drm/drm_auth.c4
-rw-r--r--drivers/gpu/drm/drm_bufs.c140
-rw-r--r--drivers/gpu/drm/drm_context.c4
-rw-r--r--drivers/gpu/drm/drm_debugfs.c9
-rw-r--r--drivers/gpu/drm/drm_dma.c31
-rw-r--r--drivers/gpu/drm/drm_drawable.c25
-rw-r--r--drivers/gpu/drm/drm_drv.c18
-rw-r--r--drivers/gpu/drm/drm_fops.c8
-rw-r--r--drivers/gpu/drm/drm_gem.c8
-rw-r--r--drivers/gpu/drm/drm_hashtab.c6
-rw-r--r--drivers/gpu/drm/drm_ioctl.c14
-rw-r--r--drivers/gpu/drm/drm_irq.c44
-rw-r--r--drivers/gpu/drm/drm_memory.c25
-rw-r--r--drivers/gpu/drm/drm_pci.c53
-rw-r--r--drivers/gpu/drm/drm_proc.c8
-rw-r--r--drivers/gpu/drm/drm_scatter.c33
-rw-r--r--drivers/gpu/drm/drm_sman.c29
-rw-r--r--drivers/gpu/drm/drm_stub.c19
-rw-r--r--drivers/gpu/drm/drm_vm.c8
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c6
-rw-r--r--drivers/gpu/drm/i830/i830_dma.c6
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c40
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c35
-rw-r--r--drivers/gpu/drm/i915/i915_mem.c24
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c6
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c11
-rw-r--r--drivers/gpu/drm/mga/mga_dma.c14
-rw-r--r--drivers/gpu/drm/r128/r128_cce.c12
-rw-r--r--drivers/gpu/drm/r128/r128_state.c84
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_mem.c24
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c16
-rw-r--r--drivers/gpu/drm/savage/savage_bci.c21
-rw-r--r--drivers/gpu/drm/savage/savage_state.c17
-rw-r--r--drivers/gpu/drm/sis/sis_drv.c6
-rw-r--r--drivers/gpu/drm/via/via_map.c8
39 files changed, 324 insertions, 523 deletions
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index 14796594e5d9..7a0d042c8d6a 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -203,7 +203,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
203 203
204 if (!dev->agp || !dev->agp->acquired) 204 if (!dev->agp || !dev->agp->acquired)
205 return -EINVAL; 205 return -EINVAL;
206 if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) 206 if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL)))
207 return -ENOMEM; 207 return -ENOMEM;
208 208
209 memset(entry, 0, sizeof(*entry)); 209 memset(entry, 0, sizeof(*entry));
@@ -211,7 +211,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
211 pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; 211 pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
212 type = (u32) request->type; 212 type = (u32) request->type;
213 if (!(memory = drm_alloc_agp(dev, pages, type))) { 213 if (!(memory = drm_alloc_agp(dev, pages, type))) {
214 drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); 214 kfree(entry);
215 return -ENOMEM; 215 return -ENOMEM;
216 } 216 }
217 217
@@ -369,7 +369,7 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
369 list_del(&entry->head); 369 list_del(&entry->head);
370 370
371 drm_free_agp(entry->memory, entry->pages); 371 drm_free_agp(entry->memory, entry->pages);
372 drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); 372 kfree(entry);
373 return 0; 373 return 0;
374} 374}
375EXPORT_SYMBOL(drm_agp_free); 375EXPORT_SYMBOL(drm_agp_free);
@@ -397,13 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
397{ 397{
398 struct drm_agp_head *head = NULL; 398 struct drm_agp_head *head = NULL;
399 399
400 if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) 400 if (!(head = kmalloc(sizeof(*head), GFP_KERNEL)))
401 return NULL; 401 return NULL;
402 memset((void *)head, 0, sizeof(*head)); 402 memset((void *)head, 0, sizeof(*head));
403 head->bridge = agp_find_bridge(dev->pdev); 403 head->bridge = agp_find_bridge(dev->pdev);
404 if (!head->bridge) { 404 if (!head->bridge) {
405 if (!(head->bridge = agp_backend_acquire(dev->pdev))) { 405 if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
406 drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); 406 kfree(head);
407 return NULL; 407 return NULL;
408 } 408 }
409 agp_copy_info(head->bridge, &head->agp_info); 409 agp_copy_info(head->bridge, &head->agp_info);
@@ -412,7 +412,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
412 agp_copy_info(head->bridge, &head->agp_info); 412 agp_copy_info(head->bridge, &head->agp_info);
413 } 413 }
414 if (head->agp_info.chipset == NOT_SUPPORTED) { 414 if (head->agp_info.chipset == NOT_SUPPORTED) {
415 drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); 415 kfree(head);
416 return NULL; 416 return NULL;
417 } 417 }
418 INIT_LIST_HEAD(&head->memory); 418 INIT_LIST_HEAD(&head->memory);
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index ca7a9ef5007b..932b5aa96a67 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -79,7 +79,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
79 struct drm_device *dev = master->minor->dev; 79 struct drm_device *dev = master->minor->dev;
80 DRM_DEBUG("%d\n", magic); 80 DRM_DEBUG("%d\n", magic);
81 81
82 entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); 82 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
83 if (!entry) 83 if (!entry)
84 return -ENOMEM; 84 return -ENOMEM;
85 memset(entry, 0, sizeof(*entry)); 85 memset(entry, 0, sizeof(*entry));
@@ -120,7 +120,7 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
120 list_del(&pt->head); 120 list_del(&pt->head);
121 mutex_unlock(&dev->struct_mutex); 121 mutex_unlock(&dev->struct_mutex);
122 122
123 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); 123 kfree(pt);
124 124
125 return 0; 125 return 0;
126} 126}
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 80a257554b30..6246e3f3dad7 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -151,7 +151,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
151 unsigned long user_token; 151 unsigned long user_token;
152 int ret; 152 int ret;
153 153
154 map = drm_alloc(sizeof(*map), DRM_MEM_MAPS); 154 map = kmalloc(sizeof(*map), GFP_KERNEL);
155 if (!map) 155 if (!map)
156 return -ENOMEM; 156 return -ENOMEM;
157 157
@@ -165,7 +165,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
165 * when processes fork. 165 * when processes fork.
166 */ 166 */
167 if ((map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM) { 167 if ((map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM) {
168 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 168 kfree(map);
169 return -EINVAL; 169 return -EINVAL;
170 } 170 }
171 DRM_DEBUG("offset = 0x%08llx, size = 0x%08lx, type = %d\n", 171 DRM_DEBUG("offset = 0x%08llx, size = 0x%08lx, type = %d\n",
@@ -179,7 +179,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
179 map->size = PAGE_ALIGN(map->size); 179 map->size = PAGE_ALIGN(map->size);
180 180
181 if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) { 181 if ((map->offset & (~(resource_size_t)PAGE_MASK)) || (map->size & (~PAGE_MASK))) {
182 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 182 kfree(map);
183 return -EINVAL; 183 return -EINVAL;
184 } 184 }
185 map->mtrr = -1; 185 map->mtrr = -1;
@@ -191,7 +191,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
191#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__) 191#if !defined(__sparc__) && !defined(__alpha__) && !defined(__ia64__) && !defined(__powerpc64__) && !defined(__x86_64__)
192 if (map->offset + (map->size-1) < map->offset || 192 if (map->offset + (map->size-1) < map->offset ||
193 map->offset < virt_to_phys(high_memory)) { 193 map->offset < virt_to_phys(high_memory)) {
194 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 194 kfree(map);
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197#endif 197#endif
@@ -212,7 +212,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
212 list->map->size = map->size; 212 list->map->size = map->size;
213 } 213 }
214 214
215 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 215 kfree(map);
216 *maplist = list; 216 *maplist = list;
217 return 0; 217 return 0;
218 } 218 }
@@ -227,7 +227,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
227 if (map->type == _DRM_REGISTERS) { 227 if (map->type == _DRM_REGISTERS) {
228 map->handle = ioremap(map->offset, map->size); 228 map->handle = ioremap(map->offset, map->size);
229 if (!map->handle) { 229 if (!map->handle) {
230 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 230 kfree(map);
231 return -ENOMEM; 231 return -ENOMEM;
232 } 232 }
233 } 233 }
@@ -243,7 +243,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
243 list->map->size = map->size; 243 list->map->size = map->size;
244 } 244 }
245 245
246 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 246 kfree(map);
247 *maplist = list; 247 *maplist = list;
248 return 0; 248 return 0;
249 } 249 }
@@ -251,7 +251,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
251 DRM_DEBUG("%lu %d %p\n", 251 DRM_DEBUG("%lu %d %p\n",
252 map->size, drm_order(map->size), map->handle); 252 map->size, drm_order(map->size), map->handle);
253 if (!map->handle) { 253 if (!map->handle) {
254 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 254 kfree(map);
255 return -ENOMEM; 255 return -ENOMEM;
256 } 256 }
257 map->offset = (unsigned long)map->handle; 257 map->offset = (unsigned long)map->handle;
@@ -259,7 +259,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
259 /* Prevent a 2nd X Server from creating a 2nd lock */ 259 /* Prevent a 2nd X Server from creating a 2nd lock */
260 if (dev->primary->master->lock.hw_lock != NULL) { 260 if (dev->primary->master->lock.hw_lock != NULL) {
261 vfree(map->handle); 261 vfree(map->handle);
262 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 262 kfree(map);
263 return -EBUSY; 263 return -EBUSY;
264 } 264 }
265 dev->sigdata.lock = dev->primary->master->lock.hw_lock = map->handle; /* Pointer to lock */ 265 dev->sigdata.lock = dev->primary->master->lock.hw_lock = map->handle; /* Pointer to lock */
@@ -270,7 +270,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
270 int valid = 0; 270 int valid = 0;
271 271
272 if (!drm_core_has_AGP(dev)) { 272 if (!drm_core_has_AGP(dev)) {
273 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 273 kfree(map);
274 return -EINVAL; 274 return -EINVAL;
275 } 275 }
276#ifdef __alpha__ 276#ifdef __alpha__
@@ -303,7 +303,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
303 } 303 }
304 } 304 }
305 if (!list_empty(&dev->agp->memory) && !valid) { 305 if (!list_empty(&dev->agp->memory) && !valid) {
306 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 306 kfree(map);
307 return -EPERM; 307 return -EPERM;
308 } 308 }
309 DRM_DEBUG("AGP offset = 0x%08llx, size = 0x%08lx\n", 309 DRM_DEBUG("AGP offset = 0x%08llx, size = 0x%08lx\n",
@@ -316,7 +316,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
316 } 316 }
317 case _DRM_SCATTER_GATHER: 317 case _DRM_SCATTER_GATHER:
318 if (!dev->sg) { 318 if (!dev->sg) {
319 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 319 kfree(map);
320 return -EINVAL; 320 return -EINVAL;
321 } 321 }
322 map->offset += (unsigned long)dev->sg->virtual; 322 map->offset += (unsigned long)dev->sg->virtual;
@@ -328,7 +328,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
328 * need to point to a 64bit variable first. */ 328 * need to point to a 64bit variable first. */
329 dmah = drm_pci_alloc(dev, map->size, map->size, 0xffffffffUL); 329 dmah = drm_pci_alloc(dev, map->size, map->size, 0xffffffffUL);
330 if (!dmah) { 330 if (!dmah) {
331 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 331 kfree(map);
332 return -ENOMEM; 332 return -ENOMEM;
333 } 333 }
334 map->handle = dmah->vaddr; 334 map->handle = dmah->vaddr;
@@ -336,15 +336,15 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
336 kfree(dmah); 336 kfree(dmah);
337 break; 337 break;
338 default: 338 default:
339 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 339 kfree(map);
340 return -EINVAL; 340 return -EINVAL;
341 } 341 }
342 342
343 list = drm_alloc(sizeof(*list), DRM_MEM_MAPS); 343 list = kmalloc(sizeof(*list), GFP_KERNEL);
344 if (!list) { 344 if (!list) {
345 if (map->type == _DRM_REGISTERS) 345 if (map->type == _DRM_REGISTERS)
346 iounmap(map->handle); 346 iounmap(map->handle);
347 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 347 kfree(map);
348 return -EINVAL; 348 return -EINVAL;
349 } 349 }
350 memset(list, 0, sizeof(*list)); 350 memset(list, 0, sizeof(*list));
@@ -362,8 +362,8 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
362 if (ret) { 362 if (ret) {
363 if (map->type == _DRM_REGISTERS) 363 if (map->type == _DRM_REGISTERS)
364 iounmap(map->handle); 364 iounmap(map->handle);
365 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 365 kfree(map);
366 drm_free(list, sizeof(*list), DRM_MEM_MAPS); 366 kfree(list);
367 mutex_unlock(&dev->struct_mutex); 367 mutex_unlock(&dev->struct_mutex);
368 return ret; 368 return ret;
369 } 369 }
@@ -448,7 +448,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
448 list_del(&r_list->head); 448 list_del(&r_list->head);
449 drm_ht_remove_key(&dev->map_hash, 449 drm_ht_remove_key(&dev->map_hash,
450 r_list->user_token >> PAGE_SHIFT); 450 r_list->user_token >> PAGE_SHIFT);
451 drm_free(r_list, sizeof(*r_list), DRM_MEM_MAPS); 451 kfree(r_list);
452 found = 1; 452 found = 1;
453 break; 453 break;
454 } 454 }
@@ -491,7 +491,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
491 DRM_ERROR("tried to rmmap GEM object\n"); 491 DRM_ERROR("tried to rmmap GEM object\n");
492 break; 492 break;
493 } 493 }
494 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 494 kfree(map);
495 495
496 return 0; 496 return 0;
497} 497}
@@ -582,24 +582,16 @@ static void drm_cleanup_buf_error(struct drm_device * dev,
582 drm_pci_free(dev, entry->seglist[i]); 582 drm_pci_free(dev, entry->seglist[i]);
583 } 583 }
584 } 584 }
585 drm_free(entry->seglist, 585 kfree(entry->seglist);
586 entry->seg_count *
587 sizeof(*entry->seglist), DRM_MEM_SEGS);
588 586
589 entry->seg_count = 0; 587 entry->seg_count = 0;
590 } 588 }
591 589
592 if (entry->buf_count) { 590 if (entry->buf_count) {
593 for (i = 0; i < entry->buf_count; i++) { 591 for (i = 0; i < entry->buf_count; i++) {
594 if (entry->buflist[i].dev_private) { 592 kfree(entry->buflist[i].dev_private);
595 drm_free(entry->buflist[i].dev_private,
596 entry->buflist[i].dev_priv_size,
597 DRM_MEM_BUFS);
598 }
599 } 593 }
600 drm_free(entry->buflist, 594 kfree(entry->buflist);
601 entry->buf_count *
602 sizeof(*entry->buflist), DRM_MEM_BUFS);
603 595
604 entry->buf_count = 0; 596 entry->buf_count = 0;
605 } 597 }
@@ -698,8 +690,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
698 return -EINVAL; 690 return -EINVAL;
699 } 691 }
700 692
701 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 693 entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
702 DRM_MEM_BUFS);
703 if (!entry->buflist) { 694 if (!entry->buflist) {
704 mutex_unlock(&dev->struct_mutex); 695 mutex_unlock(&dev->struct_mutex);
705 atomic_dec(&dev->buf_alloc); 696 atomic_dec(&dev->buf_alloc);
@@ -729,7 +720,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
729 buf->file_priv = NULL; 720 buf->file_priv = NULL;
730 721
731 buf->dev_priv_size = dev->driver->dev_priv_size; 722 buf->dev_priv_size = dev->driver->dev_priv_size;
732 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 723 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL);
733 if (!buf->dev_private) { 724 if (!buf->dev_private) {
734 /* Set count correctly so we free the proper amount. */ 725 /* Set count correctly so we free the proper amount. */
735 entry->buf_count = count; 726 entry->buf_count = count;
@@ -749,10 +740,9 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
749 740
750 DRM_DEBUG("byte_count: %d\n", byte_count); 741 DRM_DEBUG("byte_count: %d\n", byte_count);
751 742
752 temp_buflist = drm_realloc(dma->buflist, 743 temp_buflist = krealloc(dma->buflist,
753 dma->buf_count * sizeof(*dma->buflist), 744 (dma->buf_count + entry->buf_count) *
754 (dma->buf_count + entry->buf_count) 745 sizeof(*dma->buflist), GFP_KERNEL);
755 * sizeof(*dma->buflist), DRM_MEM_BUFS);
756 if (!temp_buflist) { 746 if (!temp_buflist) {
757 /* Free the entry because it isn't valid */ 747 /* Free the entry because it isn't valid */
758 drm_cleanup_buf_error(dev, entry); 748 drm_cleanup_buf_error(dev, entry);
@@ -854,8 +844,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
854 return -EINVAL; 844 return -EINVAL;
855 } 845 }
856 846
857 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 847 entry->buflist = kmalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
858 DRM_MEM_BUFS);
859 if (!entry->buflist) { 848 if (!entry->buflist) {
860 mutex_unlock(&dev->struct_mutex); 849 mutex_unlock(&dev->struct_mutex);
861 atomic_dec(&dev->buf_alloc); 850 atomic_dec(&dev->buf_alloc);
@@ -863,11 +852,9 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
863 } 852 }
864 memset(entry->buflist, 0, count * sizeof(*entry->buflist)); 853 memset(entry->buflist, 0, count * sizeof(*entry->buflist));
865 854
866 entry->seglist = drm_alloc(count * sizeof(*entry->seglist), 855 entry->seglist = kmalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
867 DRM_MEM_SEGS);
868 if (!entry->seglist) { 856 if (!entry->seglist) {
869 drm_free(entry->buflist, 857 kfree(entry->buflist);
870 count * sizeof(*entry->buflist), DRM_MEM_BUFS);
871 mutex_unlock(&dev->struct_mutex); 858 mutex_unlock(&dev->struct_mutex);
872 atomic_dec(&dev->buf_alloc); 859 atomic_dec(&dev->buf_alloc);
873 return -ENOMEM; 860 return -ENOMEM;
@@ -877,13 +864,11 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
877 /* Keep the original pagelist until we know all the allocations 864 /* Keep the original pagelist until we know all the allocations
878 * have succeeded 865 * have succeeded
879 */ 866 */
880 temp_pagelist = drm_alloc((dma->page_count + (count << page_order)) 867 temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
881 * sizeof(*dma->pagelist), DRM_MEM_PAGES); 868 sizeof(*dma->pagelist), GFP_KERNEL);
882 if (!temp_pagelist) { 869 if (!temp_pagelist) {
883 drm_free(entry->buflist, 870 kfree(entry->buflist);
884 count * sizeof(*entry->buflist), DRM_MEM_BUFS); 871 kfree(entry->seglist);
885 drm_free(entry->seglist,
886 count * sizeof(*entry->seglist), DRM_MEM_SEGS);
887 mutex_unlock(&dev->struct_mutex); 872 mutex_unlock(&dev->struct_mutex);
888 atomic_dec(&dev->buf_alloc); 873 atomic_dec(&dev->buf_alloc);
889 return -ENOMEM; 874 return -ENOMEM;
@@ -907,9 +892,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
907 entry->buf_count = count; 892 entry->buf_count = count;
908 entry->seg_count = count; 893 entry->seg_count = count;
909 drm_cleanup_buf_error(dev, entry); 894 drm_cleanup_buf_error(dev, entry);
910 drm_free(temp_pagelist, 895 kfree(temp_pagelist);
911 (dma->page_count + (count << page_order))
912 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
913 mutex_unlock(&dev->struct_mutex); 896 mutex_unlock(&dev->struct_mutex);
914 atomic_dec(&dev->buf_alloc); 897 atomic_dec(&dev->buf_alloc);
915 return -ENOMEM; 898 return -ENOMEM;
@@ -940,18 +923,14 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
940 buf->file_priv = NULL; 923 buf->file_priv = NULL;
941 924
942 buf->dev_priv_size = dev->driver->dev_priv_size; 925 buf->dev_priv_size = dev->driver->dev_priv_size;
943 buf->dev_private = drm_alloc(buf->dev_priv_size, 926 buf->dev_private = kmalloc(buf->dev_priv_size,
944 DRM_MEM_BUFS); 927 GFP_KERNEL);
945 if (!buf->dev_private) { 928 if (!buf->dev_private) {
946 /* Set count correctly so we free the proper amount. */ 929 /* Set count correctly so we free the proper amount. */
947 entry->buf_count = count; 930 entry->buf_count = count;
948 entry->seg_count = count; 931 entry->seg_count = count;
949 drm_cleanup_buf_error(dev, entry); 932 drm_cleanup_buf_error(dev, entry);
950 drm_free(temp_pagelist, 933 kfree(temp_pagelist);
951 (dma->page_count +
952 (count << page_order))
953 * sizeof(*dma->pagelist),
954 DRM_MEM_PAGES);
955 mutex_unlock(&dev->struct_mutex); 934 mutex_unlock(&dev->struct_mutex);
956 atomic_dec(&dev->buf_alloc); 935 atomic_dec(&dev->buf_alloc);
957 return -ENOMEM; 936 return -ENOMEM;
@@ -964,16 +943,13 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
964 byte_count += PAGE_SIZE << page_order; 943 byte_count += PAGE_SIZE << page_order;
965 } 944 }
966 945
967 temp_buflist = drm_realloc(dma->buflist, 946 temp_buflist = krealloc(dma->buflist,
968 dma->buf_count * sizeof(*dma->buflist), 947 (dma->buf_count + entry->buf_count) *
969 (dma->buf_count + entry->buf_count) 948 sizeof(*dma->buflist), GFP_KERNEL);
970 * sizeof(*dma->buflist), DRM_MEM_BUFS);
971 if (!temp_buflist) { 949 if (!temp_buflist) {
972 /* Free the entry because it isn't valid */ 950 /* Free the entry because it isn't valid */
973 drm_cleanup_buf_error(dev, entry); 951 drm_cleanup_buf_error(dev, entry);
974 drm_free(temp_pagelist, 952 kfree(temp_pagelist);
975 (dma->page_count + (count << page_order))
976 * sizeof(*dma->pagelist), DRM_MEM_PAGES);
977 mutex_unlock(&dev->struct_mutex); 953 mutex_unlock(&dev->struct_mutex);
978 atomic_dec(&dev->buf_alloc); 954 atomic_dec(&dev->buf_alloc);
979 return -ENOMEM; 955 return -ENOMEM;
@@ -988,9 +964,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
988 * with the new one. 964 * with the new one.
989 */ 965 */
990 if (dma->page_count) { 966 if (dma->page_count) {
991 drm_free(dma->pagelist, 967 kfree(dma->pagelist);
992 dma->page_count * sizeof(*dma->pagelist),
993 DRM_MEM_PAGES);
994 } 968 }
995 dma->pagelist = temp_pagelist; 969 dma->pagelist = temp_pagelist;
996 970
@@ -1086,8 +1060,8 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1086 return -EINVAL; 1060 return -EINVAL;
1087 } 1061 }
1088 1062
1089 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 1063 entry->buflist = kmalloc(count * sizeof(*entry->buflist),
1090 DRM_MEM_BUFS); 1064 GFP_KERNEL);
1091 if (!entry->buflist) { 1065 if (!entry->buflist) {
1092 mutex_unlock(&dev->struct_mutex); 1066 mutex_unlock(&dev->struct_mutex);
1093 atomic_dec(&dev->buf_alloc); 1067 atomic_dec(&dev->buf_alloc);
@@ -1118,7 +1092,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1118 buf->file_priv = NULL; 1092 buf->file_priv = NULL;
1119 1093
1120 buf->dev_priv_size = dev->driver->dev_priv_size; 1094 buf->dev_priv_size = dev->driver->dev_priv_size;
1121 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 1095 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL);
1122 if (!buf->dev_private) { 1096 if (!buf->dev_private) {
1123 /* Set count correctly so we free the proper amount. */ 1097 /* Set count correctly so we free the proper amount. */
1124 entry->buf_count = count; 1098 entry->buf_count = count;
@@ -1139,10 +1113,9 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1139 1113
1140 DRM_DEBUG("byte_count: %d\n", byte_count); 1114 DRM_DEBUG("byte_count: %d\n", byte_count);
1141 1115
1142 temp_buflist = drm_realloc(dma->buflist, 1116 temp_buflist = krealloc(dma->buflist,
1143 dma->buf_count * sizeof(*dma->buflist), 1117 (dma->buf_count + entry->buf_count) *
1144 (dma->buf_count + entry->buf_count) 1118 sizeof(*dma->buflist), GFP_KERNEL);
1145 * sizeof(*dma->buflist), DRM_MEM_BUFS);
1146 if (!temp_buflist) { 1119 if (!temp_buflist) {
1147 /* Free the entry because it isn't valid */ 1120 /* Free the entry because it isn't valid */
1148 drm_cleanup_buf_error(dev, entry); 1121 drm_cleanup_buf_error(dev, entry);
@@ -1248,8 +1221,8 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1248 return -EINVAL; 1221 return -EINVAL;
1249 } 1222 }
1250 1223
1251 entry->buflist = drm_alloc(count * sizeof(*entry->buflist), 1224 entry->buflist = kmalloc(count * sizeof(*entry->buflist),
1252 DRM_MEM_BUFS); 1225 GFP_KERNEL);
1253 if (!entry->buflist) { 1226 if (!entry->buflist) {
1254 mutex_unlock(&dev->struct_mutex); 1227 mutex_unlock(&dev->struct_mutex);
1255 atomic_dec(&dev->buf_alloc); 1228 atomic_dec(&dev->buf_alloc);
@@ -1279,7 +1252,7 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1279 buf->file_priv = NULL; 1252 buf->file_priv = NULL;
1280 1253
1281 buf->dev_priv_size = dev->driver->dev_priv_size; 1254 buf->dev_priv_size = dev->driver->dev_priv_size;
1282 buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS); 1255 buf->dev_private = kmalloc(buf->dev_priv_size, GFP_KERNEL);
1283 if (!buf->dev_private) { 1256 if (!buf->dev_private) {
1284 /* Set count correctly so we free the proper amount. */ 1257 /* Set count correctly so we free the proper amount. */
1285 entry->buf_count = count; 1258 entry->buf_count = count;
@@ -1299,10 +1272,9 @@ static int drm_addbufs_fb(struct drm_device * dev, struct drm_buf_desc * request
1299 1272
1300 DRM_DEBUG("byte_count: %d\n", byte_count); 1273 DRM_DEBUG("byte_count: %d\n", byte_count);
1301 1274
1302 temp_buflist = drm_realloc(dma->buflist, 1275 temp_buflist = krealloc(dma->buflist,
1303 dma->buf_count * sizeof(*dma->buflist), 1276 (dma->buf_count + entry->buf_count) *
1304 (dma->buf_count + entry->buf_count) 1277 sizeof(*dma->buflist), GFP_KERNEL);
1305 * sizeof(*dma->buflist), DRM_MEM_BUFS);
1306 if (!temp_buflist) { 1278 if (!temp_buflist) {
1307 /* Free the entry because it isn't valid */ 1279 /* Free the entry because it isn't valid */
1308 drm_cleanup_buf_error(dev, entry); 1280 drm_cleanup_buf_error(dev, entry);
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 7d1e53c10d4b..2607753a320b 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -341,7 +341,7 @@ int drm_addctx(struct drm_device *dev, void *data,
341 } 341 }
342 } 342 }
343 343
344 ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST); 344 ctx_entry = kmalloc(sizeof(*ctx_entry), GFP_KERNEL);
345 if (!ctx_entry) { 345 if (!ctx_entry) {
346 DRM_DEBUG("out of memory\n"); 346 DRM_DEBUG("out of memory\n");
347 return -ENOMEM; 347 return -ENOMEM;
@@ -456,7 +456,7 @@ int drm_rmctx(struct drm_device *dev, void *data,
456 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { 456 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
457 if (pos->handle == ctx->handle) { 457 if (pos->handle == ctx->handle) {
458 list_del(&pos->head); 458 list_del(&pos->head);
459 drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); 459 kfree(pos);
460 --dev->ctx_count; 460 --dev->ctx_count;
461 } 461 }
462 } 462 }
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 6ce0e2667a85..2960b6d73456 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -100,15 +100,13 @@ int drm_debugfs_create_files(struct drm_info_list *files, int count,
100 (dev->driver->driver_features & features) != features) 100 (dev->driver->driver_features & features) != features)
101 continue; 101 continue;
102 102
103 tmp = drm_alloc(sizeof(struct drm_info_node), 103 tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
104 _DRM_DRIVER);
105 ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO, 104 ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO,
106 root, tmp, &drm_debugfs_fops); 105 root, tmp, &drm_debugfs_fops);
107 if (!ent) { 106 if (!ent) {
108 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/%s\n", 107 DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/%s\n",
109 name, files[i].name); 108 name, files[i].name);
110 drm_free(tmp, sizeof(struct drm_info_node), 109 kfree(tmp);
111 _DRM_DRIVER);
112 ret = -1; 110 ret = -1;
113 goto fail; 111 goto fail;
114 } 112 }
@@ -196,8 +194,7 @@ int drm_debugfs_remove_files(struct drm_info_list *files, int count,
196 if (tmp->info_ent == &files[i]) { 194 if (tmp->info_ent == &files[i]) {
197 debugfs_remove(tmp->dent); 195 debugfs_remove(tmp->dent);
198 list_del(pos); 196 list_del(pos);
199 drm_free(tmp, sizeof(struct drm_info_node), 197 kfree(tmp);
200 _DRM_DRIVER);
201 } 198 }
202 } 199 }
203 } 200 }
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index 7a8e2fba4678..13f1537413fb 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -47,7 +47,7 @@ int drm_dma_setup(struct drm_device *dev)
47{ 47{
48 int i; 48 int i;
49 49
50 dev->dma = drm_alloc(sizeof(*dev->dma), DRM_MEM_DRIVER); 50 dev->dma = kmalloc(sizeof(*dev->dma), GFP_KERNEL);
51 if (!dev->dma) 51 if (!dev->dma)
52 return -ENOMEM; 52 return -ENOMEM;
53 53
@@ -88,36 +88,19 @@ void drm_dma_takedown(struct drm_device *dev)
88 drm_pci_free(dev, dma->bufs[i].seglist[j]); 88 drm_pci_free(dev, dma->bufs[i].seglist[j]);
89 } 89 }
90 } 90 }
91 drm_free(dma->bufs[i].seglist, 91 kfree(dma->bufs[i].seglist);
92 dma->bufs[i].seg_count
93 * sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS);
94 } 92 }
95 if (dma->bufs[i].buf_count) { 93 if (dma->bufs[i].buf_count) {
96 for (j = 0; j < dma->bufs[i].buf_count; j++) { 94 for (j = 0; j < dma->bufs[i].buf_count; j++) {
97 if (dma->bufs[i].buflist[j].dev_private) { 95 kfree(dma->bufs[i].buflist[j].dev_private);
98 drm_free(dma->bufs[i].buflist[j].
99 dev_private,
100 dma->bufs[i].buflist[j].
101 dev_priv_size, DRM_MEM_BUFS);
102 }
103 } 96 }
104 drm_free(dma->bufs[i].buflist, 97 kfree(dma->bufs[i].buflist);
105 dma->bufs[i].buf_count *
106 sizeof(*dma->bufs[0].buflist), DRM_MEM_BUFS);
107 } 98 }
108 } 99 }
109 100
110 if (dma->buflist) { 101 kfree(dma->buflist);
111 drm_free(dma->buflist, 102 kfree(dma->pagelist);
112 dma->buf_count * sizeof(*dma->buflist), DRM_MEM_BUFS); 103 kfree(dev->dma);
113 }
114
115 if (dma->pagelist) {
116 drm_free(dma->pagelist,
117 dma->page_count * sizeof(*dma->pagelist),
118 DRM_MEM_PAGES);
119 }
120 drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
121 dev->dma = NULL; 104 dev->dma = NULL;
122} 105}
123 106
diff --git a/drivers/gpu/drm/drm_drawable.c b/drivers/gpu/drm/drm_drawable.c
index 80be1cab62af..c53c9768cc11 100644
--- a/drivers/gpu/drm/drm_drawable.c
+++ b/drivers/gpu/drm/drm_drawable.c
@@ -85,9 +85,8 @@ int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
85 spin_unlock_irqrestore(&dev->drw_lock, irqflags); 85 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
86 return -EINVAL; 86 return -EINVAL;
87 } 87 }
88 drm_free(info->rects, info->num_rects * sizeof(struct drm_clip_rect), 88 kfree(info->rects);
89 DRM_MEM_BUFS); 89 kfree(info);
90 drm_free(info, sizeof(struct drm_drawable_info), DRM_MEM_BUFS);
91 90
92 idr_remove(&dev->drw_idr, draw->handle); 91 idr_remove(&dev->drw_idr, draw->handle);
93 92
@@ -106,12 +105,12 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
106 105
107 info = idr_find(&dev->drw_idr, update->handle); 106 info = idr_find(&dev->drw_idr, update->handle);
108 if (!info) { 107 if (!info) {
109 info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); 108 info = kzalloc(sizeof(*info), GFP_KERNEL);
110 if (!info) 109 if (!info)
111 return -ENOMEM; 110 return -ENOMEM;
112 if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) { 111 if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) {
113 DRM_ERROR("No such drawable %d\n", update->handle); 112 DRM_ERROR("No such drawable %d\n", update->handle);
114 drm_free(info, sizeof(*info), DRM_MEM_BUFS); 113 kfree(info);
115 return -EINVAL; 114 return -EINVAL;
116 } 115 }
117 } 116 }
@@ -121,8 +120,9 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
121 if (update->num == 0) 120 if (update->num == 0)
122 rects = NULL; 121 rects = NULL;
123 else if (update->num != info->num_rects) { 122 else if (update->num != info->num_rects) {
124 rects = drm_alloc(update->num * sizeof(struct drm_clip_rect), 123 rects = kmalloc(update->num *
125 DRM_MEM_BUFS); 124 sizeof(struct drm_clip_rect),
125 GFP_KERNEL);
126 } else 126 } else
127 rects = info->rects; 127 rects = info->rects;
128 128
@@ -145,8 +145,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
145 spin_lock_irqsave(&dev->drw_lock, irqflags); 145 spin_lock_irqsave(&dev->drw_lock, irqflags);
146 146
147 if (rects != info->rects) { 147 if (rects != info->rects) {
148 drm_free(info->rects, info->num_rects * 148 kfree(info->rects);
149 sizeof(struct drm_clip_rect), DRM_MEM_BUFS);
150 } 149 }
151 150
152 info->rects = rects; 151 info->rects = rects;
@@ -166,8 +165,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
166 165
167error: 166error:
168 if (rects != info->rects) 167 if (rects != info->rects)
169 drm_free(rects, update->num * sizeof(struct drm_clip_rect), 168 kfree(rects);
170 DRM_MEM_BUFS);
171 169
172 return err; 170 return err;
173} 171}
@@ -186,9 +184,8 @@ static int drm_drawable_free(int idr, void *p, void *data)
186 struct drm_drawable_info *info = p; 184 struct drm_drawable_info *info = p;
187 185
188 if (info) { 186 if (info) {
189 drm_free(info->rects, info->num_rects * 187 kfree(info->rects);
190 sizeof(struct drm_clip_rect), DRM_MEM_BUFS); 188 kfree(info);
191 drm_free(info, sizeof(*info), DRM_MEM_BUFS);
192 } 189 }
193 190
194 return 0; 191 return 0;
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1bf7efd8d334..b39d7bfc0c9c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -189,7 +189,7 @@ int drm_lastclose(struct drm_device * dev)
189 if (entry->bound) 189 if (entry->bound)
190 drm_unbind_agp(entry->memory); 190 drm_unbind_agp(entry->memory);
191 drm_free_agp(entry->memory, entry->pages); 191 drm_free_agp(entry->memory, entry->pages);
192 drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); 192 kfree(entry);
193 } 193 }
194 INIT_LIST_HEAD(&dev->agp->memory); 194 INIT_LIST_HEAD(&dev->agp->memory);
195 195
@@ -208,21 +208,15 @@ int drm_lastclose(struct drm_device * dev)
208 /* Clear vma list (only built for debugging) */ 208 /* Clear vma list (only built for debugging) */
209 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { 209 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
210 list_del(&vma->head); 210 list_del(&vma->head);
211 drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); 211 kfree(vma);
212 } 212 }
213 213
214 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { 214 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
215 for (i = 0; i < dev->queue_count; i++) { 215 for (i = 0; i < dev->queue_count; i++) {
216 if (dev->queuelist[i]) { 216 kfree(dev->queuelist[i]);
217 drm_free(dev->queuelist[i], 217 dev->queuelist[i] = NULL;
218 sizeof(*dev->queuelist[0]),
219 DRM_MEM_QUEUES);
220 dev->queuelist[i] = NULL;
221 }
222 } 218 }
223 drm_free(dev->queuelist, 219 kfree(dev->queuelist);
224 dev->queue_slots * sizeof(*dev->queuelist),
225 DRM_MEM_QUEUES);
226 dev->queuelist = NULL; 220 dev->queuelist = NULL;
227 } 221 }
228 dev->queue_count = 0; 222 dev->queue_count = 0;
@@ -344,8 +338,6 @@ static int __init drm_core_init(void)
344 goto err_p3; 338 goto err_p3;
345 } 339 }
346 340
347 drm_mem_init();
348
349 DRM_INFO("Initialized %s %d.%d.%d %s\n", 341 DRM_INFO("Initialized %s %d.%d.%d %s\n",
350 CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); 342 CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
351 return 0; 343 return 0;
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 09a3571c9908..251bc0e3b5ec 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -240,7 +240,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
240 240
241 DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id); 241 DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id);
242 242
243 priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); 243 priv = kmalloc(sizeof(*priv), GFP_KERNEL);
244 if (!priv) 244 if (!priv)
245 return -ENOMEM; 245 return -ENOMEM;
246 246
@@ -328,7 +328,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
328 328
329 return 0; 329 return 0;
330 out_free: 330 out_free:
331 drm_free(priv, sizeof(*priv), DRM_MEM_FILES); 331 kfree(priv);
332 filp->private_data = NULL; 332 filp->private_data = NULL;
333 return ret; 333 return ret;
334} 334}
@@ -471,7 +471,7 @@ int drm_release(struct inode *inode, struct file *filp)
471 drm_ctxbitmap_free(dev, pos->handle); 471 drm_ctxbitmap_free(dev, pos->handle);
472 472
473 list_del(&pos->head); 473 list_del(&pos->head);
474 drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); 474 kfree(pos);
475 --dev->ctx_count; 475 --dev->ctx_count;
476 } 476 }
477 } 477 }
@@ -516,7 +516,7 @@ int drm_release(struct inode *inode, struct file *filp)
516 516
517 if (dev->driver->postclose) 517 if (dev->driver->postclose)
518 dev->driver->postclose(dev, file_priv); 518 dev->driver->postclose(dev, file_priv);
519 drm_free(file_priv, sizeof(*file_priv), DRM_MEM_FILES); 519 kfree(file_priv);
520 520
521 /* ======================================================== 521 /* ========================================================
522 * End inline drm_release 522 * End inline drm_release
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index ec43005100d9..8104ecaea26f 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -89,7 +89,7 @@ drm_gem_init(struct drm_device *dev)
89 atomic_set(&dev->gtt_count, 0); 89 atomic_set(&dev->gtt_count, 0);
90 atomic_set(&dev->gtt_memory, 0); 90 atomic_set(&dev->gtt_memory, 0);
91 91
92 mm = drm_calloc(1, sizeof(struct drm_gem_mm), DRM_MEM_MM); 92 mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
93 if (!mm) { 93 if (!mm) {
94 DRM_ERROR("out of memory\n"); 94 DRM_ERROR("out of memory\n");
95 return -ENOMEM; 95 return -ENOMEM;
@@ -98,14 +98,14 @@ drm_gem_init(struct drm_device *dev)
98 dev->mm_private = mm; 98 dev->mm_private = mm;
99 99
100 if (drm_ht_create(&mm->offset_hash, 19)) { 100 if (drm_ht_create(&mm->offset_hash, 19)) {
101 drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); 101 kfree(mm);
102 return -ENOMEM; 102 return -ENOMEM;
103 } 103 }
104 104
105 if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START, 105 if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
106 DRM_FILE_PAGE_OFFSET_SIZE)) { 106 DRM_FILE_PAGE_OFFSET_SIZE)) {
107 drm_ht_remove(&mm->offset_hash); 107 drm_ht_remove(&mm->offset_hash);
108 drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); 108 kfree(mm);
109 return -ENOMEM; 109 return -ENOMEM;
110 } 110 }
111 111
@@ -119,7 +119,7 @@ drm_gem_destroy(struct drm_device *dev)
119 119
120 drm_mm_takedown(&mm->offset_manager); 120 drm_mm_takedown(&mm->offset_manager);
121 drm_ht_remove(&mm->offset_hash); 121 drm_ht_remove(&mm->offset_hash);
122 drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); 122 kfree(mm);
123 dev->mm_private = NULL; 123 dev->mm_private = NULL;
124} 124}
125 125
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c
index ac35145c3e20..f36b21c5b2e1 100644
--- a/drivers/gpu/drm/drm_hashtab.c
+++ b/drivers/gpu/drm/drm_hashtab.c
@@ -46,8 +46,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
46 ht->table = NULL; 46 ht->table = NULL;
47 ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); 47 ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE);
48 if (!ht->use_vmalloc) { 48 if (!ht->use_vmalloc) {
49 ht->table = drm_calloc(ht->size, sizeof(*ht->table), 49 ht->table = kcalloc(ht->size, sizeof(*ht->table), GFP_KERNEL);
50 DRM_MEM_HASHTAB);
51 } 50 }
52 if (!ht->table) { 51 if (!ht->table) {
53 ht->use_vmalloc = 1; 52 ht->use_vmalloc = 1;
@@ -200,8 +199,7 @@ void drm_ht_remove(struct drm_open_hash *ht)
200 if (ht->use_vmalloc) 199 if (ht->use_vmalloc)
201 vfree(ht->table); 200 vfree(ht->table);
202 else 201 else
203 drm_free(ht->table, ht->size * sizeof(*ht->table), 202 kfree(ht->table);
204 DRM_MEM_HASHTAB);
205 ht->table = NULL; 203 ht->table = NULL;
206 } 204 }
207} 205}
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 1fad76289e66..9b9ff46c2378 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -93,7 +93,7 @@ int drm_setunique(struct drm_device *dev, void *data,
93 93
94 master->unique_len = u->unique_len; 94 master->unique_len = u->unique_len;
95 master->unique_size = u->unique_len + 1; 95 master->unique_size = u->unique_len + 1;
96 master->unique = drm_alloc(master->unique_size, DRM_MEM_DRIVER); 96 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
97 if (!master->unique) 97 if (!master->unique)
98 return -ENOMEM; 98 return -ENOMEM;
99 if (copy_from_user(master->unique, u->unique, master->unique_len)) 99 if (copy_from_user(master->unique, u->unique, master->unique_len))
@@ -101,9 +101,8 @@ int drm_setunique(struct drm_device *dev, void *data,
101 101
102 master->unique[master->unique_len] = '\0'; 102 master->unique[master->unique_len] = '\0';
103 103
104 dev->devname = 104 dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
105 drm_alloc(strlen(dev->driver->pci_driver.name) + 105 strlen(master->unique) + 2, GFP_KERNEL);
106 strlen(master->unique) + 2, DRM_MEM_DRIVER);
107 if (!dev->devname) 106 if (!dev->devname)
108 return -ENOMEM; 107 return -ENOMEM;
109 108
@@ -138,7 +137,7 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
138 137
139 master->unique_len = 40; 138 master->unique_len = 40;
140 master->unique_size = master->unique_len; 139 master->unique_size = master->unique_len;
141 master->unique = drm_alloc(master->unique_size, DRM_MEM_DRIVER); 140 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
142 if (master->unique == NULL) 141 if (master->unique == NULL)
143 return -ENOMEM; 142 return -ENOMEM;
144 143
@@ -152,9 +151,8 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
152 else 151 else
153 master->unique_len = len; 152 master->unique_len = len;
154 153
155 dev->devname = 154 dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
156 drm_alloc(strlen(dev->driver->pci_driver.name) + master->unique_len + 155 master->unique_len + 2, GFP_KERNEL);
157 2, DRM_MEM_DRIVER);
158 if (dev->devname == NULL) 156 if (dev->devname == NULL)
159 return -ENOMEM; 157 return -ENOMEM;
160 158
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index fc8e5acd9d9a..b4a3dbcebe9b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -104,21 +104,13 @@ void drm_vblank_cleanup(struct drm_device *dev)
104 104
105 vblank_disable_fn((unsigned long)dev); 105 vblank_disable_fn((unsigned long)dev);
106 106
107 drm_free(dev->vbl_queue, sizeof(*dev->vbl_queue) * dev->num_crtcs, 107 kfree(dev->vbl_queue);
108 DRM_MEM_DRIVER); 108 kfree(dev->_vblank_count);
109 drm_free(dev->_vblank_count, sizeof(*dev->_vblank_count) * 109 kfree(dev->vblank_refcount);
110 dev->num_crtcs, DRM_MEM_DRIVER); 110 kfree(dev->vblank_enabled);
111 drm_free(dev->vblank_refcount, sizeof(*dev->vblank_refcount) * 111 kfree(dev->last_vblank);
112 dev->num_crtcs, DRM_MEM_DRIVER); 112 kfree(dev->last_vblank_wait);
113 drm_free(dev->vblank_enabled, sizeof(*dev->vblank_enabled) * 113 kfree(dev->vblank_inmodeset);
114 dev->num_crtcs, DRM_MEM_DRIVER);
115 drm_free(dev->last_vblank, sizeof(*dev->last_vblank) * dev->num_crtcs,
116 DRM_MEM_DRIVER);
117 drm_free(dev->last_vblank_wait,
118 sizeof(*dev->last_vblank_wait) * dev->num_crtcs,
119 DRM_MEM_DRIVER);
120 drm_free(dev->vblank_inmodeset, sizeof(*dev->vblank_inmodeset) *
121 dev->num_crtcs, DRM_MEM_DRIVER);
122 114
123 dev->num_crtcs = 0; 115 dev->num_crtcs = 0;
124} 116}
@@ -132,37 +124,33 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
132 spin_lock_init(&dev->vbl_lock); 124 spin_lock_init(&dev->vbl_lock);
133 dev->num_crtcs = num_crtcs; 125 dev->num_crtcs = num_crtcs;
134 126
135 dev->vbl_queue = drm_alloc(sizeof(wait_queue_head_t) * num_crtcs, 127 dev->vbl_queue = kmalloc(sizeof(wait_queue_head_t) * num_crtcs,
136 DRM_MEM_DRIVER); 128 GFP_KERNEL);
137 if (!dev->vbl_queue) 129 if (!dev->vbl_queue)
138 goto err; 130 goto err;
139 131
140 dev->_vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs, 132 dev->_vblank_count = kmalloc(sizeof(atomic_t) * num_crtcs, GFP_KERNEL);
141 DRM_MEM_DRIVER);
142 if (!dev->_vblank_count) 133 if (!dev->_vblank_count)
143 goto err; 134 goto err;
144 135
145 dev->vblank_refcount = drm_alloc(sizeof(atomic_t) * num_crtcs, 136 dev->vblank_refcount = kmalloc(sizeof(atomic_t) * num_crtcs,
146 DRM_MEM_DRIVER); 137 GFP_KERNEL);
147 if (!dev->vblank_refcount) 138 if (!dev->vblank_refcount)
148 goto err; 139 goto err;
149 140
150 dev->vblank_enabled = drm_calloc(num_crtcs, sizeof(int), 141 dev->vblank_enabled = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
151 DRM_MEM_DRIVER);
152 if (!dev->vblank_enabled) 142 if (!dev->vblank_enabled)
153 goto err; 143 goto err;
154 144
155 dev->last_vblank = drm_calloc(num_crtcs, sizeof(u32), DRM_MEM_DRIVER); 145 dev->last_vblank = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
156 if (!dev->last_vblank) 146 if (!dev->last_vblank)
157 goto err; 147 goto err;
158 148
159 dev->last_vblank_wait = drm_calloc(num_crtcs, sizeof(u32), 149 dev->last_vblank_wait = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
160 DRM_MEM_DRIVER);
161 if (!dev->last_vblank_wait) 150 if (!dev->last_vblank_wait)
162 goto err; 151 goto err;
163 152
164 dev->vblank_inmodeset = drm_calloc(num_crtcs, sizeof(int), 153 dev->vblank_inmodeset = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
165 DRM_MEM_DRIVER);
166 if (!dev->vblank_inmodeset) 154 if (!dev->vblank_inmodeset)
167 goto err; 155 goto err;
168 156
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 0c707f533eab..0a436184dd88 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -36,15 +36,6 @@
36#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include "drmP.h" 37#include "drmP.h"
38 38
39#ifdef DEBUG_MEMORY
40#include "drm_memory_debug.h"
41#else
42
43/** No-op. */
44void drm_mem_init(void)
45{
46}
47
48/** 39/**
49 * Called when "/proc/dri/%dev%/mem" is read. 40 * Called when "/proc/dri/%dev%/mem" is read.
50 * 41 *
@@ -64,20 +55,6 @@ int drm_mem_info(char *buf, char **start, off_t offset,
64 return 0; 55 return 0;
65} 56}
66 57
67/** Wrapper around kmalloc() and kfree() */
68void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
69{
70 void *pt;
71
72 if (!(pt = kmalloc(size, GFP_KERNEL)))
73 return NULL;
74 if (oldpt && oldsize) {
75 memcpy(pt, oldpt, oldsize);
76 kfree(oldpt);
77 }
78 return pt;
79}
80
81#if __OS_HAS_AGP 58#if __OS_HAS_AGP
82static void *agp_remap(unsigned long offset, unsigned long size, 59static void *agp_remap(unsigned long offset, unsigned long size,
83 struct drm_device * dev) 60 struct drm_device * dev)
@@ -157,8 +134,6 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
157 134
158#endif /* agp */ 135#endif /* agp */
159 136
160#endif /* debug_memory */
161
162void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) 137void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
163{ 138{
164 if (drm_core_has_AGP(dev) && 139 if (drm_core_has_AGP(dev) &&
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index b55d5bc6ea61..577094fb1995 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -55,17 +55,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
55 unsigned long addr; 55 unsigned long addr;
56 size_t sz; 56 size_t sz;
57#endif 57#endif
58#ifdef DRM_DEBUG_MEMORY
59 int area = DRM_MEM_DMA;
60
61 spin_lock(&drm_mem_lock);
62 if ((drm_ram_used >> PAGE_SHIFT)
63 > (DRM_RAM_PERCENT * drm_ram_available) / 100) {
64 spin_unlock(&drm_mem_lock);
65 return 0;
66 }
67 spin_unlock(&drm_mem_lock);
68#endif
69 58
70 /* pci_alloc_consistent only guarantees alignment to the smallest 59 /* pci_alloc_consistent only guarantees alignment to the smallest
71 * PAGE_SIZE order which is greater than or equal to the requested size. 60 * PAGE_SIZE order which is greater than or equal to the requested size.
@@ -86,26 +75,10 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
86 dmah->size = size; 75 dmah->size = size;
87 dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP); 76 dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP);
88 77
89#ifdef DRM_DEBUG_MEMORY
90 if (dmah->vaddr == NULL) {
91 spin_lock(&drm_mem_lock);
92 ++drm_mem_stats[area].fail_count;
93 spin_unlock(&drm_mem_lock);
94 kfree(dmah);
95 return NULL;
96 }
97
98 spin_lock(&drm_mem_lock);
99 ++drm_mem_stats[area].succeed_count;
100 drm_mem_stats[area].bytes_allocated += size;
101 drm_ram_used += size;
102 spin_unlock(&drm_mem_lock);
103#else
104 if (dmah->vaddr == NULL) { 78 if (dmah->vaddr == NULL) {
105 kfree(dmah); 79 kfree(dmah);
106 return NULL; 80 return NULL;
107 } 81 }
108#endif
109 82
110 memset(dmah->vaddr, 0, size); 83 memset(dmah->vaddr, 0, size);
111 84
@@ -132,17 +105,8 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
132 unsigned long addr; 105 unsigned long addr;
133 size_t sz; 106 size_t sz;
134#endif 107#endif
135#ifdef DRM_DEBUG_MEMORY
136 int area = DRM_MEM_DMA;
137 int alloc_count;
138 int free_count;
139#endif
140 108
141 if (!dmah->vaddr) { 109 if (dmah->vaddr) {
142#ifdef DRM_DEBUG_MEMORY
143 DRM_MEM_ERROR(area, "Attempt to free address 0\n");
144#endif
145 } else {
146 /* XXX - Is virt_to_page() legal for consistent mem? */ 110 /* XXX - Is virt_to_page() legal for consistent mem? */
147 /* Unreserve */ 111 /* Unreserve */
148 for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; 112 for (addr = (unsigned long)dmah->vaddr, sz = dmah->size;
@@ -152,21 +116,6 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
152 dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, 116 dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
153 dmah->busaddr); 117 dmah->busaddr);
154 } 118 }
155
156#ifdef DRM_DEBUG_MEMORY
157 spin_lock(&drm_mem_lock);
158 free_count = ++drm_mem_stats[area].free_count;
159 alloc_count = drm_mem_stats[area].succeed_count;
160 drm_mem_stats[area].bytes_freed += size;
161 drm_ram_used -= size;
162 spin_unlock(&drm_mem_lock);
163 if (free_count > alloc_count) {
164 DRM_MEM_ERROR(area,
165 "Excess frees: %d frees, %d allocs\n",
166 free_count, alloc_count);
167 }
168#endif
169
170} 119}
171 120
172/** 121/**
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
index bae5391165ac..bbd4b3d1074a 100644
--- a/drivers/gpu/drm/drm_proc.c
+++ b/drivers/gpu/drm/drm_proc.c
@@ -105,13 +105,12 @@ int drm_proc_create_files(struct drm_info_list *files, int count,
105 (dev->driver->driver_features & features) != features) 105 (dev->driver->driver_features & features) != features)
106 continue; 106 continue;
107 107
108 tmp = drm_alloc(sizeof(struct drm_info_node), _DRM_DRIVER); 108 tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
109 ent = create_proc_entry(files[i].name, S_IFREG | S_IRUGO, root); 109 ent = create_proc_entry(files[i].name, S_IFREG | S_IRUGO, root);
110 if (!ent) { 110 if (!ent) {
111 DRM_ERROR("Cannot create /proc/dri/%s/%s\n", 111 DRM_ERROR("Cannot create /proc/dri/%s/%s\n",
112 name, files[i].name); 112 name, files[i].name);
113 drm_free(tmp, sizeof(struct drm_info_node), 113 kfree(tmp);
114 _DRM_DRIVER);
115 ret = -1; 114 ret = -1;
116 goto fail; 115 goto fail;
117 } 116 }
@@ -192,8 +191,7 @@ int drm_proc_remove_files(struct drm_info_list *files, int count,
192 remove_proc_entry(files[i].name, 191 remove_proc_entry(files[i].name,
193 minor->proc_root); 192 minor->proc_root);
194 list_del(pos); 193 list_del(pos);
195 drm_free(tmp, sizeof(struct drm_info_node), 194 kfree(tmp);
196 _DRM_DRIVER);
197 } 195 }
198 } 196 }
199 } 197 }
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index b2b0f3d41714..c7823c863d4f 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -58,11 +58,9 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
58 58
59 vfree(entry->virtual); 59 vfree(entry->virtual);
60 60
61 drm_free(entry->busaddr, 61 kfree(entry->busaddr);
62 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); 62 kfree(entry->pagelist);
63 drm_free(entry->pagelist, 63 kfree(entry);
64 entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES);
65 drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
66} 64}
67 65
68#ifdef _LP64 66#ifdef _LP64
@@ -84,7 +82,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
84 if (dev->sg) 82 if (dev->sg)
85 return -EINVAL; 83 return -EINVAL;
86 84
87 entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS); 85 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
88 if (!entry) 86 if (!entry)
89 return -ENOMEM; 87 return -ENOMEM;
90 88
@@ -93,34 +91,27 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
93 DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages); 91 DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages);
94 92
95 entry->pages = pages; 93 entry->pages = pages;
96 entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist), 94 entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);
97 DRM_MEM_PAGES);
98 if (!entry->pagelist) { 95 if (!entry->pagelist) {
99 drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS); 96 kfree(entry);
100 return -ENOMEM; 97 return -ENOMEM;
101 } 98 }
102 99
103 memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); 100 memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
104 101
105 entry->busaddr = drm_alloc(pages * sizeof(*entry->busaddr), 102 entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);
106 DRM_MEM_PAGES);
107 if (!entry->busaddr) { 103 if (!entry->busaddr) {
108 drm_free(entry->pagelist, 104 kfree(entry->pagelist);
109 entry->pages * sizeof(*entry->pagelist), 105 kfree(entry);
110 DRM_MEM_PAGES);
111 drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
112 return -ENOMEM; 106 return -ENOMEM;
113 } 107 }
114 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); 108 memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
115 109
116 entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT); 110 entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
117 if (!entry->virtual) { 111 if (!entry->virtual) {
118 drm_free(entry->busaddr, 112 kfree(entry->busaddr);
119 entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); 113 kfree(entry->pagelist);
120 drm_free(entry->pagelist, 114 kfree(entry);
121 entry->pages * sizeof(*entry->pagelist),
122 DRM_MEM_PAGES);
123 drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
124 return -ENOMEM; 115 return -ENOMEM;
125 } 116 }
126 117
diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 926f146390ce..463aed9403db 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -48,9 +48,7 @@ void drm_sman_takedown(struct drm_sman * sman)
48{ 48{
49 drm_ht_remove(&sman->user_hash_tab); 49 drm_ht_remove(&sman->user_hash_tab);
50 drm_ht_remove(&sman->owner_hash_tab); 50 drm_ht_remove(&sman->owner_hash_tab);
51 if (sman->mm) 51 kfree(sman->mm);
52 drm_free(sman->mm, sman->num_managers * sizeof(*sman->mm),
53 DRM_MEM_MM);
54} 52}
55 53
56EXPORT_SYMBOL(drm_sman_takedown); 54EXPORT_SYMBOL(drm_sman_takedown);
@@ -61,8 +59,9 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
61{ 59{
62 int ret = 0; 60 int ret = 0;
63 61
64 sman->mm = (struct drm_sman_mm *) drm_calloc(num_managers, sizeof(*sman->mm), 62 sman->mm = (struct drm_sman_mm *) kcalloc(num_managers,
65 DRM_MEM_MM); 63 sizeof(*sman->mm),
64 GFP_KERNEL);
66 if (!sman->mm) { 65 if (!sman->mm) {
67 ret = -ENOMEM; 66 ret = -ENOMEM;
68 goto out; 67 goto out;
@@ -78,7 +77,7 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
78 77
79 drm_ht_remove(&sman->owner_hash_tab); 78 drm_ht_remove(&sman->owner_hash_tab);
80out1: 79out1:
81 drm_free(sman->mm, num_managers * sizeof(*sman->mm), DRM_MEM_MM); 80 kfree(sman->mm);
82out: 81out:
83 return ret; 82 return ret;
84} 83}
@@ -110,7 +109,7 @@ static void drm_sman_mm_destroy(void *private)
110{ 109{
111 struct drm_mm *mm = (struct drm_mm *) private; 110 struct drm_mm *mm = (struct drm_mm *) private;
112 drm_mm_takedown(mm); 111 drm_mm_takedown(mm);
113 drm_free(mm, sizeof(*mm), DRM_MEM_MM); 112 kfree(mm);
114} 113}
115 114
116static unsigned long drm_sman_mm_offset(void *private, void *ref) 115static unsigned long drm_sman_mm_offset(void *private, void *ref)
@@ -130,7 +129,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
130 BUG_ON(manager >= sman->num_managers); 129 BUG_ON(manager >= sman->num_managers);
131 130
132 sman_mm = &sman->mm[manager]; 131 sman_mm = &sman->mm[manager];
133 mm = drm_calloc(1, sizeof(*mm), DRM_MEM_MM); 132 mm = kzalloc(sizeof(*mm), GFP_KERNEL);
134 if (!mm) { 133 if (!mm) {
135 return -ENOMEM; 134 return -ENOMEM;
136 } 135 }
@@ -138,7 +137,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
138 ret = drm_mm_init(mm, start, size); 137 ret = drm_mm_init(mm, start, size);
139 138
140 if (ret) { 139 if (ret) {
141 drm_free(mm, sizeof(*mm), DRM_MEM_MM); 140 kfree(mm);
142 return ret; 141 return ret;
143 } 142 }
144 143
@@ -176,7 +175,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
176 owner_hash); 175 owner_hash);
177 } 176 }
178 177
179 owner_item = drm_calloc(1, sizeof(*owner_item), DRM_MEM_MM); 178 owner_item = kzalloc(sizeof(*owner_item), GFP_KERNEL);
180 if (!owner_item) 179 if (!owner_item)
181 goto out; 180 goto out;
182 181
@@ -189,7 +188,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
189 return owner_item; 188 return owner_item;
190 189
191out1: 190out1:
192 drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); 191 kfree(owner_item);
193out: 192out:
194 return NULL; 193 return NULL;
195} 194}
@@ -212,7 +211,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man
212 return NULL; 211 return NULL;
213 } 212 }
214 213
215 memblock = drm_calloc(1, sizeof(*memblock), DRM_MEM_MM); 214 memblock = kzalloc(sizeof(*memblock), GFP_KERNEL);
216 215
217 if (!memblock) 216 if (!memblock)
218 goto out; 217 goto out;
@@ -237,7 +236,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man
237out2: 236out2:
238 drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash); 237 drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash);
239out1: 238out1:
240 drm_free(memblock, sizeof(*memblock), DRM_MEM_MM); 239 kfree(memblock);
241out: 240out:
242 sman_mm->free(sman_mm->private, tmp); 241 sman_mm->free(sman_mm->private, tmp);
243 242
@@ -253,7 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item)
253 list_del(&item->owner_list); 252 list_del(&item->owner_list);
254 drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash); 253 drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash);
255 item->mm->free(item->mm->private, item->mm_info); 254 item->mm->free(item->mm->private, item->mm_info);
256 drm_free(item, sizeof(*item), DRM_MEM_MM); 255 kfree(item);
257} 256}
258 257
259int drm_sman_free_key(struct drm_sman *sman, unsigned int key) 258int drm_sman_free_key(struct drm_sman *sman, unsigned int key)
@@ -277,7 +276,7 @@ static void drm_sman_remove_owner(struct drm_sman *sman,
277{ 276{
278 list_del(&owner_item->sman_list); 277 list_del(&owner_item->sman_list);
279 drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash); 278 drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash);
280 drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); 279 kfree(owner_item);
281} 280}
282 281
283int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner) 282int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner)
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 387a8de1bc7e..155a5bbce680 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -107,7 +107,7 @@ struct drm_master *drm_master_create(struct drm_minor *minor)
107{ 107{
108 struct drm_master *master; 108 struct drm_master *master;
109 109
110 master = drm_calloc(1, sizeof(*master), DRM_MEM_DRIVER); 110 master = kzalloc(sizeof(*master), GFP_KERNEL);
111 if (!master) 111 if (!master)
112 return NULL; 112 return NULL;
113 113
@@ -149,7 +149,7 @@ static void drm_master_destroy(struct kref *kref)
149 } 149 }
150 150
151 if (master->unique) { 151 if (master->unique) {
152 drm_free(master->unique, master->unique_size, DRM_MEM_DRIVER); 152 kfree(master->unique);
153 master->unique = NULL; 153 master->unique = NULL;
154 master->unique_len = 0; 154 master->unique_len = 0;
155 } 155 }
@@ -157,12 +157,12 @@ static void drm_master_destroy(struct kref *kref)
157 list_for_each_entry_safe(pt, next, &master->magicfree, head) { 157 list_for_each_entry_safe(pt, next, &master->magicfree, head) {
158 list_del(&pt->head); 158 list_del(&pt->head);
159 drm_ht_remove_item(&master->magiclist, &pt->hash_item); 159 drm_ht_remove_item(&master->magiclist, &pt->hash_item);
160 drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); 160 kfree(pt);
161 } 161 }
162 162
163 drm_ht_remove(&master->magiclist); 163 drm_ht_remove(&master->magiclist);
164 164
165 drm_free(master, sizeof(*master), DRM_MEM_DRIVER); 165 kfree(master);
166} 166}
167 167
168void drm_master_put(struct drm_master **master) 168void drm_master_put(struct drm_master **master)
@@ -390,7 +390,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
390 390
391 DRM_DEBUG("\n"); 391 DRM_DEBUG("\n");
392 392
393 dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB); 393 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
394 if (!dev) 394 if (!dev)
395 return -ENOMEM; 395 return -ENOMEM;
396 396
@@ -443,7 +443,7 @@ err_g3:
443err_g2: 443err_g2:
444 pci_disable_device(pdev); 444 pci_disable_device(pdev);
445err_g1: 445err_g1:
446 drm_free(dev, sizeof(*dev), DRM_MEM_STUB); 446 kfree(dev);
447 return ret; 447 return ret;
448} 448}
449EXPORT_SYMBOL(drm_get_dev); 449EXPORT_SYMBOL(drm_get_dev);
@@ -516,7 +516,7 @@ void drm_put_dev(struct drm_device *dev)
516 dev->driver->unload(dev); 516 dev->driver->unload(dev);
517 517
518 if (drm_core_has_AGP(dev) && dev->agp) { 518 if (drm_core_has_AGP(dev) && dev->agp) {
519 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); 519 kfree(dev->agp);
520 dev->agp = NULL; 520 dev->agp = NULL;
521 } 521 }
522 522
@@ -535,10 +535,9 @@ void drm_put_dev(struct drm_device *dev)
535 drm_put_minor(&dev->primary); 535 drm_put_minor(&dev->primary);
536 536
537 if (dev->devname) { 537 if (dev->devname) {
538 drm_free(dev->devname, strlen(dev->devname) + 1, 538 kfree(dev->devname);
539 DRM_MEM_DRIVER);
540 dev->devname = NULL; 539 dev->devname = NULL;
541 } 540 }
542 drm_free(dev, sizeof(*dev), DRM_MEM_STUB); 541 kfree(dev);
543} 542}
544EXPORT_SYMBOL(drm_put_dev); 543EXPORT_SYMBOL(drm_put_dev);
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 22f76567ac7d..f95d03ac9784 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
227 found_maps++; 227 found_maps++;
228 if (pt->vma == vma) { 228 if (pt->vma == vma) {
229 list_del(&pt->head); 229 list_del(&pt->head);
230 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); 230 kfree(pt);
231 } 231 }
232 } 232 }
233 233
@@ -273,7 +273,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
273 DRM_ERROR("tried to rmmap GEM object\n"); 273 DRM_ERROR("tried to rmmap GEM object\n");
274 break; 274 break;
275 } 275 }
276 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 276 kfree(map);
277 } 277 }
278 } 278 }
279 mutex_unlock(&dev->struct_mutex); 279 mutex_unlock(&dev->struct_mutex);
@@ -414,7 +414,7 @@ void drm_vm_open_locked(struct vm_area_struct *vma)
414 vma->vm_start, vma->vm_end - vma->vm_start); 414 vma->vm_start, vma->vm_end - vma->vm_start);
415 atomic_inc(&dev->vma_count); 415 atomic_inc(&dev->vma_count);
416 416
417 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); 417 vma_entry = kmalloc(sizeof(*vma_entry), GFP_KERNEL);
418 if (vma_entry) { 418 if (vma_entry) {
419 vma_entry->vma = vma; 419 vma_entry->vma = vma;
420 vma_entry->pid = current->pid; 420 vma_entry->pid = current->pid;
@@ -454,7 +454,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
454 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { 454 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
455 if (pt->vma == vma) { 455 if (pt->vma == vma) {
456 list_del(&pt->head); 456 list_del(&pt->head);
457 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); 457 kfree(pt);
458 break; 458 break;
459 } 459 }
460 } 460 }
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index e5de8ea41544..7d1d88cdf2dc 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -227,8 +227,7 @@ static int i810_dma_cleanup(struct drm_device * dev)
227 /* Need to rewrite hardware status page */ 227 /* Need to rewrite hardware status page */
228 I810_WRITE(0x02080, 0x1ffff000); 228 I810_WRITE(0x02080, 0x1ffff000);
229 } 229 }
230 drm_free(dev->dev_private, sizeof(drm_i810_private_t), 230 kfree(dev->dev_private);
231 DRM_MEM_DRIVER);
232 dev->dev_private = NULL; 231 dev->dev_private = NULL;
233 232
234 for (i = 0; i < dma->buf_count; i++) { 233 for (i = 0; i < dma->buf_count; i++) {
@@ -439,8 +438,7 @@ static int i810_dma_init(struct drm_device *dev, void *data,
439 switch (init->func) { 438 switch (init->func) {
440 case I810_INIT_DMA_1_4: 439 case I810_INIT_DMA_1_4:
441 DRM_INFO("Using v1.4 init.\n"); 440 DRM_INFO("Using v1.4 init.\n");
442 dev_priv = drm_alloc(sizeof(drm_i810_private_t), 441 dev_priv = kmalloc(sizeof(drm_i810_private_t), GFP_KERNEL);
443 DRM_MEM_DRIVER);
444 if (dev_priv == NULL) 442 if (dev_priv == NULL)
445 return -ENOMEM; 443 return -ENOMEM;
446 retcode = i810_dma_initialize(dev, dev_priv, init); 444 retcode = i810_dma_initialize(dev, dev_priv, init);
diff --git a/drivers/gpu/drm/i830/i830_dma.c b/drivers/gpu/drm/i830/i830_dma.c
index a86ab30b4620..877bf6cb14a4 100644
--- a/drivers/gpu/drm/i830/i830_dma.c
+++ b/drivers/gpu/drm/i830/i830_dma.c
@@ -232,8 +232,7 @@ static int i830_dma_cleanup(struct drm_device * dev)
232 I830_WRITE(0x02080, 0x1ffff000); 232 I830_WRITE(0x02080, 0x1ffff000);
233 } 233 }
234 234
235 drm_free(dev->dev_private, sizeof(drm_i830_private_t), 235 kfree(dev->dev_private);
236 DRM_MEM_DRIVER);
237 dev->dev_private = NULL; 236 dev->dev_private = NULL;
238 237
239 for (i = 0; i < dma->buf_count; i++) { 238 for (i = 0; i < dma->buf_count; i++) {
@@ -459,8 +458,7 @@ static int i830_dma_init(struct drm_device *dev, void *data,
459 458
460 switch (init->func) { 459 switch (init->func) {
461 case I830_INIT_DMA: 460 case I830_INIT_DMA:
462 dev_priv = drm_alloc(sizeof(drm_i830_private_t), 461 dev_priv = kmalloc(sizeof(drm_i830_private_t), GFP_KERNEL);
463 DRM_MEM_DRIVER);
464 if (dev_priv == NULL) 462 if (dev_priv == NULL)
465 return -ENOMEM; 463 return -ENOMEM;
466 retcode = i830_dma_initialize(dev, dev_priv, init); 464 retcode = i830_dma_initialize(dev, dev_priv, init);
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 1a60626f6803..9b28c55c54fa 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -643,9 +643,9 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
643 return -EINVAL; 643 return -EINVAL;
644 644
645 if (batch->num_cliprects) { 645 if (batch->num_cliprects) {
646 cliprects = drm_calloc(batch->num_cliprects, 646 cliprects = kcalloc(batch->num_cliprects,
647 sizeof(struct drm_clip_rect), 647 sizeof(struct drm_clip_rect),
648 DRM_MEM_DRIVER); 648 GFP_KERNEL);
649 if (cliprects == NULL) 649 if (cliprects == NULL)
650 return -ENOMEM; 650 return -ENOMEM;
651 651
@@ -664,9 +664,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
664 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); 664 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
665 665
666fail_free: 666fail_free:
667 drm_free(cliprects, 667 kfree(cliprects);
668 batch->num_cliprects * sizeof(struct drm_clip_rect),
669 DRM_MEM_DRIVER);
670 668
671 return ret; 669 return ret;
672} 670}
@@ -692,7 +690,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
692 if (cmdbuf->num_cliprects < 0) 690 if (cmdbuf->num_cliprects < 0)
693 return -EINVAL; 691 return -EINVAL;
694 692
695 batch_data = drm_alloc(cmdbuf->sz, DRM_MEM_DRIVER); 693 batch_data = kmalloc(cmdbuf->sz, GFP_KERNEL);
696 if (batch_data == NULL) 694 if (batch_data == NULL)
697 return -ENOMEM; 695 return -ENOMEM;
698 696
@@ -701,9 +699,8 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
701 goto fail_batch_free; 699 goto fail_batch_free;
702 700
703 if (cmdbuf->num_cliprects) { 701 if (cmdbuf->num_cliprects) {
704 cliprects = drm_calloc(cmdbuf->num_cliprects, 702 cliprects = kcalloc(cmdbuf->num_cliprects,
705 sizeof(struct drm_clip_rect), 703 sizeof(struct drm_clip_rect), GFP_KERNEL);
706 DRM_MEM_DRIVER);
707 if (cliprects == NULL) 704 if (cliprects == NULL)
708 goto fail_batch_free; 705 goto fail_batch_free;
709 706
@@ -726,11 +723,9 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
726 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); 723 sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
727 724
728fail_clip_free: 725fail_clip_free:
729 drm_free(cliprects, 726 kfree(cliprects);
730 cmdbuf->num_cliprects * sizeof(struct drm_clip_rect),
731 DRM_MEM_DRIVER);
732fail_batch_free: 727fail_batch_free:
733 drm_free(batch_data, cmdbuf->sz, DRM_MEM_DRIVER); 728 kfree(batch_data);
734 729
735 return ret; 730 return ret;
736} 731}
@@ -1067,7 +1062,7 @@ int i915_master_create(struct drm_device *dev, struct drm_master *master)
1067{ 1062{
1068 struct drm_i915_master_private *master_priv; 1063 struct drm_i915_master_private *master_priv;
1069 1064
1070 master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); 1065 master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
1071 if (!master_priv) 1066 if (!master_priv)
1072 return -ENOMEM; 1067 return -ENOMEM;
1073 1068
@@ -1082,7 +1077,7 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
1082 if (!master_priv) 1077 if (!master_priv)
1083 return; 1078 return;
1084 1079
1085 drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); 1080 kfree(master_priv);
1086 1081
1087 master->driver_priv = NULL; 1082 master->driver_priv = NULL;
1088} 1083}
@@ -1111,12 +1106,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1111 dev->types[8] = _DRM_STAT_SECONDARY; 1106 dev->types[8] = _DRM_STAT_SECONDARY;
1112 dev->types[9] = _DRM_STAT_DMA; 1107 dev->types[9] = _DRM_STAT_DMA;
1113 1108
1114 dev_priv = drm_alloc(sizeof(drm_i915_private_t), DRM_MEM_DRIVER); 1109 dev_priv = kzalloc(sizeof(drm_i915_private_t), GFP_KERNEL);
1115 if (dev_priv == NULL) 1110 if (dev_priv == NULL)
1116 return -ENOMEM; 1111 return -ENOMEM;
1117 1112
1118 memset(dev_priv, 0, sizeof(drm_i915_private_t));
1119
1120 dev->dev_private = (void *)dev_priv; 1113 dev->dev_private = (void *)dev_priv;
1121 dev_priv->dev = dev; 1114 dev_priv->dev = dev;
1122 1115
@@ -1221,7 +1214,7 @@ out_iomapfree:
1221out_rmmap: 1214out_rmmap:
1222 iounmap(dev_priv->regs); 1215 iounmap(dev_priv->regs);
1223free_priv: 1216free_priv:
1224 drm_free(dev_priv, sizeof(struct drm_i915_private), DRM_MEM_DRIVER); 1217 kfree(dev_priv);
1225 return ret; 1218 return ret;
1226} 1219}
1227 1220
@@ -1261,8 +1254,7 @@ int i915_driver_unload(struct drm_device *dev)
1261 i915_gem_lastclose(dev); 1254 i915_gem_lastclose(dev);
1262 } 1255 }
1263 1256
1264 drm_free(dev->dev_private, sizeof(drm_i915_private_t), 1257 kfree(dev->dev_private);
1265 DRM_MEM_DRIVER);
1266 1258
1267 return 0; 1259 return 0;
1268} 1260}
@@ -1273,7 +1265,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv)
1273 1265
1274 DRM_DEBUG_DRIVER(I915_DRV, "\n"); 1266 DRM_DEBUG_DRIVER(I915_DRV, "\n");
1275 i915_file_priv = (struct drm_i915_file_private *) 1267 i915_file_priv = (struct drm_i915_file_private *)
1276 drm_alloc(sizeof(*i915_file_priv), DRM_MEM_FILES); 1268 kmalloc(sizeof(*i915_file_priv), GFP_KERNEL);
1277 1269
1278 if (!i915_file_priv) 1270 if (!i915_file_priv)
1279 return -ENOMEM; 1271 return -ENOMEM;
@@ -1326,7 +1318,7 @@ void i915_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
1326{ 1318{
1327 struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv; 1319 struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv;
1328 1320
1329 drm_free(i915_file_priv, sizeof(*i915_file_priv), DRM_MEM_FILES); 1321 kfree(i915_file_priv);
1330} 1322}
1331 1323
1332struct drm_ioctl_desc i915_ioctls[] = { 1324struct drm_ioctl_desc i915_ioctls[] = {
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 174aef2d6481..fd2b8bdffe3f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1207,8 +1207,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
1207 1207
1208 /* Set the object up for mmap'ing */ 1208 /* Set the object up for mmap'ing */
1209 list = &obj->map_list; 1209 list = &obj->map_list;
1210 list->map = drm_calloc(1, sizeof(struct drm_map_list), 1210 list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL);
1211 DRM_MEM_DRIVER);
1212 if (!list->map) 1211 if (!list->map)
1213 return -ENOMEM; 1212 return -ENOMEM;
1214 1213
@@ -1248,7 +1247,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
1248out_free_mm: 1247out_free_mm:
1249 drm_mm_put_block(list->file_offset_node); 1248 drm_mm_put_block(list->file_offset_node);
1250out_free_list: 1249out_free_list:
1251 drm_free(list->map, sizeof(struct drm_map_list), DRM_MEM_DRIVER); 1250 kfree(list->map);
1252 1251
1253 return ret; 1252 return ret;
1254} 1253}
@@ -1270,7 +1269,7 @@ i915_gem_free_mmap_offset(struct drm_gem_object *obj)
1270 } 1269 }
1271 1270
1272 if (list->map) { 1271 if (list->map) {
1273 drm_free(list->map, sizeof(struct drm_map), DRM_MEM_DRIVER); 1272 kfree(list->map);
1274 list->map = NULL; 1273 list->map = NULL;
1275 } 1274 }
1276 1275
@@ -1493,7 +1492,7 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv,
1493 if (file_priv != NULL) 1492 if (file_priv != NULL)
1494 i915_file_priv = file_priv->driver_priv; 1493 i915_file_priv = file_priv->driver_priv;
1495 1494
1496 request = drm_calloc(1, sizeof(*request), DRM_MEM_DRIVER); 1495 request = kzalloc(sizeof(*request), GFP_KERNEL);
1497 if (request == NULL) 1496 if (request == NULL)
1498 return 0; 1497 return 0;
1499 1498
@@ -1675,7 +1674,7 @@ i915_gem_retire_requests(struct drm_device *dev)
1675 1674
1676 list_del(&request->list); 1675 list_del(&request->list);
1677 list_del(&request->client_list); 1676 list_del(&request->client_list);
1678 drm_free(request, sizeof(*request), DRM_MEM_DRIVER); 1677 kfree(request);
1679 } else 1678 } else
1680 break; 1679 break;
1681 } 1680 }
@@ -2833,8 +2832,7 @@ i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj)
2833 /* Free the page_cpu_valid mappings which are now stale, whether 2832 /* Free the page_cpu_valid mappings which are now stale, whether
2834 * or not we've got I915_GEM_DOMAIN_CPU. 2833 * or not we've got I915_GEM_DOMAIN_CPU.
2835 */ 2834 */
2836 drm_free(obj_priv->page_cpu_valid, obj->size / PAGE_SIZE, 2835 kfree(obj_priv->page_cpu_valid);
2837 DRM_MEM_DRIVER);
2838 obj_priv->page_cpu_valid = NULL; 2836 obj_priv->page_cpu_valid = NULL;
2839} 2837}
2840 2838
@@ -2876,8 +2874,8 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
2876 * newly adding I915_GEM_DOMAIN_CPU 2874 * newly adding I915_GEM_DOMAIN_CPU
2877 */ 2875 */
2878 if (obj_priv->page_cpu_valid == NULL) { 2876 if (obj_priv->page_cpu_valid == NULL) {
2879 obj_priv->page_cpu_valid = drm_calloc(1, obj->size / PAGE_SIZE, 2877 obj_priv->page_cpu_valid = kzalloc(obj->size / PAGE_SIZE,
2880 DRM_MEM_DRIVER); 2878 GFP_KERNEL);
2881 if (obj_priv->page_cpu_valid == NULL) 2879 if (obj_priv->page_cpu_valid == NULL)
2882 return -ENOMEM; 2880 return -ENOMEM;
2883 } else if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0) 2881 } else if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0)
@@ -3300,8 +3298,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
3300 } 3298 }
3301 3299
3302 if (args->num_cliprects != 0) { 3300 if (args->num_cliprects != 0) {
3303 cliprects = drm_calloc(args->num_cliprects, sizeof(*cliprects), 3301 cliprects = kcalloc(args->num_cliprects, sizeof(*cliprects),
3304 DRM_MEM_DRIVER); 3302 GFP_KERNEL);
3305 if (cliprects == NULL) 3303 if (cliprects == NULL)
3306 goto pre_mutex_err; 3304 goto pre_mutex_err;
3307 3305
@@ -3554,8 +3552,7 @@ err:
3554pre_mutex_err: 3552pre_mutex_err:
3555 drm_free_large(object_list); 3553 drm_free_large(object_list);
3556 drm_free_large(exec_list); 3554 drm_free_large(exec_list);
3557 drm_free(cliprects, sizeof(*cliprects) * args->num_cliprects, 3555 kfree(cliprects);
3558 DRM_MEM_DRIVER);
3559 3556
3560 return ret; 3557 return ret;
3561} 3558}
@@ -3772,7 +3769,7 @@ int i915_gem_init_object(struct drm_gem_object *obj)
3772{ 3769{
3773 struct drm_i915_gem_object *obj_priv; 3770 struct drm_i915_gem_object *obj_priv;
3774 3771
3775 obj_priv = drm_calloc(1, sizeof(*obj_priv), DRM_MEM_DRIVER); 3772 obj_priv = kzalloc(sizeof(*obj_priv), GFP_KERNEL);
3776 if (obj_priv == NULL) 3773 if (obj_priv == NULL)
3777 return -ENOMEM; 3774 return -ENOMEM;
3778 3775
@@ -3810,9 +3807,9 @@ void i915_gem_free_object(struct drm_gem_object *obj)
3810 3807
3811 i915_gem_free_mmap_offset(obj); 3808 i915_gem_free_mmap_offset(obj);
3812 3809
3813 drm_free(obj_priv->page_cpu_valid, 1, DRM_MEM_DRIVER); 3810 kfree(obj_priv->page_cpu_valid);
3814 kfree(obj_priv->bit_17); 3811 kfree(obj_priv->bit_17);
3815 drm_free(obj->driver_private, 1, DRM_MEM_DRIVER); 3812 kfree(obj->driver_private);
3816} 3813}
3817 3814
3818/** Unbinds all objects that are on the given buffer list. */ 3815/** Unbinds all objects that are on the given buffer list. */
@@ -4266,7 +4263,7 @@ int i915_gem_init_phys_object(struct drm_device *dev,
4266 if (dev_priv->mm.phys_objs[id - 1] || !size) 4263 if (dev_priv->mm.phys_objs[id - 1] || !size)
4267 return 0; 4264 return 0;
4268 4265
4269 phys_obj = drm_calloc(1, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER); 4266 phys_obj = kzalloc(sizeof(struct drm_i915_gem_phys_object), GFP_KERNEL);
4270 if (!phys_obj) 4267 if (!phys_obj)
4271 return -ENOMEM; 4268 return -ENOMEM;
4272 4269
@@ -4285,7 +4282,7 @@ int i915_gem_init_phys_object(struct drm_device *dev,
4285 4282
4286 return 0; 4283 return 0;
4287kfree_obj: 4284kfree_obj:
4288 drm_free(phys_obj, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER); 4285 kfree(phys_obj);
4289 return ret; 4286 return ret;
4290} 4287}
4291 4288
diff --git a/drivers/gpu/drm/i915/i915_mem.c b/drivers/gpu/drm/i915/i915_mem.c
index 96e271986d2a..83b7b81bb2b8 100644
--- a/drivers/gpu/drm/i915/i915_mem.c
+++ b/drivers/gpu/drm/i915/i915_mem.c
@@ -94,8 +94,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
94{ 94{
95 /* Maybe cut off the start of an existing block */ 95 /* Maybe cut off the start of an existing block */
96 if (start > p->start) { 96 if (start > p->start) {
97 struct mem_block *newblock = 97 struct mem_block *newblock = kmalloc(sizeof(*newblock),
98 drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS); 98 GFP_KERNEL);
99 if (!newblock) 99 if (!newblock)
100 goto out; 100 goto out;
101 newblock->start = start; 101 newblock->start = start;
@@ -111,8 +111,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
111 111
112 /* Maybe cut off the end of an existing block */ 112 /* Maybe cut off the end of an existing block */
113 if (size < p->size) { 113 if (size < p->size) {
114 struct mem_block *newblock = 114 struct mem_block *newblock = kmalloc(sizeof(*newblock),
115 drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS); 115 GFP_KERNEL);
116 if (!newblock) 116 if (!newblock)
117 goto out; 117 goto out;
118 newblock->start = start + size; 118 newblock->start = start + size;
@@ -169,7 +169,7 @@ static void free_block(struct mem_block *p)
169 p->size += q->size; 169 p->size += q->size;
170 p->next = q->next; 170 p->next = q->next;
171 p->next->prev = p; 171 p->next->prev = p;
172 drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); 172 kfree(q);
173 } 173 }
174 174
175 if (p->prev->file_priv == NULL) { 175 if (p->prev->file_priv == NULL) {
@@ -177,7 +177,7 @@ static void free_block(struct mem_block *p)
177 q->size += p->size; 177 q->size += p->size;
178 q->next = p->next; 178 q->next = p->next;
179 q->next->prev = q; 179 q->next->prev = q;
180 drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS); 180 kfree(p);
181 } 181 }
182} 182}
183 183
@@ -185,14 +185,14 @@ static void free_block(struct mem_block *p)
185 */ 185 */
186static int init_heap(struct mem_block **heap, int start, int size) 186static int init_heap(struct mem_block **heap, int start, int size)
187{ 187{
188 struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS); 188 struct mem_block *blocks = kmalloc(sizeof(*blocks), GFP_KERNEL);
189 189
190 if (!blocks) 190 if (!blocks)
191 return -ENOMEM; 191 return -ENOMEM;
192 192
193 *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS); 193 *heap = kmalloc(sizeof(**heap), GFP_KERNEL);
194 if (!*heap) { 194 if (!*heap) {
195 drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS); 195 kfree(blocks);
196 return -ENOMEM; 196 return -ENOMEM;
197 } 197 }
198 198
@@ -233,7 +233,7 @@ void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
233 p->size += q->size; 233 p->size += q->size;
234 p->next = q->next; 234 p->next = q->next;
235 p->next->prev = p; 235 p->next->prev = p;
236 drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); 236 kfree(q);
237 } 237 }
238 } 238 }
239} 239}
@@ -250,10 +250,10 @@ void i915_mem_takedown(struct mem_block **heap)
250 for (p = (*heap)->next; p != *heap;) { 250 for (p = (*heap)->next; p != *heap;) {
251 struct mem_block *q = p; 251 struct mem_block *q = p;
252 p = p->next; 252 p = p->next;
253 drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); 253 kfree(q);
254 } 254 }
255 255
256 drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS); 256 kfree(*heap);
257 *heap = NULL; 257 *heap = NULL;
258} 258}
259 259
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 754dd22fdd77..cdd126d068a7 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -124,8 +124,7 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
124 entry = &lvds_lfp_data->data[lvds_options->panel_type]; 124 entry = &lvds_lfp_data->data[lvds_options->panel_type];
125 dvo_timing = &entry->dvo_timing; 125 dvo_timing = &entry->dvo_timing;
126 126
127 panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), 127 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
128 DRM_MEM_DRIVER);
129 128
130 fill_detail_timing_data(panel_fixed_mode, dvo_timing); 129 fill_detail_timing_data(panel_fixed_mode, dvo_timing);
131 130
@@ -156,8 +155,7 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
156 if (!dvo_timing) 155 if (!dvo_timing)
157 return; 156 return;
158 157
159 panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), 158 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
160 DRM_MEM_DRIVER);
161 159
162 if (!panel_fixed_mode) 160 if (!panel_fixed_mode)
163 return; 161 return;
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 50d7ed70b338..ea68992e4416 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1561,8 +1561,7 @@ intel_tv_destroy (struct drm_connector *connector)
1561 1561
1562 drm_sysfs_connector_remove(connector); 1562 drm_sysfs_connector_remove(connector);
1563 drm_connector_cleanup(connector); 1563 drm_connector_cleanup(connector);
1564 drm_free(intel_output, sizeof(struct intel_output) + sizeof(struct intel_tv_priv), 1564 kfree(intel_output);
1565 DRM_MEM_DRIVER);
1566} 1565}
1567 1566
1568 1567
@@ -1695,8 +1694,8 @@ intel_tv_init(struct drm_device *dev)
1695 (tv_dac_off & TVDAC_STATE_CHG_EN) != 0) 1694 (tv_dac_off & TVDAC_STATE_CHG_EN) != 0)
1696 return; 1695 return;
1697 1696
1698 intel_output = drm_calloc(1, sizeof(struct intel_output) + 1697 intel_output = kzalloc(sizeof(struct intel_output) +
1699 sizeof(struct intel_tv_priv), DRM_MEM_DRIVER); 1698 sizeof(struct intel_tv_priv), GFP_KERNEL);
1700 if (!intel_output) { 1699 if (!intel_output) {
1701 return; 1700 return;
1702 } 1701 }
@@ -1730,8 +1729,8 @@ intel_tv_init(struct drm_device *dev)
1730 connector->doublescan_allowed = false; 1729 connector->doublescan_allowed = false;
1731 1730
1732 /* Create TV properties then attach current values */ 1731 /* Create TV properties then attach current values */
1733 tv_format_names = drm_alloc(sizeof(char *) * NUM_TV_MODES, 1732 tv_format_names = kmalloc(sizeof(char *) * NUM_TV_MODES,
1734 DRM_MEM_DRIVER); 1733 GFP_KERNEL);
1735 if (!tv_format_names) 1734 if (!tv_format_names)
1736 goto out; 1735 goto out;
1737 for (i = 0; i < NUM_TV_MODES; i++) 1736 for (i = 0; i < NUM_TV_MODES; i++)
diff --git a/drivers/gpu/drm/mga/mga_dma.c b/drivers/gpu/drm/mga/mga_dma.c
index 7a6bf9ffc5a3..6c67a02910c8 100644
--- a/drivers/gpu/drm/mga/mga_dma.c
+++ b/drivers/gpu/drm/mga/mga_dma.c
@@ -254,23 +254,20 @@ static int mga_freelist_init(struct drm_device * dev, drm_mga_private_t * dev_pr
254 int i; 254 int i;
255 DRM_DEBUG("count=%d\n", dma->buf_count); 255 DRM_DEBUG("count=%d\n", dma->buf_count);
256 256
257 dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); 257 dev_priv->head = kzalloc(sizeof(drm_mga_freelist_t), GFP_KERNEL);
258 if (dev_priv->head == NULL) 258 if (dev_priv->head == NULL)
259 return -ENOMEM; 259 return -ENOMEM;
260 260
261 memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
262 SET_AGE(&dev_priv->head->age, MGA_BUFFER_USED, 0); 261 SET_AGE(&dev_priv->head->age, MGA_BUFFER_USED, 0);
263 262
264 for (i = 0; i < dma->buf_count; i++) { 263 for (i = 0; i < dma->buf_count; i++) {
265 buf = dma->buflist[i]; 264 buf = dma->buflist[i];
266 buf_priv = buf->dev_private; 265 buf_priv = buf->dev_private;
267 266
268 entry = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); 267 entry = kzalloc(sizeof(drm_mga_freelist_t), GFP_KERNEL);
269 if (entry == NULL) 268 if (entry == NULL)
270 return -ENOMEM; 269 return -ENOMEM;
271 270
272 memset(entry, 0, sizeof(drm_mga_freelist_t));
273
274 entry->next = dev_priv->head->next; 271 entry->next = dev_priv->head->next;
275 entry->prev = dev_priv->head; 272 entry->prev = dev_priv->head;
276 SET_AGE(&entry->age, MGA_BUFFER_FREE, 0); 273 SET_AGE(&entry->age, MGA_BUFFER_FREE, 0);
@@ -301,7 +298,7 @@ static void mga_freelist_cleanup(struct drm_device * dev)
301 entry = dev_priv->head; 298 entry = dev_priv->head;
302 while (entry) { 299 while (entry) {
303 next = entry->next; 300 next = entry->next;
304 drm_free(entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); 301 kfree(entry);
305 entry = next; 302 entry = next;
306 } 303 }
307 304
@@ -399,12 +396,11 @@ int mga_driver_load(struct drm_device * dev, unsigned long flags)
399 drm_mga_private_t *dev_priv; 396 drm_mga_private_t *dev_priv;
400 int ret; 397 int ret;
401 398
402 dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); 399 dev_priv = kzalloc(sizeof(drm_mga_private_t), GFP_KERNEL);
403 if (!dev_priv) 400 if (!dev_priv)
404 return -ENOMEM; 401 return -ENOMEM;
405 402
406 dev->dev_private = (void *)dev_priv; 403 dev->dev_private = (void *)dev_priv;
407 memset(dev_priv, 0, sizeof(drm_mga_private_t));
408 404
409 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT; 405 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
410 dev_priv->chipset = flags; 406 dev_priv->chipset = flags;
@@ -1150,7 +1146,7 @@ int mga_dma_buffers(struct drm_device *dev, void *data,
1150 */ 1146 */
1151int mga_driver_unload(struct drm_device * dev) 1147int mga_driver_unload(struct drm_device * dev)
1152{ 1148{
1153 drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER); 1149 kfree(dev->dev_private);
1154 dev->dev_private = NULL; 1150 dev->dev_private = NULL;
1155 1151
1156 return 0; 1152 return 0;
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index 077c0455a6b9..c75fd3564040 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -353,12 +353,10 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
353 353
354 DRM_DEBUG("\n"); 354 DRM_DEBUG("\n");
355 355
356 dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER); 356 dev_priv = kzalloc(sizeof(drm_r128_private_t), GFP_KERNEL);
357 if (dev_priv == NULL) 357 if (dev_priv == NULL)
358 return -ENOMEM; 358 return -ENOMEM;
359 359
360 memset(dev_priv, 0, sizeof(drm_r128_private_t));
361
362 dev_priv->is_pci = init->is_pci; 360 dev_priv->is_pci = init->is_pci;
363 361
364 if (dev_priv->is_pci && !dev->sg) { 362 if (dev_priv->is_pci && !dev->sg) {
@@ -619,8 +617,7 @@ int r128_do_cleanup_cce(struct drm_device * dev)
619 ("failed to cleanup PCI GART!\n"); 617 ("failed to cleanup PCI GART!\n");
620 } 618 }
621 619
622 drm_free(dev->dev_private, sizeof(drm_r128_private_t), 620 kfree(dev->dev_private);
623 DRM_MEM_DRIVER);
624 dev->dev_private = NULL; 621 dev->dev_private = NULL;
625 } 622 }
626 623
@@ -768,18 +765,17 @@ static int r128_freelist_init(struct drm_device * dev)
768 drm_r128_freelist_t *entry; 765 drm_r128_freelist_t *entry;
769 int i; 766 int i;
770 767
771 dev_priv->head = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); 768 dev_priv->head = kzalloc(sizeof(drm_r128_freelist_t), GFP_KERNEL);
772 if (dev_priv->head == NULL) 769 if (dev_priv->head == NULL)
773 return -ENOMEM; 770 return -ENOMEM;
774 771
775 memset(dev_priv->head, 0, sizeof(drm_r128_freelist_t));
776 dev_priv->head->age = R128_BUFFER_USED; 772 dev_priv->head->age = R128_BUFFER_USED;
777 773
778 for (i = 0; i < dma->buf_count; i++) { 774 for (i = 0; i < dma->buf_count; i++) {
779 buf = dma->buflist[i]; 775 buf = dma->buflist[i];
780 buf_priv = buf->dev_private; 776 buf_priv = buf->dev_private;
781 777
782 entry = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); 778 entry = kmalloc(sizeof(drm_r128_freelist_t), GFP_KERNEL);
783 if (!entry) 779 if (!entry)
784 return -ENOMEM; 780 return -ENOMEM;
785 781
diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index f7a5b5740764..026a48c95c8f 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -910,24 +910,24 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
910 } 910 }
911 911
912 buffer_size = depth->n * sizeof(u32); 912 buffer_size = depth->n * sizeof(u32);
913 buffer = drm_alloc(buffer_size, DRM_MEM_BUFS); 913 buffer = kmalloc(buffer_size, GFP_KERNEL);
914 if (buffer == NULL) 914 if (buffer == NULL)
915 return -ENOMEM; 915 return -ENOMEM;
916 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { 916 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
917 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 917 kfree(buffer);
918 return -EFAULT; 918 return -EFAULT;
919 } 919 }
920 920
921 mask_size = depth->n * sizeof(u8); 921 mask_size = depth->n * sizeof(u8);
922 if (depth->mask) { 922 if (depth->mask) {
923 mask = drm_alloc(mask_size, DRM_MEM_BUFS); 923 mask = kmalloc(mask_size, GFP_KERNEL);
924 if (mask == NULL) { 924 if (mask == NULL) {
925 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 925 kfree(buffer);
926 return -ENOMEM; 926 return -ENOMEM;
927 } 927 }
928 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { 928 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
929 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 929 kfree(buffer);
930 drm_free(mask, mask_size, DRM_MEM_BUFS); 930 kfree(mask);
931 return -EFAULT; 931 return -EFAULT;
932 } 932 }
933 933
@@ -954,7 +954,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
954 } 954 }
955 } 955 }
956 956
957 drm_free(mask, mask_size, DRM_MEM_BUFS); 957 kfree(mask);
958 } else { 958 } else {
959 for (i = 0; i < count; i++, x++) { 959 for (i = 0; i < count; i++, x++) {
960 BEGIN_RING(6); 960 BEGIN_RING(6);
@@ -978,7 +978,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
978 } 978 }
979 } 979 }
980 980
981 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 981 kfree(buffer);
982 982
983 return 0; 983 return 0;
984} 984}
@@ -1000,54 +1000,54 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
1000 1000
1001 xbuf_size = count * sizeof(*x); 1001 xbuf_size = count * sizeof(*x);
1002 ybuf_size = count * sizeof(*y); 1002 ybuf_size = count * sizeof(*y);
1003 x = drm_alloc(xbuf_size, DRM_MEM_BUFS); 1003 x = kmalloc(xbuf_size, GFP_KERNEL);
1004 if (x == NULL) { 1004 if (x == NULL) {
1005 return -ENOMEM; 1005 return -ENOMEM;
1006 } 1006 }
1007 y = drm_alloc(ybuf_size, DRM_MEM_BUFS); 1007 y = kmalloc(ybuf_size, GFP_KERNEL);
1008 if (y == NULL) { 1008 if (y == NULL) {
1009 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1009 kfree(x);
1010 return -ENOMEM; 1010 return -ENOMEM;
1011 } 1011 }
1012 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { 1012 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
1013 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1013 kfree(x);
1014 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1014 kfree(y);
1015 return -EFAULT; 1015 return -EFAULT;
1016 } 1016 }
1017 if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) { 1017 if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) {
1018 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1018 kfree(x);
1019 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1019 kfree(y);
1020 return -EFAULT; 1020 return -EFAULT;
1021 } 1021 }
1022 1022
1023 buffer_size = depth->n * sizeof(u32); 1023 buffer_size = depth->n * sizeof(u32);
1024 buffer = drm_alloc(buffer_size, DRM_MEM_BUFS); 1024 buffer = kmalloc(buffer_size, GFP_KERNEL);
1025 if (buffer == NULL) { 1025 if (buffer == NULL) {
1026 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1026 kfree(x);
1027 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1027 kfree(y);
1028 return -ENOMEM; 1028 return -ENOMEM;
1029 } 1029 }
1030 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { 1030 if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
1031 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1031 kfree(x);
1032 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1032 kfree(y);
1033 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 1033 kfree(buffer);
1034 return -EFAULT; 1034 return -EFAULT;
1035 } 1035 }
1036 1036
1037 if (depth->mask) { 1037 if (depth->mask) {
1038 mask_size = depth->n * sizeof(u8); 1038 mask_size = depth->n * sizeof(u8);
1039 mask = drm_alloc(mask_size, DRM_MEM_BUFS); 1039 mask = kmalloc(mask_size, GFP_KERNEL);
1040 if (mask == NULL) { 1040 if (mask == NULL) {
1041 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1041 kfree(x);
1042 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1042 kfree(y);
1043 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 1043 kfree(buffer);
1044 return -ENOMEM; 1044 return -ENOMEM;
1045 } 1045 }
1046 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { 1046 if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
1047 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1047 kfree(x);
1048 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1048 kfree(y);
1049 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 1049 kfree(buffer);
1050 drm_free(mask, mask_size, DRM_MEM_BUFS); 1050 kfree(mask);
1051 return -EFAULT; 1051 return -EFAULT;
1052 } 1052 }
1053 1053
@@ -1074,7 +1074,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
1074 } 1074 }
1075 } 1075 }
1076 1076
1077 drm_free(mask, mask_size, DRM_MEM_BUFS); 1077 kfree(mask);
1078 } else { 1078 } else {
1079 for (i = 0; i < count; i++) { 1079 for (i = 0; i < count; i++) {
1080 BEGIN_RING(6); 1080 BEGIN_RING(6);
@@ -1098,9 +1098,9 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
1098 } 1098 }
1099 } 1099 }
1100 1100
1101 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1101 kfree(x);
1102 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1102 kfree(y);
1103 drm_free(buffer, buffer_size, DRM_MEM_BUFS); 1103 kfree(buffer);
1104 1104
1105 return 0; 1105 return 0;
1106} 1106}
@@ -1167,23 +1167,23 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
1167 1167
1168 xbuf_size = count * sizeof(*x); 1168 xbuf_size = count * sizeof(*x);
1169 ybuf_size = count * sizeof(*y); 1169 ybuf_size = count * sizeof(*y);
1170 x = drm_alloc(xbuf_size, DRM_MEM_BUFS); 1170 x = kmalloc(xbuf_size, GFP_KERNEL);
1171 if (x == NULL) { 1171 if (x == NULL) {
1172 return -ENOMEM; 1172 return -ENOMEM;
1173 } 1173 }
1174 y = drm_alloc(ybuf_size, DRM_MEM_BUFS); 1174 y = kmalloc(ybuf_size, GFP_KERNEL);
1175 if (y == NULL) { 1175 if (y == NULL) {
1176 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1176 kfree(x);
1177 return -ENOMEM; 1177 return -ENOMEM;
1178 } 1178 }
1179 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { 1179 if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
1180 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1180 kfree(x);
1181 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1181 kfree(y);
1182 return -EFAULT; 1182 return -EFAULT;
1183 } 1183 }
1184 if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) { 1184 if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) {
1185 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1185 kfree(x);
1186 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1186 kfree(y);
1187 return -EFAULT; 1187 return -EFAULT;
1188 } 1188 }
1189 1189
@@ -1210,8 +1210,8 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
1210 ADVANCE_RING(); 1210 ADVANCE_RING();
1211 } 1211 }
1212 1212
1213 drm_free(x, xbuf_size, DRM_MEM_BUFS); 1213 kfree(x);
1214 drm_free(y, ybuf_size, DRM_MEM_BUFS); 1214 kfree(y);
1215 1215
1216 return 0; 1216 return 0;
1217} 1217}
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 89c4c44169f7..d8356827ef17 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -2045,11 +2045,10 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
2045 drm_radeon_private_t *dev_priv; 2045 drm_radeon_private_t *dev_priv;
2046 int ret = 0; 2046 int ret = 0;
2047 2047
2048 dev_priv = drm_alloc(sizeof(drm_radeon_private_t), DRM_MEM_DRIVER); 2048 dev_priv = kzalloc(sizeof(drm_radeon_private_t), GFP_KERNEL);
2049 if (dev_priv == NULL) 2049 if (dev_priv == NULL)
2050 return -ENOMEM; 2050 return -ENOMEM;
2051 2051
2052 memset(dev_priv, 0, sizeof(drm_radeon_private_t));
2053 dev->dev_private = (void *)dev_priv; 2052 dev->dev_private = (void *)dev_priv;
2054 dev_priv->flags = flags; 2053 dev_priv->flags = flags;
2055 2054
@@ -2103,7 +2102,7 @@ int radeon_master_create(struct drm_device *dev, struct drm_master *master)
2103 unsigned long sareapage; 2102 unsigned long sareapage;
2104 int ret; 2103 int ret;
2105 2104
2106 master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); 2105 master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
2107 if (!master_priv) 2106 if (!master_priv)
2108 return -ENOMEM; 2107 return -ENOMEM;
2109 2108
@@ -2137,7 +2136,7 @@ void radeon_master_destroy(struct drm_device *dev, struct drm_master *master)
2137 if (master_priv->sarea) 2136 if (master_priv->sarea)
2138 drm_rmmap_locked(dev, master_priv->sarea); 2137 drm_rmmap_locked(dev, master_priv->sarea);
2139 2138
2140 drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); 2139 kfree(master_priv);
2141 2140
2142 master->driver_priv = NULL; 2141 master->driver_priv = NULL;
2143} 2142}
@@ -2171,7 +2170,7 @@ int radeon_driver_unload(struct drm_device *dev)
2171 2170
2172 drm_rmmap(dev, dev_priv->mmio); 2171 drm_rmmap(dev, dev_priv->mmio);
2173 2172
2174 drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); 2173 kfree(dev_priv);
2175 2174
2176 dev->dev_private = NULL; 2175 dev->dev_private = NULL;
2177 return 0; 2176 return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 71465ed2688a..dd438d32e5c0 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -162,7 +162,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
162 struct radeon_i2c_chan *i2c; 162 struct radeon_i2c_chan *i2c;
163 int ret; 163 int ret;
164 164
165 i2c = drm_calloc(1, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); 165 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL);
166 if (i2c == NULL) 166 if (i2c == NULL)
167 return NULL; 167 return NULL;
168 168
@@ -189,7 +189,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
189 189
190 return i2c; 190 return i2c;
191out_free: 191out_free:
192 drm_free(i2c, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); 192 kfree(i2c);
193 return NULL; 193 return NULL;
194 194
195} 195}
@@ -200,7 +200,7 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c)
200 return; 200 return;
201 201
202 i2c_del_adapter(&i2c->adapter); 202 i2c_del_adapter(&i2c->adapter);
203 drm_free(i2c, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); 203 kfree(i2c);
204} 204}
205 205
206struct drm_encoder *radeon_best_encoder(struct drm_connector *connector) 206struct drm_encoder *radeon_best_encoder(struct drm_connector *connector)
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 64f42b19cbfa..4612a7c146d1 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -169,7 +169,7 @@ int radeon_master_create_kms(struct drm_device *dev, struct drm_master *master)
169 unsigned long sareapage; 169 unsigned long sareapage;
170 int ret; 170 int ret;
171 171
172 master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); 172 master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
173 if (master_priv == NULL) { 173 if (master_priv == NULL) {
174 return -ENOMEM; 174 return -ENOMEM;
175 } 175 }
@@ -199,7 +199,7 @@ void radeon_master_destroy_kms(struct drm_device *dev,
199 if (master_priv->sarea) { 199 if (master_priv->sarea) {
200 drm_rmmap_locked(dev, master_priv->sarea); 200 drm_rmmap_locked(dev, master_priv->sarea);
201 } 201 }
202 drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); 202 kfree(master_priv);
203 master->driver_priv = NULL; 203 master->driver_priv = NULL;
204} 204}
205 205
diff --git a/drivers/gpu/drm/radeon/radeon_mem.c b/drivers/gpu/drm/radeon/radeon_mem.c
index 4af5286a36fb..ed95155c4b1d 100644
--- a/drivers/gpu/drm/radeon/radeon_mem.c
+++ b/drivers/gpu/drm/radeon/radeon_mem.c
@@ -43,8 +43,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
43{ 43{
44 /* Maybe cut off the start of an existing block */ 44 /* Maybe cut off the start of an existing block */
45 if (start > p->start) { 45 if (start > p->start) {
46 struct mem_block *newblock = 46 struct mem_block *newblock = kmalloc(sizeof(*newblock),
47 drm_alloc(sizeof(*newblock), DRM_MEM_BUFS); 47 GFP_KERNEL);
48 if (!newblock) 48 if (!newblock)
49 goto out; 49 goto out;
50 newblock->start = start; 50 newblock->start = start;
@@ -60,8 +60,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
60 60
61 /* Maybe cut off the end of an existing block */ 61 /* Maybe cut off the end of an existing block */
62 if (size < p->size) { 62 if (size < p->size) {
63 struct mem_block *newblock = 63 struct mem_block *newblock = kmalloc(sizeof(*newblock),
64 drm_alloc(sizeof(*newblock), DRM_MEM_BUFS); 64 GFP_KERNEL);
65 if (!newblock) 65 if (!newblock)
66 goto out; 66 goto out;
67 newblock->start = start + size; 67 newblock->start = start + size;
@@ -118,7 +118,7 @@ static void free_block(struct mem_block *p)
118 p->size += q->size; 118 p->size += q->size;
119 p->next = q->next; 119 p->next = q->next;
120 p->next->prev = p; 120 p->next->prev = p;
121 drm_free(q, sizeof(*q), DRM_MEM_BUFS); 121 kfree(q);
122 } 122 }
123 123
124 if (p->prev->file_priv == NULL) { 124 if (p->prev->file_priv == NULL) {
@@ -126,7 +126,7 @@ static void free_block(struct mem_block *p)
126 q->size += p->size; 126 q->size += p->size;
127 q->next = p->next; 127 q->next = p->next;
128 q->next->prev = q; 128 q->next->prev = q;
129 drm_free(p, sizeof(*q), DRM_MEM_BUFS); 129 kfree(p);
130 } 130 }
131} 131}
132 132
@@ -134,14 +134,14 @@ static void free_block(struct mem_block *p)
134 */ 134 */
135static int init_heap(struct mem_block **heap, int start, int size) 135static int init_heap(struct mem_block **heap, int start, int size)
136{ 136{
137 struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS); 137 struct mem_block *blocks = kmalloc(sizeof(*blocks), GFP_KERNEL);
138 138
139 if (!blocks) 139 if (!blocks)
140 return -ENOMEM; 140 return -ENOMEM;
141 141
142 *heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS); 142 *heap = kmalloc(sizeof(**heap), GFP_KERNEL);
143 if (!*heap) { 143 if (!*heap) {
144 drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFS); 144 kfree(blocks);
145 return -ENOMEM; 145 return -ENOMEM;
146 } 146 }
147 147
@@ -179,7 +179,7 @@ void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap)
179 p->size += q->size; 179 p->size += q->size;
180 p->next = q->next; 180 p->next = q->next;
181 p->next->prev = p; 181 p->next->prev = p;
182 drm_free(q, sizeof(*q), DRM_MEM_DRIVER); 182 kfree(q);
183 } 183 }
184 } 184 }
185} 185}
@@ -196,10 +196,10 @@ void radeon_mem_takedown(struct mem_block **heap)
196 for (p = (*heap)->next; p != *heap;) { 196 for (p = (*heap)->next; p != *heap;) {
197 struct mem_block *q = p; 197 struct mem_block *q = p;
198 p = p->next; 198 p = p->next;
199 drm_free(q, sizeof(*q), DRM_MEM_DRIVER); 199 kfree(q);
200 } 200 }
201 201
202 drm_free(*heap, sizeof(**heap), DRM_MEM_DRIVER); 202 kfree(*heap);
203 *heap = NULL; 203 *heap = NULL;
204} 204}
205 205
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index fa728ec6ed34..46645f3e0328 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -2866,12 +2866,12 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
2866 */ 2866 */
2867 orig_bufsz = cmdbuf->bufsz; 2867 orig_bufsz = cmdbuf->bufsz;
2868 if (orig_bufsz != 0) { 2868 if (orig_bufsz != 0) {
2869 kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER); 2869 kbuf = kmalloc(cmdbuf->bufsz, GFP_KERNEL);
2870 if (kbuf == NULL) 2870 if (kbuf == NULL)
2871 return -ENOMEM; 2871 return -ENOMEM;
2872 if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf, 2872 if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf,
2873 cmdbuf->bufsz)) { 2873 cmdbuf->bufsz)) {
2874 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); 2874 kfree(kbuf);
2875 return -EFAULT; 2875 return -EFAULT;
2876 } 2876 }
2877 cmdbuf->buf = kbuf; 2877 cmdbuf->buf = kbuf;
@@ -2884,7 +2884,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
2884 temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf); 2884 temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf);
2885 2885
2886 if (orig_bufsz != 0) 2886 if (orig_bufsz != 0)
2887 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); 2887 kfree(kbuf);
2888 2888
2889 return temp; 2889 return temp;
2890 } 2890 }
@@ -2991,7 +2991,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
2991 } 2991 }
2992 2992
2993 if (orig_bufsz != 0) 2993 if (orig_bufsz != 0)
2994 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); 2994 kfree(kbuf);
2995 2995
2996 DRM_DEBUG("DONE\n"); 2996 DRM_DEBUG("DONE\n");
2997 COMMIT_RING(); 2997 COMMIT_RING();
@@ -2999,7 +2999,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
2999 2999
3000 err: 3000 err:
3001 if (orig_bufsz != 0) 3001 if (orig_bufsz != 0)
3002 drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); 3002 kfree(kbuf);
3003 return -EINVAL; 3003 return -EINVAL;
3004} 3004}
3005 3005
@@ -3175,9 +3175,7 @@ int radeon_driver_open(struct drm_device *dev, struct drm_file *file_priv)
3175 struct drm_radeon_driver_file_fields *radeon_priv; 3175 struct drm_radeon_driver_file_fields *radeon_priv;
3176 3176
3177 DRM_DEBUG("\n"); 3177 DRM_DEBUG("\n");
3178 radeon_priv = 3178 radeon_priv = kmalloc(sizeof(*radeon_priv), GFP_KERNEL);
3179 (struct drm_radeon_driver_file_fields *)
3180 drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
3181 3179
3182 if (!radeon_priv) 3180 if (!radeon_priv)
3183 return -ENOMEM; 3181 return -ENOMEM;
@@ -3196,7 +3194,7 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
3196 struct drm_radeon_driver_file_fields *radeon_priv = 3194 struct drm_radeon_driver_file_fields *radeon_priv =
3197 file_priv->driver_priv; 3195 file_priv->driver_priv;
3198 3196
3199 drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); 3197 kfree(radeon_priv);
3200} 3198}
3201 3199
3202struct drm_ioctl_desc radeon_ioctls[] = { 3200struct drm_ioctl_desc radeon_ioctls[] = {
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c
index 456cd040f31a..bff6fc2524c8 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -298,8 +298,8 @@ static int savage_dma_init(drm_savage_private_t * dev_priv)
298 298
299 dev_priv->nr_dma_pages = dev_priv->cmd_dma->size / 299 dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
300 (SAVAGE_DMA_PAGE_SIZE * 4); 300 (SAVAGE_DMA_PAGE_SIZE * 4);
301 dev_priv->dma_pages = drm_alloc(sizeof(drm_savage_dma_page_t) * 301 dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
302 dev_priv->nr_dma_pages, DRM_MEM_DRIVER); 302 dev_priv->nr_dma_pages, GFP_KERNEL);
303 if (dev_priv->dma_pages == NULL) 303 if (dev_priv->dma_pages == NULL)
304 return -ENOMEM; 304 return -ENOMEM;
305 305
@@ -539,7 +539,7 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset)
539{ 539{
540 drm_savage_private_t *dev_priv; 540 drm_savage_private_t *dev_priv;
541 541
542 dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER); 542 dev_priv = kmalloc(sizeof(drm_savage_private_t), GFP_KERNEL);
543 if (dev_priv == NULL) 543 if (dev_priv == NULL)
544 return -ENOMEM; 544 return -ENOMEM;
545 545
@@ -671,7 +671,7 @@ int savage_driver_unload(struct drm_device *dev)
671{ 671{
672 drm_savage_private_t *dev_priv = dev->dev_private; 672 drm_savage_private_t *dev_priv = dev->dev_private;
673 673
674 drm_free(dev_priv, sizeof(drm_savage_private_t), DRM_MEM_DRIVER); 674 kfree(dev_priv);
675 675
676 return 0; 676 return 0;
677} 677}
@@ -804,8 +804,8 @@ static int savage_do_init_bci(struct drm_device * dev, drm_savage_init_t * init)
804 dev_priv->fake_dma.offset = 0; 804 dev_priv->fake_dma.offset = 0;
805 dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE; 805 dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE;
806 dev_priv->fake_dma.type = _DRM_SHM; 806 dev_priv->fake_dma.type = _DRM_SHM;
807 dev_priv->fake_dma.handle = drm_alloc(SAVAGE_FAKE_DMA_SIZE, 807 dev_priv->fake_dma.handle = kmalloc(SAVAGE_FAKE_DMA_SIZE,
808 DRM_MEM_DRIVER); 808 GFP_KERNEL);
809 if (!dev_priv->fake_dma.handle) { 809 if (!dev_priv->fake_dma.handle) {
810 DRM_ERROR("could not allocate faked DMA buffer!\n"); 810 DRM_ERROR("could not allocate faked DMA buffer!\n");
811 savage_do_cleanup_bci(dev); 811 savage_do_cleanup_bci(dev);
@@ -903,9 +903,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
903 drm_savage_private_t *dev_priv = dev->dev_private; 903 drm_savage_private_t *dev_priv = dev->dev_private;
904 904
905 if (dev_priv->cmd_dma == &dev_priv->fake_dma) { 905 if (dev_priv->cmd_dma == &dev_priv->fake_dma) {
906 if (dev_priv->fake_dma.handle) 906 kfree(dev_priv->fake_dma.handle);
907 drm_free(dev_priv->fake_dma.handle,
908 SAVAGE_FAKE_DMA_SIZE, DRM_MEM_DRIVER);
909 } else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle && 907 } else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle &&
910 dev_priv->cmd_dma->type == _DRM_AGP && 908 dev_priv->cmd_dma->type == _DRM_AGP &&
911 dev_priv->dma_type == SAVAGE_DMA_AGP) 909 dev_priv->dma_type == SAVAGE_DMA_AGP)
@@ -920,10 +918,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
920 dev->agp_buffer_map = NULL; 918 dev->agp_buffer_map = NULL;
921 } 919 }
922 920
923 if (dev_priv->dma_pages) 921 kfree(dev_priv->dma_pages);
924 drm_free(dev_priv->dma_pages,
925 sizeof(drm_savage_dma_page_t) * dev_priv->nr_dma_pages,
926 DRM_MEM_DRIVER);
927 922
928 return 0; 923 return 0;
929} 924}
diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index 5f6238fdf1fa..8a3e31599c94 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -988,20 +988,20 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
988 * for locking on FreeBSD. 988 * for locking on FreeBSD.
989 */ 989 */
990 if (cmdbuf->size) { 990 if (cmdbuf->size) {
991 kcmd_addr = drm_alloc(cmdbuf->size * 8, DRM_MEM_DRIVER); 991 kcmd_addr = kmalloc(cmdbuf->size * 8, GFP_KERNEL);
992 if (kcmd_addr == NULL) 992 if (kcmd_addr == NULL)
993 return -ENOMEM; 993 return -ENOMEM;
994 994
995 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, 995 if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr,
996 cmdbuf->size * 8)) 996 cmdbuf->size * 8))
997 { 997 {
998 drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); 998 kfree(kcmd_addr);
999 return -EFAULT; 999 return -EFAULT;
1000 } 1000 }
1001 cmdbuf->cmd_addr = kcmd_addr; 1001 cmdbuf->cmd_addr = kcmd_addr;
1002 } 1002 }
1003 if (cmdbuf->vb_size) { 1003 if (cmdbuf->vb_size) {
1004 kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER); 1004 kvb_addr = kmalloc(cmdbuf->vb_size, GFP_KERNEL);
1005 if (kvb_addr == NULL) { 1005 if (kvb_addr == NULL) {
1006 ret = -ENOMEM; 1006 ret = -ENOMEM;
1007 goto done; 1007 goto done;
@@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1015 cmdbuf->vb_addr = kvb_addr; 1015 cmdbuf->vb_addr = kvb_addr;
1016 } 1016 }
1017 if (cmdbuf->nbox) { 1017 if (cmdbuf->nbox) {
1018 kbox_addr = drm_alloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), 1018 kbox_addr = kmalloc(cmdbuf->nbox * sizeof(struct drm_clip_rect),
1019 DRM_MEM_DRIVER); 1019 GFP_KERNEL);
1020 if (kbox_addr == NULL) { 1020 if (kbox_addr == NULL) {
1021 ret = -ENOMEM; 1021 ret = -ENOMEM;
1022 goto done; 1022 goto done;
@@ -1154,10 +1154,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
1154 1154
1155done: 1155done:
1156 /* If we didn't need to allocate them, these'll be NULL */ 1156 /* If we didn't need to allocate them, these'll be NULL */
1157 drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); 1157 kfree(kcmd_addr);
1158 drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER); 1158 kfree(kvb_addr);
1159 drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect), 1159 kfree(kbox_addr);
1160 DRM_MEM_DRIVER);
1161 1160
1162 return ret; 1161 return ret;
1163} 1162}
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 7dacc64e9b56..e725cc0b1155 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -40,7 +40,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
40 drm_sis_private_t *dev_priv; 40 drm_sis_private_t *dev_priv;
41 int ret; 41 int ret;
42 42
43 dev_priv = drm_calloc(1, sizeof(drm_sis_private_t), DRM_MEM_DRIVER); 43 dev_priv = kzalloc(sizeof(drm_sis_private_t), GFP_KERNEL);
44 if (dev_priv == NULL) 44 if (dev_priv == NULL)
45 return -ENOMEM; 45 return -ENOMEM;
46 46
@@ -48,7 +48,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
48 dev_priv->chipset = chipset; 48 dev_priv->chipset = chipset;
49 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); 49 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
50 if (ret) { 50 if (ret) {
51 drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER); 51 kfree(dev_priv);
52 } 52 }
53 53
54 return ret; 54 return ret;
@@ -59,7 +59,7 @@ static int sis_driver_unload(struct drm_device *dev)
59 drm_sis_private_t *dev_priv = dev->dev_private; 59 drm_sis_private_t *dev_priv = dev->dev_private;
60 60
61 drm_sman_takedown(&dev_priv->sman); 61 drm_sman_takedown(&dev_priv->sman);
62 drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); 62 kfree(dev_priv);
63 63
64 return 0; 64 return 0;
65} 65}
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index 2c4f0b485792..6e6f91591639 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -96,7 +96,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
96 drm_via_private_t *dev_priv; 96 drm_via_private_t *dev_priv;
97 int ret = 0; 97 int ret = 0;
98 98
99 dev_priv = drm_calloc(1, sizeof(drm_via_private_t), DRM_MEM_DRIVER); 99 dev_priv = kzalloc(sizeof(drm_via_private_t), GFP_KERNEL);
100 if (dev_priv == NULL) 100 if (dev_priv == NULL)
101 return -ENOMEM; 101 return -ENOMEM;
102 102
@@ -106,14 +106,14 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
106 106
107 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); 107 ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
108 if (ret) { 108 if (ret) {
109 drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); 109 kfree(dev_priv);
110 return ret; 110 return ret;
111 } 111 }
112 112
113 ret = drm_vblank_init(dev, 1); 113 ret = drm_vblank_init(dev, 1);
114 if (ret) { 114 if (ret) {
115 drm_sman_takedown(&dev_priv->sman); 115 drm_sman_takedown(&dev_priv->sman);
116 drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); 116 kfree(dev_priv);
117 return ret; 117 return ret;
118 } 118 }
119 119
@@ -126,7 +126,7 @@ int via_driver_unload(struct drm_device *dev)
126 126
127 drm_sman_takedown(&dev_priv->sman); 127 drm_sman_takedown(&dev_priv->sman);
128 128
129 drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); 129 kfree(dev_priv);
130 130
131 return 0; 131 return 0;
132} 132}