Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma-buf/dma-fence: remove unnecessary callbacks

The fence_value_str and timeline_value_str callbacks were just an
unnecessary abstraction in the SW sync implementation.

The only caller of those callbacks already knew that the fence in
questions is a timeline_fence. So print the values directly instead
of using a redirection.

Additional to that remove the implementations from virtgpu and vgem.
As far as I can see those were never used in the first place.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20250211163109.12200-3-christian.koenig@amd.com

+2 -87
-16
drivers/dma-buf/sw_sync.c
··· 173 173 return !__dma_fence_is_later(fence->seqno, parent->value, fence->ops); 174 174 } 175 175 176 - static void timeline_fence_value_str(struct dma_fence *fence, 177 - char *str, int size) 178 - { 179 - snprintf(str, size, "%lld", fence->seqno); 180 - } 181 - 182 - static void timeline_fence_timeline_value_str(struct dma_fence *fence, 183 - char *str, int size) 184 - { 185 - struct sync_timeline *parent = dma_fence_parent(fence); 186 - 187 - snprintf(str, size, "%d", parent->value); 188 - } 189 - 190 176 static void timeline_fence_set_deadline(struct dma_fence *fence, ktime_t deadline) 191 177 { 192 178 struct sync_pt *pt = dma_fence_to_sync_pt(fence); ··· 194 208 .get_timeline_name = timeline_fence_get_timeline_name, 195 209 .signaled = timeline_fence_signaled, 196 210 .release = timeline_fence_release, 197 - .fence_value_str = timeline_fence_value_str, 198 - .timeline_value_str = timeline_fence_timeline_value_str, 199 211 .set_deadline = timeline_fence_set_deadline, 200 212 }; 201 213
+2 -19
drivers/dma-buf/sync_debug.c
··· 82 82 seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); 83 83 } 84 84 85 - if (fence->ops->timeline_value_str && 86 - fence->ops->fence_value_str) { 87 - char value[64]; 88 - bool success; 89 - 90 - fence->ops->fence_value_str(fence, value, sizeof(value)); 91 - success = strlen(value); 92 - 93 - if (success) { 94 - seq_printf(s, ": %s", value); 95 - 96 - fence->ops->timeline_value_str(fence, value, 97 - sizeof(value)); 98 - 99 - if (strlen(value)) 100 - seq_printf(s, " / %s", value); 101 - } 102 - } 103 - 85 + seq_printf(s, ": %lld", fence->seqno); 86 + seq_printf(s, " / %d", parent->value); 104 87 seq_putc(s, '\n'); 105 88 } 106 89
-15
drivers/gpu/drm/vgem/vgem_fence.c
··· 53 53 dma_fence_free(&fence->base); 54 54 } 55 55 56 - static void vgem_fence_value_str(struct dma_fence *fence, char *str, int size) 57 - { 58 - snprintf(str, size, "%llu", fence->seqno); 59 - } 60 - 61 - static void vgem_fence_timeline_value_str(struct dma_fence *fence, char *str, 62 - int size) 63 - { 64 - snprintf(str, size, "%llu", 65 - dma_fence_is_signaled(fence) ? fence->seqno : 0); 66 - } 67 - 68 56 static const struct dma_fence_ops vgem_fence_ops = { 69 57 .get_driver_name = vgem_fence_get_driver_name, 70 58 .get_timeline_name = vgem_fence_get_timeline_name, 71 59 .release = vgem_fence_release, 72 - 73 - .fence_value_str = vgem_fence_value_str, 74 - .timeline_value_str = vgem_fence_timeline_value_str, 75 60 }; 76 61 77 62 static void vgem_fence_timeout(struct timer_list *t)
-16
drivers/gpu/drm/virtio/virtgpu_fence.c
··· 49 49 return false; 50 50 } 51 51 52 - static void virtio_gpu_fence_value_str(struct dma_fence *f, char *str, int size) 53 - { 54 - snprintf(str, size, "[%llu, %llu]", f->context, f->seqno); 55 - } 56 - 57 - static void virtio_gpu_timeline_value_str(struct dma_fence *f, char *str, 58 - int size) 59 - { 60 - struct virtio_gpu_fence *fence = to_virtio_gpu_fence(f); 61 - 62 - snprintf(str, size, "%llu", 63 - (u64)atomic64_read(&fence->drv->last_fence_id)); 64 - } 65 - 66 52 static const struct dma_fence_ops virtio_gpu_fence_ops = { 67 53 .get_driver_name = virtio_gpu_get_driver_name, 68 54 .get_timeline_name = virtio_gpu_get_timeline_name, 69 55 .signaled = virtio_gpu_fence_signaled, 70 - .fence_value_str = virtio_gpu_fence_value_str, 71 - .timeline_value_str = virtio_gpu_timeline_value_str, 72 56 }; 73 57 74 58 struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev,
-21
include/linux/dma-fence.h
··· 239 239 void (*release)(struct dma_fence *fence); 240 240 241 241 /** 242 - * @fence_value_str: 243 - * 244 - * Callback to fill in free-form debug info specific to this fence, like 245 - * the sequence number. 246 - * 247 - * This callback is optional. 248 - */ 249 - void (*fence_value_str)(struct dma_fence *fence, char *str, int size); 250 - 251 - /** 252 - * @timeline_value_str: 253 - * 254 - * Fills in the current value of the timeline as a string, like the 255 - * sequence number. Note that the specific fence passed to this function 256 - * should not matter, drivers should only use it to look up the 257 - * corresponding timeline structures. 258 - */ 259 - void (*timeline_value_str)(struct dma_fence *fence, 260 - char *str, int size); 261 - 262 - /** 263 242 * @set_deadline: 264 243 * 265 244 * Callback to allow a fence waiter to inform the fence signaler of