Commit 9a298b2a authored by Eric Anholt's avatar Eric Anholt

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: default avatarEric Anholt <eric@anholt.net>
parent 52dc7d32
...@@ -203,7 +203,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) ...@@ -203,7 +203,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (!dev->agp || !dev->agp->acquired) if (!dev->agp || !dev->agp->acquired)
return -EINVAL; return -EINVAL;
if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) if (!(entry = kmalloc(sizeof(*entry), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
...@@ -211,7 +211,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) ...@@ -211,7 +211,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request->type; type = (u32) request->type;
if (!(memory = drm_alloc_agp(dev, pages, type))) { if (!(memory = drm_alloc_agp(dev, pages, type))) {
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); kfree(entry);
return -ENOMEM; return -ENOMEM;
} }
...@@ -369,7 +369,7 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) ...@@ -369,7 +369,7 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request)
list_del(&entry->head); list_del(&entry->head);
drm_free_agp(entry->memory, entry->pages); drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); kfree(entry);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_agp_free); EXPORT_SYMBOL(drm_agp_free);
...@@ -397,13 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev) ...@@ -397,13 +397,13 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
{ {
struct drm_agp_head *head = NULL; struct drm_agp_head *head = NULL;
if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) if (!(head = kmalloc(sizeof(*head), GFP_KERNEL)))
return NULL; return NULL;
memset((void *)head, 0, sizeof(*head)); memset((void *)head, 0, sizeof(*head));
head->bridge = agp_find_bridge(dev->pdev); head->bridge = agp_find_bridge(dev->pdev);
if (!head->bridge) { if (!head->bridge) {
if (!(head->bridge = agp_backend_acquire(dev->pdev))) { if (!(head->bridge = agp_backend_acquire(dev->pdev))) {
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); kfree(head);
return NULL; return NULL;
} }
agp_copy_info(head->bridge, &head->agp_info); agp_copy_info(head->bridge, &head->agp_info);
...@@ -412,7 +412,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev) ...@@ -412,7 +412,7 @@ struct drm_agp_head *drm_agp_init(struct drm_device *dev)
agp_copy_info(head->bridge, &head->agp_info); agp_copy_info(head->bridge, &head->agp_info);
} }
if (head->agp_info.chipset == NOT_SUPPORTED) { if (head->agp_info.chipset == NOT_SUPPORTED) {
drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); kfree(head);
return NULL; return NULL;
} }
INIT_LIST_HEAD(&head->memory); INIT_LIST_HEAD(&head->memory);
......
...@@ -79,7 +79,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv, ...@@ -79,7 +79,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
struct drm_device *dev = master->minor->dev; struct drm_device *dev = master->minor->dev;
DRM_DEBUG("%d\n", magic); DRM_DEBUG("%d\n", magic);
entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(*entry)); memset(entry, 0, sizeof(*entry));
...@@ -120,7 +120,7 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic) ...@@ -120,7 +120,7 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
list_del(&pt->head); list_del(&pt->head);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); kfree(pt);
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -341,7 +341,7 @@ int drm_addctx(struct drm_device *dev, void *data, ...@@ -341,7 +341,7 @@ int drm_addctx(struct drm_device *dev, void *data,
} }
} }
ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST); ctx_entry = kmalloc(sizeof(*ctx_entry), GFP_KERNEL);
if (!ctx_entry) { if (!ctx_entry) {
DRM_DEBUG("out of memory\n"); DRM_DEBUG("out of memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -456,7 +456,7 @@ int drm_rmctx(struct drm_device *dev, void *data, ...@@ -456,7 +456,7 @@ int drm_rmctx(struct drm_device *dev, void *data,
list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
if (pos->handle == ctx->handle) { if (pos->handle == ctx->handle) {
list_del(&pos->head); list_del(&pos->head);
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); kfree(pos);
--dev->ctx_count; --dev->ctx_count;
} }
} }
......
...@@ -100,15 +100,13 @@ int drm_debugfs_create_files(struct drm_info_list *files, int count, ...@@ -100,15 +100,13 @@ int drm_debugfs_create_files(struct drm_info_list *files, int count,
(dev->driver->driver_features & features) != features) (dev->driver->driver_features & features) != features)
continue; continue;
tmp = drm_alloc(sizeof(struct drm_info_node), tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
_DRM_DRIVER);
ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO, ent = debugfs_create_file(files[i].name, S_IFREG | S_IRUGO,
root, tmp, &drm_debugfs_fops); root, tmp, &drm_debugfs_fops);
if (!ent) { if (!ent) {
DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/%s\n", DRM_ERROR("Cannot create /sys/kernel/debug/dri/%s/%s\n",
name, files[i].name); name, files[i].name);
drm_free(tmp, sizeof(struct drm_info_node), kfree(tmp);
_DRM_DRIVER);
ret = -1; ret = -1;
goto fail; goto fail;
} }
...@@ -196,8 +194,7 @@ int drm_debugfs_remove_files(struct drm_info_list *files, int count, ...@@ -196,8 +194,7 @@ int drm_debugfs_remove_files(struct drm_info_list *files, int count,
if (tmp->info_ent == &files[i]) { if (tmp->info_ent == &files[i]) {
debugfs_remove(tmp->dent); debugfs_remove(tmp->dent);
list_del(pos); list_del(pos);
drm_free(tmp, sizeof(struct drm_info_node), kfree(tmp);
_DRM_DRIVER);
} }
} }
} }
......
...@@ -47,7 +47,7 @@ int drm_dma_setup(struct drm_device *dev) ...@@ -47,7 +47,7 @@ int drm_dma_setup(struct drm_device *dev)
{ {
int i; int i;
dev->dma = drm_alloc(sizeof(*dev->dma), DRM_MEM_DRIVER); dev->dma = kmalloc(sizeof(*dev->dma), GFP_KERNEL);
if (!dev->dma) if (!dev->dma)
return -ENOMEM; return -ENOMEM;
...@@ -88,36 +88,19 @@ void drm_dma_takedown(struct drm_device *dev) ...@@ -88,36 +88,19 @@ void drm_dma_takedown(struct drm_device *dev)
drm_pci_free(dev, dma->bufs[i].seglist[j]); drm_pci_free(dev, dma->bufs[i].seglist[j]);
} }
} }
drm_free(dma->bufs[i].seglist, kfree(dma->bufs[i].seglist);
dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS);
} }
if (dma->bufs[i].buf_count) { if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) { for (j = 0; j < dma->bufs[i].buf_count; j++) {
if (dma->bufs[i].buflist[j].dev_private) { kfree(dma->bufs[i].buflist[j].dev_private);
drm_free(dma->bufs[i].buflist[j].
dev_private,
dma->bufs[i].buflist[j].
dev_priv_size, DRM_MEM_BUFS);
}
} }
drm_free(dma->bufs[i].buflist, kfree(dma->bufs[i].buflist);
dma->bufs[i].buf_count *
sizeof(*dma->bufs[0].buflist), DRM_MEM_BUFS);
} }
} }
if (dma->buflist) { kfree(dma->buflist);
drm_free(dma->buflist, kfree(dma->pagelist);
dma->buf_count * sizeof(*dma->buflist), DRM_MEM_BUFS); kfree(dev->dma);
}
if (dma->pagelist) {
drm_free(dma->pagelist,
dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES);
}
drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
dev->dma = NULL; dev->dma = NULL;
} }
......
...@@ -85,9 +85,8 @@ int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv) ...@@ -85,9 +85,8 @@ int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
spin_unlock_irqrestore(&dev->drw_lock, irqflags); spin_unlock_irqrestore(&dev->drw_lock, irqflags);
return -EINVAL; return -EINVAL;
} }
drm_free(info->rects, info->num_rects * sizeof(struct drm_clip_rect), kfree(info->rects);
DRM_MEM_BUFS); kfree(info);
drm_free(info, sizeof(struct drm_drawable_info), DRM_MEM_BUFS);
idr_remove(&dev->drw_idr, draw->handle); idr_remove(&dev->drw_idr, draw->handle);
...@@ -106,12 +105,12 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file ...@@ -106,12 +105,12 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
info = idr_find(&dev->drw_idr, update->handle); info = idr_find(&dev->drw_idr, update->handle);
if (!info) { if (!info) {
info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) { if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) {
DRM_ERROR("No such drawable %d\n", update->handle); DRM_ERROR("No such drawable %d\n", update->handle);
drm_free(info, sizeof(*info), DRM_MEM_BUFS); kfree(info);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -121,8 +120,9 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file ...@@ -121,8 +120,9 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
if (update->num == 0) if (update->num == 0)
rects = NULL; rects = NULL;
else if (update->num != info->num_rects) { else if (update->num != info->num_rects) {
rects = drm_alloc(update->num * sizeof(struct drm_clip_rect), rects = kmalloc(update->num *
DRM_MEM_BUFS); sizeof(struct drm_clip_rect),
GFP_KERNEL);
} else } else
rects = info->rects; rects = info->rects;
...@@ -145,8 +145,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file ...@@ -145,8 +145,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
spin_lock_irqsave(&dev->drw_lock, irqflags); spin_lock_irqsave(&dev->drw_lock, irqflags);
if (rects != info->rects) { if (rects != info->rects) {
drm_free(info->rects, info->num_rects * kfree(info->rects);
sizeof(struct drm_clip_rect), DRM_MEM_BUFS);
} }
info->rects = rects; info->rects = rects;
...@@ -166,8 +165,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file ...@@ -166,8 +165,7 @@ int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file
error: error:
if (rects != info->rects) if (rects != info->rects)
drm_free(rects, update->num * sizeof(struct drm_clip_rect), kfree(rects);
DRM_MEM_BUFS);
return err; return err;
} }
...@@ -186,9 +184,8 @@ static int drm_drawable_free(int idr, void *p, void *data) ...@@ -186,9 +184,8 @@ static int drm_drawable_free(int idr, void *p, void *data)
struct drm_drawable_info *info = p; struct drm_drawable_info *info = p;
if (info) { if (info) {
drm_free(info->rects, info->num_rects * kfree(info->rects);
sizeof(struct drm_clip_rect), DRM_MEM_BUFS); kfree(info);
drm_free(info, sizeof(*info), DRM_MEM_BUFS);
} }
return 0; return 0;
......
...@@ -189,7 +189,7 @@ int drm_lastclose(struct drm_device * dev) ...@@ -189,7 +189,7 @@ int drm_lastclose(struct drm_device * dev)
if (entry->bound) if (entry->bound)
drm_unbind_agp(entry->memory); drm_unbind_agp(entry->memory);
drm_free_agp(entry->memory, entry->pages); drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); kfree(entry);
} }
INIT_LIST_HEAD(&dev->agp->memory); INIT_LIST_HEAD(&dev->agp->memory);
...@@ -208,21 +208,15 @@ int drm_lastclose(struct drm_device * dev) ...@@ -208,21 +208,15 @@ int drm_lastclose(struct drm_device * dev)
/* Clear vma list (only built for debugging) */ /* Clear vma list (only built for debugging) */
list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
list_del(&vma->head); list_del(&vma->head);
drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); kfree(vma);
} }
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
for (i = 0; i < dev->queue_count; i++) { for (i = 0; i < dev->queue_count; i++) {
if (dev->queuelist[i]) { kfree(dev->queuelist[i]);
drm_free(dev->queuelist[i], dev->queuelist[i] = NULL;
sizeof(*dev->queuelist[0]),
DRM_MEM_QUEUES);
dev->queuelist[i] = NULL;
}
} }
drm_free(dev->queuelist, kfree(dev->queuelist);
dev->queue_slots * sizeof(*dev->queuelist),
DRM_MEM_QUEUES);
dev->queuelist = NULL; dev->queuelist = NULL;
} }
dev->queue_count = 0; dev->queue_count = 0;
...@@ -344,8 +338,6 @@ static int __init drm_core_init(void) ...@@ -344,8 +338,6 @@ static int __init drm_core_init(void)
goto err_p3; goto err_p3;
} }
drm_mem_init();
DRM_INFO("Initialized %s %d.%d.%d %s\n", DRM_INFO("Initialized %s %d.%d.%d %s\n",
CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
return 0; return 0;
......
...@@ -240,7 +240,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, ...@@ -240,7 +240,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id); DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id);
priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); priv = kmalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
...@@ -328,7 +328,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, ...@@ -328,7 +328,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
return 0; return 0;
out_free: out_free:
drm_free(priv, sizeof(*priv), DRM_MEM_FILES); kfree(priv);
filp->private_data = NULL; filp->private_data = NULL;
return ret; return ret;
} }
...@@ -471,7 +471,7 @@ int drm_release(struct inode *inode, struct file *filp) ...@@ -471,7 +471,7 @@ int drm_release(struct inode *inode, struct file *filp)
drm_ctxbitmap_free(dev, pos->handle); drm_ctxbitmap_free(dev, pos->handle);
list_del(&pos->head); list_del(&pos->head);
drm_free(pos, sizeof(*pos), DRM_MEM_CTXLIST); kfree(pos);
--dev->ctx_count; --dev->ctx_count;
} }
} }
...@@ -516,7 +516,7 @@ int drm_release(struct inode *inode, struct file *filp) ...@@ -516,7 +516,7 @@ int drm_release(struct inode *inode, struct file *filp)
if (dev->driver->postclose) if (dev->driver->postclose)
dev->driver->postclose(dev, file_priv); dev->driver->postclose(dev, file_priv);
drm_free(file_priv, sizeof(*file_priv), DRM_MEM_FILES); kfree(file_priv);
/* ======================================================== /* ========================================================
* End inline drm_release * End inline drm_release
......
...@@ -89,7 +89,7 @@ drm_gem_init(struct drm_device *dev) ...@@ -89,7 +89,7 @@ drm_gem_init(struct drm_device *dev)
atomic_set(&dev->gtt_count, 0); atomic_set(&dev->gtt_count, 0);
atomic_set(&dev->gtt_memory, 0); atomic_set(&dev->gtt_memory, 0);
mm = drm_calloc(1, sizeof(struct drm_gem_mm), DRM_MEM_MM); mm = kzalloc(sizeof(struct drm_gem_mm), GFP_KERNEL);
if (!mm) { if (!mm) {
DRM_ERROR("out of memory\n"); DRM_ERROR("out of memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -98,14 +98,14 @@ drm_gem_init(struct drm_device *dev) ...@@ -98,14 +98,14 @@ drm_gem_init(struct drm_device *dev)
dev->mm_private = mm; dev->mm_private = mm;
if (drm_ht_create(&mm->offset_hash, 19)) { if (drm_ht_create(&mm->offset_hash, 19)) {
drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); kfree(mm);
return -ENOMEM; return -ENOMEM;
} }
if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START, if (drm_mm_init(&mm->offset_manager, DRM_FILE_PAGE_OFFSET_START,
DRM_FILE_PAGE_OFFSET_SIZE)) { DRM_FILE_PAGE_OFFSET_SIZE)) {
drm_ht_remove(&mm->offset_hash); drm_ht_remove(&mm->offset_hash);
drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); kfree(mm);
return -ENOMEM; return -ENOMEM;
} }
...@@ -119,7 +119,7 @@ drm_gem_destroy(struct drm_device *dev) ...@@ -119,7 +119,7 @@ drm_gem_destroy(struct drm_device *dev)
drm_mm_takedown(&mm->offset_manager); drm_mm_takedown(&mm->offset_manager);
drm_ht_remove(&mm->offset_hash); drm_ht_remove(&mm->offset_hash);
drm_free(mm, sizeof(struct drm_gem_mm), DRM_MEM_MM); kfree(mm);
dev->mm_private = NULL; dev->mm_private = NULL;
} }
......
...@@ -46,8 +46,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order) ...@@ -46,8 +46,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
ht->table = NULL; ht->table = NULL;
ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE);
if (!ht->use_vmalloc) { if (!ht->use_vmalloc) {
ht->table = drm_calloc(ht->size, sizeof(*ht->table), ht->table = kcalloc(ht->size, sizeof(*ht->table), GFP_KERNEL);
DRM_MEM_HASHTAB);
} }
if (!ht->table) { if (!ht->table) {
ht->use_vmalloc = 1; ht->use_vmalloc = 1;
...@@ -200,8 +199,7 @@ void drm_ht_remove(struct drm_open_hash *ht) ...@@ -200,8 +199,7 @@ void drm_ht_remove(struct drm_open_hash *ht)
if (ht->use_vmalloc) if (ht->use_vmalloc)
vfree(ht->table); vfree(ht->table);
else else
drm_free(ht->table, ht->size * sizeof(*ht->table), kfree(ht->table);
DRM_MEM_HASHTAB);
ht->table = NULL; ht->table = NULL;
} }
} }
......
...@@ -93,7 +93,7 @@ int drm_setunique(struct drm_device *dev, void *data, ...@@ -93,7 +93,7 @@ int drm_setunique(struct drm_device *dev, void *data,
master->unique_len = u->unique_len; master->unique_len = u->unique_len;
master->unique_size = u->unique_len + 1; master->unique_size = u->unique_len + 1;
master->unique = drm_alloc(master->unique_size, DRM_MEM_DRIVER); master->unique = kmalloc(master->unique_size, GFP_KERNEL);
if (!master->unique) if (!master->unique)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(master->unique, u->unique, master->unique_len)) 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,9 +101,8 @@ int drm_setunique(struct drm_device *dev, void *data,
master->unique[master->unique_len] = '\0'; master->unique[master->unique_len] = '\0';
dev->devname = dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
drm_alloc(strlen(dev->driver->pci_driver.name) + strlen(master->unique) + 2, GFP_KERNEL);
strlen(master->unique) + 2, DRM_MEM_DRIVER);
if (!dev->devname) if (!dev->devname)
return -ENOMEM; return -ENOMEM;
...@@ -138,7 +137,7 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) ...@@ -138,7 +137,7 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
master->unique_len = 40; master->unique_len = 40;
master->unique_size = master->unique_len; master->unique_size = master->unique_len;
master->unique = drm_alloc(master->unique_size, DRM_MEM_DRIVER); master->unique = kmalloc(master->unique_size, GFP_KERNEL);
if (master->unique == NULL) if (master->unique == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -152,9 +151,8 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) ...@@ -152,9 +151,8 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
else else
master->unique_len = len; master->unique_len = len;
dev->devname = dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
drm_alloc(strlen(dev->driver->pci_driver.name) + master->unique_len + master->unique_len + 2, GFP_KERNEL);
2, DRM_MEM_DRIVER);
if (dev->devname == NULL) if (dev->devname == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -104,21 +104,13 @@ void drm_vblank_cleanup(struct drm_device *dev) ...@@ -104,21 +104,13 @@ void drm_vblank_cleanup(struct drm_device *dev)
vblank_disable_fn((unsigned long)dev); vblank_disable_fn((unsigned long)dev);
drm_free(dev->vbl_queue, sizeof(*dev->vbl_queue) * dev->num_crtcs, kfree(dev->vbl_queue);
DRM_MEM_DRIVER); kfree(dev->_vblank_count);
drm_free(dev->_vblank_count, sizeof(*dev->_vblank_count) * kfree(dev->vblank_refcount);
dev->num_crtcs, DRM_MEM_DRIVER); kfree(dev->vblank_enabled);
drm_free(dev->vblank_refcount, sizeof(*dev->vblank_refcount) * kfree(dev->last_vblank);
dev->num_crtcs, DRM_MEM_DRIVER); kfree(dev->last_vblank_wait);
drm_free(dev->vblank_enabled, sizeof(*dev->vblank_enabled) * kfree(dev->vblank_inmodeset);
dev->num_crtcs, DRM_MEM_DRIVER);
drm_free(dev->last_vblank, sizeof(*dev->last_vblank) * dev->num_crtcs,
DRM_MEM_DRIVER);
drm_free(dev->last_vblank_wait,
sizeof(*dev->last_vblank_wait) * dev->num_crtcs,
DRM_MEM_DRIVER);
drm_free(dev->vblank_inmodeset, sizeof(*dev->vblank_inmodeset) *
dev->num_crtcs, DRM_MEM_DRIVER);
dev->num_crtcs = 0; dev->num_crtcs = 0;
} }
...@@ -132,37 +124,33 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs) ...@@ -132,37 +124,33 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
spin_lock_init(&dev->vbl_lock); spin_lock_init(&dev->vbl_lock);
dev->num_crtcs = num_crtcs; dev->num_crtcs = num_crtcs;
dev->vbl_queue = drm_alloc(sizeof(wait_queue_head_t) * num_crtcs, dev->vbl_queue = kmalloc(sizeof(wait_queue_head_t) * num_crtcs,
DRM_MEM_DRIVER); GFP_KERNEL);
if (!dev->vbl_queue) if (!dev->vbl_queue)
goto err; goto err;
dev->_vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs, dev->_vblank_count = kmalloc(sizeof(atomic_t) * num_crtcs, GFP_KERNEL);
DRM_MEM_DRIVER);
if (!dev->_vblank_count) if (!dev->_vblank_count)
goto err; goto err;
dev->vblank_refcount = drm_alloc(sizeof(atomic_t) * num_crtcs, dev->vblank_refcount = kmalloc(sizeof(atomic_t) * num_crtcs,
DRM_MEM_DRIVER); GFP_KERNEL);
if (!dev->vblank_refcount) if (!dev->vblank_refcount)
goto err; goto err;
dev->vblank_enabled = drm_calloc(num_crtcs, sizeof(int), dev->vblank_enabled = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
DRM_MEM_DRIVER);
if (!dev->vblank_enabled) if (!dev->vblank_enabled)
goto err; goto err;
dev->last_vblank = drm_calloc(num_crtcs, sizeof(u32), DRM_MEM_DRIVER); dev->last_vblank = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
if (!dev->last_vblank) if (!dev->last_vblank)
goto err; goto err;
dev->last_vblank_wait = drm_calloc(num_crtcs, sizeof(u32), dev->last_vblank_wait = kcalloc(num_crtcs, sizeof(u32), GFP_KERNEL);
DRM_MEM_DRIVER);
if (!dev->last_vblank_wait) if (!dev->last_vblank_wait)
goto err; goto err;
dev->vblank_inmodeset = drm_calloc(num_crtcs, sizeof(int), dev->vblank_inmodeset = kcalloc(num_crtcs, sizeof(int), GFP_KERNEL);
DRM_MEM_DRIVER);
if (!dev->vblank_inmodeset) if (!dev->vblank_inmodeset)
goto err; goto err;
......
...@@ -36,15 +36,6 @@ ...@@ -36,15 +36,6 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include "drmP.h" #include "drmP.h"
#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
/** No-op. */
void drm_mem_init(void)
{
}
/** /**
* Called when "/proc/dri/%dev%/mem" is read. * Called when "/proc/dri/%dev%/mem" is read.
* *
...@@ -64,20 +55,6 @@ int drm_mem_info(char *buf, char **start, off_t offset, ...@@ -64,20 +55,6 @@ int drm_mem_info(char *buf, char **start, off_t offset,
return 0; return 0;
} }
/** Wrapper around kmalloc() and kfree() */
void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
if (!(pt = kmalloc(size, GFP_KERNEL)))
return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
kfree(oldpt);
}
return pt;
}
#if __OS_HAS_AGP #if __OS_HAS_AGP
static void *agp_remap(unsigned long offset, unsigned long size, static void *agp_remap(unsigned long offset, unsigned long size,
struct drm_device * dev) struct drm_device * dev)
...@@ -157,8 +134,6 @@ static inline void *agp_remap(unsigned long offset, unsigned long size, ...@@ -157,8 +134,6 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
#endif /* agp */ #endif /* agp */
#endif /* debug_memory */
void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
{ {
if (drm_core_has_AGP(dev) && if (drm_core_has_AGP(dev) &&
......
...@@ -55,17 +55,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali ...@@ -55,17 +55,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
unsigned long addr; unsigned long addr;
size_t sz; size_t sz;
#endif #endif
#ifdef DRM_DEBUG_MEMORY
int area = DRM_MEM_DMA;
spin_lock(&drm_mem_lock);
if ((drm_ram_used >> PAGE_SHIFT)
> (DRM_RAM_PERCENT * drm_ram_available) / 100) {
spin_unlock(&drm_mem_lock);
return 0;
}
spin_unlock(&drm_mem_lock);
#endif
/* pci_alloc_consistent only guarantees alignment to the smallest /* pci_alloc_consistent only guarantees alignment to the smallest
* PAGE_SIZE order which is greater than or equal to the requested size. * 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,26 +75,10 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
dmah->size = size; dmah->size = size;
dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP); dmah->vaddr = dma_alloc_coherent(&dev->pdev->dev, size, &dmah->busaddr, GFP_KERNEL | __GFP_COMP);
#ifdef DRM_DEBUG_MEMORY
if (dmah->vaddr == NULL) {
spin_lock(&drm_mem_lock);
++drm_mem_stats[area].fail_count;
spin_unlock(&drm_mem_lock);
kfree(dmah);
return NULL;
}
spin_lock(&drm_mem_lock);
++drm_mem_stats[area].succeed_count;
drm_mem_stats[area].bytes_allocated += size;
drm_ram_used += size;
spin_unlock(&drm_mem_lock);
#else
if (dmah->vaddr == NULL) { if (dmah->vaddr == NULL) {
kfree(dmah); kfree(dmah);
return NULL; return NULL;
} }
#endif
memset(dmah->vaddr, 0, size); memset(dmah->vaddr, 0, size);
...@@ -132,17 +105,8 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) ...@@ -132,17 +105,8 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
unsigned long addr; unsigned long addr;
size_t sz; size_t sz;
#endif #endif
#ifdef DRM_DEBUG_MEMORY
int area = DRM_MEM_DMA;
int alloc_count;
int free_count;
#endif
if (!dmah->vaddr) { if (dmah->vaddr) {
#ifdef DRM_DEBUG_MEMORY
DRM_MEM_ERROR(area, "Attempt to free address 0\n");
#endif
} else {
/* XXX - Is virt_to_page() legal for consistent mem? */ /* XXX - Is virt_to_page() legal for consistent mem? */
/* Unreserve */ /* Unreserve */
for (addr = (unsigned long)dmah->vaddr, sz = dmah->size; 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,21 +116,6 @@ void __drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr, dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
dmah->busaddr); dmah->busaddr);
} }
#ifdef DRM_DEBUG_MEMORY
spin_lock(&drm_mem_lock);
free_count = ++drm_mem_stats[area].free_count;
alloc_count = drm_mem_stats[area].succeed_count;
drm_mem_stats[area].bytes_freed += size;
drm_ram_used -= size;
spin_unlock(&drm_mem_lock);
if (free_count > alloc_count) {
DRM_MEM_ERROR(area,
"Excess frees: %d frees, %d allocs\n",
free_count, alloc_count);
}
#endif
} }
/** /**
......
...@@ -105,13 +105,12 @@ int drm_proc_create_files(struct drm_info_list *files, int count, ...@@ -105,13 +105,12 @@ int drm_proc_create_files(struct drm_info_list *files, int count,
(dev->driver->driver_features & features) != features) (dev->driver->driver_features & features) != features)
continue; continue;
tmp = drm_alloc(sizeof(struct drm_info_node), _DRM_DRIVER); tmp = kmalloc(sizeof(struct drm_info_node), GFP_KERNEL);
ent = create_proc_entry(files[i].name, S_IFREG | S_IRUGO, root); ent = create_proc_entry(files[i].name, S_IFREG | S_IRUGO, root);
if (!ent) { if (!ent) {
DRM_ERROR("Cannot create /proc/dri/%s/%s\n", DRM_ERROR("Cannot create /proc/dri/%s/%s\n",
name, files[i].name); name, files[i].name);
drm_free(tmp, sizeof(struct drm_info_node), kfree(tmp);
_DRM_DRIVER);
ret = -1; ret = -1;
goto fail; goto fail;
} }
...@@ -192,8 +191,7 @@ int drm_proc_remove_files(struct drm_info_list *files, int count, ...@@ -192,8 +191,7 @@ int drm_proc_remove_files(struct drm_info_list *files, int count,
remove_proc_entry(files[i].name, remove_proc_entry(files[i].name,
minor->proc_root); minor->proc_root);
list_del(pos); list_del(pos);
drm_free(tmp, sizeof(struct drm_info_node), kfree(tmp);
_DRM_DRIVER);
} }
} }
} }
......
...@@ -58,11 +58,9 @@ void drm_sg_cleanup(struct drm_sg_mem * entry) ...@@ -58,11 +58,9 @@ void drm_sg_cleanup(struct drm_sg_mem * entry)
vfree(entry->virtual); vfree(entry->virtual);
drm_free(entry->busaddr, kfree(entry->busaddr);
entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); kfree(entry->pagelist);
drm_free(entry->pagelist, kfree(entry);
entry->pages * sizeof(*entry->pagelist), DRM_MEM_PAGES);
drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
} }
#ifdef _LP64 #ifdef _LP64
...@@ -84,7 +82,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request) ...@@ -84,7 +82,7 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
if (dev->sg) if (dev->sg)
return -EINVAL; return -EINVAL;
entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
...@@ -93,34 +91,27 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request) ...@@ -93,34 +91,27 @@ int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request)
DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages); DRM_DEBUG("size=%ld pages=%ld\n", request->size, pages);
entry->pages = pages; entry->pages = pages;
entry->pagelist = drm_alloc(pages * sizeof(*entry->pagelist), entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);
DRM_MEM_PAGES);
if (!entry->pagelist) { if (!entry->pagelist) {
drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS); kfree(entry);
return -ENOMEM; return -ENOMEM;
} }
memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist)); memset(entry->pagelist, 0, pages * sizeof(*entry->pagelist));
entry->busaddr = drm_alloc(pages * sizeof(*entry->busaddr), entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);
DRM_MEM_PAGES);
if (!entry->busaddr) { if (!entry->busaddr) {
drm_free(entry->pagelist, kfree(entry->pagelist);
entry->pages * sizeof(*entry->pagelist), kfree(entry);
DRM_MEM_PAGES);
drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
return -ENOMEM; return -ENOMEM;
} }
memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr)); memset((void *)entry->busaddr, 0, pages * sizeof(*entry->busaddr));
entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT); entry->virtual = drm_vmalloc_dma(pages << PAGE_SHIFT);
if (!entry->virtual) { if (!entry->virtual) {
drm_free(entry->busaddr, kfree(entry->busaddr);
entry->pages * sizeof(*entry->busaddr), DRM_MEM_PAGES); kfree(entry->pagelist);
drm_free(entry->pagelist, kfree(entry);
entry->pages * sizeof(*entry->pagelist),
DRM_MEM_PAGES);
drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -48,9 +48,7 @@ void drm_sman_takedown(struct drm_sman * sman) ...@@ -48,9 +48,7 @@ void drm_sman_takedown(struct drm_sman * sman)
{ {
drm_ht_remove(&sman->user_hash_tab); drm_ht_remove(&sman->user_hash_tab);
drm_ht_remove(&sman->owner_hash_tab); drm_ht_remove(&sman->owner_hash_tab);
if (sman->mm) kfree(sman->mm);
drm_free(sman->mm, sman->num_managers * sizeof(*sman->mm),
DRM_MEM_MM);
} }
EXPORT_SYMBOL(drm_sman_takedown); EXPORT_SYMBOL(drm_sman_takedown);
...@@ -61,8 +59,9 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, ...@@ -61,8 +59,9 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
{ {
int ret = 0; int ret = 0;
sman->mm = (struct drm_sman_mm *) drm_calloc(num_managers, sizeof(*sman->mm), sman->mm = (struct drm_sman_mm *) kcalloc(num_managers,
DRM_MEM_MM); sizeof(*sman->mm),
GFP_KERNEL);
if (!sman->mm) { if (!sman->mm) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
...@@ -78,7 +77,7 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers, ...@@ -78,7 +77,7 @@ drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
drm_ht_remove(&sman->owner_hash_tab); drm_ht_remove(&sman->owner_hash_tab);
out1: out1:
drm_free(sman->mm, num_managers * sizeof(*sman->mm), DRM_MEM_MM); kfree(sman->mm);
out: out:
return ret; return ret;
} }
...@@ -110,7 +109,7 @@ static void drm_sman_mm_destroy(void *private) ...@@ -110,7 +109,7 @@ static void drm_sman_mm_destroy(void *private)
{ {
struct drm_mm *mm = (struct drm_mm *) private; struct drm_mm *mm = (struct drm_mm *) private;
drm_mm_takedown(mm); drm_mm_takedown(mm);
drm_free(mm, sizeof(*mm), DRM_MEM_MM); kfree(mm);
} }
static unsigned long drm_sman_mm_offset(void *private, void *ref) static 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,7 +129,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
BUG_ON(manager >= sman->num_managers); BUG_ON(manager >= sman->num_managers);
sman_mm = &sman->mm[manager]; sman_mm = &sman->mm[manager];
mm = drm_calloc(1, sizeof(*mm), DRM_MEM_MM); mm = kzalloc(sizeof(*mm), GFP_KERNEL);
if (!mm) { if (!mm) {
return -ENOMEM; return -ENOMEM;
} }
...@@ -138,7 +137,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager, ...@@ -138,7 +137,7 @@ drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
ret = drm_mm_init(mm, start, size); ret = drm_mm_init(mm, start, size);
if (ret) { if (ret) {
drm_free(mm, sizeof(*mm), DRM_MEM_MM); kfree(mm);
return ret; return ret;
} }
...@@ -176,7 +175,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman, ...@@ -176,7 +175,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
owner_hash); owner_hash);
} }
owner_item = drm_calloc(1, sizeof(*owner_item), DRM_MEM_MM); owner_item = kzalloc(sizeof(*owner_item), GFP_KERNEL);
if (!owner_item) if (!owner_item)
goto out; goto out;
...@@ -189,7 +188,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman, ...@@ -189,7 +188,7 @@ static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
return owner_item; return owner_item;
out1: out1:
drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); kfree(owner_item);
out: out:
return NULL; return NULL;
} }
...@@ -212,7 +211,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man ...@@ -212,7 +211,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man
return NULL; return NULL;
} }
memblock = drm_calloc(1, sizeof(*memblock), DRM_MEM_MM); memblock = kzalloc(sizeof(*memblock), GFP_KERNEL);
if (!memblock) if (!memblock)
goto out; goto out;
...@@ -237,7 +236,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man ...@@ -237,7 +236,7 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int man
out2: out2:
drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash); drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash);
out1: out1:
drm_free(memblock, sizeof(*memblock), DRM_MEM_MM); kfree(memblock);
out: out:
sman_mm->free(sman_mm->private, tmp); sman_mm->free(sman_mm->private, tmp);
...@@ -253,7 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item) ...@@ -253,7 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item)
list_del(&item->owner_list); list_del(&item->owner_list);
drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash); drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash);
item->mm->free(item->mm->private, item->mm_info); item->mm->free(item->mm->private, item->mm_info);
drm_free(item, sizeof(*item), DRM_MEM_MM); kfree(item);
} }
int drm_sman_free_key(struct drm_sman *sman, unsigned int key) int 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,7 +276,7 @@ static void drm_sman_remove_owner(struct drm_sman *sman,
{ {
list_del(&owner_item->sman_list); list_del(&owner_item->sman_list);
drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash); drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash);
drm_free(owner_item, sizeof(*owner_item), DRM_MEM_MM); kfree(owner_item);
} }
int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner) int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner)
......
...@@ -107,7 +107,7 @@ struct drm_master *drm_master_create(struct drm_minor *minor) ...@@ -107,7 +107,7 @@ struct drm_master *drm_master_create(struct drm_minor *minor)
{ {
struct drm_master *master; struct drm_master *master;
master = drm_calloc(1, sizeof(*master), DRM_MEM_DRIVER); master = kzalloc(sizeof(*master), GFP_KERNEL);
if (!master) if (!master)
return NULL; return NULL;
...@@ -149,7 +149,7 @@ static void drm_master_destroy(struct kref *kref) ...@@ -149,7 +149,7 @@ static void drm_master_destroy(struct kref *kref)
} }
if (master->unique) { if (master->unique) {
drm_free(master->unique, master->unique_size, DRM_MEM_DRIVER); kfree(master->unique);
master->unique = NULL; master->unique = NULL;
master->unique_len = 0; master->unique_len = 0;
} }
...@@ -157,12 +157,12 @@ static void drm_master_destroy(struct kref *kref) ...@@ -157,12 +157,12 @@ static void drm_master_destroy(struct kref *kref)
list_for_each_entry_safe(pt, next, &master->magicfree, head) { list_for_each_entry_safe(pt, next, &master->magicfree, head) {
list_del(&pt->head); list_del(&pt->head);
drm_ht_remove_item(&master->magiclist, &pt->hash_item); drm_ht_remove_item(&master->magiclist, &pt->hash_item);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); kfree(pt);
} }
drm_ht_remove(&master->magiclist); drm_ht_remove(&master->magiclist);
drm_free(master, sizeof(*master), DRM_MEM_DRIVER); kfree(master);
} }
void drm_master_put(struct drm_master **master) void 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,7 +390,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
DRM_DEBUG("\n"); DRM_DEBUG("\n");
dev = drm_calloc(1, sizeof(*dev), DRM_MEM_STUB); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
...@@ -443,7 +443,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, ...@@ -443,7 +443,7 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
err_g2: err_g2:
pci_disable_device(pdev); pci_disable_device(pdev);
err_g1: err_g1:
drm_free(dev, sizeof(*dev), DRM_MEM_STUB); kfree(dev);
return ret; return ret;
} }
EXPORT_SYMBOL(drm_get_dev); EXPORT_SYMBOL(drm_get_dev);
...@@ -516,7 +516,7 @@ void drm_put_dev(struct drm_device *dev) ...@@ -516,7 +516,7 @@ void drm_put_dev(struct drm_device *dev)
dev->driver->unload(dev); dev->driver->unload(dev);
if (drm_core_has_AGP(dev) && dev->agp) { if (drm_core_has_AGP(dev) && dev->agp) {
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); kfree(dev->agp);
dev->agp = NULL; dev->agp = NULL;
} }
...@@ -535,10 +535,9 @@ void drm_put_dev(struct drm_device *dev) ...@@ -535,10 +535,9 @@ void drm_put_dev(struct drm_device *dev)
drm_put_minor(&dev->primary); drm_put_minor(&dev->primary);
if (dev->devname) { if (dev->devname) {
drm_free(dev->devname, strlen(dev->devname) + 1, kfree(dev->devname);
DRM_MEM_DRIVER);
dev->devname = NULL; dev->devname = NULL;
} }
drm_free(dev, sizeof(*dev), DRM_MEM_STUB); kfree(dev);
} }
EXPORT_SYMBOL(drm_put_dev); EXPORT_SYMBOL(drm_put_dev);
...@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -227,7 +227,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
found_maps++; found_maps++;
if (pt->vma == vma) { if (pt->vma == vma) {
list_del(&pt->head); list_del(&pt->head);
drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); kfree(pt);
} }
} }
...@@ -273,7 +273,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -273,7 +273,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
DRM_ERROR("tried to rmmap GEM object\n"); DRM_ERROR("tried to rmmap GEM object\n");
break; break;
} }
drm_free(map, sizeof(*map), DRM_MEM_MAPS); kfree(map);
} }
} }
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
...@@ -414,7 +414,7 @@ void drm_vm_open_locked(struct vm_area_struct *vma) ...@@ -414,7 +414,7 @@ void drm_vm_open_locked(struct vm_area_struct *vma)
vma->vm_start, vma->vm_end - vma->vm_start); vma->vm_start, vma->vm_end - vma->vm_start);
atomic_inc(&dev->vma_count); atomic_inc(&dev->vma_count);
vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); vma_entry = kmalloc(sizeof(*vma_entry), GFP_KERNEL);
if (vma_entry) { if (vma_entry) {
vma_entry->vma = vma; vma_entry->vma = vma;
vma_entry->pid = current->pid; vma_entry->pid = current->pid;
...@@ -454,7 +454,7 @@ static void drm_vm_close(struct vm_area_struct *vma) ...@@ -454,7 +454,7 @@ static void drm_vm_close(struct vm_area_struct *vma)
list_for_each_entry_safe(pt, temp, &dev->vmalist, head) { list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
if (pt->vma == vma) { if (pt->vma == vma) {
list_del(&pt->head); list_del(&pt->head);
drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); kfree(pt);
break; break;
} }
} }
......
...@@ -227,8 +227,7 @@ static int i810_dma_cleanup(struct drm_device * dev) ...@@ -227,8 +227,7 @@ static int i810_dma_cleanup(struct drm_device * dev)
/* Need to rewrite hardware status page */ /* Need to rewrite hardware status page */
I810_WRITE(0x02080, 0x1ffff000); I810_WRITE(0x02080, 0x1ffff000);
} }
drm_free(dev->dev_private, sizeof(drm_i810_private_t), kfree(dev->dev_private);
DRM_MEM_DRIVER);
dev->dev_private = NULL; dev->dev_private = NULL;
for (i = 0; i < dma->buf_count; i++) { for (i = 0; i < dma->buf_count; i++) {
...@@ -439,8 +438,7 @@ static int i810_dma_init(struct drm_device *dev, void *data, ...@@ -439,8 +438,7 @@ static int i810_dma_init(struct drm_device *dev, void *data,
switch (init->func) { switch (init->func) {
case I810_INIT_DMA_1_4: case I810_INIT_DMA_1_4:
DRM_INFO("Using v1.4 init.\n"); DRM_INFO("Using v1.4 init.\n");
dev_priv = drm_alloc(sizeof(drm_i810_private_t), dev_priv = kmalloc(sizeof(drm_i810_private_t), GFP_KERNEL);
DRM_MEM_DRIVER);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
retcode = i810_dma_initialize(dev, dev_priv, init); retcode = i810_dma_initialize(dev, dev_priv, init);
......
...@@ -232,8 +232,7 @@ static int i830_dma_cleanup(struct drm_device * dev) ...@@ -232,8 +232,7 @@ static int i830_dma_cleanup(struct drm_device * dev)
I830_WRITE(0x02080, 0x1ffff000); I830_WRITE(0x02080, 0x1ffff000);
} }
drm_free(dev->dev_private, sizeof(drm_i830_private_t), kfree(dev->dev_private);
DRM_MEM_DRIVER);
dev->dev_private = NULL; dev->dev_private = NULL;
for (i = 0; i < dma->buf_count; i++) { for (i = 0; i < dma->buf_count; i++) {
...@@ -459,8 +458,7 @@ static int i830_dma_init(struct drm_device *dev, void *data, ...@@ -459,8 +458,7 @@ static int i830_dma_init(struct drm_device *dev, void *data,
switch (init->func) { switch (init->func) {
case I830_INIT_DMA: case I830_INIT_DMA:
dev_priv = drm_alloc(sizeof(drm_i830_private_t), dev_priv = kmalloc(sizeof(drm_i830_private_t), GFP_KERNEL);
DRM_MEM_DRIVER);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
retcode = i830_dma_initialize(dev, dev_priv, init); retcode = i830_dma_initialize(dev, dev_priv, init);
......
...@@ -643,9 +643,9 @@ static int i915_batchbuffer(struct drm_device *dev, void *data, ...@@ -643,9 +643,9 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
return -EINVAL; return -EINVAL;
if (batch->num_cliprects) { if (batch->num_cliprects) {
cliprects = drm_calloc(batch->num_cliprects, cliprects = kcalloc(batch->num_cliprects,
sizeof(struct drm_clip_rect), sizeof(struct drm_clip_rect),
DRM_MEM_DRIVER); GFP_KERNEL);
if (cliprects == NULL) if (cliprects == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -664,9 +664,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data, ...@@ -664,9 +664,7 @@ static int i915_batchbuffer(struct drm_device *dev, void *data,
sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
fail_free: fail_free:
drm_free(cliprects, kfree(cliprects);
batch->num_cliprects * sizeof(struct drm_clip_rect),
DRM_MEM_DRIVER);
return ret; return ret;
} }
...@@ -692,7 +690,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data, ...@@ -692,7 +690,7 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
if (cmdbuf->num_cliprects < 0) if (cmdbuf->num_cliprects < 0)
return -EINVAL; return -EINVAL;
batch_data = drm_alloc(cmdbuf->sz, DRM_MEM_DRIVER); batch_data = kmalloc(cmdbuf->sz, GFP_KERNEL);
if (batch_data == NULL) if (batch_data == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -701,9 +699,8 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data, ...@@ -701,9 +699,8 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
goto fail_batch_free; goto fail_batch_free;
if (cmdbuf->num_cliprects) { if (cmdbuf->num_cliprects) {
cliprects = drm_calloc(cmdbuf->num_cliprects, cliprects = kcalloc(cmdbuf->num_cliprects,
sizeof(struct drm_clip_rect), sizeof(struct drm_clip_rect), GFP_KERNEL);
DRM_MEM_DRIVER);
if (cliprects == NULL) if (cliprects == NULL)
goto fail_batch_free; goto fail_batch_free;
...@@ -726,11 +723,9 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data, ...@@ -726,11 +723,9 @@ static int i915_cmdbuffer(struct drm_device *dev, void *data,
sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv); sarea_priv->last_dispatch = READ_BREADCRUMB(dev_priv);
fail_clip_free: fail_clip_free:
drm_free(cliprects, kfree(cliprects);
cmdbuf->num_cliprects * sizeof(struct drm_clip_rect),
DRM_MEM_DRIVER);
fail_batch_free: fail_batch_free:
drm_free(batch_data, cmdbuf->sz, DRM_MEM_DRIVER); kfree(batch_data);
return ret; return ret;
} }
...@@ -1067,7 +1062,7 @@ int i915_master_create(struct drm_device *dev, struct drm_master *master) ...@@ -1067,7 +1062,7 @@ int i915_master_create(struct drm_device *dev, struct drm_master *master)
{ {
struct drm_i915_master_private *master_priv; struct drm_i915_master_private *master_priv;
master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
if (!master_priv) if (!master_priv)
return -ENOMEM; return -ENOMEM;
...@@ -1082,7 +1077,7 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master) ...@@ -1082,7 +1077,7 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)
if (!master_priv) if (!master_priv)
return; return;
drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); kfree(master_priv);
master->driver_priv = NULL; master->driver_priv = NULL;
} }
...@@ -1111,12 +1106,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -1111,12 +1106,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
dev->types[8] = _DRM_STAT_SECONDARY; dev->types[8] = _DRM_STAT_SECONDARY;
dev->types[9] = _DRM_STAT_DMA; dev->types[9] = _DRM_STAT_DMA;
dev_priv = drm_alloc(sizeof(drm_i915_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_i915_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev_priv, 0, sizeof(drm_i915_private_t));
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
dev_priv->dev = dev; dev_priv->dev = dev;
...@@ -1221,7 +1214,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -1221,7 +1214,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
out_rmmap: out_rmmap:
iounmap(dev_priv->regs); iounmap(dev_priv->regs);
free_priv: free_priv:
drm_free(dev_priv, sizeof(struct drm_i915_private), DRM_MEM_DRIVER); kfree(dev_priv);
return ret; return ret;
} }
...@@ -1261,8 +1254,7 @@ int i915_driver_unload(struct drm_device *dev) ...@@ -1261,8 +1254,7 @@ int i915_driver_unload(struct drm_device *dev)
i915_gem_lastclose(dev); i915_gem_lastclose(dev);
} }
drm_free(dev->dev_private, sizeof(drm_i915_private_t), kfree(dev->dev_private);
DRM_MEM_DRIVER);
return 0; return 0;
} }
...@@ -1273,7 +1265,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv) ...@@ -1273,7 +1265,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file_priv)
DRM_DEBUG_DRIVER(I915_DRV, "\n"); DRM_DEBUG_DRIVER(I915_DRV, "\n");
i915_file_priv = (struct drm_i915_file_private *) i915_file_priv = (struct drm_i915_file_private *)
drm_alloc(sizeof(*i915_file_priv), DRM_MEM_FILES); kmalloc(sizeof(*i915_file_priv), GFP_KERNEL);
if (!i915_file_priv) if (!i915_file_priv)
return -ENOMEM; return -ENOMEM;
...@@ -1326,7 +1318,7 @@ void i915_driver_postclose(struct drm_device *dev, struct drm_file *file_priv) ...@@ -1326,7 +1318,7 @@ void i915_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
{ {
struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv; struct drm_i915_file_private *i915_file_priv = file_priv->driver_priv;
drm_free(i915_file_priv, sizeof(*i915_file_priv), DRM_MEM_FILES); kfree(i915_file_priv);
} }
struct drm_ioctl_desc i915_ioctls[] = { struct drm_ioctl_desc i915_ioctls[] = {
......
...@@ -1207,8 +1207,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj) ...@@ -1207,8 +1207,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
/* Set the object up for mmap'ing */ /* Set the object up for mmap'ing */
list = &obj->map_list; list = &obj->map_list;
list->map = drm_calloc(1, sizeof(struct drm_map_list), list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL);
DRM_MEM_DRIVER);
if (!list->map) if (!list->map)
return -ENOMEM; return -ENOMEM;
...@@ -1248,7 +1247,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj) ...@@ -1248,7 +1247,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
out_free_mm: out_free_mm:
drm_mm_put_block(list->file_offset_node); drm_mm_put_block(list->file_offset_node);
out_free_list: out_free_list:
drm_free(list->map, sizeof(struct drm_map_list), DRM_MEM_DRIVER); kfree(list->map);
return ret; return ret;
} }
...@@ -1270,7 +1269,7 @@ i915_gem_free_mmap_offset(struct drm_gem_object *obj) ...@@ -1270,7 +1269,7 @@ i915_gem_free_mmap_offset(struct drm_gem_object *obj)
} }
if (list->map) { if (list->map) {
drm_free(list->map, sizeof(struct drm_map), DRM_MEM_DRIVER); kfree(list->map);
list->map = NULL; list->map = NULL;
} }
...@@ -1493,7 +1492,7 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv, ...@@ -1493,7 +1492,7 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv,
if (file_priv != NULL) if (file_priv != NULL)
i915_file_priv = file_priv->driver_priv; i915_file_priv = file_priv->driver_priv;
request = drm_calloc(1, sizeof(*request), DRM_MEM_DRIVER); request = kzalloc(sizeof(*request), GFP_KERNEL);
if (request == NULL) if (request == NULL)
return 0; return 0;
...@@ -1675,7 +1674,7 @@ i915_gem_retire_requests(struct drm_device *dev) ...@@ -1675,7 +1674,7 @@ i915_gem_retire_requests(struct drm_device *dev)
list_del(&request->list); list_del(&request->list);
list_del(&request->client_list); list_del(&request->client_list);
drm_free(request, sizeof(*request), DRM_MEM_DRIVER); kfree(request);
} else } else
break; break;
} }
...@@ -2833,8 +2832,7 @@ i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj) ...@@ -2833,8 +2832,7 @@ i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj)
/* Free the page_cpu_valid mappings which are now stale, whether /* Free the page_cpu_valid mappings which are now stale, whether
* or not we've got I915_GEM_DOMAIN_CPU. * or not we've got I915_GEM_DOMAIN_CPU.
*/ */
drm_free(obj_priv->page_cpu_valid, obj->size / PAGE_SIZE, kfree(obj_priv->page_cpu_valid);
DRM_MEM_DRIVER);
obj_priv->page_cpu_valid = NULL; obj_priv->page_cpu_valid = NULL;
} }
...@@ -2876,8 +2874,8 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj, ...@@ -2876,8 +2874,8 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
* newly adding I915_GEM_DOMAIN_CPU * newly adding I915_GEM_DOMAIN_CPU
*/ */
if (obj_priv->page_cpu_valid == NULL) { if (obj_priv->page_cpu_valid == NULL) {
obj_priv->page_cpu_valid = drm_calloc(1, obj->size / PAGE_SIZE, obj_priv->page_cpu_valid = kzalloc(obj->size / PAGE_SIZE,
DRM_MEM_DRIVER); GFP_KERNEL);
if (obj_priv->page_cpu_valid == NULL) if (obj_priv->page_cpu_valid == NULL)
return -ENOMEM; return -ENOMEM;
} else if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0) } else if ((obj->read_domains & I915_GEM_DOMAIN_CPU) == 0)
...@@ -3300,8 +3298,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, ...@@ -3300,8 +3298,8 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
} }
if (args->num_cliprects != 0) { if (args->num_cliprects != 0) {
cliprects = drm_calloc(args->num_cliprects, sizeof(*cliprects), cliprects = kcalloc(args->num_cliprects, sizeof(*cliprects),
DRM_MEM_DRIVER); GFP_KERNEL);
if (cliprects == NULL) if (cliprects == NULL)
goto pre_mutex_err; goto pre_mutex_err;
...@@ -3554,8 +3552,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, ...@@ -3554,8 +3552,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
pre_mutex_err: pre_mutex_err:
drm_free_large(object_list); drm_free_large(object_list);
drm_free_large(exec_list); drm_free_large(exec_list);
drm_free(cliprects, sizeof(*cliprects) * args->num_cliprects, kfree(cliprects);
DRM_MEM_DRIVER);
return ret; return ret;
} }
...@@ -3772,7 +3769,7 @@ int i915_gem_init_object(struct drm_gem_object *obj) ...@@ -3772,7 +3769,7 @@ int i915_gem_init_object(struct drm_gem_object *obj)
{ {
struct drm_i915_gem_object *obj_priv; struct drm_i915_gem_object *obj_priv;
obj_priv = drm_calloc(1, sizeof(*obj_priv), DRM_MEM_DRIVER); obj_priv = kzalloc(sizeof(*obj_priv), GFP_KERNEL);
if (obj_priv == NULL) if (obj_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -3810,9 +3807,9 @@ void i915_gem_free_object(struct drm_gem_object *obj) ...@@ -3810,9 +3807,9 @@ void i915_gem_free_object(struct drm_gem_object *obj)
i915_gem_free_mmap_offset(obj); i915_gem_free_mmap_offset(obj);
drm_free(obj_priv->page_cpu_valid, 1, DRM_MEM_DRIVER); kfree(obj_priv->page_cpu_valid);
kfree(obj_priv->bit_17); kfree(obj_priv->bit_17);
drm_free(obj->driver_private, 1, DRM_MEM_DRIVER); kfree(obj->driver_private);
} }
/** Unbinds all objects that are on the given buffer list. */ /** 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,7 +4263,7 @@ int i915_gem_init_phys_object(struct drm_device *dev,
if (dev_priv->mm.phys_objs[id - 1] || !size) if (dev_priv->mm.phys_objs[id - 1] || !size)
return 0; return 0;
phys_obj = drm_calloc(1, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER); phys_obj = kzalloc(sizeof(struct drm_i915_gem_phys_object), GFP_KERNEL);
if (!phys_obj) if (!phys_obj)
return -ENOMEM; return -ENOMEM;
...@@ -4285,7 +4282,7 @@ int i915_gem_init_phys_object(struct drm_device *dev, ...@@ -4285,7 +4282,7 @@ int i915_gem_init_phys_object(struct drm_device *dev,
return 0; return 0;
kfree_obj: kfree_obj:
drm_free(phys_obj, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER); kfree(phys_obj);
return ret; return ret;
} }
......
...@@ -94,8 +94,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, ...@@ -94,8 +94,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{ {
/* Maybe cut off the start of an existing block */ /* Maybe cut off the start of an existing block */
if (start > p->start) { if (start > p->start) {
struct mem_block *newblock = struct mem_block *newblock = kmalloc(sizeof(*newblock),
drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS); GFP_KERNEL);
if (!newblock) if (!newblock)
goto out; goto out;
newblock->start = start; newblock->start = start;
...@@ -111,8 +111,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, ...@@ -111,8 +111,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */ /* Maybe cut off the end of an existing block */
if (size < p->size) { if (size < p->size) {
struct mem_block *newblock = struct mem_block *newblock = kmalloc(sizeof(*newblock),
drm_alloc(sizeof(*newblock), DRM_MEM_BUFLISTS); GFP_KERNEL);
if (!newblock) if (!newblock)
goto out; goto out;
newblock->start = start + size; newblock->start = start + size;
...@@ -169,7 +169,7 @@ static void free_block(struct mem_block *p) ...@@ -169,7 +169,7 @@ static void free_block(struct mem_block *p)
p->size += q->size; p->size += q->size;
p->next = q->next; p->next = q->next;
p->next->prev = p; p->next->prev = p;
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); kfree(q);
} }
if (p->prev->file_priv == NULL) { if (p->prev->file_priv == NULL) {
...@@ -177,7 +177,7 @@ static void free_block(struct mem_block *p) ...@@ -177,7 +177,7 @@ static void free_block(struct mem_block *p)
q->size += p->size; q->size += p->size;
q->next = p->next; q->next = p->next;
q->next->prev = q; q->next->prev = q;
drm_free(p, sizeof(*q), DRM_MEM_BUFLISTS); kfree(p);
} }
} }
...@@ -185,14 +185,14 @@ static void free_block(struct mem_block *p) ...@@ -185,14 +185,14 @@ static void free_block(struct mem_block *p)
*/ */
static int init_heap(struct mem_block **heap, int start, int size) static int init_heap(struct mem_block **heap, int start, int size)
{ {
struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFLISTS); struct mem_block *blocks = kmalloc(sizeof(*blocks), GFP_KERNEL);
if (!blocks) if (!blocks)
return -ENOMEM; return -ENOMEM;
*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFLISTS); *heap = kmalloc(sizeof(**heap), GFP_KERNEL);
if (!*heap) { if (!*heap) {
drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS); kfree(blocks);
return -ENOMEM; return -ENOMEM;
} }
...@@ -233,7 +233,7 @@ void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv, ...@@ -233,7 +233,7 @@ void i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
p->size += q->size; p->size += q->size;
p->next = q->next; p->next = q->next;
p->next->prev = p; p->next->prev = p;
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); kfree(q);
} }
} }
} }
...@@ -250,10 +250,10 @@ void i915_mem_takedown(struct mem_block **heap) ...@@ -250,10 +250,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) { for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p; struct mem_block *q = p;
p = p->next; p = p->next;
drm_free(q, sizeof(*q), DRM_MEM_BUFLISTS); kfree(q);
} }
drm_free(*heap, sizeof(**heap), DRM_MEM_BUFLISTS); kfree(*heap);
*heap = NULL; *heap = NULL;
} }
......
...@@ -124,8 +124,7 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv, ...@@ -124,8 +124,7 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
entry = &lvds_lfp_data->data[lvds_options->panel_type]; entry = &lvds_lfp_data->data[lvds_options->panel_type];
dvo_timing = &entry->dvo_timing; dvo_timing = &entry->dvo_timing;
panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
DRM_MEM_DRIVER);
fill_detail_timing_data(panel_fixed_mode, dvo_timing); fill_detail_timing_data(panel_fixed_mode, dvo_timing);
...@@ -156,8 +155,7 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv, ...@@ -156,8 +155,7 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
if (!dvo_timing) if (!dvo_timing)
return; return;
panel_fixed_mode = drm_calloc(1, sizeof(*panel_fixed_mode), panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
DRM_MEM_DRIVER);
if (!panel_fixed_mode) if (!panel_fixed_mode)
return; return;
......
...@@ -1561,8 +1561,7 @@ intel_tv_destroy (struct drm_connector *connector) ...@@ -1561,8 +1561,7 @@ intel_tv_destroy (struct drm_connector *connector)
drm_sysfs_connector_remove(connector); drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
drm_free(intel_output, sizeof(struct intel_output) + sizeof(struct intel_tv_priv), kfree(intel_output);
DRM_MEM_DRIVER);
} }
...@@ -1695,8 +1694,8 @@ intel_tv_init(struct drm_device *dev) ...@@ -1695,8 +1694,8 @@ intel_tv_init(struct drm_device *dev)
(tv_dac_off & TVDAC_STATE_CHG_EN) != 0) (tv_dac_off & TVDAC_STATE_CHG_EN) != 0)
return; return;
intel_output = drm_calloc(1, sizeof(struct intel_output) + intel_output = kzalloc(sizeof(struct intel_output) +
sizeof(struct intel_tv_priv), DRM_MEM_DRIVER); sizeof(struct intel_tv_priv), GFP_KERNEL);
if (!intel_output) { if (!intel_output) {
return; return;
} }
...@@ -1730,8 +1729,8 @@ intel_tv_init(struct drm_device *dev) ...@@ -1730,8 +1729,8 @@ intel_tv_init(struct drm_device *dev)
connector->doublescan_allowed = false; connector->doublescan_allowed = false;
/* Create TV properties then attach current values */ /* Create TV properties then attach current values */
tv_format_names = drm_alloc(sizeof(char *) * NUM_TV_MODES, tv_format_names = kmalloc(sizeof(char *) * NUM_TV_MODES,
DRM_MEM_DRIVER); GFP_KERNEL);
if (!tv_format_names) if (!tv_format_names)
goto out; goto out;
for (i = 0; i < NUM_TV_MODES; i++) for (i = 0; i < NUM_TV_MODES; i++)
......
...@@ -254,23 +254,20 @@ static int mga_freelist_init(struct drm_device * dev, drm_mga_private_t * dev_pr ...@@ -254,23 +254,20 @@ static int mga_freelist_init(struct drm_device * dev, drm_mga_private_t * dev_pr
int i; int i;
DRM_DEBUG("count=%d\n", dma->buf_count); DRM_DEBUG("count=%d\n", dma->buf_count);
dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); dev_priv->head = kzalloc(sizeof(drm_mga_freelist_t), GFP_KERNEL);
if (dev_priv->head == NULL) if (dev_priv->head == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
SET_AGE(&dev_priv->head->age, MGA_BUFFER_USED, 0); SET_AGE(&dev_priv->head->age, MGA_BUFFER_USED, 0);
for (i = 0; i < dma->buf_count; i++) { for (i = 0; i < dma->buf_count; i++) {
buf = dma->buflist[i]; buf = dma->buflist[i];
buf_priv = buf->dev_private; buf_priv = buf->dev_private;
entry = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); entry = kzalloc(sizeof(drm_mga_freelist_t), GFP_KERNEL);
if (entry == NULL) if (entry == NULL)
return -ENOMEM; return -ENOMEM;
memset(entry, 0, sizeof(drm_mga_freelist_t));
entry->next = dev_priv->head->next; entry->next = dev_priv->head->next;
entry->prev = dev_priv->head; entry->prev = dev_priv->head;
SET_AGE(&entry->age, MGA_BUFFER_FREE, 0); SET_AGE(&entry->age, MGA_BUFFER_FREE, 0);
...@@ -301,7 +298,7 @@ static void mga_freelist_cleanup(struct drm_device * dev) ...@@ -301,7 +298,7 @@ static void mga_freelist_cleanup(struct drm_device * dev)
entry = dev_priv->head; entry = dev_priv->head;
while (entry) { while (entry) {
next = entry->next; next = entry->next;
drm_free(entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); kfree(entry);
entry = next; entry = next;
} }
...@@ -399,12 +396,11 @@ int mga_driver_load(struct drm_device * dev, unsigned long flags) ...@@ -399,12 +396,11 @@ int mga_driver_load(struct drm_device * dev, unsigned long flags)
drm_mga_private_t *dev_priv; drm_mga_private_t *dev_priv;
int ret; int ret;
dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_mga_private_t), GFP_KERNEL);
if (!dev_priv) if (!dev_priv)
return -ENOMEM; return -ENOMEM;
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
memset(dev_priv, 0, sizeof(drm_mga_private_t));
dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT; dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
dev_priv->chipset = flags; dev_priv->chipset = flags;
...@@ -1150,7 +1146,7 @@ int mga_dma_buffers(struct drm_device *dev, void *data, ...@@ -1150,7 +1146,7 @@ int mga_dma_buffers(struct drm_device *dev, void *data,
*/ */
int mga_driver_unload(struct drm_device * dev) int mga_driver_unload(struct drm_device * dev)
{ {
drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER); kfree(dev->dev_private);
dev->dev_private = NULL; dev->dev_private = NULL;
return 0; return 0;
......
...@@ -353,12 +353,10 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init) ...@@ -353,12 +353,10 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
DRM_DEBUG("\n"); DRM_DEBUG("\n");
dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_r128_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev_priv, 0, sizeof(drm_r128_private_t));
dev_priv->is_pci = init->is_pci; dev_priv->is_pci = init->is_pci;
if (dev_priv->is_pci && !dev->sg) { if (dev_priv->is_pci && !dev->sg) {
...@@ -619,8 +617,7 @@ int r128_do_cleanup_cce(struct drm_device * dev) ...@@ -619,8 +617,7 @@ int r128_do_cleanup_cce(struct drm_device * dev)
("failed to cleanup PCI GART!\n"); ("failed to cleanup PCI GART!\n");
} }
drm_free(dev->dev_private, sizeof(drm_r128_private_t), kfree(dev->dev_private);
DRM_MEM_DRIVER);
dev->dev_private = NULL; dev->dev_private = NULL;
} }
...@@ -768,18 +765,17 @@ static int r128_freelist_init(struct drm_device * dev) ...@@ -768,18 +765,17 @@ static int r128_freelist_init(struct drm_device * dev)
drm_r128_freelist_t *entry; drm_r128_freelist_t *entry;
int i; int i;
dev_priv->head = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); dev_priv->head = kzalloc(sizeof(drm_r128_freelist_t), GFP_KERNEL);
if (dev_priv->head == NULL) if (dev_priv->head == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev_priv->head, 0, sizeof(drm_r128_freelist_t));
dev_priv->head->age = R128_BUFFER_USED; dev_priv->head->age = R128_BUFFER_USED;
for (i = 0; i < dma->buf_count; i++) { for (i = 0; i < dma->buf_count; i++) {
buf = dma->buflist[i]; buf = dma->buflist[i];
buf_priv = buf->dev_private; buf_priv = buf->dev_private;
entry = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER); entry = kmalloc(sizeof(drm_r128_freelist_t), GFP_KERNEL);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
......
...@@ -910,24 +910,24 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev, ...@@ -910,24 +910,24 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
} }
buffer_size = depth->n * sizeof(u32); buffer_size = depth->n * sizeof(u32);
buffer = drm_alloc(buffer_size, DRM_MEM_BUFS); buffer = kmalloc(buffer_size, GFP_KERNEL);
if (buffer == NULL) if (buffer == NULL)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return -EFAULT; return -EFAULT;
} }
mask_size = depth->n * sizeof(u8); mask_size = depth->n * sizeof(u8);
if (depth->mask) { if (depth->mask) {
mask = drm_alloc(mask_size, DRM_MEM_BUFS); mask = kmalloc(mask_size, GFP_KERNEL);
if (mask == NULL) { if (mask == NULL) {
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
drm_free(mask, mask_size, DRM_MEM_BUFS); kfree(mask);
return -EFAULT; return -EFAULT;
} }
...@@ -954,7 +954,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev, ...@@ -954,7 +954,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
} }
} }
drm_free(mask, mask_size, DRM_MEM_BUFS); kfree(mask);
} else { } else {
for (i = 0; i < count; i++, x++) { for (i = 0; i < count; i++, x++) {
BEGIN_RING(6); BEGIN_RING(6);
...@@ -978,7 +978,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev, ...@@ -978,7 +978,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
} }
} }
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return 0; return 0;
} }
...@@ -1000,54 +1000,54 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev, ...@@ -1000,54 +1000,54 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
xbuf_size = count * sizeof(*x); xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y); ybuf_size = count * sizeof(*y);
x = drm_alloc(xbuf_size, DRM_MEM_BUFS); x = kmalloc(xbuf_size, GFP_KERNEL);
if (x == NULL) { if (x == NULL) {
return -ENOMEM; return -ENOMEM;
} }
y = drm_alloc(ybuf_size, DRM_MEM_BUFS); y = kmalloc(ybuf_size, GFP_KERNEL);
if (y == NULL) { if (y == NULL) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return -EFAULT; return -EFAULT;
} }
if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) { if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return -EFAULT; return -EFAULT;
} }
buffer_size = depth->n * sizeof(u32); buffer_size = depth->n * sizeof(u32);
buffer = drm_alloc(buffer_size, DRM_MEM_BUFS); buffer = kmalloc(buffer_size, GFP_KERNEL);
if (buffer == NULL) { if (buffer == NULL) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) { if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return -EFAULT; return -EFAULT;
} }
if (depth->mask) { if (depth->mask) {
mask_size = depth->n * sizeof(u8); mask_size = depth->n * sizeof(u8);
mask = drm_alloc(mask_size, DRM_MEM_BUFS); mask = kmalloc(mask_size, GFP_KERNEL);
if (mask == NULL) { if (mask == NULL) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) { if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
drm_free(mask, mask_size, DRM_MEM_BUFS); kfree(mask);
return -EFAULT; return -EFAULT;
} }
...@@ -1074,7 +1074,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev, ...@@ -1074,7 +1074,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
} }
} }
drm_free(mask, mask_size, DRM_MEM_BUFS); kfree(mask);
} else { } else {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
BEGIN_RING(6); BEGIN_RING(6);
...@@ -1098,9 +1098,9 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev, ...@@ -1098,9 +1098,9 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
} }
} }
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
drm_free(buffer, buffer_size, DRM_MEM_BUFS); kfree(buffer);
return 0; return 0;
} }
...@@ -1167,23 +1167,23 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev, ...@@ -1167,23 +1167,23 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
xbuf_size = count * sizeof(*x); xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y); ybuf_size = count * sizeof(*y);
x = drm_alloc(xbuf_size, DRM_MEM_BUFS); x = kmalloc(xbuf_size, GFP_KERNEL);
if (x == NULL) { if (x == NULL) {
return -ENOMEM; return -ENOMEM;
} }
y = drm_alloc(ybuf_size, DRM_MEM_BUFS); y = kmalloc(ybuf_size, GFP_KERNEL);
if (y == NULL) { if (y == NULL) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
return -ENOMEM; return -ENOMEM;
} }
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) { if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return -EFAULT; return -EFAULT;
} }
if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) { if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) {
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return -EFAULT; return -EFAULT;
} }
...@@ -1210,8 +1210,8 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev, ...@@ -1210,8 +1210,8 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
ADVANCE_RING(); ADVANCE_RING();
} }
drm_free(x, xbuf_size, DRM_MEM_BUFS); kfree(x);
drm_free(y, ybuf_size, DRM_MEM_BUFS); kfree(y);
return 0; return 0;
} }
......
...@@ -2045,11 +2045,10 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -2045,11 +2045,10 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags)
drm_radeon_private_t *dev_priv; drm_radeon_private_t *dev_priv;
int ret = 0; int ret = 0;
dev_priv = drm_alloc(sizeof(drm_radeon_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_radeon_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
memset(dev_priv, 0, sizeof(drm_radeon_private_t));
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
dev_priv->flags = flags; dev_priv->flags = flags;
...@@ -2103,7 +2102,7 @@ int radeon_master_create(struct drm_device *dev, struct drm_master *master) ...@@ -2103,7 +2102,7 @@ int radeon_master_create(struct drm_device *dev, struct drm_master *master)
unsigned long sareapage; unsigned long sareapage;
int ret; int ret;
master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
if (!master_priv) if (!master_priv)
return -ENOMEM; return -ENOMEM;
...@@ -2137,7 +2136,7 @@ void radeon_master_destroy(struct drm_device *dev, struct drm_master *master) ...@@ -2137,7 +2136,7 @@ void radeon_master_destroy(struct drm_device *dev, struct drm_master *master)
if (master_priv->sarea) if (master_priv->sarea)
drm_rmmap_locked(dev, master_priv->sarea); drm_rmmap_locked(dev, master_priv->sarea);
drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); kfree(master_priv);
master->driver_priv = NULL; master->driver_priv = NULL;
} }
...@@ -2171,7 +2170,7 @@ int radeon_driver_unload(struct drm_device *dev) ...@@ -2171,7 +2170,7 @@ int radeon_driver_unload(struct drm_device *dev)
drm_rmmap(dev, dev_priv->mmio); drm_rmmap(dev, dev_priv->mmio);
drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); kfree(dev_priv);
dev->dev_private = NULL; dev->dev_private = NULL;
return 0; return 0;
......
...@@ -162,7 +162,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, ...@@ -162,7 +162,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
struct radeon_i2c_chan *i2c; struct radeon_i2c_chan *i2c;
int ret; int ret;
i2c = drm_calloc(1, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL);
if (i2c == NULL) if (i2c == NULL)
return NULL; return NULL;
...@@ -189,7 +189,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, ...@@ -189,7 +189,7 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
return i2c; return i2c;
out_free: out_free:
drm_free(i2c, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); kfree(i2c);
return NULL; return NULL;
} }
...@@ -200,7 +200,7 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) ...@@ -200,7 +200,7 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c)
return; return;
i2c_del_adapter(&i2c->adapter); i2c_del_adapter(&i2c->adapter);
drm_free(i2c, sizeof(struct radeon_i2c_chan), DRM_MEM_DRIVER); kfree(i2c);
} }
struct drm_encoder *radeon_best_encoder(struct drm_connector *connector) struct drm_encoder *radeon_best_encoder(struct drm_connector *connector)
......
...@@ -169,7 +169,7 @@ int radeon_master_create_kms(struct drm_device *dev, struct drm_master *master) ...@@ -169,7 +169,7 @@ int radeon_master_create_kms(struct drm_device *dev, struct drm_master *master)
unsigned long sareapage; unsigned long sareapage;
int ret; int ret;
master_priv = drm_calloc(1, sizeof(*master_priv), DRM_MEM_DRIVER); master_priv = kzalloc(sizeof(*master_priv), GFP_KERNEL);
if (master_priv == NULL) { if (master_priv == NULL) {
return -ENOMEM; return -ENOMEM;
} }
...@@ -199,7 +199,7 @@ void radeon_master_destroy_kms(struct drm_device *dev, ...@@ -199,7 +199,7 @@ void radeon_master_destroy_kms(struct drm_device *dev,
if (master_priv->sarea) { if (master_priv->sarea) {
drm_rmmap_locked(dev, master_priv->sarea); drm_rmmap_locked(dev, master_priv->sarea);
} }
drm_free(master_priv, sizeof(*master_priv), DRM_MEM_DRIVER); kfree(master_priv);
master->driver_priv = NULL; master->driver_priv = NULL;
} }
......
...@@ -43,8 +43,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, ...@@ -43,8 +43,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{ {
/* Maybe cut off the start of an existing block */ /* Maybe cut off the start of an existing block */
if (start > p->start) { if (start > p->start) {
struct mem_block *newblock = struct mem_block *newblock = kmalloc(sizeof(*newblock),
drm_alloc(sizeof(*newblock), DRM_MEM_BUFS); GFP_KERNEL);
if (!newblock) if (!newblock)
goto out; goto out;
newblock->start = start; newblock->start = start;
...@@ -60,8 +60,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size, ...@@ -60,8 +60,8 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */ /* Maybe cut off the end of an existing block */
if (size < p->size) { if (size < p->size) {
struct mem_block *newblock = struct mem_block *newblock = kmalloc(sizeof(*newblock),
drm_alloc(sizeof(*newblock), DRM_MEM_BUFS); GFP_KERNEL);
if (!newblock) if (!newblock)
goto out; goto out;
newblock->start = start + size; newblock->start = start + size;
...@@ -118,7 +118,7 @@ static void free_block(struct mem_block *p) ...@@ -118,7 +118,7 @@ static void free_block(struct mem_block *p)
p->size += q->size; p->size += q->size;
p->next = q->next; p->next = q->next;
p->next->prev = p; p->next->prev = p;
drm_free(q, sizeof(*q), DRM_MEM_BUFS); kfree(q);
} }
if (p->prev->file_priv == NULL) { if (p->prev->file_priv == NULL) {
...@@ -126,7 +126,7 @@ static void free_block(struct mem_block *p) ...@@ -126,7 +126,7 @@ static void free_block(struct mem_block *p)
q->size += p->size; q->size += p->size;
q->next = p->next; q->next = p->next;
q->next->prev = q; q->next->prev = q;
drm_free(p, sizeof(*q), DRM_MEM_BUFS); kfree(p);
} }
} }
...@@ -134,14 +134,14 @@ static void free_block(struct mem_block *p) ...@@ -134,14 +134,14 @@ static void free_block(struct mem_block *p)
*/ */
static int init_heap(struct mem_block **heap, int start, int size) static int init_heap(struct mem_block **heap, int start, int size)
{ {
struct mem_block *blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS); struct mem_block *blocks = kmalloc(sizeof(*blocks), GFP_KERNEL);
if (!blocks) if (!blocks)
return -ENOMEM; return -ENOMEM;
*heap = drm_alloc(sizeof(**heap), DRM_MEM_BUFS); *heap = kmalloc(sizeof(**heap), GFP_KERNEL);
if (!*heap) { if (!*heap) {
drm_free(blocks, sizeof(*blocks), DRM_MEM_BUFS); kfree(blocks);
return -ENOMEM; return -ENOMEM;
} }
...@@ -179,7 +179,7 @@ void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap) ...@@ -179,7 +179,7 @@ void radeon_mem_release(struct drm_file *file_priv, struct mem_block *heap)
p->size += q->size; p->size += q->size;
p->next = q->next; p->next = q->next;
p->next->prev = p; p->next->prev = p;
drm_free(q, sizeof(*q), DRM_MEM_DRIVER); kfree(q);
} }
} }
} }
...@@ -196,10 +196,10 @@ void radeon_mem_takedown(struct mem_block **heap) ...@@ -196,10 +196,10 @@ void radeon_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) { for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p; struct mem_block *q = p;
p = p->next; p = p->next;
drm_free(q, sizeof(*q), DRM_MEM_DRIVER); kfree(q);
} }
drm_free(*heap, sizeof(**heap), DRM_MEM_DRIVER); kfree(*heap);
*heap = NULL; *heap = NULL;
} }
......
...@@ -2866,12 +2866,12 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file ...@@ -2866,12 +2866,12 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
*/ */
orig_bufsz = cmdbuf->bufsz; orig_bufsz = cmdbuf->bufsz;
if (orig_bufsz != 0) { if (orig_bufsz != 0) {
kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER); kbuf = kmalloc(cmdbuf->bufsz, GFP_KERNEL);
if (kbuf == NULL) if (kbuf == NULL)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf, if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf,
cmdbuf->bufsz)) { cmdbuf->bufsz)) {
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); kfree(kbuf);
return -EFAULT; return -EFAULT;
} }
cmdbuf->buf = kbuf; cmdbuf->buf = kbuf;
...@@ -2884,7 +2884,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file ...@@ -2884,7 +2884,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf); temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf);
if (orig_bufsz != 0) if (orig_bufsz != 0)
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); kfree(kbuf);
return temp; return temp;
} }
...@@ -2991,7 +2991,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file ...@@ -2991,7 +2991,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
} }
if (orig_bufsz != 0) if (orig_bufsz != 0)
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); kfree(kbuf);
DRM_DEBUG("DONE\n"); DRM_DEBUG("DONE\n");
COMMIT_RING(); COMMIT_RING();
...@@ -2999,7 +2999,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file ...@@ -2999,7 +2999,7 @@ static int radeon_cp_cmdbuf(struct drm_device *dev, void *data, struct drm_file
err: err:
if (orig_bufsz != 0) if (orig_bufsz != 0)
drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER); kfree(kbuf);
return -EINVAL; return -EINVAL;
} }
...@@ -3175,9 +3175,7 @@ int radeon_driver_open(struct drm_device *dev, struct drm_file *file_priv) ...@@ -3175,9 +3175,7 @@ int radeon_driver_open(struct drm_device *dev, struct drm_file *file_priv)
struct drm_radeon_driver_file_fields *radeon_priv; struct drm_radeon_driver_file_fields *radeon_priv;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
radeon_priv = radeon_priv = kmalloc(sizeof(*radeon_priv), GFP_KERNEL);
(struct drm_radeon_driver_file_fields *)
drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
if (!radeon_priv) if (!radeon_priv)
return -ENOMEM; return -ENOMEM;
...@@ -3196,7 +3194,7 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv) ...@@ -3196,7 +3194,7 @@ void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
struct drm_radeon_driver_file_fields *radeon_priv = struct drm_radeon_driver_file_fields *radeon_priv =
file_priv->driver_priv; file_priv->driver_priv;
drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES); kfree(radeon_priv);
} }
struct drm_ioctl_desc radeon_ioctls[] = { struct drm_ioctl_desc radeon_ioctls[] = {
......
...@@ -298,8 +298,8 @@ static int savage_dma_init(drm_savage_private_t * dev_priv) ...@@ -298,8 +298,8 @@ static int savage_dma_init(drm_savage_private_t * dev_priv)
dev_priv->nr_dma_pages = dev_priv->cmd_dma->size / dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
(SAVAGE_DMA_PAGE_SIZE * 4); (SAVAGE_DMA_PAGE_SIZE * 4);
dev_priv->dma_pages = drm_alloc(sizeof(drm_savage_dma_page_t) * dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
dev_priv->nr_dma_pages, DRM_MEM_DRIVER); dev_priv->nr_dma_pages, GFP_KERNEL);
if (dev_priv->dma_pages == NULL) if (dev_priv->dma_pages == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -539,7 +539,7 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -539,7 +539,7 @@ int savage_driver_load(struct drm_device *dev, unsigned long chipset)
{ {
drm_savage_private_t *dev_priv; drm_savage_private_t *dev_priv;
dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER); dev_priv = kmalloc(sizeof(drm_savage_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -671,7 +671,7 @@ int savage_driver_unload(struct drm_device *dev) ...@@ -671,7 +671,7 @@ int savage_driver_unload(struct drm_device *dev)
{ {
drm_savage_private_t *dev_priv = dev->dev_private; drm_savage_private_t *dev_priv = dev->dev_private;
drm_free(dev_priv, sizeof(drm_savage_private_t), DRM_MEM_DRIVER); kfree(dev_priv);
return 0; return 0;
} }
...@@ -804,8 +804,8 @@ static int savage_do_init_bci(struct drm_device * dev, drm_savage_init_t * init) ...@@ -804,8 +804,8 @@ static int savage_do_init_bci(struct drm_device * dev, drm_savage_init_t * init)
dev_priv->fake_dma.offset = 0; dev_priv->fake_dma.offset = 0;
dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE; dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE;
dev_priv->fake_dma.type = _DRM_SHM; dev_priv->fake_dma.type = _DRM_SHM;
dev_priv->fake_dma.handle = drm_alloc(SAVAGE_FAKE_DMA_SIZE, dev_priv->fake_dma.handle = kmalloc(SAVAGE_FAKE_DMA_SIZE,
DRM_MEM_DRIVER); GFP_KERNEL);
if (!dev_priv->fake_dma.handle) { if (!dev_priv->fake_dma.handle) {
DRM_ERROR("could not allocate faked DMA buffer!\n"); DRM_ERROR("could not allocate faked DMA buffer!\n");
savage_do_cleanup_bci(dev); savage_do_cleanup_bci(dev);
...@@ -903,9 +903,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev) ...@@ -903,9 +903,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
drm_savage_private_t *dev_priv = dev->dev_private; drm_savage_private_t *dev_priv = dev->dev_private;
if (dev_priv->cmd_dma == &dev_priv->fake_dma) { if (dev_priv->cmd_dma == &dev_priv->fake_dma) {
if (dev_priv->fake_dma.handle) kfree(dev_priv->fake_dma.handle);
drm_free(dev_priv->fake_dma.handle,
SAVAGE_FAKE_DMA_SIZE, DRM_MEM_DRIVER);
} else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle && } else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle &&
dev_priv->cmd_dma->type == _DRM_AGP && dev_priv->cmd_dma->type == _DRM_AGP &&
dev_priv->dma_type == SAVAGE_DMA_AGP) dev_priv->dma_type == SAVAGE_DMA_AGP)
...@@ -920,10 +918,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev) ...@@ -920,10 +918,7 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
dev->agp_buffer_map = NULL; dev->agp_buffer_map = NULL;
} }
if (dev_priv->dma_pages) kfree(dev_priv->dma_pages);
drm_free(dev_priv->dma_pages,
sizeof(drm_savage_dma_page_t) * dev_priv->nr_dma_pages,
DRM_MEM_DRIVER);
return 0; return 0;
} }
......
...@@ -988,20 +988,20 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -988,20 +988,20 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
* for locking on FreeBSD. * for locking on FreeBSD.
*/ */
if (cmdbuf->size) { if (cmdbuf->size) {
kcmd_addr = drm_alloc(cmdbuf->size * 8, DRM_MEM_DRIVER); kcmd_addr = kmalloc(cmdbuf->size * 8, GFP_KERNEL);
if (kcmd_addr == NULL) if (kcmd_addr == NULL)
return -ENOMEM; return -ENOMEM;
if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr, if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr,
cmdbuf->size * 8)) cmdbuf->size * 8))
{ {
drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); kfree(kcmd_addr);
return -EFAULT; return -EFAULT;
} }
cmdbuf->cmd_addr = kcmd_addr; cmdbuf->cmd_addr = kcmd_addr;
} }
if (cmdbuf->vb_size) { if (cmdbuf->vb_size) {
kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER); kvb_addr = kmalloc(cmdbuf->vb_size, GFP_KERNEL);
if (kvb_addr == NULL) { if (kvb_addr == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto done; goto done;
...@@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -1015,8 +1015,8 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
cmdbuf->vb_addr = kvb_addr; cmdbuf->vb_addr = kvb_addr;
} }
if (cmdbuf->nbox) { if (cmdbuf->nbox) {
kbox_addr = drm_alloc(cmdbuf->nbox * sizeof(struct drm_clip_rect), kbox_addr = kmalloc(cmdbuf->nbox * sizeof(struct drm_clip_rect),
DRM_MEM_DRIVER); GFP_KERNEL);
if (kbox_addr == NULL) { if (kbox_addr == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto done; goto done;
...@@ -1154,10 +1154,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -1154,10 +1154,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
done: done:
/* If we didn't need to allocate them, these'll be NULL */ /* If we didn't need to allocate them, these'll be NULL */
drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER); kfree(kcmd_addr);
drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER); kfree(kvb_addr);
drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect), kfree(kbox_addr);
DRM_MEM_DRIVER);
return ret; return ret;
} }
...@@ -40,7 +40,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -40,7 +40,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
drm_sis_private_t *dev_priv; drm_sis_private_t *dev_priv;
int ret; int ret;
dev_priv = drm_calloc(1, sizeof(drm_sis_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_sis_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -48,7 +48,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -48,7 +48,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned long chipset)
dev_priv->chipset = chipset; dev_priv->chipset = chipset;
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret) { if (ret) {
drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER); kfree(dev_priv);
} }
return ret; return ret;
...@@ -59,7 +59,7 @@ static int sis_driver_unload(struct drm_device *dev) ...@@ -59,7 +59,7 @@ static int sis_driver_unload(struct drm_device *dev)
drm_sis_private_t *dev_priv = dev->dev_private; drm_sis_private_t *dev_priv = dev->dev_private;
drm_sman_takedown(&dev_priv->sman); drm_sman_takedown(&dev_priv->sman);
drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); kfree(dev_priv);
return 0; return 0;
} }
......
...@@ -96,7 +96,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -96,7 +96,7 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
drm_via_private_t *dev_priv; drm_via_private_t *dev_priv;
int ret = 0; int ret = 0;
dev_priv = drm_calloc(1, sizeof(drm_via_private_t), DRM_MEM_DRIVER); dev_priv = kzalloc(sizeof(drm_via_private_t), GFP_KERNEL);
if (dev_priv == NULL) if (dev_priv == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -106,14 +106,14 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -106,14 +106,14 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset)
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret) { if (ret) {
drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); kfree(dev_priv);
return ret; return ret;
} }
ret = drm_vblank_init(dev, 1); ret = drm_vblank_init(dev, 1);
if (ret) { if (ret) {
drm_sman_takedown(&dev_priv->sman); drm_sman_takedown(&dev_priv->sman);
drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); kfree(dev_priv);
return ret; return ret;
} }
...@@ -126,7 +126,7 @@ int via_driver_unload(struct drm_device *dev) ...@@ -126,7 +126,7 @@ int via_driver_unload(struct drm_device *dev)
drm_sman_takedown(&dev_priv->sman); drm_sman_takedown(&dev_priv->sman);
drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); kfree(dev_priv);
return 0; return 0;
} }
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
#ifndef _DRM_P_H_ #ifndef _DRM_P_H_
#define _DRM_P_H_ #define _DRM_P_H_
/* If you want the memory alloc debug functionality, change define below */
/* #define DEBUG_MEMORY */
#ifdef __KERNEL__ #ifdef __KERNEL__
#ifdef __alpha__ #ifdef __alpha__
/* add include of current.h so that "current" is defined /* add include of current.h so that "current" is defined
...@@ -133,31 +130,6 @@ extern void drm_ut_debug_printk(unsigned int request_level, ...@@ -133,31 +130,6 @@ extern void drm_ut_debug_printk(unsigned int request_level,
#define DRM_FLAG_DEBUG 0x01 #define DRM_FLAG_DEBUG 0x01
#define DRM_MEM_DMA 0
#define DRM_MEM_SAREA 1
#define DRM_MEM_DRIVER 2
#define DRM_MEM_MAGIC 3
#define DRM_MEM_IOCTLS 4
#define DRM_MEM_MAPS 5
#define DRM_MEM_VMAS 6
#define DRM_MEM_BUFS 7
#define DRM_MEM_SEGS 8
#define DRM_MEM_PAGES 9
#define DRM_MEM_FILES 10
#define DRM_MEM_QUEUES 11
#define DRM_MEM_CMDS 12
#define DRM_MEM_MAPPINGS 13
#define DRM_MEM_BUFLISTS 14
#define DRM_MEM_AGPLISTS 15
#define DRM_MEM_TOTALAGP 16
#define DRM_MEM_BOUNDAGP 17
#define DRM_MEM_CTXBITMAP 18
#define DRM_MEM_STUB 19
#define DRM_MEM_SGLISTS 20
#define DRM_MEM_CTXLIST 21
#define DRM_MEM_MM 22
#define DRM_MEM_HASHTAB 23
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
#define DRM_MAP_HASH_OFFSET 0x10000000 #define DRM_MAP_HASH_OFFSET 0x10000000
...@@ -1517,24 +1489,6 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map) ...@@ -1517,24 +1489,6 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
{ {
} }
#ifndef DEBUG_MEMORY
/** Wrapper around kmalloc() */
static __inline__ void *drm_alloc(size_t size, int area)
{
return kmalloc(size, GFP_KERNEL);
}
/** Wrapper around kfree() */
static __inline__ void drm_free(void *pt, size_t size, int area)
{
kfree(pt);
}
/** Wrapper around kcalloc() */
static __inline__ void *drm_calloc(size_t nmemb, size_t size, int area)
{
return kcalloc(nmemb, size, GFP_KERNEL);
}
static __inline__ void *drm_calloc_large(size_t nmemb, size_t size) static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
{ {
...@@ -1555,12 +1509,6 @@ static __inline void drm_free_large(void *ptr) ...@@ -1555,12 +1509,6 @@ static __inline void drm_free_large(void *ptr)
vfree(ptr); vfree(ptr);
} }
#else
extern void *drm_alloc(size_t size, int area);
extern void drm_free(void *pt, size_t size, int area);
extern void *drm_calloc(size_t nmemb, size_t size, int area);
#endif
/*@}*/ /*@}*/
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
/**
* \file drm_memory_debug.h
* Memory management wrappers for DRM.
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "drmP.h"
typedef struct drm_mem_stats {
const char *name;
int succeed_count;
int free_count;
int fail_count;
unsigned long bytes_allocated;
unsigned long bytes_freed;
} drm_mem_stats_t;
static DEFINE_SPINLOCK(drm_mem_lock);
static unsigned long drm_ram_available = 0; /* In pages */
static unsigned long drm_ram_used = 0;
static drm_mem_stats_t drm_mem_stats[] =
{
[DRM_MEM_DMA] = {"dmabufs"},
[DRM_MEM_SAREA] = {"sareas"},
[DRM_MEM_DRIVER] = {"driver"},
[DRM_MEM_MAGIC] = {"magic"},
[DRM_MEM_IOCTLS] = {"ioctltab"},
[DRM_MEM_MAPS] = {"maplist"},
[DRM_MEM_VMAS] = {"vmalist"},
[DRM_MEM_BUFS] = {"buflist"},
[DRM_MEM_SEGS] = {"seglist"},
[DRM_MEM_PAGES] = {"pagelist"},
[DRM_MEM_FILES] = {"files"},
[DRM_MEM_QUEUES] = {"queues"},
[DRM_MEM_CMDS] = {"commands"},
[DRM_MEM_MAPPINGS] = {"mappings"},
[DRM_MEM_BUFLISTS] = {"buflists"},
[DRM_MEM_AGPLISTS] = {"agplist"},
[DRM_MEM_SGLISTS] = {"sglist"},
[DRM_MEM_TOTALAGP] = {"totalagp"},
[DRM_MEM_BOUNDAGP] = {"boundagp"},
[DRM_MEM_CTXBITMAP] = {"ctxbitmap"},
[DRM_MEM_CTXLIST] = {"ctxlist"},
[DRM_MEM_STUB] = {"stub"},
{NULL, 0,} /* Last entry must be null */
};
void drm_mem_init (void) {
drm_mem_stats_t *mem;
struct sysinfo si;
for (mem = drm_mem_stats; mem->name; ++mem) {
mem->succeed_count = 0;
mem->free_count = 0;
mem->fail_count = 0;
mem->bytes_allocated = 0;
mem->bytes_freed = 0;
}
si_meminfo(&si);
drm_ram_available = si.totalram;
drm_ram_used = 0;
}
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
static int drm__mem_info (char *buf, char **start, off_t offset,
int request, int *eof, void *data) {
drm_mem_stats_t *pt;
int len = 0;
if (offset > DRM_PROC_LIMIT) {
*eof = 1;
return 0;
}
*eof = 0;
*start = &buf[offset];
DRM_PROC_PRINT(" total counts "
" | outstanding \n");
DRM_PROC_PRINT("type alloc freed fail bytes freed"
" | allocs bytes\n\n");
DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
"system", 0, 0, 0,
drm_ram_available << (PAGE_SHIFT - 10));
DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
"locked", 0, 0, 0, drm_ram_used >> 10);
DRM_PROC_PRINT("\n");
for (pt = drm_mem_stats; pt->name; pt++) {
DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
pt->name,
pt->succeed_count,
pt->free_count,
pt->fail_count,
pt->bytes_allocated,
pt->bytes_freed,
pt->succeed_count - pt->free_count,
(long)pt->bytes_allocated
- (long)pt->bytes_freed);
}
if (len > request + offset)
return request;
*eof = 1;
return len - offset;
}
int drm_mem_info (char *buf, char **start, off_t offset,
int len, int *eof, void *data) {
int ret;
spin_lock(&drm_mem_lock);
ret = drm__mem_info (buf, start, offset, len, eof, data);
spin_unlock(&drm_mem_lock);
return ret;
}
void *drm_alloc (size_t size, int area) {
void *pt;
if (!size) {
DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
return NULL;
}
if (!(pt = kmalloc(size, GFP_KERNEL))) {
spin_lock(&drm_mem_lock);
++drm_mem_stats[area].fail_count;
spin_unlock(&drm_mem_lock);
return NULL;
}
spin_lock(&drm_mem_lock);
++drm_mem_stats[area].succeed_count;
drm_mem_stats[area].bytes_allocated += size;
spin_unlock(&drm_mem_lock);
return pt;
}
void *drm_calloc (size_t nmemb, size_t size, int area) {
void *addr;
addr = drm_alloc (nmemb * size, area);
if (addr != NULL)
memset((void *)addr, 0, size * nmemb);
return addr;
}
void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) {
void *pt;
if (!(pt = drm_alloc (size, area)))
return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
drm_free (oldpt, oldsize, area);
}
return pt;
}
void drm_free (void *pt, size_t size, int area) {
int alloc_count;
int free_count;
if (!pt)
DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
else
kfree(pt);
spin_lock(&drm_mem_lock);
drm_mem_stats[area].bytes_freed += size;
free_count = ++drm_mem_stats[area].free_count;
alloc_count = drm_mem_stats[area].succeed_count;
spin_unlock(&drm_mem_lock);
if (free_count > alloc_count) {
DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
free_count, alloc_count);
}
}
#if __OS_HAS_AGP
DRM_AGP_MEM *drm_alloc_agp (drm_device_t *dev, int pages, u32 type) {
DRM_AGP_MEM *handle;
if (!pages) {
DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
return NULL;
}
if ((handle = drm_agp_allocate_memory (pages, type))) {
spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated
+= pages << PAGE_SHIFT;
spin_unlock(&drm_mem_lock);
return handle;
}
spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count;
spin_unlock(&drm_mem_lock);
return NULL;
}
int drm_free_agp (DRM_AGP_MEM * handle, int pages) {
int alloc_count;
int free_count;
int retval = -EINVAL;
if (!handle) {
DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
"Attempt to free NULL AGP handle\n");
return retval;
}
if (drm_agp_free_memory (handle)) {
spin_lock(&drm_mem_lock);
free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count;
alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
drm_mem_stats[DRM_MEM_TOTALAGP].bytes_freed
+= pages << PAGE_SHIFT;
spin_unlock(&drm_mem_lock);
if (free_count > alloc_count) {
DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
"Excess frees: %d frees, %d allocs\n",
free_count, alloc_count);
}
return 0;
}
return retval;
}
int drm_bind_agp (DRM_AGP_MEM * handle, unsigned int start) {
int retcode = -EINVAL;
if (!handle) {
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
"Attempt to bind NULL AGP handle\n");
return retcode;
}
if (!(retcode = drm_agp_bind_memory (handle, start))) {
spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated
+= handle->page_count << PAGE_SHIFT;
spin_unlock(&drm_mem_lock);
return retcode;
}
spin_lock(&drm_mem_lock);
++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count;
spin_unlock(&drm_mem_lock);
return retcode;
}
int drm_unbind_agp (DRM_AGP_MEM * handle) {
int alloc_count;
int free_count;
int retcode = -EINVAL;
if (!handle) {
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
"Attempt to unbind NULL AGP handle\n");
return retcode;
}
if ((retcode = drm_agp_unbind_memory (handle)))
return retcode;
spin_lock(&drm_mem_lock);
free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count;
alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed
+= handle->page_count << PAGE_SHIFT;
spin_unlock(&drm_mem_lock);
if (free_count > alloc_count) {
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
"Excess frees: %d frees, %d allocs\n",
free_count, alloc_count);
}
return retcode;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment