diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-02-28 09:08:52 +0100 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2008-03-12 09:49:27 +0100 |
commit | 8a18d123f55a7fb11ce333f0b1095020918b8616 (patch) | |
tree | 8d49c10e3001408cd4778a11fd535c19a70850af | |
parent | f13936f7fc4d4932d5c511ccec29f1c4d24dc2dc (diff) |
Avoid large kmallocs.
-rw-r--r-- | shared-core/i915_dma.c | 28 | ||||
-rw-r--r-- | shared-core/i915_drv.h | 2 |
2 files changed, 19 insertions, 11 deletions
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c index 7d247f9c..f6df74a7 100644 --- a/shared-core/i915_dma.c +++ b/shared-core/i915_dma.c @@ -1181,7 +1181,6 @@ static int i915_handle_copyback(struct drm_device *dev, buffers++; } } - return err; } @@ -1272,7 +1271,6 @@ static int i915_execbuffer(struct drm_device *dev, void *data, struct drm_fence_arg *fence_arg = &exec_buf->fence_arg; int num_buffers; int ret; - struct drm_i915_validate_buffer *buffers; if (!dev_priv->allow_batchbuffer) { DRM_ERROR("Batchbuffer ioctl disabled\n"); @@ -1288,7 +1286,6 @@ static int i915_execbuffer(struct drm_device *dev, void *data, if (exec_buf->num_buffers > dev_priv->max_validate_buffers) return -EINVAL; - ret = drm_bo_read_lock(&dev->bm.bm_lock); if (ret) return ret; @@ -1306,8 +1303,12 @@ static int i915_execbuffer(struct drm_device *dev, void *data, num_buffers = exec_buf->num_buffers; - buffers = drm_calloc(num_buffers, sizeof(struct drm_i915_validate_buffer), DRM_MEM_DRIVER); - if (!buffers) { + if (!dev_priv->val_bufs) { + dev_priv->val_bufs = + vmalloc(sizeof(struct drm_i915_validate_buffer)* + dev_priv->max_validate_buffers); + } + if (!dev_priv->val_bufs) { drm_bo_read_unlock(&dev->bm.bm_lock); mutex_unlock(&dev_priv->cmdbuf_mutex); return -ENOMEM; @@ -1315,7 +1316,7 @@ static int i915_execbuffer(struct drm_device *dev, void *data, /* validate buffer list + fixup relocations */ ret = i915_validate_buffer_list(file_priv, 0, exec_buf->ops_list, - buffers, &num_buffers); + dev_priv->val_bufs, &num_buffers); if (ret) goto out_err0; @@ -1324,7 +1325,7 @@ static int i915_execbuffer(struct drm_device *dev, void *data, drm_agp_chipset_flush(dev); /* submit buffer */ - batch->start = buffers[num_buffers-1].buffer->offset; + batch->start = dev_priv->val_bufs[num_buffers-1].buffer->offset; DRM_DEBUG("i915 exec batchbuffer, start %x used %d cliprects %d\n", batch->start, batch->used, batch->num_cliprects); @@ -1341,13 +1342,11 @@ static int i915_execbuffer(struct drm_device *dev, void *data, out_err0: /* handle errors */ - ret = i915_handle_copyback(dev, buffers, num_buffers, ret); + ret = i915_handle_copyback(dev, dev_priv->val_bufs, num_buffers, ret); mutex_lock(&dev->struct_mutex); - i915_dereference_buffers_locked(buffers, num_buffers); + i915_dereference_buffers_locked(dev_priv->val_bufs, num_buffers); mutex_unlock(&dev->struct_mutex); - drm_free(buffers, (exec_buf->num_buffers * sizeof(struct drm_buffer_object *)), DRM_MEM_DRIVER); - mutex_unlock(&dev_priv->cmdbuf_mutex); drm_bo_read_unlock(&dev->bm.bm_lock); return ret; @@ -1618,6 +1617,13 @@ void i915_driver_lastclose(struct drm_device * dev) { drm_i915_private_t *dev_priv = dev->dev_private; +#ifdef I915_HAVE_BUFFER + if (dev_priv->val_bufs) { + vfree(dev_priv->val_bufs); + dev_priv->val_bufs = NULL; + } +#endif + if (drm_getsarea(dev) && dev_priv->sarea_priv) i915_do_cleanup_pageflip(dev); if (dev_priv->agp_heap) diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index 570fc4d3..3bc39e2a 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -69,6 +69,7 @@ #ifdef I915_HAVE_BUFFER #define I915_MAX_VALIDATE_BUFFERS 4096 +struct drm_i915_validate_buffer; #endif typedef struct _drm_i915_ring_buffer { @@ -141,6 +142,7 @@ typedef struct drm_i915_private { void *agp_iomap; unsigned int max_validate_buffers; struct mutex cmdbuf_mutex; + struct drm_i915_validate_buffer *val_bufs; #endif DRM_SPINTYPE swaps_lock; |