blob: d269aa6783aaa57c3137ee93b02c72c620a6fd0f [file] [log] [blame]
Erik Gilling7ad530b2013-02-28 16:42:57 -08001/*
Gustavo Padovane912c882016-08-11 12:26:42 -03002 * Sync File validation framework and debug infomation
Erik Gilling7ad530b2013-02-28 16:42:57 -08003 *
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
Erik Gilling7ad530b2013-02-28 16:42:57 -080016#include <linux/list.h>
17#include <linux/spinlock.h>
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020018#include <linux/fence.h>
Erik Gilling7ad530b2013-02-28 16:42:57 -080019
Gustavo Padovan460bfc42016-04-28 10:46:57 -030020#include <linux/sync_file.h>
21#include <uapi/linux/sync_file.h>
Colin Cross64907b92014-02-17 13:58:32 -080022
Erik Gilling7ad530b2013-02-28 16:42:57 -080023/**
24 * struct sync_timeline - sync object
Erik Gillingc5b86b72013-02-28 16:43:11 -080025 * @kref: reference count on fence.
Erik Gilling7ad530b2013-02-28 16:42:57 -080026 * @name: name of the sync_timeline. Useful for debugging
Erik Gilling7ad530b2013-02-28 16:42:57 -080027 * @child_list_head: list of children sync_pts for this sync_timeline
Gustavo Padovan342952d2016-05-31 16:59:09 -030028 * @child_list_lock: lock protecting @child_list_head and fence.status
Erik Gilling7ad530b2013-02-28 16:42:57 -080029 * @active_list_head: list of active (unsignaled/errored) sync_pts
Erik Gillingaf7582f2013-02-28 16:43:00 -080030 * @sync_timeline_list: membership in global sync_timeline_list
Erik Gilling7ad530b2013-02-28 16:42:57 -080031 */
32struct sync_timeline {
Erik Gillingc5b86b72013-02-28 16:43:11 -080033 struct kref kref;
Erik Gilling7ad530b2013-02-28 16:42:57 -080034 char name[32];
35
36 /* protected by child_list_lock */
Linus Torvalds731c7d32016-08-01 21:44:08 -040037 u64 context;
38 int value;
Erik Gilling7ad530b2013-02-28 16:42:57 -080039
40 struct list_head child_list_head;
41 spinlock_t child_list_lock;
42
43 struct list_head active_list_head;
Erik Gillingaf7582f2013-02-28 16:43:00 -080044
45 struct list_head sync_timeline_list;
Erik Gilling7ad530b2013-02-28 16:42:57 -080046};
47
Gustavo Padovanb55b54b2016-01-21 10:49:21 -020048static inline struct sync_timeline *fence_parent(struct fence *fence)
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020049{
Gustavo Padovanb55b54b2016-01-21 10:49:21 -020050 return container_of(fence->lock, struct sync_timeline,
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020051 child_list_lock);
52}
Erik Gilling7ad530b2013-02-28 16:42:57 -080053
Gustavo Padovan0431b902016-05-31 16:59:04 -030054/**
55 * struct sync_pt - sync_pt object
56 * @base: base fence object
57 * @child_list: sync timeline child's list
58 * @active_list: sync timeline active child's list
59 */
60struct sync_pt {
61 struct fence base;
62 struct list_head child_list;
63 struct list_head active_list;
64};
65
Gustavo Padovanb1f65602016-05-31 16:59:13 -030066#ifdef CONFIG_SW_SYNC
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020067
Gustavo Padovan1867a232016-05-31 16:59:05 -030068extern const struct file_operations sw_sync_debugfs_fops;
69
Joe Perchesd30649a2015-08-10 14:51:16 -070070void sync_timeline_debug_add(struct sync_timeline *obj);
71void sync_timeline_debug_remove(struct sync_timeline *obj);
Gustavo Padovand7fdb0a2016-01-21 10:49:19 -020072void sync_file_debug_add(struct sync_file *fence);
73void sync_file_debug_remove(struct sync_file *fence);
Joe Perchesd30649a2015-08-10 14:51:16 -070074void sync_dump(void);
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020075
76#else
77# define sync_timeline_debug_add(obj)
78# define sync_timeline_debug_remove(obj)
Gustavo Padovand7fdb0a2016-01-21 10:49:19 -020079# define sync_file_debug_add(fence)
80# define sync_file_debug_remove(fence)
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020081# define sync_dump()
82#endif
Maarten Lankhorst0f0d8402014-07-01 12:57:31 +020083
Erik Gilling7ad530b2013-02-28 16:42:57 -080084#endif /* _LINUX_SYNC_H */