提交 14415745 编写于 作者: C Chris Wilson 提交者: Daniel Vetter

drm/i915: Refactor get_fence() to use the common fence writing routine

We can also take advantage of the new 'no retire' mode for seqno waiting
to avoid having to take a reference on the old fence object whilst
flushing an existing fence.
Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 ada726c7
...@@ -2361,7 +2361,7 @@ i915_gem_object_flush_fence(struct drm_i915_gem_object *obj) ...@@ -2361,7 +2361,7 @@ i915_gem_object_flush_fence(struct drm_i915_gem_object *obj)
if (obj->last_fenced_seqno) { if (obj->last_fenced_seqno) {
ret = i915_wait_request(obj->ring, ret = i915_wait_request(obj->ring,
obj->last_fenced_seqno, obj->last_fenced_seqno,
true); false);
if (ret) if (ret)
return ret; return ret;
...@@ -2449,63 +2449,47 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj) ...@@ -2449,63 +2449,47 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
{ {
struct drm_device *dev = obj->base.dev; struct drm_device *dev = obj->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
bool enable = obj->tiling_mode != I915_TILING_NONE;
struct drm_i915_fence_reg *reg; struct drm_i915_fence_reg *reg;
int ret; int ret;
if (obj->tiling_mode == I915_TILING_NONE) /* Have we updated the tiling parameters upon the object and so
return i915_gem_object_put_fence(obj); * will need to serialise the write to the associated fence register?
*/
if (obj->tiling_changed) {
ret = i915_gem_object_flush_fence(obj);
if (ret)
return ret;
}
/* Just update our place in the LRU if our fence is getting reused. */ /* Just update our place in the LRU if our fence is getting reused. */
if (obj->fence_reg != I915_FENCE_REG_NONE) { if (obj->fence_reg != I915_FENCE_REG_NONE) {
reg = &dev_priv->fence_regs[obj->fence_reg]; reg = &dev_priv->fence_regs[obj->fence_reg];
list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list); if (!obj->tiling_changed) {
list_move_tail(&reg->lru_list,
&dev_priv->mm.fence_list);
return 0;
}
} else if (enable) {
reg = i915_find_fence_reg(dev);
if (reg == NULL)
return -EDEADLK;
if (reg->obj) {
struct drm_i915_gem_object *old = reg->obj;
if (obj->tiling_changed) { ret = i915_gem_object_flush_fence(old);
ret = i915_gem_object_flush_fence(obj);
if (ret) if (ret)
return ret; return ret;
goto update; i915_gem_object_fence_lost(old);
} }
} else
return 0; return 0;
}
reg = i915_find_fence_reg(dev);
if (reg == NULL)
return -EDEADLK;
ret = i915_gem_object_flush_fence(obj);
if (ret)
return ret;
if (reg->obj) {
struct drm_i915_gem_object *old = reg->obj;
drm_gem_object_reference(&old->base); i915_gem_object_update_fence(obj, reg, enable);
if (old->tiling_mode)
i915_gem_release_mmap(old);
ret = i915_gem_object_flush_fence(old);
if (ret) {
drm_gem_object_unreference(&old->base);
return ret;
}
old->fence_reg = I915_FENCE_REG_NONE;
old->last_fenced_seqno = 0;
drm_gem_object_unreference(&old->base);
}
reg->obj = obj;
list_move_tail(&reg->lru_list, &dev_priv->mm.fence_list);
obj->fence_reg = reg - dev_priv->fence_regs;
update:
obj->tiling_changed = false; obj->tiling_changed = false;
i915_gem_write_fence(dev, reg - dev_priv->fence_regs, obj);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册