summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2004-08-30 09:01:50 +0000
committerDave Airlie <airlied@linux.ie>2004-08-30 09:01:50 +0000
commit7809efc8c32520e6b25c143ee3276edbf534ed14 (patch)
treecfa0ada45d368025b7506277fb4d2d22db243518
parent08de6e5b04c1950a5f396315e59d2476726e26d8 (diff)
drm-memory patch, cleans up alloc/free and makes calloc look more libc like
-rw-r--r--linux-core/drmP.h22
-rw-r--r--linux-core/drm_irq.c4
-rw-r--r--linux-core/drm_memory.h20
-rw-r--r--linux-core/drm_memory_debug.h2
-rw-r--r--linux-core/drm_os_linux.h5
-rw-r--r--linux/drmP.h22
-rw-r--r--linux/drm_irq.h4
-rw-r--r--linux/drm_memory.h20
-rw-r--r--linux/drm_memory_debug.h2
-rw-r--r--linux/drm_os_linux.h5
-rw-r--r--shared-core/i915_mem.c20
-rw-r--r--shared-core/r128_state.c84
-rw-r--r--shared-core/radeon_mem.c20
-rw-r--r--shared-core/radeon_state.c3
-rw-r--r--shared-core/via_ds.c25
-rw-r--r--shared/i915_mem.c20
-rw-r--r--shared/r128_state.c84
-rw-r--r--shared/radeon_mem.c20
-rw-r--r--shared/radeon_state.c3
-rw-r--r--shared/via_ds.c25
20 files changed, 196 insertions, 214 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index f3dc57be..384390de 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -85,6 +85,8 @@
#include "drm_os_linux.h"
+/* If you want the memory alloc debug functionality, change define below */
+/* #define DEBUG_MEMORY */
/***********************************************************************/
/** \name DRM template customization defaults */
@@ -726,11 +728,9 @@ extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count
extern void DRM(mem_init)(void);
extern int DRM(mem_info)(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
-extern void *DRM(alloc)(size_t size, int area);
extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
-extern void DRM(free)(void *pt, size_t size, int area);
extern unsigned long DRM(alloc_pages)(int order, int area);
extern void DRM(free_pages)(unsigned long address, int order,
int area);
@@ -958,6 +958,24 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsig
static __inline__ void drm_core_dropmap(struct drm_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);
+}
+#else
+extern void *DRM(alloc)(size_t size, int area);
+extern void DRM(free)(void *pt, size_t size, int area);
+#endif
+
/*@}*/
extern unsigned long DRM(core_get_map_ofs)(drm_map_t *map);
diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c
index d9eb9f1d..b34f1ce4 100644
--- a/linux-core/drm_irq.c
+++ b/linux-core/drm_irq.c
@@ -304,7 +304,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
- if ( !( vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) ) ) ) {
+ if ( !( vbl_sig = DRM(alloc)( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) {
return -ENOMEM;
}
@@ -360,7 +360,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del( list );
- DRM_FREE( vbl_sig, sizeof(*vbl_sig) );
+ DRM(free)( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER );
dev->vbl_pending--;
}
diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h
index fe8141c9..669bef08 100644
--- a/linux-core/drm_memory.h
+++ b/linux-core/drm_memory.h
@@ -39,10 +39,8 @@
/**
* Cut down version of drm_memory_debug.h, which used to be called
- * drm_memory.h. If you want the debug functionality, change 0 to 1
- * below.
+ * drm_memory.h.
*/
-#define DEBUG_MEMORY 0
/* Need the 4-argument version of vmap(). */
#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
@@ -199,7 +197,7 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
}
-#if DEBUG_MEMORY
+#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
@@ -228,13 +226,7 @@ int DRM(mem_info)(char *buf, char **start, off_t offset,
}
/** Wrapper around kmalloc() */
-void *DRM(alloc)(size_t size, int area)
-{
- return kmalloc(size, GFP_KERNEL);
-}
-
-/** Wrapper around kmalloc() */
-void *DRM(calloc)(size_t size, size_t nmemb, int area)
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
{
void *addr;
@@ -258,12 +250,6 @@ void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
return pt;
}
-/** Wrapper around kfree() */
-void DRM(free)(void *pt, size_t size, int area)
-{
- kfree(pt);
-}
-
/**
* Allocate pages.
*
diff --git a/linux-core/drm_memory_debug.h b/linux-core/drm_memory_debug.h
index 0053679a..8b484ad9 100644
--- a/linux-core/drm_memory_debug.h
+++ b/linux-core/drm_memory_debug.h
@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area)
return pt;
}
-void *DRM(calloc)(size_t size, size_t nmemb, int area)
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
{
void *addr;
diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h
index 5a7c162d..bf58a1c2 100644
--- a/linux-core/drm_os_linux.h
+++ b/linux-core/drm_os_linux.h
@@ -85,11 +85,6 @@ typedef void irqreturn_t;
__put_user(val, uaddr)
-/** 'malloc' without the overhead of DRM(alloc)() */
-#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
-/** 'free' without the overhead of DRM(free)() */
-#define DRM_FREE(x,size) kfree(x)
-
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
/**
diff --git a/linux/drmP.h b/linux/drmP.h
index f3dc57be..384390de 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -85,6 +85,8 @@
#include "drm_os_linux.h"
+/* If you want the memory alloc debug functionality, change define below */
+/* #define DEBUG_MEMORY */
/***********************************************************************/
/** \name DRM template customization defaults */
@@ -726,11 +728,9 @@ extern ssize_t DRM(read)(struct file *filp, char __user *buf, size_t count
extern void DRM(mem_init)(void);
extern int DRM(mem_info)(char *buf, char **start, off_t offset,
int request, int *eof, void *data);
-extern void *DRM(alloc)(size_t size, int area);
extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
-extern void DRM(free)(void *pt, size_t size, int area);
extern unsigned long DRM(alloc_pages)(int order, int area);
extern void DRM(free_pages)(unsigned long address, int order,
int area);
@@ -958,6 +958,24 @@ static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, unsig
static __inline__ void drm_core_dropmap(struct drm_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);
+}
+#else
+extern void *DRM(alloc)(size_t size, int area);
+extern void DRM(free)(void *pt, size_t size, int area);
+#endif
+
/*@}*/
extern unsigned long DRM(core_get_map_ofs)(drm_map_t *map);
diff --git a/linux/drm_irq.h b/linux/drm_irq.h
index d9eb9f1d..b34f1ce4 100644
--- a/linux/drm_irq.h
+++ b/linux/drm_irq.h
@@ -304,7 +304,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
spin_unlock_irqrestore( &dev->vbl_lock, irqflags );
- if ( !( vbl_sig = DRM_MALLOC( sizeof( drm_vbl_sig_t ) ) ) ) {
+ if ( !( vbl_sig = DRM(alloc)( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) {
return -ENOMEM;
}
@@ -360,7 +360,7 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
list_del( list );
- DRM_FREE( vbl_sig, sizeof(*vbl_sig) );
+ DRM(free)( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER );
dev->vbl_pending--;
}
diff --git a/linux/drm_memory.h b/linux/drm_memory.h
index fe8141c9..669bef08 100644
--- a/linux/drm_memory.h
+++ b/linux/drm_memory.h
@@ -39,10 +39,8 @@
/**
* Cut down version of drm_memory_debug.h, which used to be called
- * drm_memory.h. If you want the debug functionality, change 0 to 1
- * below.
+ * drm_memory.h.
*/
-#define DEBUG_MEMORY 0
/* Need the 4-argument version of vmap(). */
#if __OS_HAS_AGP && defined(VMAP_4_ARGS)
@@ -199,7 +197,7 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
}
-#if DEBUG_MEMORY
+#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
@@ -228,13 +226,7 @@ int DRM(mem_info)(char *buf, char **start, off_t offset,
}
/** Wrapper around kmalloc() */
-void *DRM(alloc)(size_t size, int area)
-{
- return kmalloc(size, GFP_KERNEL);
-}
-
-/** Wrapper around kmalloc() */
-void *DRM(calloc)(size_t size, size_t nmemb, int area)
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
{
void *addr;
@@ -258,12 +250,6 @@ void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
return pt;
}
-/** Wrapper around kfree() */
-void DRM(free)(void *pt, size_t size, int area)
-{
- kfree(pt);
-}
-
/**
* Allocate pages.
*
diff --git a/linux/drm_memory_debug.h b/linux/drm_memory_debug.h
index 0053679a..8b484ad9 100644
--- a/linux/drm_memory_debug.h
+++ b/linux/drm_memory_debug.h
@@ -167,7 +167,7 @@ void *DRM(alloc)(size_t size, int area)
return pt;
}
-void *DRM(calloc)(size_t size, size_t nmemb, int area)
+void *DRM(calloc)(size_t nmemb, size_t size, int area)
{
void *addr;
diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h
index 5a7c162d..bf58a1c2 100644
--- a/linux/drm_os_linux.h
+++ b/linux/drm_os_linux.h
@@ -85,11 +85,6 @@ typedef void irqreturn_t;
__put_user(val, uaddr)
-/** 'malloc' without the overhead of DRM(alloc)() */
-#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
-/** 'free' without the overhead of DRM(free)() */
-#define DRM_FREE(x,size) kfree(x)
-
#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) _priv = _filp->private_data
/**
diff --git a/shared-core/i915_mem.c b/shared-core/i915_mem.c
index 42c1e353..c6115b7e 100644
--- a/shared-core/i915_mem.c
+++ b/shared-core/i915_mem.c
@@ -75,7 +75,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
@@ -91,7 +91,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
@@ -148,7 +148,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
@@ -156,7 +156,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM_FREE(p, sizeof(*q));
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
@@ -164,14 +164,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM_MALLOC(sizeof(*blocks));
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
- *heap = DRM_MALLOC(sizeof(**heap));
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
- DRM_FREE(blocks, sizeof(*blocks));
+ DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
@@ -211,7 +211,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
@@ -228,10 +228,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
- DRM_FREE(*heap, sizeof(**heap));
+ DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index d772f173..5b8af9f9 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -926,24 +926,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM_MALLOC( buffer_size );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM_FREE( buffer, buffer_size);
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
- mask = DRM_MALLOC( mask_size );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM_FREE( buffer, buffer_size );
- DRM_FREE( mask, mask_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -970,7 +970,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_FREE( mask, mask_size );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -994,7 +994,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1016,54 +1016,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM_MALLOC( xbuf_size );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM_MALLOC( ybuf_size );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM_FREE( x, xbuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM_MALLOC( buffer_size );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
- mask = DRM_MALLOC( mask_size );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
- DRM_FREE( mask, mask_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1090,7 +1090,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_FREE( mask, mask_size );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1114,9 +1114,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1184,23 +1184,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM_MALLOC( xbuf_size );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM_MALLOC( ybuf_size );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM_FREE( x, xbuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1228,8 +1228,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
diff --git a/shared-core/radeon_mem.c b/shared-core/radeon_mem.c
index 28995740..9d7fded7 100644
--- a/shared-core/radeon_mem.c
+++ b/shared-core/radeon_mem.c
@@ -44,7 +44,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
@@ -60,7 +60,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
@@ -118,7 +118,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
@@ -126,7 +126,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM_FREE(p, sizeof(*q));
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
}
}
@@ -134,14 +134,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM_MALLOC(sizeof(*blocks));
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
- *heap = DRM_MALLOC(sizeof(**heap));
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
- DRM_FREE( blocks, sizeof(*blocks) );
+ DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
@@ -180,7 +180,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
@@ -197,10 +197,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
- DRM_FREE( *heap, sizeof(**heap) );
+ DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index cdbd7a8e..e67bdc0f 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -1441,7 +1441,8 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
}
if ( !buf ) {
DRM_DEBUG("radeon_cp_dispatch_texture: EAGAIN\n");
- DRM_COPY_TO_USER( tex->image, image, sizeof(*image) );
+ if (DRM_COPY_TO_USER( tex->image, image, sizeof(*image) ))
+ return DRM_ERR(EFAULT);
return DRM_ERR(EAGAIN);
}
diff --git a/shared-core/via_ds.c b/shared-core/via_ds.c
index ca99a1ed..a29204ce 100644
--- a/shared-core/via_ds.c
+++ b/shared-core/via_ds.c
@@ -38,7 +38,7 @@ set_t *via_setInit(void)
{
int i;
set_t *set;
- set = (set_t *)DRM_MALLOC(sizeof(set_t));
+ set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i+1;
set->list[i].alloc_next = -1;
@@ -120,7 +120,7 @@ int via_setNext(set_t *set, ITEM_TYPE *item)
int via_setDestroy(set_t *set)
{
- DRM_FREE(set, sizeof(set_t));
+ DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -130,15 +130,6 @@ int via_setDestroy(set_t *set)
#define PRINTF(fmt, arg...) do{}while(0)
#define fprintf(fmt, arg...) do{}while(0)
-static void *calloc(size_t nmemb, size_t size)
-{
- void *addr;
- addr = kmalloc(nmemb*size, GFP_KERNEL);
- memset(addr, 0, nmemb*size);
- return addr;
-}
-#define free(n) kfree(n)
-
void via_mmDumpMemInfo( memHeap_t *heap )
{
TMemBlock *p;
@@ -170,7 +161,7 @@ memHeap_t *via_mmInit(int ofs,
return 0;
- blocks = (TMemBlock *)calloc(1,sizeof(TMemBlock));
+ blocks = (TMemBlock *)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks->ofs = ofs;
@@ -186,7 +177,7 @@ memHeap_t *via_mmAddRange(memHeap_t *heap,
int size)
{
PMemBlock blocks;
- blocks = (TMemBlock *) calloc(2,sizeof(TMemBlock));
+ blocks = (TMemBlock *)DRM(calloc)(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks[0].size = size;
@@ -215,7 +206,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*)calloc(1,sizeof(TMemBlock));
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -227,7 +218,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -286,7 +277,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- free(q);
+ DRM(free)(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
return 1;
}
@@ -393,7 +384,7 @@ void via_mmDestroy(memHeap_t *heap)
while (p) {
q = p->next;
- free(p);
+ DRM(free)(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
p = q;
}
}
diff --git a/shared/i915_mem.c b/shared/i915_mem.c
index 42c1e353..c6115b7e 100644
--- a/shared/i915_mem.c
+++ b/shared/i915_mem.c
@@ -75,7 +75,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start;
@@ -91,7 +91,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFLISTS);
if (!newblock)
goto out;
newblock->start = start + size;
@@ -148,7 +148,7 @@ static void free_block(struct mem_block *p)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
if (p->prev->filp == NULL) {
@@ -156,7 +156,7 @@ static void free_block(struct mem_block *p)
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM_FREE(p, sizeof(*q));
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
@@ -164,14 +164,14 @@ static void free_block(struct mem_block *p)
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM_MALLOC(sizeof(*blocks));
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFLISTS);
if (!blocks)
return -ENOMEM;
- *heap = DRM_MALLOC(sizeof(**heap));
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFLISTS);
if (!*heap) {
- DRM_FREE(blocks, sizeof(*blocks));
+ DRM(free)(blocks, sizeof(*blocks), DRM_MEM_BUFLISTS);
return -ENOMEM;
}
@@ -211,7 +211,7 @@ void i915_mem_release(drm_device_t * dev, DRMFILE filp, struct mem_block *heap)
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
}
}
@@ -228,10 +228,10 @@ void i915_mem_takedown(struct mem_block **heap)
for (p = (*heap)->next; p != *heap;) {
struct mem_block *q = p;
p = p->next;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFLISTS);
}
- DRM_FREE(*heap, sizeof(**heap));
+ DRM(free)(*heap, sizeof(**heap), DRM_MEM_BUFLISTS);
*heap = NULL;
}
diff --git a/shared/r128_state.c b/shared/r128_state.c
index d772f173..5b8af9f9 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -926,24 +926,24 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM_MALLOC( buffer_size );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL )
return DRM_ERR(ENOMEM);
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM_FREE( buffer, buffer_size);
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS);
return DRM_ERR(EFAULT);
}
mask_size = depth->n * sizeof(u8);
if ( depth->mask ) {
- mask = DRM_MALLOC( mask_size );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM_FREE( buffer, buffer_size );
- DRM_FREE( mask, mask_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -970,7 +970,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_FREE( mask, mask_size );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -994,7 +994,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1016,54 +1016,54 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM_MALLOC( xbuf_size );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM_MALLOC( ybuf_size );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM_FREE( x, xbuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
buffer_size = depth->n * sizeof(u32);
- buffer = DRM_MALLOC( buffer_size );
+ buffer = DRM(alloc)( buffer_size, DRM_MEM_BUFS );
if ( buffer == NULL ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( buffer, depth->buffer, buffer_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
mask_size = depth->n * sizeof(u8);
- mask = DRM_MALLOC( mask_size );
+ mask = DRM(alloc)( mask_size, DRM_MEM_BUFS );
if ( mask == NULL ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( mask, depth->mask, mask_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
- DRM_FREE( mask, mask_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1090,7 +1090,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_FREE( mask, mask_size );
+ DRM(free)( mask, mask_size, DRM_MEM_BUFS );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1114,9 +1114,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
- DRM_FREE( buffer, buffer_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
+ DRM(free)( buffer, buffer_size, DRM_MEM_BUFS );
return 0;
}
@@ -1184,23 +1184,23 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = DRM_MALLOC( xbuf_size );
+ x = DRM(alloc)( xbuf_size, DRM_MEM_BUFS );
if ( x == NULL ) {
return DRM_ERR(ENOMEM);
}
- y = DRM_MALLOC( ybuf_size );
+ y = DRM(alloc)( ybuf_size, DRM_MEM_BUFS );
if ( y == NULL ) {
- DRM_FREE( x, xbuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
if ( DRM_COPY_FROM_USER( x, depth->x, xbuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
if ( DRM_COPY_FROM_USER( y, depth->y, ybuf_size ) ) {
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return DRM_ERR(EFAULT);
}
@@ -1228,8 +1228,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM_FREE( x, xbuf_size );
- DRM_FREE( y, ybuf_size );
+ DRM(free)( x, xbuf_size, DRM_MEM_BUFS );
+ DRM(free)( y, ybuf_size, DRM_MEM_BUFS );
return 0;
}
diff --git a/shared/radeon_mem.c b/shared/radeon_mem.c
index 28995740..9d7fded7 100644
--- a/shared/radeon_mem.c
+++ b/shared/radeon_mem.c
@@ -44,7 +44,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start;
@@ -60,7 +60,7 @@ static struct mem_block *split_block(struct mem_block *p, int start, int size,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct mem_block *newblock = DRM_MALLOC(sizeof(*newblock));
+ struct mem_block *newblock = DRM(alloc)(sizeof(*newblock), DRM_MEM_BUFS );
if (!newblock)
goto out;
newblock->start = start + size;
@@ -118,7 +118,7 @@ static void free_block( struct mem_block *p )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q), DRM_MEM_BUFS );
}
if (p->prev->filp == 0) {
@@ -126,7 +126,7 @@ static void free_block( struct mem_block *p )
q->size += p->size;
q->next = p->next;
q->next->prev = q;
- DRM_FREE(p, sizeof(*q));
+ DRM(free)(p, sizeof(*q), DRM_MEM_BUFS );
}
}
@@ -134,14 +134,14 @@ static void free_block( struct mem_block *p )
*/
static int init_heap(struct mem_block **heap, int start, int size)
{
- struct mem_block *blocks = DRM_MALLOC(sizeof(*blocks));
+ struct mem_block *blocks = DRM(alloc)(sizeof(*blocks), DRM_MEM_BUFS );
if (!blocks)
return DRM_ERR(ENOMEM);
- *heap = DRM_MALLOC(sizeof(**heap));
+ *heap = DRM(alloc)(sizeof(**heap), DRM_MEM_BUFS );
if (!*heap) {
- DRM_FREE( blocks, sizeof(*blocks) );
+ DRM(free)( blocks, sizeof(*blocks), DRM_MEM_BUFS );
return DRM_ERR(ENOMEM);
}
@@ -180,7 +180,7 @@ void radeon_mem_release( DRMFILE filp, struct mem_block *heap )
p->size += q->size;
p->next = q->next;
p->next->prev = p;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
}
}
@@ -197,10 +197,10 @@ void radeon_mem_takedown( struct mem_block **heap )
for (p = (*heap)->next ; p != *heap ; ) {
struct mem_block *q = p;
p = p->next;
- DRM_FREE(q, sizeof(*q));
+ DRM(free)(q, sizeof(*q),DRM_MEM_DRIVER);
}
- DRM_FREE( *heap, sizeof(**heap) );
+ DRM(free)( *heap, sizeof(**heap),DRM_MEM_DRIVER );
*heap = NULL;
}
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index cdbd7a8e..e67bdc0f 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -1441,7 +1441,8 @@ static int radeon_cp_dispatch_texture( DRMFILE filp,
}
if ( !buf ) {
DRM_DEBUG("radeon_cp_dispatch_texture: EAGAIN\n");
- DRM_COPY_TO_USER( tex->image, image, sizeof(*image) );
+ if (DRM_COPY_TO_USER( tex->image, image, sizeof(*image) ))
+ return DRM_ERR(EFAULT);
return DRM_ERR(EAGAIN);
}
diff --git a/shared/via_ds.c b/shared/via_ds.c
index ca99a1ed..a29204ce 100644
--- a/shared/via_ds.c
+++ b/shared/via_ds.c
@@ -38,7 +38,7 @@ set_t *via_setInit(void)
{
int i;
set_t *set;
- set = (set_t *)DRM_MALLOC(sizeof(set_t));
+ set = (set_t *)DRM(alloc)(sizeof(set_t), DRM_MEM_DRIVER);
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i+1;
set->list[i].alloc_next = -1;
@@ -120,7 +120,7 @@ int via_setNext(set_t *set, ITEM_TYPE *item)
int via_setDestroy(set_t *set)
{
- DRM_FREE(set, sizeof(set_t));
+ DRM(free)(set, sizeof(set_t), DRM_MEM_DRIVER);
return 1;
}
@@ -130,15 +130,6 @@ int via_setDestroy(set_t *set)
#define PRINTF(fmt, arg...) do{}while(0)
#define fprintf(fmt, arg...) do{}while(0)
-static void *calloc(size_t nmemb, size_t size)
-{
- void *addr;
- addr = kmalloc(nmemb*size, GFP_KERNEL);
- memset(addr, 0, nmemb*size);
- return addr;
-}
-#define free(n) kfree(n)
-
void via_mmDumpMemInfo( memHeap_t *heap )
{
TMemBlock *p;
@@ -170,7 +161,7 @@ memHeap_t *via_mmInit(int ofs,
return 0;
- blocks = (TMemBlock *)calloc(1,sizeof(TMemBlock));
+ blocks = (TMemBlock *)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks->ofs = ofs;
@@ -186,7 +177,7 @@ memHeap_t *via_mmAddRange(memHeap_t *heap,
int size)
{
PMemBlock blocks;
- blocks = (TMemBlock *) calloc(2,sizeof(TMemBlock));
+ blocks = (TMemBlock *)DRM(calloc)(2,sizeof(TMemBlock),DRM_MEM_DRIVER);
if (blocks) {
blocks[0].size = size;
@@ -215,7 +206,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock*)calloc(1,sizeof(TMemBlock));
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -227,7 +218,7 @@ static TMemBlock* SliceBlock(TMemBlock *p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock*) calloc(1,sizeof(TMemBlock));
+ newblock = (TMemBlock*)DRM(calloc)(1,sizeof(TMemBlock),DRM_MEM_DRIVER);
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -286,7 +277,7 @@ static __inline__ int Join2Blocks(TMemBlock *p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- free(q);
+ DRM(free)(q,sizeof(TMemBlock),DRM_MEM_DRIVER);
return 1;
}
@@ -393,7 +384,7 @@ void via_mmDestroy(memHeap_t *heap)
while (p) {
q = p->next;
- free(p);
+ DRM(free)(p,sizeof(TMemBlock),DRM_MEM_DRIVER);
p = q;
}
}