]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dma-fence: Fix sparse warnings due __rcu annotations
authorTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Mon, 16 Jun 2025 15:59:52 +0000 (16:59 +0100)
committerChristian König <christian.koenig@amd.com>
Mon, 9 Feb 2026 13:05:20 +0000 (14:05 +0100)
__rcu annotations on the return types from dma_fence_driver_name() and
dma_fence_timeline_name() cause sparse to complain because both the
constant signaled strings, and the strings return by the dma_fence_ops are
not __rcu annotated.

For a simple fix it is easiest to cast them with __rcu added and undo the
smarts from the tracpoints side of things. There is no functional change
since the rest is left in place. Later we can consider changing the
dma_fence_ops return types too, and handle all the individual drivers
which define them.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Fixes: 506aa8b02a8d ("dma-fence: Add safe access helpers and document the rules")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506162214.1eA69hLe-lkp@intel.com/
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20250616155952.24259-1-tvrtko.ursulin@igalia.com
Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/dma-buf/dma-fence.c
include/trace/events/dma_fence.h

index c9a036b0d5923dcc884a4c4f0b9007afca8e8087..e05beae6e40729df9a5472090c5de969bb98e738 100644 (file)
@@ -1133,9 +1133,9 @@ const char __rcu *dma_fence_driver_name(struct dma_fence *fence)
                         "RCU protection is required for safe access to returned string");
 
        if (!dma_fence_test_signaled_flag(fence))
-               return fence->ops->get_driver_name(fence);
+               return (const char __rcu *)fence->ops->get_driver_name(fence);
        else
-               return "detached-driver";
+               return (const char __rcu *)"detached-driver";
 }
 EXPORT_SYMBOL(dma_fence_driver_name);
 
@@ -1165,8 +1165,8 @@ const char __rcu *dma_fence_timeline_name(struct dma_fence *fence)
                         "RCU protection is required for safe access to returned string");
 
        if (!dma_fence_test_signaled_flag(fence))
-               return fence->ops->get_timeline_name(fence);
+               return (const char __rcu *)fence->ops->get_driver_name(fence);
        else
-               return "signaled-timeline";
+               return (const char __rcu *)"signaled-timeline";
 }
 EXPORT_SYMBOL(dma_fence_timeline_name);
index 4814a65b68dcb7fc9cef931eb2419db65f2ac1c5..3abba45c0601a49103e470d88950929934b6f3a8 100644 (file)
@@ -9,37 +9,12 @@
 
 struct dma_fence;
 
-DECLARE_EVENT_CLASS(dma_fence,
-
-       TP_PROTO(struct dma_fence *fence),
-
-       TP_ARGS(fence),
-
-       TP_STRUCT__entry(
-               __string(driver, dma_fence_driver_name(fence))
-               __string(timeline, dma_fence_timeline_name(fence))
-               __field(unsigned int, context)
-               __field(unsigned int, seqno)
-       ),
-
-       TP_fast_assign(
-               __assign_str(driver);
-               __assign_str(timeline);
-               __entry->context = fence->context;
-               __entry->seqno = fence->seqno;
-       ),
-
-       TP_printk("driver=%s timeline=%s context=%u seqno=%u",
-                 __get_str(driver), __get_str(timeline), __entry->context,
-                 __entry->seqno)
-);
-
 /*
  * Safe only for call sites which are guaranteed to not race with fence
  * signaling,holding the fence->lock and having checked for not signaled, or the
  * signaling path itself.
  */
-DECLARE_EVENT_CLASS(dma_fence_unsignaled,
+DECLARE_EVENT_CLASS(dma_fence,
 
        TP_PROTO(struct dma_fence *fence),
 
@@ -64,14 +39,14 @@ DECLARE_EVENT_CLASS(dma_fence_unsignaled,
                  __entry->seqno)
 );
 
-DEFINE_EVENT(dma_fence_unsignaled, dma_fence_emit,
+DEFINE_EVENT(dma_fence, dma_fence_emit,
 
        TP_PROTO(struct dma_fence *fence),
 
        TP_ARGS(fence)
 );
 
-DEFINE_EVENT(dma_fence_unsignaled, dma_fence_init,
+DEFINE_EVENT(dma_fence, dma_fence_init,
 
        TP_PROTO(struct dma_fence *fence),
 
@@ -85,14 +60,14 @@ DEFINE_EVENT(dma_fence, dma_fence_destroy,
        TP_ARGS(fence)
 );
 
-DEFINE_EVENT(dma_fence_unsignaled, dma_fence_enable_signal,
+DEFINE_EVENT(dma_fence, dma_fence_enable_signal,
 
        TP_PROTO(struct dma_fence *fence),
 
        TP_ARGS(fence)
 );
 
-DEFINE_EVENT(dma_fence_unsignaled, dma_fence_signaled,
+DEFINE_EVENT(dma_fence, dma_fence_signaled,
 
        TP_PROTO(struct dma_fence *fence),