|
|
|
@ -43,10 +43,10 @@ typedef struct drm_mem_stats {
|
|
|
|
|
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)[] =
|
|
|
|
|
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"},
|
|
|
|
@ -73,11 +73,11 @@ static drm_mem_stats_t DRM(mem_stats)[] =
|
|
|
|
|
{NULL, 0,} /* Last entry must be null */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void DRM(mem_init) (void) {
|
|
|
|
|
void drm_mem_init (void) {
|
|
|
|
|
drm_mem_stats_t *mem;
|
|
|
|
|
struct sysinfo si;
|
|
|
|
|
|
|
|
|
|
for (mem = DRM(mem_stats); mem->name; ++mem) {
|
|
|
|
|
for (mem = drm_mem_stats; mem->name; ++mem) {
|
|
|
|
|
mem->succeed_count = 0;
|
|
|
|
|
mem->free_count = 0;
|
|
|
|
|
mem->fail_count = 0;
|
|
|
|
@ -86,13 +86,13 @@ void DRM(mem_init) (void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
si_meminfo(&si);
|
|
|
|
|
DRM(ram_available) = si.totalram;
|
|
|
|
|
DRM(ram_used) = 0;
|
|
|
|
|
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,
|
|
|
|
|
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;
|
|
|
|
@ -111,11 +111,11 @@ static int DRM(_mem_info) (char *buf, char **start, off_t offset,
|
|
|
|
|
" | 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_ram_available << (PAGE_SHIFT - 10));
|
|
|
|
|
DRM_PROC_PRINT("%-9.9s %5d %5d %4d %10lu kB |\n",
|
|
|
|
|
"locked", 0, 0, 0, DRM(ram_used) >> 10);
|
|
|
|
|
"locked", 0, 0, 0, drm_ram_used >> 10);
|
|
|
|
|
DRM_PROC_PRINT("\n");
|
|
|
|
|
for (pt = DRM(mem_stats); pt->name; pt++) {
|
|
|
|
|
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,
|
|
|
|
@ -134,17 +134,17 @@ static int DRM(_mem_info) (char *buf, char **start, off_t offset,
|
|
|
|
|
return len - offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DRM(mem_info) (char *buf, char **start, off_t 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));
|
|
|
|
|
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 *drm_alloc (size_t size, int area) {
|
|
|
|
|
void *pt;
|
|
|
|
|
|
|
|
|
|
if (!size) {
|
|
|
|
@ -153,41 +153,41 @@ void *DRM(alloc) (size_t size, int area) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(pt = kmalloc(size, GFP_KERNEL))) {
|
|
|
|
|
spin_lock(&DRM(mem_lock));
|
|
|
|
|
++DRM(mem_stats)[area].fail_count;
|
|
|
|
|
spin_unlock(&DRM(mem_lock));
|
|
|
|
|
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));
|
|
|
|
|
spin_lock(&drm_mem_lock);
|
|
|
|
|
++drm_mem_stats[area].succeed_count;
|
|
|
|
|
drm_mem_stats[area].bytes_allocated += size;
|
|
|
|
|
spin_unlock(&drm_mem_lock);
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *DRM(calloc) (size_t nmemb, size_t size, int area) {
|
|
|
|
|
void *drm_calloc (size_t nmemb, size_t size, int area) {
|
|
|
|
|
void *addr;
|
|
|
|
|
|
|
|
|
|
addr = DRM(alloc) (nmemb * size, area);
|
|
|
|
|
addr = drm_alloc (nmemb * size, area);
|
|
|
|
|
if (addr != NULL)
|
|
|
|
|
memset((void *)addr, 0, size * nmemb);
|
|
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *DRM(realloc) (void *oldpt, size_t oldsize, size_t size, int area) {
|
|
|
|
|
void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) {
|
|
|
|
|
void *pt;
|
|
|
|
|
|
|
|
|
|
if (!(pt = DRM(alloc) (size, area)))
|
|
|
|
|
if (!(pt = drm_alloc (size, area)))
|
|
|
|
|
return NULL;
|
|
|
|
|
if (oldpt && oldsize) {
|
|
|
|
|
memcpy(pt, oldpt, oldsize);
|
|
|
|
|
DRM(free) (oldpt, oldsize, area);
|
|
|
|
|
drm_free (oldpt, oldsize, area);
|
|
|
|
|
}
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DRM(free) (void *pt, size_t size, int area) {
|
|
|
|
|
void drm_free (void *pt, size_t size, int area) {
|
|
|
|
|
int alloc_count;
|
|
|
|
|
int free_count;
|
|
|
|
|
|
|
|
|
@ -195,43 +195,43 @@ void DRM(free) (void *pt, size_t size, int area) {
|
|
|
|
|
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));
|
|
|
|
|
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 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));
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
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);
|
|
|
|
@ -245,7 +245,7 @@ unsigned long DRM(alloc_pages) (int order, int area) {
|
|
|
|
|
return address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DRM(free_pages) (unsigned long address, int order, int area) {
|
|
|
|
|
void drm_free_pages (unsigned long address, int order, int area) {
|
|
|
|
|
unsigned long bytes = PAGE_SIZE << order;
|
|
|
|
|
int alloc_count;
|
|
|
|
|
int free_count;
|
|
|
|
@ -263,12 +263,12 @@ void DRM(free_pages) (unsigned long address, int order, int area) {
|
|
|
|
|
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));
|
|
|
|
|
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",
|
|
|
|
@ -276,7 +276,7 @@ void DRM(free_pages) (unsigned long address, int order, int area) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *DRM(ioremap) (unsigned long offset, unsigned long size,
|
|
|
|
|
void *drm_ioremap (unsigned long offset, unsigned long size,
|
|
|
|
|
drm_device_t * dev) {
|
|
|
|
|
void *pt;
|
|
|
|
|
|
|
|
|
@ -287,19 +287,19 @@ void *DRM(ioremap) (unsigned long offset, unsigned long size,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
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,
|
|
|
|
|
void *drm_ioremap_nocache (unsigned long offset, unsigned long size,
|
|
|
|
|
drm_device_t * dev) {
|
|
|
|
|
void *pt;
|
|
|
|
|
|
|
|
|
@ -310,19 +310,19 @@ void *DRM(ioremap_nocache) (unsigned long offset, unsigned long size,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
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) {
|
|
|
|
|
void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) {
|
|
|
|
|
int alloc_count;
|
|
|
|
|
int free_count;
|
|
|
|
|
|
|
|
|
@ -332,11 +332,11 @@ void DRM(ioremapfree) (void *pt, unsigned long size, drm_device_t * dev) {
|
|
|
|
|
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));
|
|
|
|
|
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",
|
|
|
|
@ -346,7 +346,7 @@ void DRM(ioremapfree) (void *pt, unsigned long size, drm_device_t * dev) {
|
|
|
|
|
|
|
|
|
|
#if __OS_HAS_AGP
|
|
|
|
|
|
|
|
|
|
DRM_AGP_MEM *DRM(alloc_agp) (int pages, u32 type) {
|
|
|
|
|
DRM_AGP_MEM *drm_alloc_agp (int pages, u32 type) {
|
|
|
|
|
DRM_AGP_MEM *handle;
|
|
|
|
|
|
|
|
|
|
if (!pages) {
|
|
|
|
@ -354,21 +354,21 @@ DRM_AGP_MEM *DRM(alloc_agp) (int pages, u32 type) {
|
|
|
|
|
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
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
spin_lock(&drm_mem_lock);
|
|
|
|
|
++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count;
|
|
|
|
|
spin_unlock(&drm_mem_lock);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DRM(free_agp) (DRM_AGP_MEM * handle, int pages) {
|
|
|
|
|
int drm_free_agp (DRM_AGP_MEM * handle, int pages) {
|
|
|
|
|
int alloc_count;
|
|
|
|
|
int free_count;
|
|
|
|
|
int retval = -EINVAL;
|
|
|
|
@ -379,13 +379,13 @@ int DRM(free_agp) (DRM_AGP_MEM * handle, int pages) {
|
|
|
|
|
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
|
|
|
|
|
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));
|
|
|
|
|
spin_unlock(&drm_mem_lock);
|
|
|
|
|
if (free_count > alloc_count) {
|
|
|
|
|
DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
|
|
|
|
|
"Excess frees: %d frees, %d allocs\n",
|
|
|
|
@ -396,7 +396,7 @@ int DRM(free_agp) (DRM_AGP_MEM * handle, int pages) {
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DRM(bind_agp) (DRM_AGP_MEM * handle, unsigned int start) {
|
|
|
|
|
int drm_bind_agp (DRM_AGP_MEM * handle, unsigned int start) {
|
|
|
|
|
int retcode = -EINVAL;
|
|
|
|
|
|
|
|
|
|
if (!handle) {
|
|
|
|
@ -405,21 +405,21 @@ int DRM(bind_agp) (DRM_AGP_MEM * handle, unsigned int start) {
|
|
|
|
|
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
|
|
|
|
|
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));
|
|
|
|
|
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));
|
|
|
|
|
spin_lock(&drm_mem_lock);
|
|
|
|
|
++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count;
|
|
|
|
|
spin_unlock(&drm_mem_lock);
|
|
|
|
|
return retcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DRM(unbind_agp) (DRM_AGP_MEM * handle) {
|
|
|
|
|
int drm_unbind_agp (DRM_AGP_MEM * handle) {
|
|
|
|
|
int alloc_count;
|
|
|
|
|
int free_count;
|
|
|
|
|
int retcode = -EINVAL;
|
|
|
|
@ -430,14 +430,14 @@ int DRM(unbind_agp) (DRM_AGP_MEM * handle) {
|
|
|
|
|
return retcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((retcode = DRM(agp_unbind_memory) (handle)))
|
|
|
|
|
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
|
|
|
|
|
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));
|
|
|
|
|
spin_unlock(&drm_mem_lock);
|
|
|
|
|
if (free_count > alloc_count) {
|
|
|
|
|
DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
|
|
|
|
|
"Excess frees: %d frees, %d allocs\n",
|
|
|
|
|