Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1696018 > unrolled thread

[PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions.

Started byEric Anholt <eric@anholt.net>
First post2017-07-25 20:30 +0200
Last post2017-07-26 13:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions. Eric Anholt <eric@anholt.net> - 2017-07-25 20:30 +0200
    Re: [PATCH v2 3/3] drm/vc4: Convert more lock requirement comments  to lockdep assertions. Daniel Vetter <daniel@ffwll.ch> - 2017-07-26 13:40 +0200

#1696018 — [PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions.

FromEric Anholt <eric@anholt.net>
Date2017-07-25 20:30 +0200
Subject[PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions.
Message-ID<u7cKK-6j1-29@gated-at.bofh.it>
Since I do my development with lockdep on, this will help make sure I
don't introduce bugs here.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/vc4/vc4_bo.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index f4387e1e178d..b24dd8685590 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -163,10 +163,12 @@ static uint32_t bo_page_index(size_t size)
 	return (size / PAGE_SIZE) - 1;
 }
 
-/* Must be called with bo_lock held. */
 static void vc4_bo_destroy(struct vc4_bo *bo)
 {
 	struct drm_gem_object *obj = &bo->base.base;
+	struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
+
+	lockdep_assert_held(&vc4->bo_lock);
 
 	vc4_bo_set_label(obj, -1);
 
@@ -181,9 +183,11 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
 	drm_gem_cma_free_object(obj);
 }
 
-/* Must be called with bo_lock held. */
 static void vc4_bo_remove_from_cache(struct vc4_bo *bo)
 {
+	struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
+
+	lockdep_assert_held(&vc4->bo_lock);
 	list_del(&bo->unref_head);
 	list_del(&bo->size_head);
 }
@@ -367,12 +371,13 @@ int vc4_dumb_create(struct drm_file *file_priv,
 	return ret;
 }
 
-/* Must be called with bo_lock held. */
 static void vc4_bo_cache_free_old(struct drm_device *dev)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	unsigned long expire_time = jiffies - msecs_to_jiffies(1000);
 
+	lockdep_assert_held(&vc4->bo_lock);
+
 	while (!list_empty(&vc4->bo_cache.time_list)) {
 		struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
 						    struct vc4_bo, unref_head);
-- 
2.11.0

[toc] | [next] | [standalone]


#1697005 — Re: [PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions.

FromDaniel Vetter <daniel@ffwll.ch>
Date2017-07-26 13:40 +0200
SubjectRe: [PATCH v2 3/3] drm/vc4: Convert more lock requirement comments to lockdep assertions.
Message-ID<u7sPx-89V-19@gated-at.bofh.it>
In reply to#1696018
On Tue, Jul 25, 2017 at 11:27:18AM -0700, Eric Anholt wrote:
> Since I do my development with lockdep on, this will help make sure I
> don't introduce bugs here.

Yeah it's somewhat annoying that lockdep_assert_held doesn't reduce to a
"no false positives, maybe some false negatives, but real fast" runtime
check without lockdep and just mutex debugging enabled. We even have it as
mutex_is_locked already. But not doing to fight that bikeshed :-/

> Signed-off-by: Eric Anholt <eric@anholt.net>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/vc4/vc4_bo.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
> index f4387e1e178d..b24dd8685590 100644
> --- a/drivers/gpu/drm/vc4/vc4_bo.c
> +++ b/drivers/gpu/drm/vc4/vc4_bo.c
> @@ -163,10 +163,12 @@ static uint32_t bo_page_index(size_t size)
>  	return (size / PAGE_SIZE) - 1;
>  }
>  
> -/* Must be called with bo_lock held. */
>  static void vc4_bo_destroy(struct vc4_bo *bo)
>  {
>  	struct drm_gem_object *obj = &bo->base.base;
> +	struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
> +
> +	lockdep_assert_held(&vc4->bo_lock);
>  
>  	vc4_bo_set_label(obj, -1);
>  
> @@ -181,9 +183,11 @@ static void vc4_bo_destroy(struct vc4_bo *bo)
>  	drm_gem_cma_free_object(obj);
>  }
>  
> -/* Must be called with bo_lock held. */
>  static void vc4_bo_remove_from_cache(struct vc4_bo *bo)
>  {
> +	struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
> +
> +	lockdep_assert_held(&vc4->bo_lock);
>  	list_del(&bo->unref_head);
>  	list_del(&bo->size_head);
>  }
> @@ -367,12 +371,13 @@ int vc4_dumb_create(struct drm_file *file_priv,
>  	return ret;
>  }
>  
> -/* Must be called with bo_lock held. */
>  static void vc4_bo_cache_free_old(struct drm_device *dev)
>  {
>  	struct vc4_dev *vc4 = to_vc4_dev(dev);
>  	unsigned long expire_time = jiffies - msecs_to_jiffies(1000);
>  
> +	lockdep_assert_held(&vc4->bo_lock);
> +
>  	while (!list_empty(&vc4->bo_cache.time_list)) {
>  		struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
>  						    struct vc4_bo, unref_head);
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web