summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-05-01 20:41:55 -0700
committerKeith Packard <keithp@keithp.com>2008-05-01 20:41:55 -0700
commit0d547c9ed92c0183f2c727496154baa2849f326e (patch)
tree25a815d82922f4e37a704a39d7f59ad5de4ea928
parent30efad5113944681c1abd6452e10355c105e9c39 (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.
-rw-r--r--linux-core/i915_gem.c15
-rw-r--r--shared-core/i915_drm.h16
2 files changed, 21 insertions, 10 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);
diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h
index 91461c41..0c64e866 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -451,15 +451,18 @@ struct drm_i915_gem_validate_entry {
* operation.
*/
uint32_t buffer_handle;
+
+ /** List of relocations to be performed on this buffer */
+ uint32_t relocation_count;
+ uint64_t relocs_ptr; /* struct drm_i915_gem_relocation_entry *relocs */
+
+ /** Required alignment in graphics aperture */
+ uint64_t alignment;
/**
* Returned value of the updated offset of the buffer, for future
* presumed_offset writes.
*/
- uint32_t buffer_offset;
- /** List of relocations to be performed on this buffer */
- uint64_t relocs_ptr; /* struct drm_i915_gem_relocation_entry *relocs */
- uint32_t relocation_count;
- uint32_t pad;
+ uint64_t buffer_offset;
};
struct drm_i915_gem_execbuffer {
@@ -488,6 +491,9 @@ struct drm_i915_gem_pin {
/** Handle of the buffer to be pinned. */
uint32_t handle;
uint32_t pad;
+
+ /** alignment required within the aperture */
+ uint64_t alignment;
/** Returned GTT offset of the buffer. */
uint64_t offset;