• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * DMA-BUF: dmabuf usage of all processes statistics.
4  *
5  * Copyright (c) 2022 Huawei Device Co., Ltd.
6  */
7 
8 #ifndef __DMA_BUF_PROCESS_INFO_H
9 #define __DMA_BUF_PROCESS_INFO_H
10 
11 #ifdef CONFIG_DMABUF_PROCESS_INFO
12 /**
13  * init_dma_buf_task_info - init exp_pid and exp_task_comm of dma_buf
14  * @buf:	[in]	pointer to struct dma_buf. If @buf IS_ERR_OR_NULL,
15  *		return with doing nothing.
16  */
17 void init_dma_buf_task_info(struct dma_buf *buf);
18 
19 /**
20  * dma_buf_exp_pid - return exp_pid of @buf
21  * @buf:	[in]	pointer to struct dma_buf
22  *
23  * Return 0 if @buf IS_ERR_OR_NULL, else return buf->exp_pid
24  */
25 pid_t dma_buf_exp_pid(const struct dma_buf *buf);
26 
27 /**
28  * dma_buf_exp_task_comm - return exp_task_comm of @buf
29  * @buf:	[in]	pointer to struct dma_buf
30  *
31  * Return NULL if @buf IS_ERR_OR_NULL, else return buf->exp_task_comm
32  */
33 const char *dma_buf_exp_task_comm(const struct dma_buf *buf);
34 
35 /**
36  * dma_buf_process_info_init_procfs - module init: create node in procfs
37  */
38 void dma_buf_process_info_init_procfs(void);
39 
40 /**
41  * dma_buf_process_info_uninit_procfs - module exit: remove node in procfs
42  */
43 void dma_buf_process_info_uninit_procfs(void);
44 
45 /**
46  * dma_buf_process_info_init_debugfs - create debug node under @parent
47  * in debugfs.
48  * @parent:	[in]	pointer to struct dentry. If @parent IS_ERR_OR_NULL,
49  *		return -EINVAL
50  *
51  * Return 0 if success, otherwise return errno.
52  *
53  * Note that there is no related uninit function, since the debug node will
54  * be removed in dma_buf_uninit_debugfs() when dma_buf_deinit() called.
55  */
56 int dma_buf_process_info_init_debugfs(struct dentry *parent);
57 
58 #else /* CONFIG_DMABUF_PROCESS_INFO */
59 
init_dma_buf_task_info(struct dma_buf * buf)60 static inline void init_dma_buf_task_info(struct dma_buf *buf) {}
61 
dma_buf_exp_pid(const struct dma_buf * buf)62 static inline pid_t dma_buf_exp_pid(const struct dma_buf *buf)
63 {
64 	return 0;
65 }
66 
dma_buf_exp_task_comm(const struct dma_buf * buf)67 static inline const char *dma_buf_exp_task_comm(const struct dma_buf *buf)
68 {
69 	return NULL;
70 }
71 
dma_buf_process_info_init_procfs(void)72 static inline void dma_buf_process_info_init_procfs(void) {}
73 
dma_buf_process_info_uninit_procfs(void)74 static inline void dma_buf_process_info_uninit_procfs(void) {}
75 
76 static inline int
dma_buf_process_info_init_debugfs(struct dentry * parent)77 dma_buf_process_info_init_debugfs(struct dentry *parent)
78 {
79 	return 0;
80 }
81 #endif /* CONFIG_DMABUF_PROCESS_INFO */
82 #endif /* __DMA_BUF_PROCESS_INFO_H */
83 
84