From 94daf32a1162f2baabb4eee60e9c3d91b8353a54 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Thu, 4 Mar 2021 10:55:05 +0800 Subject: [PATCH] dma-buf: show attached devices name to bufprocs node console:/ # cat /sys/kernel/debug/dma_buf/bufprocs surfaceflinger (PID 187) size: 66596 DMA Buffers: Name Exp_name Size (KB) Alive (sec) Attached Devices (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 12480 9 display-subsystem ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 4 9 ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 12480 9 display-subsystem ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 2288 1 ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 2288 1 ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 12288 8 display-subsystem ff9a0000.gpu ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 12480 9 display-subsystem ff9a0000.gpu (null) ion_alloc-ion_system_heap-218-allocator@4.0-s 12288 8 display-subsystem ff9a0000.gpu ff9a0000.gpu Change-Id: I95b1feaf933cc46c8936db129f9152ead71ed664 Signed-off-by: Jianqun Xu --- drivers/dma-buf/dma-buf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 69fc7f06fe2e..239dde7a006a 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -1479,19 +1479,25 @@ static void write_proc(struct seq_file *s, struct dma_proc *proc) seq_printf(s, "\n%s (PID %d) size: %zu\nDMA Buffers:\n", proc->name, proc->pid, proc->size); - seq_printf(s, "%-8s\t%-60s\t%-8s\t%-8s\n", - "Name", "Exp_name", "Size (KB)", "Time Alive (sec)"); + seq_printf(s, "%-8s\t%-60s\t%-8s\t%-8s\t%s\n", + "Name", "Exp_name", "Size (KB)", "Alive (sec)", "Attached Devices"); hash_for_each(proc->dma_bufs, i, tmp, head) { struct dma_buf *dmabuf = tmp->dmabuf; + struct dma_buf_attachment *a; ktime_t elapmstime = ktime_ms_delta(ktime_get(), dmabuf->ktime); elapmstime = ktime_divns(elapmstime, MSEC_PER_SEC); - seq_printf(s, "%-8s\t%-60s\t%-8zu\t%-8lld\n", + seq_printf(s, "%-8s\t%-60s\t%-8zu\t%-8lld", dmabuf->name, dmabuf->exp_name, dmabuf->size / SZ_1K, elapmstime); + + list_for_each_entry(a, &dmabuf->attachments, node) { + seq_printf(s, "\t%s", dev_name(a->dev)); + } + seq_printf(s, "\n"); } }