Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] dma-buf: sync_debug: recursive spinlock deadlock in
  sync_print_fence()
--

commit 771cc9b6d800a1a39680e74552adf1782c101ea3
Author: Philipp Stanner <[email protected]>

dma-buf: sync_debug: don't use TIMESTAMP bit

This commit replaces the direct DMA_FENCE_FLAG_TIMESTAMP_BIT check in
sync_print_fence() with a call to dma_fence_timestamp().

> diff --git a/drivers/dma-buf/sync_debug.c b/drivers/dma-buf/sync_debug.c
> index 9e5d662cd4e84..58c0d00ba5b3c 100644
> --- a/drivers/dma-buf/sync_debug.c
> +++ b/drivers/dma-buf/sync_debug.c
> @@ -46,6 +46,8 @@ static void sync_print_fence(struct seq_file *s,
>                            struct dma_fence *fence, bool show)
>  {
>       struct sync_timeline *parent = dma_fence_parent(fence);
> +     struct timespec64 ts64;
> +     ktime_t ts;
>       int status;
>  
>       status = dma_fence_get_status_locked(fence);
> @@ -55,10 +57,8 @@ static void sync_print_fence(struct seq_file *s,
>                  show ? "_" : "",
>                  sync_status_str(status));
>  
> -     if (test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags)) {
> -             struct timespec64 ts64 =
> -                     ktime_to_timespec64(fence->timestamp);
> -
> +     if (dma_fence_timestamp(fence, &ts) == 0) {
> +             ts64 = ktime_to_timespec64(ts);
>               seq_printf(s, "@%ptSp", &ts64);
>       }

[Severity: High]
Does calling dma_fence_timestamp() here self-deadlock on obj->lock?

sync_pt_create() initializes each sync_pt fence with &obj->lock as its
external fence spinlock, and sync_print_obj() already holds obj->lock when it
calls sync_print_fence() (which is why dma_fence_get_status_locked() is used
above):

sync_info_debugfs_show()
  spin_lock_irq(&sync_timeline_list_lock)
  sync_print_obj()
    spin_lock(&obj->lock)
    sync_print_fence()
      dma_fence_timestamp()
        dma_fence_lock_irqsave()  <-- spins forever on &obj->lock

Reading /sys/kernel/debug/sync/info while any sync_timeline has a sync_pt on
obj->pt_list will deadlock the CPU with interrupts disabled.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=6

Reply via email to