a347cbab68f295ff31ad4397d13fd9f0b5c20cd3
[linux-3.10.git] / drivers / gpu / nvgpu / gk20a / channel_sync_gk20a.h
1 /*
2  * drivers/video/tegra/host/gk20a/channel_sync_gk20a.h
3  *
4  * GK20A Channel Synchronization Abstraction
5  *
6  * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms and conditions of the GNU General Public License,
10  * version 2, as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  */
17
18 #ifndef _GK20A_CHANNEL_SYNC_H_
19 #define _GK20A_CHANNEL_SYNC_H_
20
21 #include <linux/types.h>
22
23 struct gk20a_channel_sync;
24 struct priv_cmd_entry;
25 struct channel_gk20a;
26 struct gk20a_semaphore;
27 struct gk20a_fence;
28
29 struct gk20a_channel_sync {
30         /* Generate a gpu wait cmdbuf from syncpoint.
31          * Returns
32          *  - a gpu cmdbuf that performs the wait when executed,
33          *  - possibly a helper fence that the caller must hold until the
34          *    cmdbuf is executed.
35          */
36         int (*wait_syncpt)(struct gk20a_channel_sync *s, u32 id, u32 thresh,
37                            struct priv_cmd_entry **entry,
38                            struct gk20a_fence **fence);
39
40         /* Generate a gpu wait cmdbuf from sync fd.
41          * Returns
42          *  - a gpu cmdbuf that performs the wait when executed,
43          *  - possibly a helper fence that the caller must hold until the
44          *    cmdbuf is executed.
45          */
46         int (*wait_fd)(struct gk20a_channel_sync *s, int fd,
47                        struct priv_cmd_entry **entry,
48                        struct gk20a_fence **fence);
49
50         /* Increment syncpoint/semaphore.
51          * Returns
52          *  - a gpu cmdbuf that performs the increment when executed,
53          *  - a fence that can be passed to wait_cpu() and is_expired().
54          */
55         int (*incr)(struct gk20a_channel_sync *s,
56                     struct priv_cmd_entry **entry,
57                     struct gk20a_fence **fence);
58
59         /* Increment syncpoint/semaphore, preceded by a wfi.
60          * Returns
61          *  - a gpu cmdbuf that performs the increment when executed,
62          *  - a fence that can be passed to wait_cpu() and is_expired().
63          */
64         int (*incr_wfi)(struct gk20a_channel_sync *s,
65                         struct priv_cmd_entry **entry,
66                         struct gk20a_fence **fence);
67
68         /* Increment syncpoint/semaphore, so that the returned fence represents
69          * work completion (may need wfi) and can be returned to user space.
70          * Returns
71          *  - a gpu cmdbuf that performs the increment when executed,
72          *  - a fence that can be passed to wait_cpu() and is_expired(),
73          *  - a gk20a_fence that signals when the incr has happened.
74          */
75         int (*incr_user)(struct gk20a_channel_sync *s,
76                          int wait_fence_fd,
77                          struct priv_cmd_entry **entry,
78                          struct gk20a_fence **fence,
79                          bool wfi);
80
81         /* Reset the channel syncpoint/semaphore. */
82         void (*set_min_eq_max)(struct gk20a_channel_sync *s);
83
84         /* Signals the sync timeline (if owned by the gk20a_channel_sync layer).
85          * This should be called when we notice that a gk20a_fence is
86          * expired. */
87         void (*signal_timeline)(struct gk20a_channel_sync *s);
88
89         /* Returns the sync point id or negative number if no syncpt*/
90         int (*syncpt_id)(struct gk20a_channel_sync *s);
91
92         /* flag to set sync destroy aggressiveness */
93         bool aggressive_destroy;
94
95         /* Free the resources allocated by gk20a_channel_sync_create. */
96         void (*destroy)(struct gk20a_channel_sync *s);
97 };
98
99 struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c);
100
101 #endif