summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h
diff options
context:
space:
mode:
authorLauri Peltonen <lpeltonen@nvidia.com>2014-02-25 06:31:47 -0500
committerDan Willemsen <dwillemsen@nvidia.com>2015-03-18 15:10:08 -0400
commite204224b26e6b5f609bc4e542368c1a13aeece61 (patch)
tree9d351eb734a54ff677a2f26fec2d6f96adc1e220 /drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h
parent4d278fdfd70082da3c020a15ba0dd722f9da1b3b (diff)
gpu: nvgpu: Add semaphore based gk20a_channel_sync
Add semaphore implementation of the gk20a_channel_sync interface. Each channel has one semaphore pool, which is mapped as read-write to the channel vm. We allocate one or two semaphores from the pool for each submit. The first semaphore is only needed if we need to wait for an opaque sync fd. In that case, we allocate the semaphore, and ask GPU to wait for it's value to become 1 (semaphore acquire method). We also queue a kernel work that waits on the fence fd, and subsequently releases the semaphore (sets its value to 1) so that the command buffer can proceed. The second semaphore is used on every submit, and is used for work completion tracking. The GPU sets its value to 1 when the command buffer has been processed. The channel jobs need to hold references to both semaphores so that their backing semaphore pool slots are not reused while the job is in flight. Therefore gk20a_channel_fence will keep a reference to the semaphore that it represents (channel fences are stored in the job structure). This means that we must diligently close and dup the gk20a_channel_fence objects to avoid leaking semaphores. Bug 1450122 Bug 1445450 Change-Id: Ib61091a1b7632fa36efe0289011040ef7c4ae8f8 Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com> Reviewed-on: http://git-master/r/374844 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h')
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h
index 90b61bfd..baa4a151 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h
@@ -23,11 +23,13 @@
23struct gk20a_channel_sync; 23struct gk20a_channel_sync;
24struct priv_cmd_entry; 24struct priv_cmd_entry;
25struct channel_gk20a; 25struct channel_gk20a;
26struct gk20a_semaphore;
26 27
27struct gk20a_channel_fence { 28struct gk20a_channel_fence {
28 bool valid; 29 bool valid;
29 bool wfi; /* was issued with preceding wfi */ 30 bool wfi; /* was issued with preceding wfi */
30 u32 thresh; /* either semaphore or syncpoint value */ 31 u32 thresh; /* syncpoint fences only */
32 struct gk20a_semaphore *semaphore; /* semaphore fences only */
31}; 33};
32 34
33struct gk20a_channel_sync { 35struct gk20a_channel_sync {
@@ -43,11 +45,13 @@ struct gk20a_channel_sync {
43 45
44 /* Generate a gpu wait cmdbuf from syncpoint. */ 46 /* Generate a gpu wait cmdbuf from syncpoint. */
45 int (*wait_syncpt)(struct gk20a_channel_sync *s, u32 id, u32 thresh, 47 int (*wait_syncpt)(struct gk20a_channel_sync *s, u32 id, u32 thresh,
46 struct priv_cmd_entry **entry); 48 struct priv_cmd_entry **entry,
49 struct gk20a_channel_fence *fence);
47 50
48 /* Generate a gpu wait cmdbuf from sync fd. */ 51 /* Generate a gpu wait cmdbuf from sync fd. */
49 int (*wait_fd)(struct gk20a_channel_sync *s, int fd, 52 int (*wait_fd)(struct gk20a_channel_sync *s, int fd,
50 struct priv_cmd_entry **entry); 53 struct priv_cmd_entry **entry,
54 struct gk20a_channel_fence *fence);
51 55
52 /* Increment syncpoint/semaphore. 56 /* Increment syncpoint/semaphore.
53 * Returns 57 * Returns
@@ -88,6 +92,7 @@ struct gk20a_channel_sync {
88 * - a sync fd that can be returned to user space. 92 * - a sync fd that can be returned to user space.
89 */ 93 */
90 int (*incr_user_fd)(struct gk20a_channel_sync *s, 94 int (*incr_user_fd)(struct gk20a_channel_sync *s,
95 int wait_fence_fd,
91 struct priv_cmd_entry **entry, 96 struct priv_cmd_entry **entry,
92 struct gk20a_channel_fence *fence, 97 struct gk20a_channel_fence *fence,
93 bool wfi, 98 bool wfi,
@@ -96,12 +101,16 @@ struct gk20a_channel_sync {
96 /* Reset the channel syncpoint/semaphore. */ 101 /* Reset the channel syncpoint/semaphore. */
97 void (*set_min_eq_max)(struct gk20a_channel_sync *s); 102 void (*set_min_eq_max)(struct gk20a_channel_sync *s);
98 103
99 /* flag to set syncpt destroy aggressiveness */ 104 /* flag to set sync destroy aggressiveness */
100 bool syncpt_aggressive_destroy; 105 bool aggressive_destroy;
101 106
102 /* Free the resources allocated by gk20a_channel_sync_create. */ 107 /* Free the resources allocated by gk20a_channel_sync_create. */
103 void (*destroy)(struct gk20a_channel_sync *s); 108 void (*destroy)(struct gk20a_channel_sync *s);
104}; 109};
105 110
106struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c); 111struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c);
112
113void gk20a_channel_fence_close(struct gk20a_channel_fence *f);
114void gk20a_channel_fence_dup(struct gk20a_channel_fence *from,
115 struct gk20a_channel_fence *to);
107#endif 116#endif