diff options
author | Keith Packard <keithp@keithp.com> | 2008-05-01 20:41:55 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-05-01 20:41:55 -0700 |
commit | 0d547c9ed92c0183f2c727496154baa2849f326e (patch) | |
tree | 25a815d82922f4e37a704a39d7f59ad5de4ea928 /linux-core | |
parent | 30efad5113944681c1abd6452e10355c105e9c39 (diff) |
Add alignment to all aperture allocation requests.
When pinning buffers, or using execbuffer, allow the application to specify
the necessary aperture allocation alignment constraints.
Diffstat (limited to 'linux-core')
-rw-r--r-- | linux-core/i915_gem.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/linux-core/i915_gem.c b/linux-core/i915_gem.c index 335f0618..30e67742 100644 --- a/linux-core/i915_gem.c +++ b/linux-core/i915_gem.c @@ -96,21 +96,26 @@ i915_gem_object_unbind(struct drm_device *dev, struct drm_gem_object *obj) * Finds free space in the GTT aperture and binds the object there. */ static int -i915_gem_object_bind_to_gtt(struct drm_device *dev, struct drm_gem_object *obj) +i915_gem_object_bind_to_gtt(struct drm_device *dev, struct drm_gem_object *obj, unsigned alignment) { drm_i915_private_t *dev_priv = dev->dev_private; struct drm_i915_gem_object *obj_priv = obj->driver_private; struct drm_memrange_node *free_space; int page_count, i; + if (alignment == 0) + alignment = PAGE_SIZE; + if (alignment & (PAGE_SIZE - 1)) + return -EINVAL; + free_space = drm_memrange_search_free(&dev_priv->mm.gtt_space, obj->size, - PAGE_SIZE, 0); + alignment, 0); if (free_space == NULL) return -ENOMEM; obj_priv->gtt_space = drm_memrange_get_block(free_space, obj->size, - PAGE_SIZE); + alignment); if (obj_priv->gtt_space == NULL) return -ENOMEM; @@ -173,7 +178,7 @@ i915_gem_reloc_and_validate_object(struct drm_device *dev, /* Choose the GTT offset for our buffer and put it there. */ if (obj_priv->gtt_space == NULL) { - i915_gem_object_bind_to_gtt(dev, obj); + i915_gem_object_bind_to_gtt(dev, obj, (unsigned) entry->alignment); if (obj_priv->gtt_space == NULL) return -ENOMEM; } @@ -367,7 +372,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data, return -EINVAL; } - ret = i915_gem_object_bind_to_gtt(dev, obj); + ret = i915_gem_object_bind_to_gtt(dev, obj, (unsigned) args->alignment); if (ret != 0) { DRM_ERROR("Failure to bind in i915_gem_pin_ioctl(): %d\n", ret); |