From 33665060728693c28ed5222a0d9004e261c63e82 Mon Sep 17 00:00:00 2001 From: Aingara Paramakuru Date: Mon, 15 Aug 2016 14:17:43 -0400 Subject: gpu: nvgpu: move gpfifo submit wait to userspace Instead of blocking for gpfifo space in the nvgpu driver, return -EAGAIN and allow userspace to decide the blocking policy. Bug 1795076 Change-Id: Ie091caa92aad3f68bc01a3456ad948e76883bc50 Signed-off-by: Aingara Paramakuru Reviewed-on: http://git-master/r/1202591 (cherry picked from commit 8056f422c6a34a4239fc4993c40c2e517c932714) Reviewed-on: http://git-master/r/1203800 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 32 +++++++++----------------------- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 1 - drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 1 - drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | 1 - include/trace/events/gk20a.h | 10 ---------- 5 files changed, 9 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 4c03f955..b4c132ce 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -1194,7 +1194,6 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, init_waitqueue_head(&ch->notifier_wq); init_waitqueue_head(&ch->semaphore_wq); - init_waitqueue_head(&ch->submit_wq); ch->update_fn = NULL; ch->update_fn_data = NULL; @@ -1974,9 +1973,6 @@ void gk20a_channel_update(struct channel_gk20a *c, int nr_completed) return; } - update_gp_get(c->g, c); - wake_up(&c->submit_wq); - trace_gk20a_channel_update(c->hw_chid); gk20a_channel_schedule_job_clean_up(c); @@ -2181,22 +2177,16 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, gk20a_dbg_info("pre-submit put %d, get %d, size %d", c->gpfifo.put, c->gpfifo.get, c->gpfifo.entry_num); - /* Make sure we have enough space for gpfifo entries. If not, - * wait for signals from completed submits */ + /* + * Make sure we have enough space for gpfifo entries. Check cached + * values first and then read from HW. If no space, return EAGAIN + * and let userpace decide to re-try request or not. + */ if (gp_free_count(c) < num_entries + extra_entries) { - /* we can get here via locked ioctl and other paths too */ - int locked_path = mutex_is_locked(&c->ioctl_lock); - if (locked_path) - mutex_unlock(&c->ioctl_lock); - - trace_gk20a_gpfifo_submit_wait_for_space(dev_name(c->g->dev)); - err = wait_event_interruptible(c->submit_wq, - get_gp_free_count(c) >= num_entries + extra_entries || - c->has_timedout); - trace_gk20a_gpfifo_submit_wait_for_space_done(dev_name(c->g->dev)); - - if (locked_path) - mutex_lock(&c->ioctl_lock); + if (get_gp_free_count(c) < num_entries + extra_entries) { + err = -EAGAIN; + goto clean_up; + } } if (c->has_timedout) { @@ -2204,10 +2194,6 @@ int gk20a_submit_channel_gpfifo(struct channel_gk20a *c, goto clean_up; } - if (err) { - err = -ENOSPC; - goto clean_up; - } mutex_lock(&c->sync_lock); if (!c->sync) { diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index 5ad23bab..9b909962 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -145,7 +145,6 @@ struct channel_gk20a { wait_queue_head_t notifier_wq; wait_queue_head_t semaphore_wq; - wait_queue_head_t submit_wq; u32 timeout_accumulated_ms; u32 timeout_gpfifo_get; diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index ee42f4d7..ff052400 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -1210,7 +1210,6 @@ static bool gk20a_fifo_set_ctx_mmu_error(struct gk20a *g, /* unblock pending waits */ wake_up(&ch->semaphore_wq); wake_up(&ch->notifier_wq); - wake_up(&ch->submit_wq); return verbose; } diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 2bd36b91..3d00e72c 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c @@ -694,7 +694,6 @@ static void vgpu_fifo_set_ctx_mmu_error(struct gk20a *g, /* unblock pending waits */ wake_up(&ch->semaphore_wq); wake_up(&ch->notifier_wq); - wake_up(&ch->submit_wq); } int vgpu_fifo_isr(struct gk20a *g, struct tegra_vgpu_fifo_intr_info *info) diff --git a/include/trace/events/gk20a.h b/include/trace/events/gk20a.h index ba71dda2..a6939833 100644 --- a/include/trace/events/gk20a.h +++ b/include/trace/events/gk20a.h @@ -55,16 +55,6 @@ DEFINE_EVENT(gk20a, gk20a_finalize_poweron_done, TP_ARGS(name) ); -DEFINE_EVENT(gk20a, gk20a_gpfifo_submit_wait_for_space, - TP_PROTO(const char *name), - TP_ARGS(name) -); - -DEFINE_EVENT(gk20a, gk20a_gpfifo_submit_wait_for_space_done, - TP_PROTO(const char *name), - TP_ARGS(name) -); - DEFINE_EVENT(gk20a, gk20a_mm_l2_invalidate, TP_PROTO(const char *name), TP_ARGS(name) -- cgit v1.2.2