All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
	etnaviv@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c
Date: Thu, 25 Nov 2021 10:31:35 +0100	[thread overview]
Message-ID: <7729c40e-fe4e-853e-06d4-5e39dff17d32@linux.intel.com> (raw)
In-Reply-To: <20211028132630.2330-1-christian.koenig@amd.com>

On 28-10-2021 15:26, Christian König wrote:
> The i915 driver implements a prune function which is called when it is very
> likely that the fences inside the dma_resv object can be removed because they
> are all signaled.
>
> Move that function into the dma-resv.c code since the behavior of pruning
> fences is something internal to the object.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/dma-resv.c                   | 18 ++++++++++++++++++
>  drivers/gpu/drm/i915/Makefile                |  1 -
>  drivers/gpu/drm/i915/dma_resv_utils.c        | 17 -----------------
>  drivers/gpu/drm/i915/dma_resv_utils.h        | 13 -------------
>  drivers/gpu/drm/i915/gem/i915_gem_shrinker.c |  3 +--
>  drivers/gpu/drm/i915/gem/i915_gem_wait.c     |  3 +--
>  include/linux/dma-resv.h                     |  1 +
>  7 files changed, 21 insertions(+), 35 deletions(-)
>  delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.c
>  delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.h
>
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index ff3c0558b3b8..64d4f95778c4 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -324,6 +324,24 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
>  }
>  EXPORT_SYMBOL(dma_resv_add_excl_fence);
>  
> +/**
> + * dma_resv_prune_unlocked - try to remove signaled fences
> + * @obj: The dma_resv object to prune
> + *
> + * Try to lock the object, test if it is signaled and if yes then remove all the
> + * signaled fences.
> + */
> +void dma_resv_prune_unlocked(struct dma_resv *obj)
> +{
> +	if (!dma_resv_trylock(obj))
> +		return;
> +
> +	if (dma_resv_test_signaled(obj, true))
> +		dma_resv_add_excl_fence(obj, NULL);
> +	dma_resv_unlock(obj);
> +}
> +EXPORT_SYMBOL(dma_resv_prune_unlocked);
> +
>  /**
>   * dma_resv_iter_restart_unlocked - restart the unlocked iterator
>   * @cursor: The dma_resv_iter object to restart
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 660bb03de6fc..5c1af130cb6d 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -60,7 +60,6 @@ i915-y += i915_drv.o \
>  
>  # core library code
>  i915-y += \
> -	dma_resv_utils.o \
>  	i915_memcpy.o \
>  	i915_mm.o \
>  	i915_sw_fence.o \
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.c b/drivers/gpu/drm/i915/dma_resv_utils.c
> deleted file mode 100644
> index 7df91b7e4ca8..000000000000
> --- a/drivers/gpu/drm/i915/dma_resv_utils.c
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -// SPDX-License-Identifier: MIT
> -/*
> - * Copyright © 2020 Intel Corporation
> - */
> -
> -#include <linux/dma-resv.h>
> -
> -#include "dma_resv_utils.h"
> -
> -void dma_resv_prune(struct dma_resv *resv)
> -{
> -	if (dma_resv_trylock(resv)) {
> -		if (dma_resv_test_signaled(resv, true))
> -			dma_resv_add_excl_fence(resv, NULL);
> -		dma_resv_unlock(resv);
> -	}
> -}
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.h b/drivers/gpu/drm/i915/dma_resv_utils.h
> deleted file mode 100644
> index b9d8fb5f8367..000000000000
> --- a/drivers/gpu/drm/i915/dma_resv_utils.h
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -/* SPDX-License-Identifier: MIT */
> -/*
> - * Copyright © 2020 Intel Corporation
> - */
> -
> -#ifndef DMA_RESV_UTILS_H
> -#define DMA_RESV_UTILS_H
> -
> -struct dma_resv;
> -
> -void dma_resv_prune(struct dma_resv *resv);
> -
> -#endif /* DMA_RESV_UTILS_H */
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index 5ab136ffdeb2..48029bbda682 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -15,7 +15,6 @@
>  
>  #include "gt/intel_gt_requests.h"
>  
> -#include "dma_resv_utils.h"
>  #include "i915_trace.h"
>  
>  static bool swap_available(void)
> @@ -229,7 +228,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
>  					i915_gem_object_unlock(obj);
>  			}
>  
> -			dma_resv_prune(obj->base.resv);
> +			dma_resv_prune_unlocked(obj->base.resv);
>  
>  			scanned += obj->base.size >> PAGE_SHIFT;
>  skip:
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> index 569658c7859c..1915d203a72d 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> @@ -10,7 +10,6 @@
>  
>  #include "gt/intel_engine.h"
>  
> -#include "dma_resv_utils.h"
>  #include "i915_gem_ioctls.h"
>  #include "i915_gem_object.h"
>  
> @@ -53,7 +52,7 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
>  	 * signaled.
>  	 */
>  	if (timeout > 0)
> -		dma_resv_prune(resv);
> +		dma_resv_prune_unlocked(resv);
>  
>  	return timeout;
>  }
> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
> index eebf04325b34..e0558429a5ee 100644
> --- a/include/linux/dma-resv.h
> +++ b/include/linux/dma-resv.h
> @@ -458,6 +458,7 @@ void dma_resv_fini(struct dma_resv *obj);
>  int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences);
>  void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
>  void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
> +void dma_resv_prune_unlocked(struct dma_resv *obj);
>  int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
>  			unsigned *pshared_count, struct dma_fence ***pshared);
>  int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);

I don't mind adding a dma_resv_prune for locked case, but I don't think unlocked would have benefits.

Furthermore, I'm trying to remove the unlocked versions from i915. Could this be a prereq patch instead?

https://patchwork.freedesktop.org/patch/460722/?series=96115&rev=1

~Maarten

~Maarten


  parent reply	other threads:[~2021-11-25  9:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
2021-11-11  8:58   ` Christian König
2021-11-16 10:43     ` Christian König
2021-11-16 14:54       ` Deucher, Alexander
2021-10-28 13:26 ` [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here Christian König
2021-11-01  9:51   ` Lucas Stach
2021-10-28 13:26 ` [PATCH 4/6] dma-buf: drop excl_fence parameter from dma_resv_get_fences Christian König
2021-10-28 13:26 ` [PATCH 5/6] RDMA: use dma_resv_wait() instead of extracting the fence Christian König
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
2021-11-03  7:55   ` Christian König
2021-11-03  7:55     ` Christian König
2021-11-03 16:36   ` Das, Nirmoy
2021-11-25  9:31 ` Maarten Lankhorst [this message]
2021-11-25  9:44   ` [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7729c40e-fe4e-853e-06d4-5e39dff17d32@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.