summaryrefslogtreecommitdiff
path: root/shared-core
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2007-04-17 18:16:38 +1000
committerDave Airlie <airlied@linux.ie>2007-04-17 18:16:38 +1000
commit79aa1d54746f33c33ffbf98fb96ccbf88c3cb390 (patch)
tree7ccbdbc7750015391833988a68b8058d2eb77235 /shared-core
parentcd5769c3b563048357535b24dc40783775adb227 (diff)
another large overhaul of interactions with userspace...
We need to keep a list of user created fbs to nuke on master exit. We also need to use the bo properly.
Diffstat (limited to 'shared-core')
-rw-r--r--shared-core/i915_dma.c12
-rw-r--r--shared-core/i915_drv.h1
-rw-r--r--shared-core/i915_init.c35
3 files changed, 34 insertions, 14 deletions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 2b29dbe2..25172c1b 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -85,6 +85,8 @@ int i915_dma_cleanup(drm_device_t * dev)
* may not have been called from userspace and after dev_private
* is freed, it's too late.
*/
+ I915_WRITE(LP_RING + RING_LEN, 0);
+
if (dev->irq)
drm_irq_uninstall(dev);
@@ -97,6 +99,16 @@ static int i915_initialize(drm_device_t * dev,
drm_i915_init_t * init)
{
+ /* reset ring pointers */
+ I915_WRITE(LP_RING + RING_LEN, 0);
+ mb();
+
+ memset((void *)(dev_priv->ring.virtual_start), 0, dev_priv->ring.Size);
+
+ I915_WRITE(LP_RING + RING_START, dev_priv->ring.Start);
+ I915_WRITE(LP_RING + RING_LEN, ((dev_priv->ring.Size - 4096) & RING_NR_PAGES) | (RING_NO_REPORT | RING_VALID));
+
+
dev_priv->cpp = init->cpp;
dev_priv->sarea_priv->pf_current_page = 0;
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index f4343014..8c2b4817 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -93,7 +93,6 @@ typedef struct drm_i915_private {
drm_local_map_t *sarea;
drm_local_map_t *mmio_map;
- unsigned long baseaddr;
unsigned long mmiobase;
unsigned long mmiolen;
diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c
index 273a1116..2ed7a822 100644
--- a/shared-core/i915_init.c
+++ b/shared-core/i915_init.c
@@ -138,12 +138,12 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
if (IS_I9XX(dev)) {
dev_priv->mmiobase = drm_get_resource_start(dev, 0);
dev_priv->mmiolen = drm_get_resource_len(dev, 0);
- dev->mode_config.fb_base = dev_priv->baseaddr =
+ dev->mode_config.fb_base =
drm_get_resource_start(dev, 2) & 0xff000000;
} else if (drm_get_resource_start(dev, 1)) {
dev_priv->mmiobase = drm_get_resource_start(dev, 1);
dev_priv->mmiolen = drm_get_resource_len(dev, 1);
- dev->mode_config.fb_base = dev_priv->baseaddr =
+ dev->mode_config.fb_base =
drm_get_resource_start(dev, 0) & 0xff000000;
} else {
DRM_ERROR("Unable to find MMIO registers\n");
@@ -178,14 +178,18 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
i915_probe_agp(dev->pdev, &agp_size, &prealloc_size);
DRM_DEBUG("setting up %d bytes of PRIV0 space\n", prealloc_size);
- drm_bo_init_mm(dev, DRM_BO_MEM_PRIV0, dev_priv->baseaddr,
+ drm_bo_init_mm(dev, DRM_BO_MEM_PRIV0, 0,
prealloc_size >> PAGE_SHIFT);
+ I915_WRITE(LP_RING + RING_LEN, 0);
+ I915_WRITE(LP_RING + RING_HEAD, 0);
+ I915_WRITE(LP_RING + RING_TAIL, 0);
+
size = PRIMARY_RINGBUFFER_SIZE;
ret = drm_buffer_object_create(dev, size, drm_bo_type_kernel,
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE |
DRM_BO_FLAG_MEM_PRIV0 |
- DRM_BO_FLAG_NO_MOVE,
+ DRM_BO_FLAG_NO_EVICT,
DRM_BO_HINT_DONT_FENCE, 0x1, 0,
&dev_priv->ring_buffer);
if (ret < 0) {
@@ -194,23 +198,17 @@ int i915_driver_load(drm_device_t *dev, unsigned long flags)
}
/* remap the buffer object properly */
- dev_priv->ring.Start = dev_priv->ring_buffer->offset + dev_priv->baseaddr;
+ dev_priv->ring.Start = dev_priv->ring_buffer->offset;
dev_priv->ring.End = dev_priv->ring.Start + size;
dev_priv->ring.Size = size;
dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
-
ret = drm_mem_reg_ioremap(dev, &dev_priv->ring_buffer->mem,
&dev_priv->ring.virtual_start);
if (ret)
DRM_ERROR("error mapping ring buffer: %d\n", ret);
DRM_DEBUG("ring start %08X, %08X, %08X\n", dev_priv->ring.Start, dev_priv->ring.virtual_start, dev_priv->ring.Size);
- I915_WRITE(LP_RING + RING_HEAD, 0);
- I915_WRITE(LP_RING + RING_TAIL, 0);
- I915_WRITE(LP_RING + RING_START, dev_priv->ring.Start);
- I915_WRITE(LP_RING + RING_LEN, ((dev_priv->ring.Size - 4096) & RING_NR_PAGES) |
- (RING_NO_REPORT | RING_VALID));
dev_priv->sarea_priv->pf_current_page = 0;
@@ -294,11 +292,22 @@ int i915_driver_unload(drm_device_t *dev)
I915_WRITE(LP_RING + RING_LEN, 0);
- iounmap(dev_priv->ring.virtual_start);
+ intel_modeset_cleanup(dev);
+
+ drm_mem_reg_iounmap(dev, &dev_priv->ring_buffer->mem,
+ dev_priv->ring.virtual_start);
+
+ mutex_lock(&dev->struct_mutex);
+ drm_bo_usage_deref_locked(dev_priv->ring_buffer);
+ mutex_unlock(&dev->struct_mutex);
+
+ if (drm_bo_clean_mm(dev, DRM_BO_MEM_PRIV0)) {
+ DRM_ERROR("Memory manager type 3 not clean. "
+ "Delaying takedown\n");
+ }
drm_bo_driver_finish(dev);
- intel_modeset_cleanup(dev);
DRM_DEBUG("%p, %p\n", dev_priv->mmio_map, dev_priv->sarea);
drm_rmmap(dev, dev_priv->mmio_map);
drm_rmmap(dev, dev_priv->sarea);