Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d1df7b9 authored by Greg Hackmann's avatar Greg Hackmann Committed by Alistair Delva
Browse files

UPSTREAM: dma-buf: add show_fdinfo handler



The show_fdinfo handler exports the same information available through
debugfs on a per-buffer basis.

Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
Signed-off-by: default avatarChenbo Feng <fengc@google.com>
Signed-off-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190613223408.139221-4-fengc@google.com
(cherry picked from commit bcc071110aeacd28a87525a2442dd96eab145a3c)

Bug: 135613055
Test: run dmabufinfo_test.cpp and check the info is showed up in
      /proc/pid/fdinfo

Change-Id: I7e82209af812e2a3160ec470113c2ced991c9fc3
parent bf93f26d
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -397,6 +397,20 @@ static long dma_buf_ioctl(struct file *file,
	}
}

static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file)
{
	struct dma_buf *dmabuf = file->private_data;

	seq_printf(m, "size:\t%zu\n", dmabuf->size);
	/* Don't count the temporary reference taken inside procfs seq_show */
	seq_printf(m, "count:\t%ld\n", file_count(dmabuf->file) - 1);
	seq_printf(m, "exp_name:\t%s\n", dmabuf->exp_name);
	mutex_lock(&dmabuf->lock);
	if (dmabuf->name)
		seq_printf(m, "name:\t%s\n", dmabuf->name);
	mutex_unlock(&dmabuf->lock);
}

static const struct file_operations dma_buf_fops = {
	.release	= dma_buf_release,
	.mmap		= dma_buf_mmap_internal,
@@ -406,6 +420,7 @@ static const struct file_operations dma_buf_fops = {
#ifdef CONFIG_COMPAT
	.compat_ioctl	= dma_buf_ioctl,
#endif
	.show_fdinfo	= dma_buf_show_fdinfo,
};

/*