Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2008 18:03:27 +0000 (UTC)
From:      Robert Noland <rnoland@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r183833 - head/sys/dev/drm
Message-ID:  <200810131803.m9DI3R1o082570@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rnoland
Date: Mon Oct 13 18:03:27 2008
New Revision: 183833
URL: http://svn.freebsd.org/changeset/base/183833

Log:
  Rework memory allocation to allocate memory with different type names.  This
  will ease the identification of memory leaks as the OS will be able to track
  allocations for us by malloc type.  vmstat -m will show all of the
  allocations.
  
  Convert the calls to drm_alloc() and friends, which are used in shared code
  to static __inline__ while we are here.
  
  Approved by:	jhb (mentor)

Modified:
  head/sys/dev/drm/ati_pcigart.c
  head/sys/dev/drm/drmP.h
  head/sys/dev/drm/drm_agpsupport.c
  head/sys/dev/drm/drm_auth.c
  head/sys/dev/drm/drm_bufs.c
  head/sys/dev/drm/drm_context.c
  head/sys/dev/drm/drm_dma.c
  head/sys/dev/drm/drm_drv.c
  head/sys/dev/drm/drm_fops.c
  head/sys/dev/drm/drm_ioctl.c
  head/sys/dev/drm/drm_irq.c
  head/sys/dev/drm/drm_memory.c
  head/sys/dev/drm/drm_pci.c
  head/sys/dev/drm/drm_scatter.c
  head/sys/dev/drm/drm_sysctl.c
  head/sys/dev/drm/i915_drv.c
  head/sys/dev/drm/mach64_drv.c
  head/sys/dev/drm/mga_drv.c
  head/sys/dev/drm/r128_drv.c
  head/sys/dev/drm/radeon_drv.c
  head/sys/dev/drm/savage_drv.c
  head/sys/dev/drm/sis_drv.c
  head/sys/dev/drm/tdfx_drv.c

Modified: head/sys/dev/drm/ati_pcigart.c
==============================================================================
--- head/sys/dev/drm/ati_pcigart.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/ati_pcigart.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -64,7 +64,8 @@ drm_ati_alloc_pcigart_table(struct drm_d
 	struct drm_dma_handle *dmah;
 	int flags, ret;
 
-	dmah = malloc(sizeof(struct drm_dma_handle), M_DRM, M_ZERO | M_NOWAIT);
+	dmah = malloc(sizeof(struct drm_dma_handle), DRM_MEM_DMA,
+	    M_ZERO | M_NOWAIT);
 	if (dmah == NULL)
 		return ENOMEM;
 
@@ -77,7 +78,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
 	    BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */
 	    &dmah->tag);
 	if (ret != 0) {
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return ENOMEM;
 	}
 
@@ -88,7 +89,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
 	ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, flags, &dmah->map);
 	if (ret != 0) {
 		bus_dma_tag_destroy(dmah->tag);
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return ENOMEM;
 	}
 	DRM_LOCK();
@@ -98,7 +99,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
 	if (ret != 0) {
 		bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
 		bus_dma_tag_destroy(dmah->tag);
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return ENOMEM;
 	}
 
@@ -115,7 +116,7 @@ drm_ati_free_pcigart_table(struct drm_de
 
 	bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
 	bus_dma_tag_destroy(dmah->tag);
-	free(dmah, M_DRM);
+	free(dmah, DRM_MEM_DMA);
 	dev->sg->dmah = NULL;
 }
 

Modified: head/sys/dev/drm/drmP.h
==============================================================================
--- head/sys/dev/drm/drmP.h	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drmP.h	Mon Oct 13 18:03:27 2008	(r183833)
@@ -129,27 +129,24 @@ struct drm_file;
 #define DRM_KERNEL_CONTEXT    0	 /* Change drm_resctx if changed	  */
 #define DRM_RESERVED_CONTEXTS 1	 /* Change drm_resctx if changed	  */
 
-#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_BUFS	   6
-#define DRM_MEM_SEGS	   7
-#define DRM_MEM_PAGES	   8
-#define DRM_MEM_FILES	  9
-#define DRM_MEM_QUEUES	  10
-#define DRM_MEM_CMDS	  11
-#define DRM_MEM_MAPPINGS  12
-#define DRM_MEM_BUFLISTS  13
-#define DRM_MEM_AGPLISTS  14
-#define DRM_MEM_TOTALAGP  15
-#define DRM_MEM_BOUNDAGP  16
-#define DRM_MEM_CTXBITMAP 17
-#define DRM_MEM_STUB	  18
-#define DRM_MEM_SGLISTS	  19
-#define DRM_MEM_DRAWABLE  20
+MALLOC_DECLARE(DRM_MEM_DMA);
+MALLOC_DECLARE(DRM_MEM_SAREA);
+MALLOC_DECLARE(DRM_MEM_DRIVER);
+MALLOC_DECLARE(DRM_MEM_MAGIC);
+MALLOC_DECLARE(DRM_MEM_IOCTLS);
+MALLOC_DECLARE(DRM_MEM_MAPS);
+MALLOC_DECLARE(DRM_MEM_BUFS);
+MALLOC_DECLARE(DRM_MEM_SEGS);
+MALLOC_DECLARE(DRM_MEM_PAGES);
+MALLOC_DECLARE(DRM_MEM_FILES);
+MALLOC_DECLARE(DRM_MEM_QUEUES);
+MALLOC_DECLARE(DRM_MEM_CMDS);
+MALLOC_DECLARE(DRM_MEM_MAPPINGS);
+MALLOC_DECLARE(DRM_MEM_BUFLISTS);
+MALLOC_DECLARE(DRM_MEM_AGPLISTS);
+MALLOC_DECLARE(DRM_MEM_CTXBITMAP);
+MALLOC_DECLARE(DRM_MEM_SGLISTS);
+MALLOC_DECLARE(DRM_MEM_DRAWABLE);
 
 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 
@@ -160,8 +157,6 @@ struct drm_file;
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
-MALLOC_DECLARE(M_DRM);
-
 #define __OS_HAS_AGP	1
 
 #define DRM_DEV_MODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
@@ -748,11 +743,6 @@ extern int		drm_open_helper(struct cdev 
 /* Memory management support (drm_memory.c) */
 void	drm_mem_init(void);
 void	drm_mem_uninit(void);
-void	*drm_alloc(size_t size, int area);
-void	*drm_calloc(size_t nmemb, size_t size, int area);
-void	*drm_realloc(void *oldpt, size_t oldsize, size_t size,
-				   int area);
-void	drm_free(void *pt, size_t size, int area);
 void	*drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
 void	*drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
 void	drm_ioremapfree(drm_local_map_t *map);
@@ -966,6 +956,32 @@ drm_dma_handle_t *drm_pci_alloc(struct d
 				size_t align, dma_addr_t maxaddr);
 void	drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
 
+/* Inline replacements for drm_alloc and friends */
+static __inline__ void *
+drm_alloc(size_t size, struct malloc_type *area)
+{
+	return malloc(size, area, M_NOWAIT);
+}
+
+static __inline__ void *
+drm_calloc(size_t nmemb, size_t size, struct malloc_type *area)
+{
+	return malloc(size * nmemb, area, M_NOWAIT | M_ZERO);
+}
+
+static __inline__ void *
+drm_realloc(void *oldpt, size_t oldsize, size_t size,
+    struct malloc_type *area)
+{
+	return reallocf(oldpt, size, area, M_NOWAIT);
+}
+
+static __inline__ void
+drm_free(void *pt, size_t size, struct malloc_type *area)
+{
+	free(pt, area);
+}
+
 /* Inline replacements for DRM_IOREMAP macros */
 static __inline__ void
 drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)

Modified: head/sys/dev/drm/drm_agpsupport.c
==============================================================================
--- head/sys/dev/drm/drm_agpsupport.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_agpsupport.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -212,7 +212,7 @@ int drm_agp_alloc(struct drm_device *dev
 	if (!dev->agp || !dev->agp->acquired)
 		return EINVAL;
 
-	entry = malloc(sizeof(*entry), M_DRM, M_NOWAIT | M_ZERO);
+	entry = malloc(sizeof(*entry), DRM_MEM_AGPLISTS, M_NOWAIT | M_ZERO);
 	if (entry == NULL)
 		return ENOMEM;
 
@@ -223,7 +223,7 @@ int drm_agp_alloc(struct drm_device *dev
 	handle = drm_agp_allocate_memory(pages, type);
 	DRM_LOCK();
 	if (handle == NULL) {
-		free(entry, M_DRM);
+		free(entry, DRM_MEM_AGPLISTS);
 		return ENOMEM;
 	}
 	
@@ -374,7 +374,7 @@ int drm_agp_free(struct drm_device *dev,
 	drm_agp_free_memory(entry->handle);
 	DRM_LOCK();
 
-	free(entry, M_DRM);
+	free(entry, DRM_MEM_AGPLISTS);
 
 	return 0;
 
@@ -408,7 +408,8 @@ drm_agp_head_t *drm_agp_init(void)
 	DRM_DEBUG("agp_available = %d\n", agp_available);
 
 	if (agp_available) {
-		head = malloc(sizeof(*head), M_DRM, M_NOWAIT | M_ZERO);
+		head = malloc(sizeof(*head), DRM_MEM_AGPLISTS,
+		    M_NOWAIT | M_ZERO);
 		if (head == NULL)
 			return NULL;
 		head->agpdev = agpdev;

Modified: head/sys/dev/drm/drm_auth.c
==============================================================================
--- head/sys/dev/drm/drm_auth.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_auth.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -77,7 +77,7 @@ static int drm_add_magic(struct drm_devi
 	DRM_SPINLOCK_ASSERT(&dev->dev_lock);
 
 	hash = drm_hash_magic(magic);
-	entry = malloc(sizeof(*entry), M_DRM, M_ZERO | M_NOWAIT);
+	entry = malloc(sizeof(*entry), DRM_MEM_MAGIC, M_ZERO | M_NOWAIT);
 	if (!entry)
 		return ENOMEM;
 	entry->magic = magic;
@@ -121,7 +121,7 @@ static int drm_remove_magic(struct drm_d
 			if (prev) {
 				prev->next = pt->next;
 			}
-			free(pt, M_DRM);
+			free(pt, DRM_MEM_MAGIC);
 			return 0;
 		}
 	}

Modified: head/sys/dev/drm/drm_bufs.c
==============================================================================
--- head/sys/dev/drm/drm_bufs.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_bufs.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -138,7 +138,7 @@ int drm_addmap(struct drm_device * dev, 
 	/* Allocate a new map structure, fill it in, and do any type-specific
 	 * initialization necessary.
 	 */
-	map = malloc(sizeof(*map), M_DRM, M_ZERO | M_NOWAIT);
+	map = malloc(sizeof(*map), DRM_MEM_MAPS, M_ZERO | M_NOWAIT);
 	if (!map) {
 		DRM_LOCK();
 		return ENOMEM;
@@ -160,11 +160,11 @@ int drm_addmap(struct drm_device * dev, 
 			map->mtrr = 1;
 		break;
 	case _DRM_SHM:
-		map->handle = malloc(map->size, M_DRM, M_NOWAIT);
+		map->handle = malloc(map->size, DRM_MEM_MAPS, M_NOWAIT);
 		DRM_DEBUG("%lu %d %p\n",
 		    map->size, drm_order(map->size), map->handle);
 		if (!map->handle) {
-			free(map, M_DRM);
+			free(map, DRM_MEM_MAPS);
 			DRM_LOCK();
 			return ENOMEM;
 		}
@@ -174,8 +174,8 @@ int drm_addmap(struct drm_device * dev, 
 			DRM_LOCK();
 			if (dev->lock.hw_lock != NULL) {
 				DRM_UNLOCK();
-				free(map->handle, M_DRM);
-				free(map, M_DRM);
+				free(map->handle, DRM_MEM_MAPS);
+				free(map, DRM_MEM_MAPS);
 				return EBUSY;
 			}
 			dev->lock.hw_lock = map->handle; /* Pointer to lock */
@@ -205,14 +205,14 @@ int drm_addmap(struct drm_device * dev, 
 			}
 		}
 		if (!valid) {
-			free(map, M_DRM);
+			free(map, DRM_MEM_MAPS);
 			DRM_LOCK();
 			return EACCES;
 		}*/
 		break;
 	case _DRM_SCATTER_GATHER:
 		if (!dev->sg) {
-			free(map, M_DRM);
+			free(map, DRM_MEM_MAPS);
 			DRM_LOCK();
 			return EINVAL;
 		}
@@ -230,7 +230,7 @@ int drm_addmap(struct drm_device * dev, 
 			align = PAGE_SIZE;
 		map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful);
 		if (map->dmah == NULL) {
-			free(map, M_DRM);
+			free(map, DRM_MEM_MAPS);
 			DRM_LOCK();
 			return ENOMEM;
 		}
@@ -239,7 +239,7 @@ int drm_addmap(struct drm_device * dev, 
 		break;
 	default:
 		DRM_ERROR("Bad map type %d\n", map->type);
-		free(map, M_DRM);
+		free(map, DRM_MEM_MAPS);
 		DRM_LOCK();
 		return EINVAL;
 	}
@@ -313,7 +313,7 @@ void drm_rmmap(struct drm_device *dev, d
 		}
 		break;
 	case _DRM_SHM:
-		free(map->handle, M_DRM);
+		free(map->handle, DRM_MEM_MAPS);
 		break;
 	case _DRM_AGP:
 	case _DRM_SCATTER_GATHER:
@@ -331,7 +331,7 @@ void drm_rmmap(struct drm_device *dev, d
 		    map->bsr);
 	}
 
-	free(map, M_DRM);
+	free(map, DRM_MEM_MAPS);
 }
 
 /* Remove a map private from list and deallocate resources if the mapping
@@ -374,16 +374,16 @@ static void drm_cleanup_buf_error(struct
 		for (i = 0; i < entry->seg_count; i++) {
 			drm_pci_free(dev, entry->seglist[i]);
 		}
-		free(entry->seglist, M_DRM);
+		free(entry->seglist, DRM_MEM_SEGS);
 
 		entry->seg_count = 0;
 	}
 
    	if (entry->buf_count) {
 	   	for (i = 0; i < entry->buf_count; i++) {
-			free(entry->buflist[i].dev_private, M_DRM);
+			free(entry->buflist[i].dev_private, DRM_MEM_BUFS);
 		}
-		free(entry->buflist, M_DRM);
+		free(entry->buflist, DRM_MEM_BUFS);
 
 		entry->buf_count = 0;
 	}
@@ -450,7 +450,7 @@ static int drm_do_addbufs_agp(struct drm
 
 	entry = &dma->bufs[order];
 
-	entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+	entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
 	    M_NOWAIT | M_ZERO);
 	if (!entry->buflist) {
 		return ENOMEM;
@@ -476,7 +476,7 @@ static int drm_do_addbufs_agp(struct drm
 		buf->file_priv = NULL;
 
 		buf->dev_priv_size = dev->driver->buf_priv_size;
-		buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
+		buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS,
 		    M_NOWAIT | M_ZERO);
 		if (buf->dev_private == NULL) {
 			/* Set count correctly so we free the proper amount. */
@@ -493,8 +493,8 @@ static int drm_do_addbufs_agp(struct drm
 	DRM_DEBUG("byte_count: %d\n", byte_count);
 
 	temp_buflist = realloc(dma->buflist,
-	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
-	    M_NOWAIT);
+	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
+	    DRM_MEM_BUFS, M_NOWAIT);
 	if (temp_buflist == NULL) {
 		/* Free the entry because it isn't valid */
 		drm_cleanup_buf_error(dev, entry);
@@ -552,22 +552,22 @@ static int drm_do_addbufs_pci(struct drm
 
 	entry = &dma->bufs[order];
 
-	entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+	entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
 	    M_NOWAIT | M_ZERO);
-	entry->seglist = malloc(count * sizeof(*entry->seglist), M_DRM,
+	entry->seglist = malloc(count * sizeof(*entry->seglist), DRM_MEM_SEGS,
 	    M_NOWAIT | M_ZERO);
 
 	/* Keep the original pagelist until we know all the allocations
 	 * have succeeded
 	 */
 	temp_pagelist = malloc((dma->page_count + (count << page_order)) *
-	    sizeof(*dma->pagelist), M_DRM, M_NOWAIT);
+	    sizeof(*dma->pagelist), DRM_MEM_PAGES, M_NOWAIT);
 
 	if (entry->buflist == NULL || entry->seglist == NULL || 
 	    temp_pagelist == NULL) {
-		free(temp_pagelist, M_DRM);
-		free(entry->seglist, M_DRM);
-		free(entry->buflist, M_DRM);
+		free(temp_pagelist, DRM_MEM_PAGES);
+		free(entry->seglist, DRM_MEM_SEGS);
+		free(entry->buflist, DRM_MEM_BUFS);
 		return ENOMEM;
 	}
 
@@ -592,7 +592,7 @@ static int drm_do_addbufs_pci(struct drm
 			entry->buf_count = count;
 			entry->seg_count = count;
 			drm_cleanup_buf_error(dev, entry);
-			free(temp_pagelist, M_DRM);
+			free(temp_pagelist, DRM_MEM_PAGES);
 			return ENOMEM;
 		}
 
@@ -620,14 +620,14 @@ static int drm_do_addbufs_pci(struct drm
 			buf->file_priv = NULL;
 
 			buf->dev_priv_size = dev->driver->buf_priv_size;
-			buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
-			    M_NOWAIT | M_ZERO);
+			buf->dev_private = malloc(buf->dev_priv_size,
+			    DRM_MEM_BUFS, 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);
-				free(temp_pagelist, M_DRM);
+				free(temp_pagelist, DRM_MEM_PAGES);
 				return ENOMEM;
 			}
 
@@ -638,12 +638,12 @@ static int drm_do_addbufs_pci(struct drm
 	}
 
 	temp_buflist = realloc(dma->buflist,
-	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
-	    M_NOWAIT);
+	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
+	    DRM_MEM_BUFS, M_NOWAIT);
 	if (temp_buflist == NULL) {
 		/* Free the entry because it isn't valid */
 		drm_cleanup_buf_error(dev, entry);
-		free(temp_pagelist, M_DRM);
+		free(temp_pagelist, DRM_MEM_PAGES);
 		return ENOMEM;
 	}
 	dma->buflist = temp_buflist;
@@ -655,7 +655,7 @@ static int drm_do_addbufs_pci(struct drm
 	/* No allocations failed, so now we can replace the orginal pagelist
 	 * with the new one.
 	 */
-	free(dma->pagelist, M_DRM);
+	free(dma->pagelist, DRM_MEM_PAGES);
 	dma->pagelist = temp_pagelist;
 
 	dma->buf_count += entry->buf_count;
@@ -709,7 +709,7 @@ static int drm_do_addbufs_sg(struct drm_
 
 	entry = &dma->bufs[order];
 
-	entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM,
+	entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS,
 	    M_NOWAIT | M_ZERO);
 	if (entry->buflist == NULL)
 		return ENOMEM;
@@ -734,7 +734,7 @@ static int drm_do_addbufs_sg(struct drm_
 		buf->file_priv = NULL;
 
 		buf->dev_priv_size = dev->driver->buf_priv_size;
-		buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
+		buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS,
 		    M_NOWAIT | M_ZERO);
 		if (buf->dev_private == NULL) {
 			/* Set count correctly so we free the proper amount. */
@@ -754,8 +754,8 @@ static int drm_do_addbufs_sg(struct drm_
 	DRM_DEBUG("byte_count: %d\n", byte_count);
 
 	temp_buflist = realloc(dma->buflist,
-	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
-	    M_NOWAIT);
+	    (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist),
+	    DRM_MEM_BUFS, M_NOWAIT);
 	if (temp_buflist == NULL) {
 		/* Free the entry because it isn't valid */
 		drm_cleanup_buf_error(dev, entry);

Modified: head/sys/dev/drm/drm_context.c
==============================================================================
--- head/sys/dev/drm/drm_context.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_context.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -80,7 +80,7 @@ int drm_ctxbitmap_next(struct drm_device
 
 			ctx_sareas = realloc(dev->context_sareas,
 			    dev->max_context * sizeof(*dev->context_sareas),
-			    M_DRM, M_NOWAIT);
+			    DRM_MEM_SAREA, M_NOWAIT);
 			if (ctx_sareas == NULL) {
 				clear_bit(bit, dev->ctx_bitmap);
 				DRM_UNLOCK();
@@ -91,7 +91,8 @@ int drm_ctxbitmap_next(struct drm_device
 		} else {
 			/* max_context == 1 at this point */
 			dev->context_sareas = malloc(dev->max_context * 
-			    sizeof(*dev->context_sareas), M_DRM, M_NOWAIT);
+			    sizeof(*dev->context_sareas), DRM_MEM_SAREA,
+			    M_NOWAIT);
 			if (dev->context_sareas == NULL) {
 				clear_bit(bit, dev->ctx_bitmap);
 				DRM_UNLOCK();
@@ -110,7 +111,8 @@ int drm_ctxbitmap_init(struct drm_device
    	int temp;
 
 	DRM_LOCK();
-	dev->ctx_bitmap = malloc(PAGE_SIZE, M_DRM, M_NOWAIT | M_ZERO);
+	dev->ctx_bitmap = malloc(PAGE_SIZE, DRM_MEM_CTXBITMAP,
+	    M_NOWAIT | M_ZERO);
 	if (dev->ctx_bitmap == NULL) {
 		DRM_UNLOCK();
 		return ENOMEM;
@@ -131,8 +133,8 @@ void drm_ctxbitmap_cleanup(struct drm_de
 {
 	DRM_LOCK();
 	if (dev->context_sareas != NULL)
-		free(dev->context_sareas, M_DRM);
-	free(dev->ctx_bitmap, M_DRM);
+		free(dev->context_sareas, DRM_MEM_SAREA);
+	free(dev->ctx_bitmap, DRM_MEM_CTXBITMAP);
 	DRM_UNLOCK();
 }
 

Modified: head/sys/dev/drm/drm_dma.c
==============================================================================
--- head/sys/dev/drm/drm_dma.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_dma.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
 int drm_dma_setup(struct drm_device *dev)
 {
 
-	dev->dma = malloc(sizeof(*dev->dma), M_DRM, M_NOWAIT | M_ZERO);
+	dev->dma = malloc(sizeof(*dev->dma), DRM_MEM_DRIVER, M_NOWAIT | M_ZERO);
 	if (dev->dma == NULL)
 		return ENOMEM;
 
@@ -70,21 +70,21 @@ void drm_dma_takedown(struct drm_device 
 			for (j = 0; j < dma->bufs[i].seg_count; j++) {
 				drm_pci_free(dev, dma->bufs[i].seglist[j]);
 			}
-			free(dma->bufs[i].seglist, M_DRM);
+			free(dma->bufs[i].seglist, DRM_MEM_SEGS);
 		}
 
 	   	if (dma->bufs[i].buf_count) {
 		   	for (j = 0; j < dma->bufs[i].buf_count; j++) {
 				free(dma->bufs[i].buflist[j].dev_private,
-				    M_DRM);
+				    DRM_MEM_BUFS);
 			}
-		   	free(dma->bufs[i].buflist, M_DRM);
+		   	free(dma->bufs[i].buflist, DRM_MEM_BUFS);
 		}
 	}
 
-	free(dma->buflist, M_DRM);
-	free(dma->pagelist, M_DRM);
-	free(dev->dma, M_DRM);
+	free(dma->buflist, DRM_MEM_BUFS);
+	free(dma->pagelist, DRM_MEM_PAGES);
+	free(dev->dma, DRM_MEM_DRIVER);
 	dev->dma = NULL;
 	DRM_SPINUNINIT(&dev->dma_lock);
 }

Modified: head/sys/dev/drm/drm_drv.c
==============================================================================
--- head/sys/dev/drm/drm_drv.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_drv.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -283,7 +283,7 @@ static int drm_lastclose(struct drm_devi
 		drm_irq_uninstall(dev);
 
 	if (dev->unique) {
-		free(dev->unique, M_DRM);
+		free(dev->unique, DRM_MEM_DRIVER);
 		dev->unique = NULL;
 		dev->unique_len = 0;
 	}
@@ -291,7 +291,7 @@ static int drm_lastclose(struct drm_devi
 	for (i = 0; i < DRM_HASH_SIZE; i++) {
 		for (pt = dev->magiclist[i].head; pt; pt = next) {
 			next = pt->next;
-			free(pt, M_DRM);
+			free(pt, DRM_MEM_MAGIC);
 		}
 		dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
 	}
@@ -313,7 +313,7 @@ static int drm_lastclose(struct drm_devi
 			if (entry->bound)
 				drm_agp_unbind_memory(entry->handle);
 			drm_agp_free_memory(entry->handle);
-			free(entry, M_DRM);
+			free(entry, DRM_MEM_AGPLISTS);
 		}
 		dev->agp->memory = NULL;
 
@@ -482,7 +482,7 @@ static void drm_unload(struct drm_device
 	}
 
 	if (dev->agp) {
-		free(dev->agp, M_DRM);
+		free(dev->agp, DRM_MEM_AGPLISTS);
 		dev->agp = NULL;
 	}
 
@@ -626,7 +626,7 @@ void drm_close(void *data)
 	if (dev->driver->postclose != NULL)
 		dev->driver->postclose(dev, file_priv);
 	TAILQ_REMOVE(&dev->files, file_priv, link);
-	free(file_priv, M_DRM);
+	free(file_priv, DRM_MEM_FILES);
 
 	/* ========================================================
 	 * End inline drm_release

Modified: head/sys/dev/drm/drm_fops.c
==============================================================================
--- head/sys/dev/drm/drm_fops.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_fops.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -53,14 +53,14 @@ int drm_open_helper(struct cdev *kdev, i
 
 	DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
 
-	priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO);
+	priv = malloc(sizeof(*priv), DRM_MEM_FILES, M_NOWAIT | M_ZERO);
 	if (priv == NULL) {
 		return ENOMEM;
 	}
 
 	retcode = devfs_set_cdevpriv(priv, drm_close);
 	if (retcode != 0) {
-		free(priv, M_DRM);
+		free(priv, DRM_MEM_FILES);
 		return retcode;
 	}
 
@@ -79,7 +79,7 @@ int drm_open_helper(struct cdev *kdev, i
 		retcode = -dev->driver->open(dev, priv);
 		if (retcode != 0) {
 			devfs_clear_cdevpriv();
-			free(priv, M_DRM);
+			free(priv, DRM_MEM_FILES);
 			DRM_UNLOCK();
 			return retcode;
 		}

Modified: head/sys/dev/drm/drm_ioctl.c
==============================================================================
--- head/sys/dev/drm/drm_ioctl.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_ioctl.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -72,12 +72,12 @@ int drm_setunique(struct drm_device *dev
 	if (!u->unique_len || u->unique_len > 1024)
 		return EINVAL;
 
-	busid = malloc(u->unique_len + 1, M_DRM, M_WAITOK);
+	busid = malloc(u->unique_len + 1, DRM_MEM_DRIVER, M_WAITOK);
 	if (busid == NULL)
 		return ENOMEM;
 
 	if (DRM_COPY_FROM_USER(busid, u->unique, u->unique_len)) {
-		free(busid, M_DRM);
+		free(busid, DRM_MEM_DRIVER);
 		return EFAULT;
 	}
 	busid[u->unique_len] = '\0';
@@ -87,7 +87,7 @@ int drm_setunique(struct drm_device *dev
 	 */
 	ret = sscanf(busid, "PCI:%d:%d:%d", &bus, &slot, &func);
 	if (ret != 3) {
-		free(busid, M_DRM);
+		free(busid, DRM_MEM_DRIVER);
 		return EINVAL;
 	}
 	domain = bus >> 8;
@@ -97,7 +97,7 @@ int drm_setunique(struct drm_device *dev
 	    (bus != dev->pci_bus) ||
 	    (slot != dev->pci_slot) ||
 	    (func != dev->pci_func)) {
-		free(busid, M_DRM);
+		free(busid, DRM_MEM_DRIVER);
 		return EINVAL;
 	}
 
@@ -128,7 +128,7 @@ drm_set_busid(struct drm_device *dev)
 	}
 
 	dev->unique_len = 20;
-	dev->unique = malloc(dev->unique_len + 1, M_DRM, M_NOWAIT);
+	dev->unique = malloc(dev->unique_len + 1, DRM_MEM_DRIVER, M_NOWAIT);
 	if (dev->unique == NULL) {
 		DRM_UNLOCK();
 		return ENOMEM;

Modified: head/sys/dev/drm/drm_irq.c
==============================================================================
--- head/sys/dev/drm/drm_irq.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_irq.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -114,8 +114,7 @@ static void drm_vblank_cleanup(struct dr
 
 	vblank_disable_fn((void *)dev);
 
-	drm_free(dev->vblank, sizeof(struct drm_vblank_info) * dev->num_crtcs,
-	    DRM_MEM_DRIVER);
+	free(dev->vblank, DRM_MEM_DRIVER);
 
 	dev->num_crtcs = 0;
 }
@@ -128,8 +127,8 @@ int drm_vblank_init(struct drm_device *d
 	atomic_set(&dev->vbl_signal_pending, 0);
 	dev->num_crtcs = num_crtcs;
 
-	dev->vblank = drm_calloc(num_crtcs, sizeof(struct drm_vblank_info),
-	    DRM_MEM_DRIVER);
+	dev->vblank = malloc(sizeof(struct drm_vblank_info) * num_crtcs,
+	    DRM_MEM_DRIVER, M_NOWAIT | M_ZERO);
 	if (!dev->vblank)
 	    goto err;
 
@@ -432,8 +431,8 @@ int drm_wait_vblank(struct drm_device *d
 
 	if (flags & _DRM_VBLANK_SIGNAL) {
 #if 0 /* disabled */
-		drm_vbl_sig_t *vbl_sig = malloc(sizeof(drm_vbl_sig_t), M_DRM,
-		    M_NOWAIT | M_ZERO);
+		drm_vbl_sig_t *vbl_sig = malloc(sizeof(drm_vbl_sig_t),
+		    DRM_MEM_DRIVER, M_NOWAIT | M_ZERO);
 		if (vbl_sig == NULL)
 			return ENOMEM;
 

Modified: head/sys/dev/drm/drm_memory.c
==============================================================================
--- head/sys/dev/drm/drm_memory.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_memory.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -41,7 +41,25 @@ __FBSDID("$FreeBSD$");
 
 #include "dev/drm/drmP.h"
 
-MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures");
+MALLOC_DEFINE(DRM_MEM_DMA, "drm_dma", "DRM DMA Data Structures");
+MALLOC_DEFINE(DRM_MEM_SAREA, "drm_sarea", "DRM SAREA Data Structures");
+MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures");
+MALLOC_DEFINE(DRM_MEM_MAGIC, "drm_magic", "DRM MAGIC Data Structures");
+MALLOC_DEFINE(DRM_MEM_IOCTLS, "drm_ioctls", "DRM IOCTL Data Structures");
+MALLOC_DEFINE(DRM_MEM_MAPS, "drm_maps", "DRM MAP Data Structures");
+MALLOC_DEFINE(DRM_MEM_BUFS, "drm_bufs", "DRM BUFFER Data Structures");
+MALLOC_DEFINE(DRM_MEM_SEGS, "drm_segs", "DRM SEGMENTS Data Structures");
+MALLOC_DEFINE(DRM_MEM_PAGES, "drm_pages", "DRM PAGES Data Structures");
+MALLOC_DEFINE(DRM_MEM_FILES, "drm_files", "DRM FILE Data Structures");
+MALLOC_DEFINE(DRM_MEM_QUEUES, "drm_queues", "DRM QUEUE Data Structures");
+MALLOC_DEFINE(DRM_MEM_CMDS, "drm_cmds", "DRM COMMAND Data Structures");
+MALLOC_DEFINE(DRM_MEM_MAPPINGS, "drm_mapping", "DRM MAPPING Data Structures");
+MALLOC_DEFINE(DRM_MEM_BUFLISTS, "drm_buflists", "DRM BUFLISTS Data Structures");
+MALLOC_DEFINE(DRM_MEM_AGPLISTS, "drm_agplists", "DRM AGPLISTS Data Structures");
+MALLOC_DEFINE(DRM_MEM_CTXBITMAP, "drm_ctxbitmap",
+    "DRM CTXBITMAP Data Structures");
+MALLOC_DEFINE(DRM_MEM_SGLISTS, "drm_sglists", "DRM SGLISTS Data Structures");
+MALLOC_DEFINE(DRM_MEM_DRAWABLE, "drm_drawable", "DRM DRAWABLE Data Structures");
 
 void drm_mem_init(void)
 {
@@ -51,35 +69,6 @@ void drm_mem_uninit(void)
 {
 }
 
-void *drm_alloc(size_t size, int area)
-{
-	return malloc(size, M_DRM, M_NOWAIT);
-}
-
-void *drm_calloc(size_t nmemb, size_t size, int area)
-{
-	return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO);
-}
-
-void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
-{
-	void *pt;
-
-	pt = malloc(size, M_DRM, M_NOWAIT);
-	if (pt == NULL)
-		return NULL;
-	if (oldpt && oldsize) {
-		memcpy(pt, oldpt, DRM_MIN(oldsize,size));
-		free(oldpt, M_DRM);
-	}
-	return pt;
-}
-
-void drm_free(void *pt, size_t size, int area)
-{
-	free(pt, M_DRM);
-}
-
 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map)
 {
 	return pmap_mapdev_attr(map->offset, map->size, PAT_WRITE_COMBINING);

Modified: head/sys/dev/drm/drm_pci.c
==============================================================================
--- head/sys/dev/drm/drm_pci.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_pci.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -67,7 +67,7 @@ drm_pci_alloc(struct drm_device *dev, si
 		return NULL;
 	}
 
-	dmah = malloc(sizeof(drm_dma_handle_t), M_DRM, M_ZERO | M_NOWAIT);
+	dmah = malloc(sizeof(drm_dma_handle_t), DRM_MEM_DMA, M_ZERO | M_NOWAIT);
 	if (dmah == NULL)
 		return NULL;
 
@@ -86,7 +86,7 @@ drm_pci_alloc(struct drm_device *dev, si
 	    BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */
 	    &dmah->tag);
 	if (ret != 0) {
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return NULL;
 	}
 
@@ -94,7 +94,7 @@ drm_pci_alloc(struct drm_device *dev, si
 	    &dmah->map);
 	if (ret != 0) {
 		bus_dma_tag_destroy(dmah->tag);
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return NULL;
 	}
 
@@ -103,7 +103,7 @@ drm_pci_alloc(struct drm_device *dev, si
 	if (ret != 0) {
 		bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
 		bus_dma_tag_destroy(dmah->tag);
-		free(dmah, M_DRM);
+		free(dmah, DRM_MEM_DMA);
 		return NULL;
 	}
 
@@ -122,7 +122,7 @@ drm_pci_free(struct drm_device *dev, drm
 	bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
 	bus_dma_tag_destroy(dmah->tag);
 
-	free(dmah, M_DRM);
+	free(dmah, DRM_MEM_DMA);
 }
 
 /*@}*/

Modified: head/sys/dev/drm/drm_scatter.c
==============================================================================
--- head/sys/dev/drm/drm_scatter.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_scatter.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -43,9 +43,9 @@ __FBSDID("$FreeBSD$");
 
 void drm_sg_cleanup(drm_sg_mem_t *entry)
 {
-	free((void *)entry->handle, M_DRM);
-	free(entry->busaddr, M_DRM);
-	free(entry, M_DRM);
+	free((void *)entry->handle, DRM_MEM_PAGES);
+	free(entry->busaddr, DRM_MEM_PAGES);
+	free(entry, DRM_MEM_SGLISTS);
 }
 
 int drm_sg_alloc(struct drm_device * dev, struct drm_scatter_gather * request)
@@ -57,7 +57,7 @@ int drm_sg_alloc(struct drm_device * dev
 	if (dev->sg)
 		return EINVAL;
 
-	entry = malloc(sizeof(*entry), M_DRM, M_WAITOK | M_ZERO);
+	entry = malloc(sizeof(*entry), DRM_MEM_SGLISTS, M_WAITOK | M_ZERO);
 	if (!entry)
 		return ENOMEM;
 
@@ -66,14 +66,14 @@ int drm_sg_alloc(struct drm_device * dev
 
 	entry->pages = pages;
 
-	entry->busaddr = malloc(pages * sizeof(*entry->busaddr), M_DRM,
+	entry->busaddr = malloc(pages * sizeof(*entry->busaddr), DRM_MEM_PAGES,
 	    M_WAITOK | M_ZERO);
 	if (!entry->busaddr) {
 		drm_sg_cleanup(entry);
 		return ENOMEM;
 	}
 
-	entry->handle = (long)malloc(pages << PAGE_SHIFT, M_DRM,
+	entry->handle = (long)malloc(pages << PAGE_SHIFT, DRM_MEM_PAGES,
 	    M_WAITOK | M_ZERO);
 	if (entry->handle == 0) {
 		drm_sg_cleanup(entry);

Modified: head/sys/dev/drm/drm_sysctl.c
==============================================================================
--- head/sys/dev/drm/drm_sysctl.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/drm_sysctl.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -62,7 +62,7 @@ int drm_sysctl_init(struct drm_device *d
 	struct sysctl_oid *top, *drioid;
 	int		  i;
 
-	info = malloc(sizeof *info, M_DRM, M_WAITOK | M_ZERO);
+	info = malloc(sizeof *info, DRM_MEM_DRIVER, M_WAITOK | M_ZERO);
 	if ( !info )
 		return 1;
 	dev->sysctl = info;
@@ -114,7 +114,7 @@ int drm_sysctl_cleanup(struct drm_device
 	int error;
 	error = sysctl_ctx_free( &dev->sysctl->ctx );
 
-	free(dev->sysctl, M_DRM);
+	free(dev->sysctl, DRM_MEM_DRIVER);
 	dev->sysctl = NULL;
 
 	return error;
@@ -172,7 +172,8 @@ static int drm_vm_info DRM_SYSCTL_HANDLE
 	TAILQ_FOREACH(map, &dev->maplist, link)
 		mapcount++;
 
-	tempmaps = malloc(sizeof(drm_local_map_t) * mapcount, M_DRM, M_NOWAIT);
+	tempmaps = malloc(sizeof(drm_local_map_t) * mapcount, DRM_MEM_DRIVER,
+	    M_NOWAIT);
 	if (tempmaps == NULL) {
 		DRM_UNLOCK();
 		return ENOMEM;
@@ -208,7 +209,7 @@ static int drm_vm_info DRM_SYSCTL_HANDLE
 	SYSCTL_OUT(req, "", 1);
 
 done:
-	free(tempmaps, M_DRM);
+	free(tempmaps, DRM_MEM_DRIVER);
 	return retcode;
 }
 
@@ -232,7 +233,8 @@ static int drm_bufs_info DRM_SYSCTL_HAND
 	}
 	DRM_SPINLOCK(&dev->dma_lock);
 	tempdma = *dma;
-	templists = malloc(sizeof(int) * dma->buf_count, M_DRM, M_NOWAIT);
+	templists = malloc(sizeof(int) * dma->buf_count, DRM_MEM_DRIVER,
+	    M_NOWAIT);
 	for (i = 0; i < dma->buf_count; i++)
 		templists[i] = dma->buflist[i]->list;
 	dma = &tempdma;
@@ -264,7 +266,7 @@ static int drm_bufs_info DRM_SYSCTL_HAND
 
 	SYSCTL_OUT(req, "", 1);
 done:
-	free(templists, M_DRM);
+	free(templists, DRM_MEM_DRIVER);
 	return retcode;
 }
 
@@ -282,7 +284,8 @@ static int drm_clients_info DRM_SYSCTL_H
 	TAILQ_FOREACH(priv, &dev->files, link)
 		privcount++;
 
-	tempprivs = malloc(sizeof(struct drm_file) * privcount, M_DRM, M_NOWAIT);
+	tempprivs = malloc(sizeof(struct drm_file) * privcount, DRM_MEM_DRIVER,
+	    M_NOWAIT);
 	if (tempprivs == NULL) {
 		DRM_UNLOCK();
 		return ENOMEM;
@@ -307,6 +310,6 @@ static int drm_clients_info DRM_SYSCTL_H
 
 	SYSCTL_OUT(req, "", 1);
 done:
-	free(tempprivs, M_DRM);
+	free(tempprivs, DRM_MEM_DRIVER);
 	return retcode;
 }

Modified: head/sys/dev/drm/i915_drv.c
==============================================================================
--- head/sys/dev/drm/i915_drv.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/i915_drv.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -112,7 +112,7 @@ i915_attach(device_t nbdev)
 {
 	struct drm_device *dev = device_get_softc(nbdev);
 
-	dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM,
+	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
 	    M_WAITOK | M_ZERO);
 
 	i915_configure(dev);
@@ -128,7 +128,7 @@ i915_detach(device_t nbdev)
 
 	ret = drm_detach(nbdev);
 
-	free(dev->driver, M_DRM);
+	free(dev->driver, DRM_MEM_DRIVER);
 
 	return ret;
 }

Modified: head/sys/dev/drm/mach64_drv.c
==============================================================================
--- head/sys/dev/drm/mach64_drv.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/mach64_drv.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -86,7 +86,7 @@ mach64_attach(device_t nbdev)
 {
 	struct drm_device *dev = device_get_softc(nbdev);
 
-	dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM,
+	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
 	    M_WAITOK | M_ZERO);
 
 	mach64_configure(dev);
@@ -102,7 +102,7 @@ mach64_detach(device_t nbdev)
 
 	ret = drm_detach(nbdev);
 
-	free(dev->driver, M_DRM);
+	free(dev->driver, DRM_MEM_DRIVER);
 
 	return ret;
 }

Modified: head/sys/dev/drm/mga_drv.c
==============================================================================
--- head/sys/dev/drm/mga_drv.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/mga_drv.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -130,7 +130,7 @@ mga_attach(device_t nbdev)
 {
 	struct drm_device *dev = device_get_softc(nbdev);
 
-	dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM,
+	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
 	    M_WAITOK | M_ZERO);
 
 	mga_configure(dev);
@@ -146,7 +146,7 @@ mga_detach(device_t nbdev)
 
 	ret = drm_detach(nbdev);
 
-	free(dev->driver, M_DRM);
+	free(dev->driver, DRM_MEM_DRIVER);
 
 	return ret;
 }

Modified: head/sys/dev/drm/r128_drv.c
==============================================================================
--- head/sys/dev/drm/r128_drv.c	Mon Oct 13 17:52:41 2008	(r183832)
+++ head/sys/dev/drm/r128_drv.c	Mon Oct 13 18:03:27 2008	(r183833)
@@ -85,7 +85,7 @@ r128_attach(device_t nbdev)
 {
 	struct drm_device *dev = device_get_softc(nbdev);
 
-	dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM,
+	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
 	    M_WAITOK | M_ZERO);
 
 	r128_configure(dev);
@@ -101,7 +101,7 @@ r128_detach(device_t nbdev)
 
 	ret = drm_detach(nbdev);
 
-	free(dev->driver, M_DRM);
+	free(dev->driver, DRM_MEM_DRIVER);
 
 	return ret;
 }

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810131803.m9DI3R1o082570>