]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/dma-buf/sync_debug.h
dma-buf/sw-sync: Fix locking around sync_timeline lists
[mirror_ubuntu-bionic-kernel.git] / drivers / dma-buf / sync_debug.h
CommitLineData
7ad530bf 1/*
e912c881 2 * Sync File validation framework and debug infomation
7ad530bf
EG
3 *
4 * Copyright (C) 2012 Google, Inc.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 */
12
13#ifndef _LINUX_SYNC_H
14#define _LINUX_SYNC_H
15
7ad530bf
EG
16#include <linux/list.h>
17#include <linux/spinlock.h>
f54d1867 18#include <linux/dma-fence.h>
7ad530bf 19
460bfc41
GP
20#include <linux/sync_file.h>
21#include <uapi/linux/sync_file.h>
64907b94 22
7ad530bf
EG
23/**
24 * struct sync_timeline - sync object
c5b86b74 25 * @kref: reference count on fence.
7ad530bf 26 * @name: name of the sync_timeline. Useful for debugging
d3862e44
CW
27 * @lock: lock protecting @pt_list and @value
28 * @pt_list: list of active (unsignaled/errored) sync_pts
af7582f2 29 * @sync_timeline_list: membership in global sync_timeline_list
7ad530bf
EG
30 */
31struct sync_timeline {
c5b86b74 32 struct kref kref;
7ad530bf
EG
33 char name[32];
34
d3862e44 35 /* protected by lock */
731c7d3a
LT
36 u64 context;
37 int value;
7ad530bf 38
d3862e44
CW
39 struct list_head pt_list;
40 spinlock_t lock;
af7582f2
EG
41
42 struct list_head sync_timeline_list;
7ad530bf
EG
43};
44
f54d1867 45static inline struct sync_timeline *dma_fence_parent(struct dma_fence *fence)
0f0d8406 46{
d3862e44 47 return container_of(fence->lock, struct sync_timeline, lock);
0f0d8406 48}
97a84843 49
0431b906
GP
50/**
51 * struct sync_pt - sync_pt object
52 * @base: base fence object
d3862e44 53 * @link: link on the sync timeline's list
0431b906
GP
54 */
55struct sync_pt {
f54d1867 56 struct dma_fence base;
d3862e44 57 struct list_head link;
0431b906
GP
58};
59
b1f65604 60#ifdef CONFIG_SW_SYNC
0f0d8406 61
1867a23b
GP
62extern const struct file_operations sw_sync_debugfs_fops;
63
d30649a8
JP
64void sync_timeline_debug_add(struct sync_timeline *obj);
65void sync_timeline_debug_remove(struct sync_timeline *obj);
d7fdb0ae
GP
66void sync_file_debug_add(struct sync_file *fence);
67void sync_file_debug_remove(struct sync_file *fence);
d30649a8 68void sync_dump(void);
0f0d8406
ML
69
70#else
71# define sync_timeline_debug_add(obj)
72# define sync_timeline_debug_remove(obj)
d7fdb0ae
GP
73# define sync_file_debug_add(fence)
74# define sync_file_debug_remove(fence)
0f0d8406
ML
75# define sync_dump()
76#endif
0f0d8406 77
7ad530bf 78#endif /* _LINUX_SYNC_H */