summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas@tungstengraphics.com>2006-02-28 20:26:21 +0000
committerThomas Hellstrom <thomas@tungstengraphics.com>2006-02-28 20:26:21 +0000
commit2639c7af46c15ca08a9504ac0915d70bb3dcfe9a (patch)
tree400e0745e1512e62917cfa8bb138dab2086f62a2
parent82f75bb0c2446172b5ea0dc844ed348671af0b69 (diff)
mm: Initialize and update mm sarea. Lindent.
-rw-r--r--linux-core/drmP.h6
-rw-r--r--linux-core/drm_mm.c4
-rw-r--r--linux-core/drm_ttm.c57
-rw-r--r--linux-core/drm_ttm.h4
-rw-r--r--shared-core/drm.h26
-rw-r--r--shared-core/i915_dma.c30
-rw-r--r--shared-core/i915_drv.h8
7 files changed, 98 insertions, 37 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 91a6e7a6..6c351f0a 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -585,10 +585,14 @@ typedef struct drm_ttm_mm {
} drm_ttm_mm_t;
typedef struct drm_mm_driver {
+ int evicted_vram;
+ int evicted_tt;
+ int validated;
int cached_pages;
drm_ttm_mm_t ttm_mm;
drm_mm_t vr_mm;
- drm_map_list_t *mm_sarea;
+ drm_map_list_t *mm_sarea_map;
+ volatile drm_mm_sarea_t *mm_sarea;
uint32_t(*emit_fence) (struct drm_device * dev);
int (*wait_fence) (struct drm_device * dev, uint32_t fence);
int (*test_fence) (struct drm_device * dev, uint32_t fence);
diff --git a/linux-core/drm_mm.c b/linux-core/drm_mm.c
index f7a5fc25..fe576fcc 100644
--- a/linux-core/drm_mm.c
+++ b/linux-core/drm_mm.c
@@ -179,9 +179,10 @@ int drm_mm_init(drm_mm_t * mm, unsigned long start, unsigned long size)
return 0;
}
+
EXPORT_SYMBOL(drm_mm_init);
-void drm_mm_takedown(drm_mm_t *mm)
+void drm_mm_takedown(drm_mm_t * mm)
{
struct list_head *bnode = mm->root_node.fl_entry.next;
drm_mm_node_t *entry;
@@ -193,4 +194,5 @@ void drm_mm_takedown(drm_mm_t *mm)
drm_free(entry, sizeof(*entry), DRM_MEM_MM);
}
+
EXPORT_SYMBOL(drm_mm_takedown);
diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c
index 4461135a..78b28ca3 100644
--- a/linux-core/drm_ttm.c
+++ b/linux-core/drm_ttm.c
@@ -826,6 +826,7 @@ static int drm_ttm_evict_lru_sl(drm_ttm_backend_list_t * entry,
*have_fence = TRUE;
} while (TRUE);
DRM_ERROR("Evicting 0x%lx\n", (unsigned long)evict_priv->region);
+ dev->mm_driver->evicted_tt = TRUE;
evict_node = evict_priv->region->mm_node;
drm_evict_ttm_region(evict_priv->region);
list_del_init(list);
@@ -911,8 +912,8 @@ static int drm_validate_ttm_region(drm_ttm_backend_list_t * entry,
return 0;
}
-static void drm_ttm_mm_init(drm_device_t * dev, drm_ttm_mm_t * mm, unsigned long start,
- unsigned long size)
+static void drm_ttm_mm_init(drm_device_t * dev, drm_ttm_mm_t * mm,
+ unsigned long start, unsigned long size)
{
drm_mm_init(&mm->mm, start, size);
INIT_LIST_HEAD(&mm->lru_head);
@@ -924,7 +925,6 @@ static void drm_ttm_mm_takedown(drm_ttm_mm_t * mm)
drm_mm_takedown(&mm->mm);
}
-
static int drm_ttm_from_handle(drm_handle_t handle, drm_file_t * priv,
drm_ttm_t ** used_ttm,
drm_map_list_t ** used_list)
@@ -1136,6 +1136,8 @@ int drm_ttm_handle_bufs(drm_file_t * priv, drm_ttm_arg_t * ttm_arg)
drm_mm_driver_t *mm_driver = dev->mm_driver;
drm_ttm_buf_arg_t *bufs = NULL, *next, *buf_p;
int i;
+ volatile drm_mm_sarea_t *sa;
+
static void *old_priv;
if (ttm_arg->num_bufs > DRM_TTM_MAX_BUF_BATCH) {
@@ -1143,6 +1145,10 @@ int drm_ttm_handle_bufs(drm_file_t * priv, drm_ttm_arg_t * ttm_arg)
return -EINVAL;
}
+ mm_driver->evicted_vram = FALSE;
+ mm_driver->evicted_tt = FALSE;
+ mm_driver->validated = FALSE;
+
if (ttm_arg->num_bufs) {
bufs =
@@ -1200,6 +1206,15 @@ int drm_ttm_handle_bufs(drm_file_t * priv, drm_ttm_arg_t * ttm_arg)
drm_free(bufs, ttm_arg->num_bufs * sizeof(*bufs), DRM_MEM_TTM);
}
+
+ sa = mm_driver->mm_sarea;
+ if (mm_driver->validated)
+ sa->validation_seq++;
+ if (mm_driver->evicted_vram)
+ sa->evict_vram_seq++;
+ if (mm_driver->evicted_tt)
+ sa->evict_vram_seq++;
+
return 0;
}
@@ -1296,22 +1311,20 @@ int drm_ttm_ioctl(DRM_IOCTL_ARGS)
return 0;
}
-
/*
* FIXME: Temporarily non-static to allow for intel initialization hack.
*/
-int drm_mm_do_takedown(drm_device_t *dev)
+int drm_mm_do_takedown(drm_device_t * dev)
{
if (!dev->mm_driver) {
DRM_ERROR("Memory manager not initialized.\n");
return -EINVAL;
}
-
drm_mm_takedown(&dev->mm_driver->vr_mm);
drm_ttm_mm_takedown(&dev->mm_driver->ttm_mm);
- drm_rmmap_locked(dev, dev->mm_driver->mm_sarea->map);
+ drm_rmmap_locked(dev, dev->mm_driver->mm_sarea_map->map);
dev->mm_driver->takedown(dev->mm_driver);
dev->mm_driver = NULL;
return 0;
@@ -1322,8 +1335,8 @@ EXPORT_SYMBOL(drm_mm_do_takedown);
/*
* FIXME: Temporarily non-static to allow for intel initialization hack.
*/
-
-int drm_mm_do_init(drm_device_t *dev, drm_mm_init_arg_t *arg)
+
+int drm_mm_do_init(drm_device_t * dev, drm_mm_init_arg_t * arg)
{
int ret;
unsigned long vr_size;
@@ -1349,11 +1362,10 @@ int drm_mm_do_init(drm_device_t *dev, drm_mm_init_arg_t *arg)
tt_p_size |= (arg->tt_p_size_hi << shift);
tt_p_offset |= (arg->tt_p_offset_hi << shift);
}
-
-
+
dev->mm_driver = dev->driver->init_mm(dev);
- drm_ttm_mm_init(dev, &dev->mm_driver->ttm_mm, tt_p_offset, tt_p_size);
+ drm_ttm_mm_init(dev, &dev->mm_driver->ttm_mm, tt_p_offset, tt_p_size);
drm_mm_init(&dev->mm_driver->vr_mm, vr_offset >> MM_VR_GRANULARITY,
vr_size >> MM_VR_GRANULARITY);
@@ -1362,24 +1374,26 @@ int drm_mm_do_init(drm_device_t *dev, drm_mm_init_arg_t *arg)
return -EINVAL;
}
- ret = drm_addmap_core(dev, 0, 4096, _DRM_SHM, 0, &mm_sarea);
+ ret = drm_addmap_core(dev, 0, DRM_MM_SAREA_SIZE,
+ _DRM_SHM, 0, &mm_sarea);
if (ret) {
dev->mm_driver->takedown(dev->mm_driver);
DRM_ERROR("Failed to add a Memory manager SAREA.\n");
return -ENOMEM;
}
-
- dev->mm_driver->mm_sarea = mm_sarea;
+
+ dev->mm_driver->mm_sarea_map = mm_sarea;
+ dev->mm_driver->mm_sarea = (drm_mm_sarea_t *) mm_sarea->map->handle;
+ memset((void *)dev->mm_driver->mm_sarea, 0, DRM_MM_SAREA_SIZE);
+
arg->mm_sarea = mm_sarea->user_token;
-
+
return 0;
}
EXPORT_SYMBOL(drm_mm_do_init);
-
int drm_mm_init_ioctl(DRM_IOCTL_ARGS)
-
{
DRM_DEVICE;
@@ -1387,14 +1401,15 @@ int drm_mm_init_ioctl(DRM_IOCTL_ARGS)
drm_mm_init_arg_t arg;
if (!dev->driver->init_mm) {
- DRM_ERROR("Memory management not supported with this driver.\n");
+ DRM_ERROR
+ ("Memory management not supported with this driver.\n");
return -EINVAL;
}
DRM_COPY_FROM_USER_IOCTL(arg, (void __user *)data, sizeof(arg));
down(&dev->struct_sem);
- switch(arg.op) {
+ switch (arg.op) {
case mm_init:
ret = drm_mm_do_init(dev, &arg);
break;
@@ -1409,7 +1424,7 @@ int drm_mm_init_ioctl(DRM_IOCTL_ARGS)
if (ret)
return ret;
-
+
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
return 0;
diff --git a/linux-core/drm_ttm.h b/linux-core/drm_ttm.h
index 00ff5f24..77f11bf0 100644
--- a/linux-core/drm_ttm.h
+++ b/linux-core/drm_ttm.h
@@ -68,7 +68,6 @@ typedef struct drm_ttm {
drm_file_t *owner;
} drm_ttm_t;
-
/*
* Initialize a ttm. Currently the size is fixed. Currently drmAddMap calls this function
* and creates a DRM map of type _DRM_TTM, and returns a reference to that map to the
@@ -124,10 +123,9 @@ extern void drm_user_destroy_region(drm_ttm_backend_list_t * entry);
extern int drm_ttm_ioctl(DRM_IOCTL_ARGS);
extern int drm_mm_init_ioctl(DRM_IOCTL_ARGS);
-
#define DRM_MASK_VAL(dest, mask, val) \
(dest) = ((dest) & ~(mask)) | ((val) & (mask));
-
+
#define DRM_TTM_MASK_FLAGS ((1 << PAGE_SHIFT) - 1)
#define DRM_TTM_MASK_PFN (0xFFFFFFFFU - DRM_TTM_MASK_FLAGS)
diff --git a/shared-core/drm.h b/shared-core/drm.h
index 342976c4..e0e25769 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -675,7 +675,31 @@ typedef struct drm_ttm_arg {
struct drm_ttm_buf_arg __user *first;
} drm_ttm_arg_t;
-
+typedef struct drm_mm_init_arg {
+ enum {
+ mm_init,
+ mm_takedown
+ } op;
+ uint32_t vr_offset_lo;
+ uint32_t vr_offset_hi;
+ uint32_t vr_size_lo;
+ uint32_t vr_size_hi;
+ uint32_t tt_p_offset_lo;
+ uint32_t tt_p_offset_hi;
+ uint32_t tt_p_size_lo;
+ uint32_t tt_p_size_hi;
+ drm_handle_t mm_sarea;
+} drm_mm_init_arg_t;
+
+#define DRM_MM_SAREA_SIZE 4096
+
+typedef struct drm_mm_sarea{
+ unsigned emitted[32]; /* Last emitted fence */
+ unsigned retired[32]; /* Last retired fence */
+ unsigned validation_seq; /* Seq. no of last validation call */
+ unsigned evict_vram_seq; /* Seq. no of last call vram was evicted */
+ unsigned evict_tt_seq; /* Seq. no of last call agp pages were evicted */
+} drm_mm_sarea_t;
/**
* \name Ioctls Definitions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index e3f634f3..15828ff1 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -191,11 +191,28 @@ static int i915_initialize(drm_device_t * dev,
I915_WRITE(0x02080, dev_priv->dma_status_page);
DRM_DEBUG("Enabled hardware status page\n");
-#ifdef DRM_HAS_TTM
- i915_init_ttm(dev, dev_priv);
-#endif
dev->dev_private = (void *)dev_priv;
+ /*
+ * FIXME: Temporary initialization hack.
+ */
+
+ {
+ drm_mm_init_arg_t arg;
+
+ arg.vr_size_lo = 1024*1024*24;
+ arg.vr_size_hi = 0;
+ arg.vr_offset_lo = 1024*1024*8;
+ arg.vr_offset_hi = 0;
+
+ arg.tt_p_size_lo = 1024*1024*48;
+ arg.tt_p_size_hi = 0;
+ arg.tt_p_offset_lo = 1024*1024*128/4096;
+ arg.tt_p_offset_hi = 0;
+ arg.op = mm_init;
+ drm_mm_do_init(dev, &arg);
+ }
+
return 0;
}
@@ -749,6 +766,13 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
void i915_driver_lastclose(drm_device_t * dev)
{
+ /*
+ * FIXME: Temporary initialization hack.
+ */
+
+
+ drm_mm_do_takedown (dev);
+
if (dev->dev_private) {
drm_i915_private_t *dev_priv = dev->dev_private;
i915_mem_takedown(&(dev_priv->agp_heap));
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 79adbcff..19b256b2 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -96,10 +96,6 @@ typedef struct drm_i915_private {
int allow_batchbuffer;
struct mem_block *agp_heap;
unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
-#ifdef DRM_HAS_TTM
- drm_ttm_mm_t ttm_mm;
- drm_ttm_driver_t ttm_driver;
-#endif
} drm_i915_private_t;
extern drm_ioctl_desc_t i915_ioctls[];
@@ -139,9 +135,7 @@ extern void i915_mem_takedown(struct mem_block **heap);
extern void i915_mem_release(drm_device_t * dev,
DRMFILE filp, struct mem_block *heap);
/* i915_ttm.c */
-extern void i915_init_ttm(drm_device_t *dev, drm_i915_private_t *dev_priv);
-
-
+extern drm_mm_driver_t *i915_mm_init(drm_device_t *dev);
#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))