From e204224b26e6b5f609bc4e542368c1a13aeece61 Mon Sep 17 00:00:00 2001 From: Lauri Peltonen Date: Tue, 25 Feb 2014 13:31:47 +0200 Subject: 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 Reviewed-on: http://git-master/r/374844 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/channel_sync_gk20a.h') 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 @@ struct gk20a_channel_sync; struct priv_cmd_entry; struct channel_gk20a; +struct gk20a_semaphore; struct gk20a_channel_fence { bool valid; bool wfi; /* was issued with preceding wfi */ - u32 thresh; /* either semaphore or syncpoint value */ + u32 thresh; /* syncpoint fences only */ + struct gk20a_semaphore *semaphore; /* semaphore fences only */ }; struct gk20a_channel_sync { @@ -43,11 +45,13 @@ struct gk20a_channel_sync { /* Generate a gpu wait cmdbuf from syncpoint. */ int (*wait_syncpt)(struct gk20a_channel_sync *s, u32 id, u32 thresh, - struct priv_cmd_entry **entry); + struct priv_cmd_entry **entry, + struct gk20a_channel_fence *fence); /* Generate a gpu wait cmdbuf from sync fd. */ int (*wait_fd)(struct gk20a_channel_sync *s, int fd, - struct priv_cmd_entry **entry); + struct priv_cmd_entry **entry, + struct gk20a_channel_fence *fence); /* Increment syncpoint/semaphore. * Returns @@ -88,6 +92,7 @@ struct gk20a_channel_sync { * - a sync fd that can be returned to user space. */ int (*incr_user_fd)(struct gk20a_channel_sync *s, + int wait_fence_fd, struct priv_cmd_entry **entry, struct gk20a_channel_fence *fence, bool wfi, @@ -96,12 +101,16 @@ struct gk20a_channel_sync { /* Reset the channel syncpoint/semaphore. */ void (*set_min_eq_max)(struct gk20a_channel_sync *s); - /* flag to set syncpt destroy aggressiveness */ - bool syncpt_aggressive_destroy; + /* flag to set sync destroy aggressiveness */ + bool aggressive_destroy; /* Free the resources allocated by gk20a_channel_sync_create. */ void (*destroy)(struct gk20a_channel_sync *s); }; struct gk20a_channel_sync *gk20a_channel_sync_create(struct channel_gk20a *c); + +void gk20a_channel_fence_close(struct gk20a_channel_fence *f); +void gk20a_channel_fence_dup(struct gk20a_channel_fence *from, + struct gk20a_channel_fence *to); #endif -- cgit v1.2.2