summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-01-25 14:26:58 +0100
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2007-01-25 14:27:29 +0100
commit582637641abbadc75795ac7e0671e1a5e3b41880 (patch)
tree0df2009a7b164cac50485fd8dd241465f6c299b2
parent90ae39d2f07058dd128d2fb19ffad712ee75c9a0 (diff)
Remove a scary error printed when we were leaking memory caches.
We don't use memory caches anymore... Fix memory accounting initialization to only use low or DMA32 memory.
-rw-r--r--linux-core/drmP.h3
-rw-r--r--linux-core/drm_drv.c32
-rw-r--r--linux-core/drm_memory.c7
3 files changed, 32 insertions, 10 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index af8a544d..ff3fc67f 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -1127,7 +1127,8 @@ extern void drm_query_memctl(drm_u64_t *cur_used,
drm_u64_t *low_threshold,
drm_u64_t *high_threshold);
extern void drm_init_memctl(size_t low_threshold,
- size_t high_threshold);
+ size_t high_threshold,
+ size_t unit_size);
/* Misc. IOCTL support (drm_ioctl.h) */
extern int drm_irq_by_busid(struct inode *inode, struct file *filp,
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 45f563ff..ff9b29e7 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -148,10 +148,11 @@ int drm_lastclose(drm_device_t * dev)
DRM_DEBUG("\n");
- if (drm_bo_driver_finish(dev)) {
- DRM_ERROR("DRM memory manager still busy. "
- "System is unstable. Please reboot.\n");
- }
+ /*
+ * We can't do much about this function failing.
+ */
+
+ drm_bo_driver_finish(dev);
if (dev->driver->lastclose)
dev->driver->lastclose(dev);
@@ -450,9 +451,28 @@ static int __init drm_core_init(void)
{
int ret;
struct sysinfo si;
-
+ unsigned long avail_memctl_mem;
+ unsigned long max_memctl_mem;
+
si_meminfo(&si);
- drm_init_memctl(si.totalram/2, si.totalram*3/4);
+
+ /*
+ * AGP only allows low / DMA32 memory ATM.
+ */
+
+ avail_memctl_mem = si.totalram - si.totalhigh;
+
+ /*
+ * Avoid overflows
+ */
+
+ max_memctl_mem = 1UL << (32 - PAGE_SHIFT);
+ max_memctl_mem = (max_memctl_mem / si.mem_unit) * PAGE_SIZE;
+
+ if (avail_memctl_mem >= max_memctl_mem)
+ avail_memctl_mem = max_memctl_mem;
+
+ drm_init_memctl(avail_memctl_mem/2, avail_memctl_mem*3/4, si.mem_unit);
ret = -ENOMEM;
drm_cards_limit =
diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c
index 62f54b67..9a53fa82 100644
--- a/linux-core/drm_memory.c
+++ b/linux-core/drm_memory.c
@@ -95,12 +95,13 @@ void drm_query_memctl(drm_u64_t *cur_used,
EXPORT_SYMBOL(drm_query_memctl);
void drm_init_memctl(size_t p_low_threshold,
- size_t p_high_threshold)
+ size_t p_high_threshold,
+ size_t unit_size)
{
spin_lock(&drm_memctl.lock);
drm_memctl.cur_used = 0;
- drm_memctl.low_threshold = p_low_threshold << PAGE_SHIFT;
- drm_memctl.high_threshold = p_high_threshold << PAGE_SHIFT;
+ drm_memctl.low_threshold = p_low_threshold * unit_size;
+ drm_memctl.high_threshold = p_high_threshold * unit_size;
spin_unlock(&drm_memctl.lock);
}