[Intel-gfx] [PATCH 1/3] drm/i915: Unbind the bo if the user requests a different alignment
Chris Wilson
chris at chris-wilson.co.uk
Sun Apr 4 23:35:19 CEST 2010
If the buffer is currently bound and does not meet the requested
alignment, then unbind it and repin.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 309fd06..c148170 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1332,7 +1332,7 @@ i915_gem_free_mmap_offset(struct drm_gem_object *obj)
* potential fence register mapping if needed.
*/
static uint32_t
-i915_gem_get_gtt_alignment(struct drm_gem_object *obj)
+i915_gem_get_fence_alignment(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
@@ -2615,6 +2615,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
{
struct drm_device *dev = obj->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
+ unsigned fence_alignment;
struct drm_i915_gem_object *obj_priv = obj->driver_private;
struct drm_mm_node *free_space;
gfp_t gfpmask = __GFP_NORETRY | __GFP_NOWARN;
@@ -2625,12 +2626,9 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
return -EINVAL;
}
- if (alignment == 0)
- alignment = i915_gem_get_gtt_alignment(obj);
- if (alignment & (i915_gem_get_gtt_alignment(obj) - 1)) {
- DRM_ERROR("Invalid object alignment requested %u\n", alignment);
- return -EINVAL;
- }
+ fence_alignment = i915_gem_get_fence_alignment(obj);
+ if (alignment < fence_alignment)
+ alignment = fence_alignment;
search_free:
free_space = drm_mm_search_free(&dev_priv->mm.gtt_space,
@@ -3286,9 +3284,11 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
obj_priv->tiling_mode != I915_TILING_NONE;
/* Check fence reg constraints and rebind if necessary */
- if (need_fence &&
- !i915_gem_object_fence_offset_ok(obj,
- obj_priv->tiling_mode)) {
+ if ((need_fence &&
+ !i915_gem_object_fence_offset_ok(obj,
+ obj_priv->tiling_mode)) ||
+ (entry->alignment &&
+ obj_priv->gtt_offset & (entry->alignment - 1))) {
ret = i915_gem_object_unbind(obj);
if (ret)
return ret;
--
1.7.0.3
More information about the Intel-gfx
mailing list