[Intel-gfx] [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()

Wang, Zhi A zhi.a.wang at intel.com
Fri Mar 11 12:29:06 UTC 2016


Hi Chris:
    Do you mean I should also check the fence pin count in this API like i915_find_fence_reg, then it will be safe here? :) 

-----Original Message-----
From: Chris Wilson [mailto:chris at chris-wilson.co.uk] 
Sent: Friday, March 11, 2016 7:22 PM
To: Wang, Zhi A
Cc: intel-gfx at lists.freedesktop.org; igvt-g at lists.01.org; Tian, Kevin; Lv, Zhiyuan; Niu, Bing; Song, Jike; daniel.vetter at ffwll.ch; Cowperthwaite, David J; joonas.lahtinen at linux.intel.com
Subject: Re: [RFCv3 14/15] drm/i915: factor out and expose i915_steal_fence()

On Fri, Mar 11, 2016 at 06:59:45PM +0800, Zhi Wang wrote:
> Factor out and expose fence stealing functionality for GVT-g. GVT-g
> will use i915_find_fence_reg() to find a free/unpin fence register
> and use i915_steal_fence() to steal it.
> 
> Signed-off-by: Zhi Wang <zhi.a.wang at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h       |  1 +
>  drivers/gpu/drm/i915/i915_gem_fence.c | 36 ++++++++++++++++++++++++++---------
>  2 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 26106e5..deb7143b 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3247,6 +3247,7 @@ i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj)
>  /* i915_gem_fence.c */
>  int __must_check i915_gem_object_get_fence(struct drm_i915_gem_object *obj);
>  int __must_check i915_gem_object_put_fence(struct drm_i915_gem_object *obj);
> +int i915_steal_fence(struct drm_i915_fence_reg *reg);
>  
>  bool i915_gem_object_pin_fence(struct drm_i915_gem_object *obj);
>  void i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj);
> diff --git a/drivers/gpu/drm/i915/i915_gem_fence.c b/drivers/gpu/drm/i915/i915_gem_fence.c
> index 5981985..dd897c6 100644
> --- a/drivers/gpu/drm/i915/i915_gem_fence.c
> +++ b/drivers/gpu/drm/i915/i915_gem_fence.c
> @@ -346,6 +346,30 @@ deadlock:
>  }
>  
>  /**
> + * i915_steal_fence - steal a fence from a GEM object
> + * @reg: the fence register to be stolen
> + *
> + * Returns:
> + *
> + * 0 on success, negative error code on failure.
> + */
> +int i915_steal_fence(struct drm_i915_fence_reg *reg)
> +{
> +	int ret;
> +

No, this is not safe.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list