From: Lucas Stach <l.stach@pengutronix.de>
To: Sumit Semwal <sumit.semwal@linaro.org>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, kernel@pengutronix.de,
patchwork-lst@pengutronix.de
Subject: [PATCH] dma-buf: add some lockdep asserts to the reservation object implementation
Date: Fri, 1 Dec 2017 12:12:16 +0100 [thread overview]
Message-ID: <20171201111216.7050-1-l.stach@pengutronix.de> (raw)
This adds lockdep asserts to the reservation functions which state in their
documentation that obj->lock must be held. Allows builds with PROVE_LOCKING
enabled to check that the locking requirements are met.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
drivers/dma-buf/reservation.c | 8 ++++++++
include/linux/reservation.h | 2 ++
2 files changed, 10 insertions(+)
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index b44d9d7db347..accd398e2ea6 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -71,6 +71,8 @@ int reservation_object_reserve_shared(struct reservation_object *obj)
struct reservation_object_list *fobj, *old;
u32 max;
+ reservation_object_assert_held(obj);
+
old = reservation_object_get_list(obj);
if (old && old->shared_max) {
@@ -211,6 +213,8 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
{
struct reservation_object_list *old, *fobj = obj->staged;
+ reservation_object_assert_held(obj);
+
old = reservation_object_get_list(obj);
obj->staged = NULL;
@@ -236,6 +240,8 @@ void reservation_object_add_excl_fence(struct reservation_object *obj,
struct reservation_object_list *old;
u32 i = 0;
+ reservation_object_assert_held(obj);
+
old = reservation_object_get_list(obj);
if (old)
i = old->shared_count;
@@ -276,6 +282,8 @@ int reservation_object_copy_fences(struct reservation_object *dst,
size_t size;
unsigned i;
+ reservation_object_assert_held(dst);
+
rcu_read_lock();
src_list = rcu_dereference(src->fence);
diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index 21fc84d82d41..55e7318800fd 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -212,6 +212,8 @@ reservation_object_unlock(struct reservation_object *obj)
static inline struct dma_fence *
reservation_object_get_excl(struct reservation_object *obj)
{
+ reservation_object_assert_held(obj);
+
return rcu_dereference_protected(obj->fence_excl,
reservation_object_held(obj));
}
--
2.11.0
next reply other threads:[~2017-12-01 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-01 11:12 Lucas Stach [this message]
2018-01-11 10:43 ` [Linaro-mm-sig] [PATCH] dma-buf: add some lockdep asserts to the reservation object implementation Lucas Stach
2018-01-11 10:54 ` Christian König
2018-01-11 11:13 ` Lucas Stach
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=20171201111216.7050-1-l.stach@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@pengutronix.de \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=patchwork-lst@pengutronix.de \
--cc=sumit.semwal@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).