summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsd-core/drm_agpsupport.c13
-rw-r--r--bsd-core/drm_auth.c7
-rw-r--r--bsd-core/drm_bufs.c144
-rw-r--r--bsd-core/drm_context.c21
-rw-r--r--bsd-core/drm_dma.c37
-rw-r--r--bsd-core/drm_drv.c28
-rw-r--r--bsd-core/drm_fops.c3
-rw-r--r--bsd-core/drm_ioctl.c4
-rw-r--r--bsd-core/drm_irq.c6
-rw-r--r--bsd-core/drm_pci.c2
-rw-r--r--bsd-core/drm_scatter.c27
-rw-r--r--bsd-core/drm_sysctl.c17
12 files changed, 123 insertions, 186 deletions
diff --git a/bsd-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c
index eecf2e59..e26be833 100644
--- a/bsd-core/drm_agpsupport.c
+++ b/bsd-core/drm_agpsupport.c
@@ -131,16 +131,15 @@ int drm_agp_alloc(DRM_IOCTL_ARGS)
request = *(drm_agp_buffer_t *) data;
- if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
+ entry = malloc(sizeof(*entry), M_DRM, M_NOWAIT | M_ZERO);
+ if (entry == NULL)
return ENOMEM;
-
- bzero(entry, sizeof(*entry));
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u_int32_t) request.type;
if (!(handle = drm_agp_allocate_memory(pages, type))) {
- drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ free(entry, M_DRM);
return ENOMEM;
}
@@ -239,7 +238,7 @@ int drm_agp_free(DRM_IOCTL_ARGS)
if (entry->next)
entry->next->prev = entry->prev;
drm_agp_free_memory(entry->handle);
- drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ free(entry, M_DRM);
return 0;
}
@@ -256,9 +255,9 @@ drm_agp_head_t *drm_agp_init(void)
DRM_DEBUG("agp_available = %d\n", agp_available);
if (agp_available) {
- if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
+ head = malloc(sizeof(*head), M_DRM, M_NOWAIT | M_ZERO);
+ if (head == NULL)
return NULL;
- bzero((void *)head, sizeof(*head));
head->agpdev = agpdev;
agp_get_info(agpdev, &head->info);
head->memory = NULL;
diff --git a/bsd-core/drm_auth.c b/bsd-core/drm_auth.c
index c04c6546..fb556f33 100644
--- a/bsd-core/drm_auth.c
+++ b/bsd-core/drm_auth.c
@@ -63,10 +63,9 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
DRM_DEBUG("%d\n", magic);
- hash = drm_hash_magic(magic);
- entry = (drm_magic_entry_t*) drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
+ hash = drm_hash_magic(magic);
+ entry = malloc(sizeof(*entry), M_DRM, M_ZERO | M_NOWAIT);
if (!entry) return DRM_ERR(ENOMEM);
- memset(entry, 0, sizeof(*entry));
entry->magic = magic;
entry->priv = priv;
entry->next = NULL;
@@ -111,7 +110,7 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
}
DRM_UNLOCK();
- drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ free(pt, M_DRM);
return DRM_ERR(EINVAL);
}
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 860b38b5..26007a4d 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -60,7 +60,7 @@ int drm_addmap(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL( request, (drm_map_t *)data, sizeof(drm_map_t) );
- map = (drm_local_map_t *) drm_alloc(sizeof(*map), DRM_MEM_MAPS);
+ map = malloc(sizeof(*map), M_DRM, M_NOWAIT);
if ( !map )
return DRM_ERR(ENOMEM);
@@ -76,17 +76,17 @@ int drm_addmap(DRM_IOCTL_ARGS)
* when processes fork.
*/
if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n",
map->offset, map->size, map->type );
if ( (map->offset & PAGE_MASK) || (map->size & PAGE_MASK) ) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
if (map->offset + map->size < map->offset) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
@@ -101,11 +101,11 @@ int drm_addmap(DRM_IOCTL_ARGS)
map->mtrr = 1;
break;
case _DRM_SHM:
- map->handle = (void *)drm_alloc(map->size, DRM_MEM_SAREA);
+ map->handle = malloc(map->size, M_DRM, M_NOWAIT);
DRM_DEBUG( "%lu %d %p\n",
map->size, drm_order(map->size), map->handle );
if ( !map->handle ) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(ENOMEM);
}
map->offset = (unsigned long)map->handle;
@@ -114,8 +114,8 @@ int drm_addmap(DRM_IOCTL_ARGS)
DRM_LOCK();
if (dev->lock.hw_lock != NULL) {
DRM_UNLOCK();
- drm_free(map->handle, map->size, DRM_MEM_SAREA);
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map->handle, M_DRM);
+ free(map, M_DRM);
return DRM_ERR(EBUSY);
}
dev->lock.hw_lock = map->handle; /* Pointer to lock */
@@ -128,20 +128,20 @@ int drm_addmap(DRM_IOCTL_ARGS)
break;
case _DRM_SCATTER_GATHER:
if (!dev->sg) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
map->offset = map->offset + dev->sg->handle;
break;
default:
- drm_free( map, sizeof(*map), DRM_MEM_MAPS );
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
- list = drm_calloc(1, sizeof(*list), DRM_MEM_MAPS);
+ list = malloc(sizeof(*list), M_DRM, M_NOWAIT | M_ZERO);
if (list == NULL) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return DRM_ERR(EINVAL);
}
list->map = map;
@@ -196,7 +196,7 @@ int drm_rmmap(DRM_IOCTL_ARGS)
TAILQ_REMOVE(dev->maplist, list, link);
DRM_UNLOCK();
- drm_free(list, sizeof(*list), DRM_MEM_MAPS);
+ free(list, M_DRM);
switch (map->type) {
case _DRM_REGISTERS:
@@ -211,13 +211,13 @@ int drm_rmmap(DRM_IOCTL_ARGS)
drm_ioremapfree(map);
break;
case _DRM_SHM:
- drm_free(map->handle, map->size, DRM_MEM_SAREA);
+ free(map->handle, M_DRM);
break;
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
break;
}
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(map, M_DRM);
return 0;
}
@@ -228,30 +228,21 @@ static void drm_cleanup_buf_error(drm_device_t *dev, drm_buf_entry_t *entry)
if (entry->seg_count) {
for (i = 0; i < entry->seg_count; i++) {
- if (entry->seglist[i] != 0)
- drm_pci_free(dev, entry->buf_size,
- (void *)entry->seglist[i],
- entry->seglist_bus[i]);
+ drm_pci_free(dev, entry->buf_size,
+ (void *)entry->seglist[i],
+ entry->seglist_bus[i]);
}
- drm_free(entry->seglist,
- entry->seg_count *
- sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- drm_free(entry->seglist_bus, entry->seg_count *
- sizeof(*entry->seglist_bus), DRM_MEM_SEGS);
+ free(entry->seglist, M_DRM);
+ free(entry->seglist_bus, M_DRM);
entry->seg_count = 0;
}
if (entry->buf_count) {
for (i = 0; i < entry->buf_count; i++) {
- drm_free(entry->buflist[i].dev_private,
- entry->buflist[i].dev_priv_size, DRM_MEM_BUFS);
+ free(entry->buflist[i].dev_private, M_DRM);
}
- drm_free(entry->buflist,
- entry->buf_count *
- sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ free(entry->buflist, M_DRM);
entry->buf_count = 0;
}
@@ -296,12 +287,11 @@ static int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+ M_NOWAIT | M_ZERO);
if ( !entry->buflist ) {
return DRM_ERR(ENOMEM);
}
- memset( entry->buflist, 0, count * sizeof(*entry->buflist) );
entry->buf_size = size;
entry->page_order = page_order;
@@ -323,8 +313,8 @@ static int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = drm_calloc(1, buf->dev_priv_size,
- DRM_MEM_BUFS);
+ buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
+ M_NOWAIT | M_ZERO);
if (buf->dev_private == NULL) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
@@ -339,11 +329,9 @@ static int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
- temp_buflist = drm_realloc(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS );
+ temp_buflist = realloc(dma->buflist,
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
+ M_NOWAIT);
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
@@ -403,32 +391,26 @@ static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- entry->seglist_bus = drm_alloc(count * sizeof(*entry->seglist_bus),
- DRM_MEM_SEGS);
+ entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+ M_NOWAIT | M_ZERO);
+ entry->seglist = malloc(count * sizeof(*entry->seglist), M_DRM,
+ M_NOWAIT | M_ZERO);
+ entry->seglist_bus = malloc(count * sizeof(*entry->seglist_bus), M_DRM,
+ M_NOWAIT | M_ZERO);
/* Keep the original pagelist until we know all the allocations
* have succeeded
*/
- temp_pagelist = drm_alloc((dma->page_count + (count << page_order)) *
- sizeof(*dma->pagelist), DRM_MEM_PAGES);
+ temp_pagelist = malloc((dma->page_count + (count << page_order)) *
+ sizeof(*dma->pagelist), M_DRM, M_NOWAIT);
if (entry->buflist == NULL || entry->seglist == NULL ||
- temp_pagelist == NULL) {
- drm_free(entry->buflist, count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- drm_free(entry->seglist, count * sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- drm_free(entry->seglist_bus, count *
- sizeof(*entry->seglist_bus), DRM_MEM_SEGS);
+ entry->seglist_bus == NULL || temp_pagelist == NULL) {
+ free(entry->buflist, M_DRM);
+ free(entry->seglist, M_DRM);
+ free(entry->seglist_bus, M_DRM);
return DRM_ERR(ENOMEM);
}
-
- bzero(entry->buflist, count * sizeof(*entry->buflist));
- bzero(entry->seglist, count * sizeof(*entry->seglist));
memcpy(temp_pagelist, dma->pagelist, dma->page_count *
sizeof(*dma->pagelist));
@@ -449,9 +431,7 @@ static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
entry->buf_count = count;
entry->seg_count = count;
drm_cleanup_buf_error(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
+ free(temp_pagelist, M_DRM);
return DRM_ERR(ENOMEM);
}
@@ -480,19 +460,16 @@ static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = drm_alloc(buf->dev_priv_size,
- DRM_MEM_BUFS);
+ buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
+ M_NOWAIT | M_ZERO);
if (buf->dev_private == NULL) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
entry->seg_count = count;
drm_cleanup_buf_error(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) *
- sizeof(*dma->pagelist), DRM_MEM_PAGES );
+ free(temp_pagelist, M_DRM);
return DRM_ERR(ENOMEM);
}
- bzero(buf->dev_private, buf->dev_priv_size);
DRM_DEBUG( "buffer %d @ %p\n",
entry->buf_count, buf->address );
@@ -500,17 +477,13 @@ static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
byte_count += PAGE_SIZE << page_order;
}
- temp_buflist = drm_realloc(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
+ temp_buflist = realloc(dma->buflist,
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
+ M_NOWAIT);
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
+ free(temp_pagelist, M_DRM);
return DRM_ERR(ENOMEM);
}
dma->buflist = temp_buflist;
@@ -522,8 +495,7 @@ static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
/* No allocations failed, so now we can replace the orginal pagelist
* with the new one.
*/
- drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
+ free(dma->pagelist, M_DRM);
dma->pagelist = temp_pagelist;
dma->buf_count += entry->buf_count;
@@ -577,8 +549,8 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = drm_calloc(1, count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+ M_NOWAIT | M_ZERO);
if (entry->buflist == NULL)
return DRM_ERR(ENOMEM);
@@ -602,8 +574,8 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = drm_calloc(1, buf->dev_priv_size,
- DRM_MEM_BUFS);
+ buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
+ M_NOWAIT | M_ZERO);
if (buf->dev_private == NULL) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
@@ -621,11 +593,9 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
- temp_buflist = drm_realloc(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS );
+ temp_buflist = realloc(dma->buflist,
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
+ M_NOWAIT);
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index 87185f4e..d785d361 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -73,12 +73,9 @@ int drm_ctxbitmap_next(drm_device_t *dev)
if (dev->context_sareas != NULL) {
drm_local_map_t **ctx_sareas;
- ctx_sareas = drm_realloc(dev->context_sareas,
- (dev->max_context - 1) *
- sizeof(*dev->context_sareas),
- dev->max_context *
- sizeof(*dev->context_sareas),
- DRM_MEM_MAPS);
+ ctx_sareas = realloc(dev->context_sareas,
+ dev->max_context * sizeof(*dev->context_sareas),
+ M_DRM, M_NOWAIT);
if (ctx_sareas == NULL) {
clear_bit(bit, dev->ctx_bitmap);
DRM_UNLOCK();
@@ -88,8 +85,8 @@ int drm_ctxbitmap_next(drm_device_t *dev)
dev->context_sareas[bit] = NULL;
} else {
/* max_context == 1 at this point */
- dev->context_sareas = drm_alloc(dev->max_context *
- sizeof(*dev->context_sareas), DRM_MEM_MAPS);
+ dev->context_sareas = malloc(dev->max_context *
+ sizeof(*dev->context_sareas), M_DRM, M_NOWAIT);
if (dev->context_sareas == NULL) {
clear_bit(bit, dev->ctx_bitmap);
DRM_UNLOCK();
@@ -108,8 +105,7 @@ int drm_ctxbitmap_init(drm_device_t *dev)
int temp;
DRM_LOCK();
- dev->ctx_bitmap = (atomic_t *)drm_calloc(1, PAGE_SIZE,
- DRM_MEM_CTXBITMAP);
+ dev->ctx_bitmap = malloc(PAGE_SIZE, M_DRM, M_NOWAIT | M_ZERO);
if ( dev->ctx_bitmap == NULL ) {
DRM_UNLOCK();
return DRM_ERR(ENOMEM);
@@ -130,9 +126,8 @@ void drm_ctxbitmap_cleanup(drm_device_t *dev)
{
DRM_LOCK();
if (dev->context_sareas != NULL)
- drm_free(dev->context_sareas, sizeof(*dev->context_sareas) *
- dev->max_context, DRM_MEM_MAPS);
- drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
+ free(dev->context_sareas, M_DRM);
+ free(dev->ctx_bitmap, M_DRM);
DRM_UNLOCK();
}
diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c
index 28828703..f421eb8f 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -35,7 +35,7 @@
int drm_dma_setup(drm_device_t *dev)
{
- dev->dma = drm_calloc(1, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ dev->dma = malloc(sizeof(*dev->dma), M_DRM, M_NOWAIT | M_ZERO);
if (dev->dma == NULL)
return DRM_ERR(ENOMEM);
@@ -61,39 +61,26 @@ void drm_dma_takedown(drm_device_t *dev)
dma->bufs[i].buf_count,
dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) {
- if (dma->bufs[i].seglist[j] != 0)
- drm_pci_free(dev, dma->bufs[i].buf_size,
- (void *)dma->bufs[i].seglist[j],
- dma->bufs[i].seglist_bus[j]);
+ drm_pci_free(dev, dma->bufs[i].buf_size,
+ (void *)dma->bufs[i].seglist[j],
+ dma->bufs[i].seglist_bus[j]);
}
- drm_free(dma->bufs[i].seglist,
- dma->bufs[i].seg_count
- * sizeof(*dma->bufs[0].seglist),
- DRM_MEM_SEGS);
- drm_free(dma->bufs[i].seglist_bus,
- dma->bufs[i].seg_count
- * sizeof(*dma->bufs[0].seglist_bus),
- DRM_MEM_SEGS);
+ free(dma->bufs[i].seglist, M_DRM);
+ free(dma->bufs[i].seglist_bus, M_DRM);
}
if (dma->bufs[i].buf_count) {
for (j = 0; j < dma->bufs[i].buf_count; j++) {
- drm_free(dma->bufs[i].buflist[j].dev_private,
- dma->bufs[i].buflist[j].dev_priv_size,
- DRM_MEM_BUFS);
+ free(dma->bufs[i].buflist[j].dev_private,
+ M_DRM);
}
- drm_free(dma->bufs[i].buflist,
- dma->bufs[i].buf_count *
- sizeof(*dma->bufs[0].buflist),
- DRM_MEM_BUFS);
+ free(dma->bufs[i].buflist, M_DRM);
}
}
- drm_free(dma->buflist, dma->buf_count * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ free(dma->buflist, M_DRM);
+ free(dma->pagelist, M_DRM);
+ free(dev->dma, M_DRM);
dev->dma = NULL;
DRM_SPINUNINIT(dev->dma_lock);
}
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 21cf8f79..7880f76c 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -275,8 +275,7 @@ void drm_attach(struct pci_attach_args *pa, dev_t kdev,
drm_device_t *dev;
config_makeroom(kdev, &drm_cd);
- drm_cd.cd_devs[(kdev)] = drm_alloc(sizeof(drm_device_t),
- DRM_MEM_DRIVER);
+ drm_cd.cd_devs[(kdev)] = malloc(sizeof(drm_device_t), M_DRM, M_WAITOK);
dev = DRIVER_SOFTC(kdev);
memset(dev, 0, sizeof(drm_device_t));
@@ -393,8 +392,7 @@ static int drm_takedown(drm_device_t *dev)
drm_irq_uninstall(dev);
if ( dev->unique ) {
- drm_free(dev->unique, strlen( dev->unique ) + 1,
- DRM_MEM_DRIVER);
+ free(dev->unique, M_DRM);
dev->unique = NULL;
dev->unique_len = 0;
}
@@ -402,7 +400,7 @@ static int drm_takedown(drm_device_t *dev)
for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) {
for ( pt = dev->magiclist[i].head ; pt ; pt = next ) {
next = pt->next;
- drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ free(pt, M_DRM);
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
@@ -419,7 +417,7 @@ static int drm_takedown(drm_device_t *dev)
if ( entry->bound )
drm_agp_unbind_memory(entry->handle);
drm_agp_free_memory(entry->handle);
- drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ free(entry, M_DRM);
}
dev->agp->memory = NULL;
@@ -451,9 +449,7 @@ static int drm_takedown(drm_device_t *dev)
}
break;
case _DRM_SHM:
- drm_free(map->handle,
- map->size,
- DRM_MEM_SAREA);
+ free(map->handle, M_DRM);
break;
case _DRM_AGP:
@@ -464,8 +460,8 @@ static int drm_takedown(drm_device_t *dev)
break;
}
TAILQ_REMOVE(dev->maplist, list, link);
- drm_free(list, sizeof(*list), DRM_MEM_MAPS);
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ free(list, M_DRM);
+ free(map, M_DRM);
}
}
@@ -526,7 +522,7 @@ static int drm_init(device_t nbdev)
dev->pci_slot = pci_get_slot(dev->device);
dev->pci_func = pci_get_function(dev->device);
- dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ dev->maplist = malloc(sizeof(*dev->maplist), M_DRM, M_WAITOK);
if (dev->maplist == NULL) {
retcode = ENOMEM;
goto error;
@@ -585,7 +581,7 @@ error:
mtx_destroy(&dev->dev_lock);
#endif
#endif
- drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ free(dev->maplist, M_DRM);
return retcode;
}
@@ -619,7 +615,7 @@ static void drm_cleanup(drm_device_t *dev)
if ( dev->agp ) {
drm_agp_uninit();
- drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ free(dev->agp, M_DRM);
dev->agp = NULL;
}
@@ -630,7 +626,7 @@ static void drm_cleanup(drm_device_t *dev)
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
mtx_destroy(&dev->dev_lock);
#endif
- drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ free(dev->maplist, M_DRM);
}
@@ -783,7 +779,7 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if (--priv->refs == 0) {
TAILQ_REMOVE(&dev->files, priv, link);
- drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ free(priv, M_DRM);
}
/* ========================================================
diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c
index 072a6e22..eeb4847a 100644
--- a/bsd-core/drm_fops.c
+++ b/bsd-core/drm_fops.c
@@ -70,12 +70,11 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
if (priv) {
priv->refs++;
} else {
- priv = (drm_file_t *)drm_alloc(sizeof(*priv), DRM_MEM_FILES);
+ priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO);
if (priv == NULL) {
DRM_UNLOCK();
return DRM_ERR(ENOMEM);
}
- bzero(priv, sizeof(*priv));
#if __FreeBSD_version >= 500000
priv->uid = p->td_ucred->cr_svuid;
priv->pid = p->td_proc->p_pid;
diff --git a/bsd-core/drm_ioctl.c b/bsd-core/drm_ioctl.c
index 014c6b4e..829a99fe 100644
--- a/bsd-core/drm_ioctl.c
+++ b/bsd-core/drm_ioctl.c
@@ -74,7 +74,7 @@ int drm_setunique(DRM_IOCTL_ARGS)
return DRM_ERR(EINVAL);
dev->unique_len = u.unique_len;
- dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
+ dev->unique = malloc(u.unique_len + 1, M_DRM, M_NOWAIT);
if (dev->unique == NULL)
return DRM_ERR(ENOMEM);
@@ -111,7 +111,7 @@ drm_set_busid(drm_device_t *dev)
return EBUSY;
dev->unique_len = 20;
- dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
+ dev->unique = malloc(dev->unique_len + 1, M_DRM, M_NOWAIT);
if (dev->unique == NULL)
return ENOMEM;
diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c
index 32ad5a61..eb32bac4 100644
--- a/bsd-core/drm_irq.c
+++ b/bsd-core/drm_irq.c
@@ -224,11 +224,11 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
if (flags & _DRM_VBLANK_SIGNAL) {
#if 0 /* disabled */
- drm_vbl_sig_t *vbl_sig = DRM_MALLOC(sizeof(drm_vbl_sig_t));
+ drm_vbl_sig_t *vbl_sig = malloc(sizeof(drm_vbl_sig_t), M_DRM,
+ M_NOWAIT | M_ZERO);
if (vbl_sig == NULL)
return ENOMEM;
- bzero(vbl_sig, sizeof(*vbl_sig));
-
+
vbl_sig->sequence = vblwait.request.sequence;
vbl_sig->signo = vblwait.request.signal;
vbl_sig->pid = DRM_CURRENTPID;
diff --git a/bsd-core/drm_pci.c b/bsd-core/drm_pci.c
index 07b8a643..4c8941d0 100644
--- a/bsd-core/drm_pci.c
+++ b/bsd-core/drm_pci.c
@@ -58,6 +58,8 @@ void
drm_pci_free(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr)
{
#if __FreeBSD_version > 500000
+ if (vaddr == NULL)
+ return;
contigfree(vaddr, size, M_DRM); /* Not available on 4.x */
#endif
}
diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c
index 82e6ef9a..03e82439 100644
--- a/bsd-core/drm_scatter.c
+++ b/bsd-core/drm_scatter.c
@@ -37,10 +37,8 @@ void drm_sg_cleanup(drm_sg_mem_t *entry)
{
free(entry->virtual, M_DRM);
- drm_free(entry->busaddr,
- entry->pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
- drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
+ free(entry->busaddr, M_DRM);
+ free(entry, M_DRM);
}
int drm_sg_alloc(DRM_IOCTL_ARGS)
@@ -58,36 +56,29 @@ int drm_sg_alloc(DRM_IOCTL_ARGS)
DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
sizeof(request) );
- entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
+ entry = malloc(sizeof(*entry), M_DRM, M_NOWAIT | M_ZERO);
if ( !entry )
return ENOMEM;
- bzero( entry, sizeof(*entry) );
-
pages = round_page(request.size) / PAGE_SIZE;
DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
entry->pages = pages;
- entry->busaddr = drm_alloc(pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES);
+ entry->busaddr = malloc(pages * sizeof(*entry->busaddr), M_DRM,
+ M_NOWAIT | M_ZERO);
if ( !entry->busaddr ) {
- drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
+ free(entry, M_DRM);
return ENOMEM;
}
- bzero( (void *)entry->busaddr, pages * sizeof(*entry->busaddr) );
- entry->virtual = malloc(pages << PAGE_SHIFT, M_DRM, M_WAITOK);
+ entry->virtual = malloc(pages << PAGE_SHIFT, M_DRM, M_WAITOK | M_ZERO);
if ( !entry->virtual ) {
- drm_free(entry->busaddr,
- entry->pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES);
- drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
+ free(entry->busaddr, M_DRM);
+ free(entry, M_DRM);
return ENOMEM;
}
- bzero( entry->virtual, pages << PAGE_SHIFT );
-
entry->handle = (unsigned long)entry->virtual;
DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );
diff --git a/bsd-core/drm_sysctl.c b/bsd-core/drm_sysctl.c
index 09cba5b9..d1a3dd8f 100644
--- a/bsd-core/drm_sysctl.c
+++ b/bsd-core/drm_sysctl.c
@@ -55,10 +55,9 @@ int drm_sysctl_init(drm_device_t *dev)
struct sysctl_oid *top, *drioid;
int i;
- info = drm_alloc(sizeof *info, DRM_MEM_DRIVER);
+ info = malloc(sizeof *info, M_DRM, M_WAITOK | M_ZERO);
if ( !info )
return 1;
- bzero(info, sizeof *info);
dev->sysctl = info;
/* Add the sysctl node for DRI if it doesn't already exist */
@@ -108,7 +107,7 @@ int drm_sysctl_cleanup(drm_device_t *dev)
int error;
error = sysctl_ctx_free( &dev->sysctl->ctx );
- drm_free(dev->sysctl, sizeof *dev->sysctl, DRM_MEM_DRIVER);
+ free(dev->sysctl, M_DRM);
dev->sysctl = NULL;
return error;
@@ -167,7 +166,7 @@ static int drm_vm_info DRM_SYSCTL_HANDLER_ARGS
TAILQ_FOREACH(listentry, dev->maplist, link)
mapcount++;
- tempmaps = drm_alloc(sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
+ tempmaps = malloc(sizeof(drm_local_map_t) * mapcount, M_DRM, M_NOWAIT);
if (tempmaps == NULL) {
DRM_UNLOCK();
return ENOMEM;
@@ -203,7 +202,7 @@ static int drm_vm_info DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- drm_free(tempmaps, sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
+ free(tempmaps, M_DRM);
return retcode;
}
@@ -227,7 +226,7 @@ static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS
}
DRM_SPINLOCK(&dev->dma_lock);
tempdma = *dma;
- templists = drm_alloc(sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
+ templists = malloc(sizeof(int) * dma->buf_count, M_DRM, M_NOWAIT);
for (i = 0; i < dma->buf_count; i++)
templists[i] = dma->buflist[i]->list;
dma = &tempdma;
@@ -259,7 +258,7 @@ static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- drm_free(templists, sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
+ free(templists, M_DRM);
return retcode;
}
@@ -277,7 +276,7 @@ static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS
TAILQ_FOREACH(priv, &dev->files, link)
privcount++;
- tempprivs = drm_alloc(sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
+ tempprivs = malloc(sizeof(drm_file_t) * privcount, M_DRM, M_NOWAIT);
if (tempprivs == NULL) {
DRM_UNLOCK();
return ENOMEM;
@@ -302,6 +301,6 @@ static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- drm_free(tempprivs, sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
+ free(tempprivs, M_DRM);
return retcode;
}