diff mbox series

dma-fence/reservation: Markup rcu protected access for DEBUG_MUTEXES

Message ID 20190612132830.31221-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series dma-fence/reservation: Markup rcu protected access for DEBUG_MUTEXES | expand

Commit Message

Chris Wilson June 12, 2019, 1:28 p.m. UTC
Mark the access to reservation_object.fence as being protected to
silence sparse.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 include/linux/reservation.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Christian König June 12, 2019, 1:29 p.m. UTC | #1
Am 12.06.19 um 15:28 schrieb Chris Wilson:
> Mark the access to reservation_object.fence as being protected to
> silence sparse.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   include/linux/reservation.h | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/reservation.h b/include/linux/reservation.h
> index ee750765cc94..644a22dbe53b 100644
> --- a/include/linux/reservation.h
> +++ b/include/linux/reservation.h
> @@ -216,8 +216,12 @@ reservation_object_unlock(struct reservation_object *obj)
>   {
>   #ifdef CONFIG_DEBUG_MUTEXES
>   	/* Test shared fence slot reservation */
> -	if (obj->fence)
> -		obj->fence->shared_max = obj->fence->shared_count;
> +	if (rcu_access_pointer(obj->fence)) {
> +		struct reservation_object_list *fence =
> +			reservation_object_get_list(obj);
> +
> +		fence->shared_max = fence->shared_count;
> +	}
>   #endif
>   	ww_mutex_unlock(&obj->lock);
>   }
Chris Wilson June 12, 2019, 2:36 p.m. UTC | #2
Quoting Patchwork (2019-06-12 15:07:50)
> == Series Details ==
> 
> Series: dma-fence/reservation: Markup rcu protected access for DEBUG_MUTEXES
> URL   : https://patchwork.freedesktop.org/series/61963/
> State : warning
> 
> == Summary ==
> 
> $ dim sparse origin/drm-tip
> Sparse version: v0.5.2
> Commit: dma-fence/reservation: Markup rcu protected access for DEBUG_MUTEXES
> -./include/linux/reservation.h:220:20: warning: dereference of noderef expression
[snip]
> -./include/linux/reservation.h:220:45: warning: dereference of noderef expression
> -./include/linux/reservation

That'll cheer up some of the warnings CI periodically sends.
Thanks for the quick review,
-Chris
diff mbox series

Patch

diff --git a/include/linux/reservation.h b/include/linux/reservation.h
index ee750765cc94..644a22dbe53b 100644
--- a/include/linux/reservation.h
+++ b/include/linux/reservation.h
@@ -216,8 +216,12 @@  reservation_object_unlock(struct reservation_object *obj)
 {
 #ifdef CONFIG_DEBUG_MUTEXES
 	/* Test shared fence slot reservation */
-	if (obj->fence)
-		obj->fence->shared_max = obj->fence->shared_count;
+	if (rcu_access_pointer(obj->fence)) {
+		struct reservation_object_list *fence =
+			reservation_object_get_list(obj);
+
+		fence->shared_max = fence->shared_count;
+	}
 #endif
 	ww_mutex_unlock(&obj->lock);
 }