Re: [PATCH 05/10] dma-buf/resv: add dma_resv_prune_fences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Christian König (2019-08-21 13:31:42)
> Add a new dma_resv_prune_fences() function to improve memory management.
> 
> Signed-off-by: Christian König <christian.koenig@xxxxxxx>
> ---
>  drivers/dma-buf/dma-resv.c                 | 37 ++++++++++++++++++++++
>  drivers/gpu/drm/i915/gem/i915_gem_wait.c   |  3 +-
>  drivers/gpu/drm/i915/i915_gem_batch_pool.c |  2 +-
>  drivers/gpu/drm/i915/i915_vma.c            |  3 +-
>  drivers/gpu/drm/ttm/ttm_bo.c               |  2 +-
>  include/linux/dma-resv.h                   |  1 +
>  6 files changed, 42 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index 42a8f3f11681..24adc32d36d4 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -301,6 +301,43 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
>  }
>  EXPORT_SYMBOL(dma_resv_add_excl_fence);
>  
> +/**
> + * dma_resv_prune_fences - prune signaled fences from the resv object
> + * @obj: the reservation object to prune
> + *
> + * Prune all signaled fences from the reservation object.
> + */
> +void dma_resv_prune_fences(struct dma_resv *obj)
> +{
> +       struct dma_resv_list *list;
> +       struct dma_fence *fence;
> +       unsigned int i;
> +
> +       dma_resv_assert_held(obj);
> +
> +       fence = dma_resv_get_excl(obj);
> +       if (dma_fence_is_signaled(fence)) {
> +               RCU_INIT_POINTER(obj->fence_excl, NULL);
> +               dma_fence_put(fence);
> +       }
> +
> +       list = dma_resv_get_list(obj);
> +       if (!list)
> +               return;
> +
> +       for (i = 0; i < list->shared_count; ++i) {
> +               fence = rcu_dereference_protected(list->shared[i],
> +                                                 dma_resv_held(obj));
> +
> +               if (!dma_fence_is_signaled(fence))
> +                       continue;
> +
> +               RCU_INIT_POINTER(list->shared[i], dma_fence_get_stub());
> +               dma_fence_put(fence);

Not worth reusing the compaction logic from add_shared_fence?
-Chris
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux