summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jrfonseca@users.sourceforge.net>2003-06-21 13:31:01 +0000
committerJose Fonseca <jrfonseca@users.sourceforge.net>2003-06-21 13:31:01 +0000
commitc9796d6a46e24001220d6cd3328c35edaa980f94 (patch)
tree2f3b8a2204cded77016c3b818dbade7d1fa71f92
parentbe79faa6c57c759738cba1a7242ad03b371381b3 (diff)
Remove the memory debugging statistics (drm_memory_debug.h) and thereby
eliminating another wrapper layer over the AGP functions.
-rw-r--r--linux-core/drm_drv.c2
-rw-r--r--linux-core/drm_memory.h9
-rw-r--r--linux-core/drm_memory_debug.h448
-rw-r--r--linux-core/drm_proc.c1
-rw-r--r--linux/drm_agp.h8
-rw-r--r--linux/drm_agp_tmp.h17
-rw-r--r--linux/drm_drv.h2
-rw-r--r--linux/drm_memory.h9
-rw-r--r--linux/drm_memory_debug.h448
-rw-r--r--linux/drm_memory_tmp.h64
-rw-r--r--linux/drm_proc.h1
11 files changed, 11 insertions, 998 deletions
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 8cc8a77ca..78fb0aadd 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -590,8 +590,6 @@ static int __init drm_init( void )
DRIVER_PREINIT();
- DRM(mem_init)();
-
#if __REALLY_HAVE_AGP
DRM(agp_init)();
#endif
diff --git a/linux-core/drm_memory.h b/linux-core/drm_memory.h
index 4257cde6c..5ccaa5b05 100644
--- a/linux-core/drm_memory.h
+++ b/linux-core/drm_memory.h
@@ -39,8 +39,6 @@
/** \name Prototypes */
/*@{*/
-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(realloc)(void *oldpt, size_t oldsize, size_t size, int area);
extern void DRM(free)(void *pt, size_t size, int area);
@@ -50,13 +48,6 @@ extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_dev
extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev);
extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
-#if __REALLY_HAVE_AGP
-extern agp_memory *DRM(agp_alloc)(int pages, u32 type);
-extern int DRM(agp_free)(agp_memory *handle, int pages);
-extern int DRM(agp_bind)(agp_memory *handle, unsigned int start);
-extern int DRM(agp_unbind)(agp_memory *handle);
-#endif
-
/*@}*/
diff --git a/linux-core/drm_memory_debug.h b/linux-core/drm_memory_debug.h
deleted file mode 100644
index 91b42126a..000000000
--- a/linux-core/drm_memory_debug.h
+++ /dev/null
@@ -1,448 +0,0 @@
-/**
- * \file drm_memory_debug.h
- * Memory management wrappers for DRM.
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#define __NO_VERSION__
-#include <linux/config.h>
-#include "drmP.h"
-
-typedef struct drm_mem_stats {
- const char *name;
- int succeed_count;
- int free_count;
- int fail_count;
- unsigned long bytes_allocated;
- unsigned long bytes_freed;
-} drm_mem_stats_t;
-
-static spinlock_t DRM(mem_lock) = SPIN_LOCK_UNLOCKED;
-static unsigned long DRM(ram_available) = 0; /* In pages */
-static unsigned long DRM(ram_used) = 0;
-static drm_mem_stats_t DRM(mem_stats)[] = {
- [DRM_MEM_DMA] = { "dmabufs" },
- [DRM_MEM_SAREA] = { "sareas" },
- [DRM_MEM_DRIVER] = { "driver" },
- [DRM_MEM_MAGIC] = { "magic" },
- [DRM_MEM_IOCTLS] = { "ioctltab" },
- [DRM_MEM_MAPS] = { "maplist" },
- [DRM_MEM_VMAS] = { "vmalist" },
- [DRM_MEM_BUFS] = { "buflist" },
- [DRM_MEM_SEGS] = { "seglist" },
- [DRM_MEM_PAGES] = { "pagelist" },
- [DRM_MEM_FILES] = { "files" },
- [DRM_MEM_QUEUES] = { "queues" },
- [DRM_MEM_CMDS] = { "commands" },
- [DRM_MEM_MAPPINGS] = { "mappings" },
- [DRM_MEM_BUFLISTS] = { "buflists" },
- [DRM_MEM_AGPLISTS] = { "agplist" },
- [DRM_MEM_SGLISTS] = { "sglist" },
- [DRM_MEM_TOTALAGP] = { "totalagp" },
- [DRM_MEM_BOUNDAGP] = { "boundagp" },
- [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
- [DRM_MEM_STUB] = { "stub" },
- { NULL, 0, } /* Last entry must be null */
-};
-
-void DRM(mem_init)(void)
-{
- drm_mem_stats_t *mem;
- struct sysinfo si;
-
- for (mem = DRM(mem_stats); mem->name; ++mem) {
- mem->succeed_count = 0;
- mem->free_count = 0;
- mem->fail_count = 0;
- mem->bytes_allocated = 0;
- mem->bytes_freed = 0;
- }
-
- si_meminfo(&si);
- DRM(ram_available) = si.totalram;
- DRM(ram_used) = 0;
-}
-
-/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-
-static int DRM(_mem_info)(char *buf, char **start, off_t offset,
- int request, int *eof, void *data)
-{
- drm_mem_stats_t *pt;
- int len = 0;
-
- if (offset > DRM_PROC_LIMIT) {
- *eof = 1;
- return 0;
- }
-
- *eof = 0;
- *start = &buf[offset];
-
- DRM_PROC_PRINT(" total counts "
- " | outstanding \n");
- DRM_PROC_PRINT("type alloc freed fail bytes freed"
- " | allocs bytes\n\n");
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
- "system", 0, 0, 0,
- DRM(ram_available) << (PAGE_SHIFT - 10));
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
- "locked", 0, 0, 0, DRM(ram_used) >> 10);
- DRM_PROC_PRINT("\n");
- for (pt = DRM(mem_stats); pt->name; pt++) {
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
- pt->name,
- pt->succeed_count,
- pt->free_count,
- pt->fail_count,
- pt->bytes_allocated,
- pt->bytes_freed,
- pt->succeed_count - pt->free_count,
- (long)pt->bytes_allocated
- - (long)pt->bytes_freed);
- }
-
- if (len > request + offset) return request;
- *eof = 1;
- return len - offset;
-}
-
-int DRM(mem_info)(char *buf, char **start, off_t offset,
- int len, int *eof, void *data)
-{
- int ret;
-
- spin_lock(&DRM(mem_lock));
- ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
- spin_unlock(&DRM(mem_lock));
- return ret;
-}
-
-void *DRM(alloc)(size_t size, int area)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
- return NULL;
- }
-
- if (!(pt = kmalloc(size, GFP_KERNEL))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
-{
- void *pt;
-
- if (!(pt = DRM(alloc)(size, area))) return NULL;
- if (oldpt && oldsize) {
- memcpy(pt, oldpt, oldsize);
- DRM(free)(oldpt, oldsize, area);
- }
- return pt;
-}
-
-void DRM(free)(void *pt, size_t size, int area)
-{
- int alloc_count;
- int free_count;
-
- if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
- else kfree(pt);
- spin_lock(&DRM(mem_lock));
- DRM(mem_stats)[area].bytes_freed += size;
- free_count = ++DRM(mem_stats)[area].free_count;
- alloc_count = DRM(mem_stats)[area].succeed_count;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-unsigned long DRM(alloc_pages)(int order, int area)
-{
- unsigned long address;
- unsigned long bytes = PAGE_SIZE << order;
- unsigned long addr;
- unsigned int sz;
-
- spin_lock(&DRM(mem_lock));
- if ((DRM(ram_used) >> PAGE_SHIFT)
- > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
- spin_unlock(&DRM(mem_lock));
- return 0;
- }
- spin_unlock(&DRM(mem_lock));
-
- address = __get_free_pages(GFP_KERNEL, order);
- if (!address) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].fail_count;
- spin_unlock(&DRM(mem_lock));
- return 0;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_allocated += bytes;
- DRM(ram_used) += bytes;
- spin_unlock(&DRM(mem_lock));
-
-
- /* Zero outside the lock */
- memset((void *)address, 0, bytes);
-
- /* Reserve */
- for (addr = address, sz = bytes;
- sz > 0;
- addr += PAGE_SIZE, sz -= PAGE_SIZE) {
- SetPageReserved(virt_to_page(addr));
- }
-
- return address;
-}
-
-void DRM(free_pages)(unsigned long address, int order, int area)
-{
- unsigned long bytes = PAGE_SIZE << order;
- int alloc_count;
- int free_count;
- unsigned long addr;
- unsigned int sz;
-
- if (!address) {
- DRM_MEM_ERROR(area, "Attempt to free address 0\n");
- } else {
- /* Unreserve */
- for (addr = address, sz = bytes;
- sz > 0;
- addr += PAGE_SIZE, sz -= PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- }
- free_pages(address, order);
- }
-
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[area].free_count;
- alloc_count = DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_freed += bytes;
- DRM(ram_used) -= bytes;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(area,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
- return NULL;
- }
-
- if (!(pt = drm_ioremap(offset, size, dev))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
- return NULL;
- }
-
- if (!(pt = drm_ioremap_nocache(offset, size, dev))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
-{
- int alloc_count;
- int free_count;
-
- if (!pt)
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Attempt to free NULL pointer\n");
- else
- drm_ioremapfree(pt, size, dev);
-
- spin_lock(&DRM(mem_lock));
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
- free_count = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-#if __REALLY_HAVE_AGP
-
-agp_memory *DRM(agp_alloc)(int pages, u32 type)
-{
- agp_memory *handle;
-
- if (!pages) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
- return NULL;
- }
-
- if ((handle = DRM(agp_allocate_memory)(pages, type))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
- += pages << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- return handle;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
-}
-
-int DRM(agp_free)(agp_memory *handle, int pages)
-{
- int alloc_count;
- int free_count;
- int retval = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Attempt to free NULL AGP handle\n");
- return retval;;
- }
-
- if (DRM(agp_free_memory)(handle)) {
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
- += pages << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return 0;
- }
- return retval;
-}
-
-int DRM(agp_bind)(agp_memory *handle, unsigned int start)
-{
- int retcode = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to bind NULL AGP handle\n");
- return retcode;
- }
-
- if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
- += handle->page_count << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- return retcode;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
- spin_unlock(&DRM(mem_lock));
- return retcode;
-}
-
-int DRM(agp_unbind)(agp_memory *handle)
-{
- int alloc_count;
- int free_count;
- int retcode = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to unbind NULL AGP handle\n");
- return retcode;
- }
-
- if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
- += handle->page_count << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return retcode;
-}
-#endif
diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c
index 3d2c96b46..ac87e4548 100644
--- a/linux-core/drm_proc.c
+++ b/linux-core/drm_proc.c
@@ -63,7 +63,6 @@ struct drm_proc_list {
int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/
} DRM(proc_list)[] = {
{ "name", DRM(name_info) },
- { "mem", DRM(mem_info) },
{ "vm", DRM(vm_info) },
{ "clients", DRM(clients_info) },
{ "queues", DRM(queues_info) },
diff --git a/linux/drm_agp.h b/linux/drm_agp.h
index 1bd932e15..d76af6516 100644
--- a/linux/drm_agp.h
+++ b/linux/drm_agp.h
@@ -84,10 +84,10 @@ typedef struct drm_agp_head {
extern int DRM(agp_acquire)(void);
extern void DRM(agp_release)(void);
extern void DRM(agp_enable)(unsigned long mode);
-extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type);
-extern int DRM(agp_free_memory)(agp_memory *handle);
-extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start);
-extern int DRM(agp_unbind_memory)(agp_memory *handle);
+extern agp_memory *DRM(agp_alloc)(size_t pages, u32 type);
+extern int DRM(agp_free)(agp_memory *handle);
+extern int DRM(agp_bind)(agp_memory *handle, off_t start);
+extern int DRM(agp_unbind)(agp_memory *handle);
extern int DRM(agp_acquire_ioctl)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
extern int DRM(agp_release_ioctl)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
diff --git a/linux/drm_agp_tmp.h b/linux/drm_agp_tmp.h
index 8ae64b1dc..5f47b4214 100644
--- a/linux/drm_agp_tmp.h
+++ b/linux/drm_agp_tmp.h
@@ -89,11 +89,8 @@ void DRM(agp_enable)(unsigned long mode)
/**
* Allocate AGP memory.
- *
- * Not meant to be called directly. Use agp_alloc() instead, which can provide
- * some debugging features.
*/
-agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type)
+agp_memory *DRM(agp_alloc)(size_t pages, u32 type)
{
if (!drm_agp || !drm_agp->allocate_memory)
return NULL;
@@ -106,7 +103,7 @@ agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type)
* Not meant to be called directly. Use agp_free() instead, which can provide
* some debugging features.
*/
-int DRM(agp_free_memory)(agp_memory *handle)
+int DRM(agp_free)(agp_memory *handle)
{
if (!handle || !drm_agp || !drm_agp->free_memory)
return 0;
@@ -120,7 +117,7 @@ int DRM(agp_free_memory)(agp_memory *handle)
* Not meant to be called directly. Use agp_bind() instead, which can provide
* some debugging features.
*/
-int DRM(agp_bind_memory)(agp_memory *handle, off_t start)
+int DRM(agp_bind)(agp_memory *handle, off_t start)
{
if (!handle || !drm_agp || !drm_agp->bind_memory)
return -EINVAL;
@@ -133,7 +130,7 @@ int DRM(agp_bind_memory)(agp_memory *handle, off_t start)
* Not meant to be called directly. Use agp_unbind() instead, which can provide
* some debugging features.
*/
-int DRM(agp_unbind_memory)(agp_memory *handle)
+int DRM(agp_unbind)(agp_memory *handle)
{
if (!handle || !drm_agp || !drm_agp->unbind_memory)
return -EINVAL;
@@ -323,7 +320,7 @@ int DRM(agp_alloc_ioctl)(struct inode *inode, struct file *filp,
if (copy_to_user((drm_agp_buffer_t *)arg, &request, sizeof(request))) {
dev->agp->memory = entry->next;
dev->agp->memory->prev = NULL;
- DRM(agp_free)(memory, pages);
+ DRM(agp_free)(memory);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return -EFAULT;
}
@@ -453,7 +450,7 @@ int DRM(agp_free_ioctl)(struct inode *inode, struct file *filp,
if (entry->prev) entry->prev->next = entry->next;
else dev->agp->memory = entry->next;
if (entry->next) entry->next->prev = entry->prev;
- DRM(agp_free)(entry->memory, entry->pages);
+ DRM(agp_free)(entry->memory);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0;
}
@@ -542,7 +539,7 @@ void DRM(agp_cleanup_dev)(drm_device_t *dev)
for ( entry = dev->agp->memory ; entry ; entry = nexte ) {
nexte = entry->next;
if ( entry->bound ) DRM(agp_unbind)( entry->memory );
- DRM(agp_free)( entry->memory, entry->pages );
+ DRM(agp_free)( entry->memory );
DRM(free)( entry, sizeof(*entry), DRM_MEM_AGPLISTS );
}
dev->agp->memory = NULL;
diff --git a/linux/drm_drv.h b/linux/drm_drv.h
index 8cc8a77ca..78fb0aadd 100644
--- a/linux/drm_drv.h
+++ b/linux/drm_drv.h
@@ -590,8 +590,6 @@ static int __init drm_init( void )
DRIVER_PREINIT();
- DRM(mem_init)();
-
#if __REALLY_HAVE_AGP
DRM(agp_init)();
#endif
diff --git a/linux/drm_memory.h b/linux/drm_memory.h
index 4257cde6c..5ccaa5b05 100644
--- a/linux/drm_memory.h
+++ b/linux/drm_memory.h
@@ -39,8 +39,6 @@
/** \name Prototypes */
/*@{*/
-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(realloc)(void *oldpt, size_t oldsize, size_t size, int area);
extern void DRM(free)(void *pt, size_t size, int area);
@@ -50,13 +48,6 @@ extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_dev
extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev);
extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
-#if __REALLY_HAVE_AGP
-extern agp_memory *DRM(agp_alloc)(int pages, u32 type);
-extern int DRM(agp_free)(agp_memory *handle, int pages);
-extern int DRM(agp_bind)(agp_memory *handle, unsigned int start);
-extern int DRM(agp_unbind)(agp_memory *handle);
-#endif
-
/*@}*/
diff --git a/linux/drm_memory_debug.h b/linux/drm_memory_debug.h
deleted file mode 100644
index 91b42126a..000000000
--- a/linux/drm_memory_debug.h
+++ /dev/null
@@ -1,448 +0,0 @@
-/**
- * \file drm_memory_debug.h
- * Memory management wrappers for DRM.
- *
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
-/*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#define __NO_VERSION__
-#include <linux/config.h>
-#include "drmP.h"
-
-typedef struct drm_mem_stats {
- const char *name;
- int succeed_count;
- int free_count;
- int fail_count;
- unsigned long bytes_allocated;
- unsigned long bytes_freed;
-} drm_mem_stats_t;
-
-static spinlock_t DRM(mem_lock) = SPIN_LOCK_UNLOCKED;
-static unsigned long DRM(ram_available) = 0; /* In pages */
-static unsigned long DRM(ram_used) = 0;
-static drm_mem_stats_t DRM(mem_stats)[] = {
- [DRM_MEM_DMA] = { "dmabufs" },
- [DRM_MEM_SAREA] = { "sareas" },
- [DRM_MEM_DRIVER] = { "driver" },
- [DRM_MEM_MAGIC] = { "magic" },
- [DRM_MEM_IOCTLS] = { "ioctltab" },
- [DRM_MEM_MAPS] = { "maplist" },
- [DRM_MEM_VMAS] = { "vmalist" },
- [DRM_MEM_BUFS] = { "buflist" },
- [DRM_MEM_SEGS] = { "seglist" },
- [DRM_MEM_PAGES] = { "pagelist" },
- [DRM_MEM_FILES] = { "files" },
- [DRM_MEM_QUEUES] = { "queues" },
- [DRM_MEM_CMDS] = { "commands" },
- [DRM_MEM_MAPPINGS] = { "mappings" },
- [DRM_MEM_BUFLISTS] = { "buflists" },
- [DRM_MEM_AGPLISTS] = { "agplist" },
- [DRM_MEM_SGLISTS] = { "sglist" },
- [DRM_MEM_TOTALAGP] = { "totalagp" },
- [DRM_MEM_BOUNDAGP] = { "boundagp" },
- [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
- [DRM_MEM_STUB] = { "stub" },
- { NULL, 0, } /* Last entry must be null */
-};
-
-void DRM(mem_init)(void)
-{
- drm_mem_stats_t *mem;
- struct sysinfo si;
-
- for (mem = DRM(mem_stats); mem->name; ++mem) {
- mem->succeed_count = 0;
- mem->free_count = 0;
- mem->fail_count = 0;
- mem->bytes_allocated = 0;
- mem->bytes_freed = 0;
- }
-
- si_meminfo(&si);
- DRM(ram_available) = si.totalram;
- DRM(ram_used) = 0;
-}
-
-/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-
-static int DRM(_mem_info)(char *buf, char **start, off_t offset,
- int request, int *eof, void *data)
-{
- drm_mem_stats_t *pt;
- int len = 0;
-
- if (offset > DRM_PROC_LIMIT) {
- *eof = 1;
- return 0;
- }
-
- *eof = 0;
- *start = &buf[offset];
-
- DRM_PROC_PRINT(" total counts "
- " | outstanding \n");
- DRM_PROC_PRINT("type alloc freed fail bytes freed"
- " | allocs bytes\n\n");
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
- "system", 0, 0, 0,
- DRM(ram_available) << (PAGE_SHIFT - 10));
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
- "locked", 0, 0, 0, DRM(ram_used) >> 10);
- DRM_PROC_PRINT("\n");
- for (pt = DRM(mem_stats); pt->name; pt++) {
- DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
- pt->name,
- pt->succeed_count,
- pt->free_count,
- pt->fail_count,
- pt->bytes_allocated,
- pt->bytes_freed,
- pt->succeed_count - pt->free_count,
- (long)pt->bytes_allocated
- - (long)pt->bytes_freed);
- }
-
- if (len > request + offset) return request;
- *eof = 1;
- return len - offset;
-}
-
-int DRM(mem_info)(char *buf, char **start, off_t offset,
- int len, int *eof, void *data)
-{
- int ret;
-
- spin_lock(&DRM(mem_lock));
- ret = DRM(_mem_info)(buf, start, offset, len, eof, data);
- spin_unlock(&DRM(mem_lock));
- return ret;
-}
-
-void *DRM(alloc)(size_t size, int area)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
- return NULL;
- }
-
- if (!(pt = kmalloc(size, GFP_KERNEL))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
-{
- void *pt;
-
- if (!(pt = DRM(alloc)(size, area))) return NULL;
- if (oldpt && oldsize) {
- memcpy(pt, oldpt, oldsize);
- DRM(free)(oldpt, oldsize, area);
- }
- return pt;
-}
-
-void DRM(free)(void *pt, size_t size, int area)
-{
- int alloc_count;
- int free_count;
-
- if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
- else kfree(pt);
- spin_lock(&DRM(mem_lock));
- DRM(mem_stats)[area].bytes_freed += size;
- free_count = ++DRM(mem_stats)[area].free_count;
- alloc_count = DRM(mem_stats)[area].succeed_count;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-unsigned long DRM(alloc_pages)(int order, int area)
-{
- unsigned long address;
- unsigned long bytes = PAGE_SIZE << order;
- unsigned long addr;
- unsigned int sz;
-
- spin_lock(&DRM(mem_lock));
- if ((DRM(ram_used) >> PAGE_SHIFT)
- > (DRM_RAM_PERCENT * DRM(ram_available)) / 100) {
- spin_unlock(&DRM(mem_lock));
- return 0;
- }
- spin_unlock(&DRM(mem_lock));
-
- address = __get_free_pages(GFP_KERNEL, order);
- if (!address) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].fail_count;
- spin_unlock(&DRM(mem_lock));
- return 0;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_allocated += bytes;
- DRM(ram_used) += bytes;
- spin_unlock(&DRM(mem_lock));
-
-
- /* Zero outside the lock */
- memset((void *)address, 0, bytes);
-
- /* Reserve */
- for (addr = address, sz = bytes;
- sz > 0;
- addr += PAGE_SIZE, sz -= PAGE_SIZE) {
- SetPageReserved(virt_to_page(addr));
- }
-
- return address;
-}
-
-void DRM(free_pages)(unsigned long address, int order, int area)
-{
- unsigned long bytes = PAGE_SIZE << order;
- int alloc_count;
- int free_count;
- unsigned long addr;
- unsigned int sz;
-
- if (!address) {
- DRM_MEM_ERROR(area, "Attempt to free address 0\n");
- } else {
- /* Unreserve */
- for (addr = address, sz = bytes;
- sz > 0;
- addr += PAGE_SIZE, sz -= PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- }
- free_pages(address, order);
- }
-
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[area].free_count;
- alloc_count = DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_freed += bytes;
- DRM(ram_used) -= bytes;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(area,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
- return NULL;
- }
-
- if (!(pt = drm_ioremap(offset, size, dev))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size, drm_device_t *dev)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
- return NULL;
- }
-
- if (!(pt = drm_ioremap_nocache(offset, size, dev))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
- spin_unlock(&DRM(mem_lock));
- return pt;
-}
-
-void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
-{
- int alloc_count;
- int free_count;
-
- if (!pt)
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Attempt to free NULL pointer\n");
- else
- drm_ioremapfree(pt, size, dev);
-
- spin_lock(&DRM(mem_lock));
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
- free_count = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-#if __REALLY_HAVE_AGP
-
-agp_memory *DRM(agp_alloc)(int pages, u32 type)
-{
- agp_memory *handle;
-
- if (!pages) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
- return NULL;
- }
-
- if ((handle = DRM(agp_allocate_memory)(pages, type))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
- += pages << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- return handle;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
- spin_unlock(&DRM(mem_lock));
- return NULL;
-}
-
-int DRM(agp_free)(agp_memory *handle, int pages)
-{
- int alloc_count;
- int free_count;
- int retval = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Attempt to free NULL AGP handle\n");
- return retval;;
- }
-
- if (DRM(agp_free_memory)(handle)) {
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
- += pages << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return 0;
- }
- return retval;
-}
-
-int DRM(agp_bind)(agp_memory *handle, unsigned int start)
-{
- int retcode = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to bind NULL AGP handle\n");
- return retcode;
- }
-
- if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
- += handle->page_count << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- return retcode;
- }
- spin_lock(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
- spin_unlock(&DRM(mem_lock));
- return retcode;
-}
-
-int DRM(agp_unbind)(agp_memory *handle)
-{
- int alloc_count;
- int free_count;
- int retcode = -EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to unbind NULL AGP handle\n");
- return retcode;
- }
-
- if ((retcode = DRM(agp_unbind_memory)(handle))) return retcode;
- spin_lock(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
- += handle->page_count << PAGE_SHIFT;
- spin_unlock(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return retcode;
-}
-#endif
diff --git a/linux/drm_memory_tmp.h b/linux/drm_memory_tmp.h
index 0c580c20d..c633079aa 100644
--- a/linux/drm_memory_tmp.h
+++ b/linux/drm_memory_tmp.h
@@ -35,13 +35,6 @@
#include <linux/config.h>
#include "drmP.h"
-/**
- * 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.
- */
-#define DEBUG_MEMORY 0
-
/* Need the 4-argument version of vmap(). */
#if __REALLY_HAVE_AGP && defined(VMAP_4_ARGS)
@@ -196,34 +189,6 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
iounmap(pt);
}
-#if DEBUG_MEMORY
-#include "drm_memory_debug.h"
-#else
-
-/** No-op. */
-void DRM(mem_init)(void)
-{
-}
-
-/**
- * Called when "/proc/dri/%dev%/mem" is read.
- *
- * \param buf output buffer.
- * \param start start of output data.
- * \param offset requested start offset.
- * \param len requested number of bytes.
- * \param eof whether there is no more data to return.
- * \param data private data.
- * \return number of written bytes.
- *
- * No-op.
- */
-int DRM(mem_info)(char *buf, char **start, off_t offset,
- int len, int *eof, void *data)
-{
- return 0;
-}
-
/** Wrapper around kmalloc() */
void *DRM(alloc)(size_t size, int area)
{
@@ -327,32 +292,3 @@ void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev)
{
drm_ioremapfree(pt, size, dev);
}
-
-#if __REALLY_HAVE_AGP
-/** Wrapper around agp_allocate_memory() */
-agp_memory *DRM(agp_alloc)(int pages, u32 type)
-{
- return DRM(agp_allocate_memory)(pages, type);
-}
-
-/** Wrapper around agp_free_memory() */
-int DRM(agp_free)(agp_memory *handle, int pages)
-{
- return DRM(agp_free_memory)(handle) ? 0 : -EINVAL;
-}
-
-/** Wrapper around agp_bind_memory() */
-int DRM(agp_bind)(agp_memory *handle, unsigned int start)
-{
- return DRM(agp_bind_memory)(handle, start);
-}
-
-/** Wrapper around agp_unbind_memory() */
-int DRM(agp_unbind)(agp_memory *handle)
-{
- return DRM(agp_unbind_memory)(handle);
-}
-#endif /* __REALLY_HAVE_AGP */
-
-
-#endif /* debug_memory */
diff --git a/linux/drm_proc.h b/linux/drm_proc.h
index 3d2c96b46..ac87e4548 100644
--- a/linux/drm_proc.h
+++ b/linux/drm_proc.h
@@ -63,7 +63,6 @@ struct drm_proc_list {
int (*f)(char *, char **, off_t, int, int *, void *); /**< proc callback*/
} DRM(proc_list)[] = {
{ "name", DRM(name_info) },
- { "mem", DRM(mem_info) },
{ "vm", DRM(vm_info) },
{ "clients", DRM(clients_info) },
{ "queues", DRM(queues_info) },