[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <92449ad6-25b0-b28e-97b3-b947d5ff963c@amd.com>
Date: Mon, 28 Aug 2023 12:21:23 +0200
From: Christian König <christian.koenig@....com>
To: Dmitry Osipenko <dmitry.osipenko@...labora.com>,
David Airlie <airlied@...il.com>,
Gerd Hoffmann <kraxel@...hat.com>,
Gurchetan Singh <gurchetansingh@...omium.org>,
Chia-I Wu <olvaffe@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Qiang Yu <yuq825@...il.com>,
Steven Price <steven.price@....com>,
Boris Brezillon <boris.brezillon@...labora.com>,
Emma Anholt <emma@...olt.net>, Melissa Wen <mwen@...lia.com>,
Will Deacon <will@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>,
Mark Rutland <mark.rutland@....com>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
kernel@...labora.com, virtualization@...ts.linux-foundation.org,
intel-gfx@...ts.freedesktop.org
Subject: Re: [PATCH v15 11/23] dma-resv: Add kref_put_dma_resv()
Am 27.08.23 um 19:54 schrieb Dmitry Osipenko:
> Add simple kref_put_dma_resv() helper that wraps around kref_put_ww_mutex()
> for drivers that needs to lock dma-resv on kref_put().
>
> It's not possible to easily add this helper to kref.h because of the
> headers inclusion dependency, hence add it to dma-resv.h.
I was never really a big fan of kref_put_mutex() in the first place.
The main advantage comes from the included memory barrier, but this
actually doesn't work like most people think it works and is usually
pretty dangerous.
And IIRC this was done because of the some special behavior mutexes have
with memory barriers and that isn't necessary with ww-mutex.
Christian.
>
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>
> ---
> include/linux/dma-resv.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
> index 8d0e34dad446..c5cf302e4194 100644
> --- a/include/linux/dma-resv.h
> +++ b/include/linux/dma-resv.h
> @@ -41,6 +41,7 @@
>
> #include <linux/ww_mutex.h>
> #include <linux/dma-fence.h>
> +#include <linux/kref.h>
> #include <linux/slab.h>
> #include <linux/seqlock.h>
> #include <linux/rcupdate.h>
> @@ -464,6 +465,14 @@ static inline void dma_resv_unlock(struct dma_resv *obj)
> ww_mutex_unlock(&obj->lock);
> }
>
> +static inline int kref_put_dma_resv(struct kref *kref,
> + void (*release)(struct kref *kref),
> + struct dma_resv *resv,
> + struct ww_acquire_ctx *ctx)
> +{
> + return kref_put_ww_mutex(kref, release, &resv->lock, ctx);
> +}
> +
> void dma_resv_init(struct dma_resv *obj);
> void dma_resv_fini(struct dma_resv *obj);
> int dma_resv_reserve_fences(struct dma_resv *obj, unsigned int num_fences);
Powered by blists - more mailing lists