Skip to content

Commit af77c1d

Browse files
jayxurockchiprkhuangtao
authored andcommitted
soc: rockchip: rk_dmabuf add 'peak' child node
Add a child node 'peak' to stat the peak size for dmabuf. Signed-off-by: Jianqun Xu <[email protected]> Change-Id: I6ee9e69f60e9c7660477dafb3d7f789677406abb
1 parent d870c5b commit af77c1d

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

drivers/soc/rockchip/rk_dmabuf_procfs.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ static int rk_dmabuf_cb(const struct dma_buf *dmabuf, void *private)
9797
return 0;
9898
}
9999

100-
static int rk_dmabuf_cb2(const struct dma_buf *dmabuf, void *private)
101-
{
102-
*((unsigned long *)private) += dmabuf->size;
103-
104-
return 0;
105-
}
106-
107100
static int rk_dmabuf_cb3(const struct dma_buf *dmabuf, void *private)
108101
{
109102
struct seq_file *s = private;
@@ -138,14 +131,50 @@ static int rk_dmabuf_dev_show(struct seq_file *s, void *v)
138131

139132
static int rk_dmabuf_size_show(struct seq_file *s, void *v)
140133
{
141-
unsigned long total_size = 0;
134+
seq_printf(s, "Total: %lu KiB\n", K(dma_buf_get_total_size()));
142135

143-
get_each_dmabuf(rk_dmabuf_cb2, &total_size);
144-
seq_printf(s, "Total: %lu KiB\n", K(total_size));
136+
return 0;
137+
}
138+
139+
static int rk_dmabuf_peak_show(struct seq_file *s, void *v)
140+
{
141+
seq_printf(s, "Peak: %lu MiB\n", K(K(dma_buf_get_peak_size())));
145142

146143
return 0;
147144
}
148145

146+
static ssize_t rk_dmabuf_peak_write(struct file *file,
147+
const char __user *buffer,
148+
size_t count, loff_t *ppos)
149+
{
150+
char c;
151+
int rc;
152+
153+
rc = get_user(c, buffer);
154+
if (rc)
155+
return rc;
156+
157+
if (c != '0')
158+
return -EINVAL;
159+
160+
dma_buf_reset_peak_size();
161+
162+
return count;
163+
}
164+
165+
static int rk_dmabuf_peak_open(struct inode *inode, struct file *file)
166+
{
167+
return single_open(file, rk_dmabuf_peak_show, NULL);
168+
}
169+
170+
static const struct proc_ops rk_dmabuf_peak_ops = {
171+
.proc_open = rk_dmabuf_peak_open,
172+
.proc_read = seq_read,
173+
.proc_lseek = seq_lseek,
174+
.proc_release = single_release,
175+
.proc_write = rk_dmabuf_peak_write,
176+
};
177+
149178
static int __init rk_dmabuf_init(void)
150179
{
151180
struct platform_device *pdev;
@@ -163,6 +192,7 @@ static int __init rk_dmabuf_init(void)
163192
proc_create_single("sgt", 0, root, rk_dmabuf_sgt_show);
164193
proc_create_single("dev", 0, root, rk_dmabuf_dev_show);
165194
proc_create_single("size", 0, root, rk_dmabuf_size_show);
195+
proc_create("peak", 0644, root, &rk_dmabuf_peak_ops);
166196

167197
return 0;
168198
}

0 commit comments

Comments
 (0)