A client like GVT-g will request fence register from host when creating vGPUs. According to Chris's comments, we'd better not expose the fence stealing function as a dedicated API as the caller may not know if the fence register could be stealed without touching the inner pin_count. This patch merges the fence stealing parts into i915_find_fence_reg(). Cc: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> Cc: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxxxxxxxx> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> Signed-off-by: Zhi Wang <zhi.a.wang@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_gem_fence.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_fence.c b/drivers/gpu/drm/i915/i915_gem_fence.c index 1dfb09b..7a5a02c 100644 --- a/drivers/gpu/drm/i915/i915_gem_fence.c +++ b/drivers/gpu/drm/i915/i915_gem_fence.c @@ -313,7 +313,7 @@ i915_find_fence_reg(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_fence_reg *reg, *avail; - int i; + int i, ret; /* First try to find a free reg */ avail = NULL; @@ -333,6 +333,15 @@ i915_find_fence_reg(struct drm_device *dev) if (reg->pin_count) continue; + if (reg->obj) { + struct drm_i915_gem_object *old = reg->obj; + + ret = i915_gem_object_wait_fence(old); + if (ret) + return ERR_PTR(ret); + + i915_gem_object_fence_lost(old); + } return reg; } @@ -395,16 +404,6 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj) reg = i915_find_fence_reg(dev); if (IS_ERR(reg)) return PTR_ERR(reg); - - if (reg->obj) { - struct drm_i915_gem_object *old = reg->obj; - - ret = i915_gem_object_wait_fence(old); - if (ret) - return ret; - - i915_gem_object_fence_lost(old); - } } else return 0; -- 1.9.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx