Remove a scary error printed when we were leaking memory caches.
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Thu, 25 Jan 2007 13:26:58 +0000 (14:26 +0100)
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Thu, 25 Jan 2007 13:27:29 +0000 (14:27 +0100)
We don't use memory caches anymore...

Fix memory accounting initialization to only use low or DMA32 memory.

linux-core/drmP.h
linux-core/drm_drv.c
linux-core/drm_memory.c

index af8a544..ff3fc67 100644 (file)
@@ -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,
index 45f563f..ff9b29e 100644 (file)
@@ -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 =
index 62f54b6..9a53fa8 100644 (file)
@@ -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);
 }