summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
Diffstat (limited to 'linux-core')
-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);
}