From 80a6291c9c5e373a3a534ba100b616b6789fb568 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 25 Apr 2017 13:51:27 -0700 Subject: gpu: nvgpu: Use nvgpu_cond in semaphore wq Change semaphore wait queue to use nvgpu_cond instead of Linux wait queue. JIRA NVGPU-14 Change-Id: I3be5097ded168300b4480e986218d9f4fd6104b1 Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1469852 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 4 ++-- drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 7 ++++--- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 2 +- drivers/gpu/nvgpu/gk20a/fence_gk20a.c | 6 +++--- drivers/gpu/nvgpu/gk20a/fence_gk20a.h | 6 ++---- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 2 +- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 2 +- drivers/gpu/nvgpu/vgpu/fifo_vgpu.c | 2 +- drivers/gpu/nvgpu/vgpu/gr_vgpu.c | 2 +- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 79cea30c..8a87e4cb 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -413,8 +413,8 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch, semaphore = data + (offset & ~PAGE_MASK); - remain = wait_event_interruptible_timeout( - ch->semaphore_wq, + remain = NVGPU_COND_WAIT_INTERRUPTIBLE( + &ch->semaphore_wq, *semaphore == payload || ch->has_timedout, timeout); diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index 65dc1c72..536ca9f3 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -252,7 +252,7 @@ void gk20a_channel_abort_clean_up(struct channel_gk20a *ch) nvgpu_mutex_release(&ch->joblist.cleanup_lock); if (released_job_semaphore) - wake_up_interruptible_all(&ch->semaphore_wq); + nvgpu_cond_broadcast_interruptible(&ch->semaphore_wq); /* * When closing the channel, this scheduled update holds one ref which @@ -850,7 +850,7 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, * an address space bound and allocate a gpfifo and grctx. */ init_waitqueue_head(&ch->notifier_wq); - init_waitqueue_head(&ch->semaphore_wq); + nvgpu_cond_init(&ch->semaphore_wq); ch->update_fn = NULL; ch->update_fn_data = NULL; @@ -2783,7 +2783,8 @@ void gk20a_channel_semaphore_wakeup(struct gk20a *g, bool post_events) struct channel_gk20a *c = g->fifo.channel+chid; if (gk20a_channel_get(c)) { if (atomic_read(&c->bound)) { - wake_up_interruptible_all(&c->semaphore_wq); + nvgpu_cond_broadcast_interruptible( + &c->semaphore_wq); if (post_events) { if (gk20a_is_channel_marked_as_tsg(c)) { struct tsg_gk20a *tsg = diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index ea77985e..1cbf7689 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -218,7 +218,7 @@ struct channel_gk20a { struct priv_cmd_queue priv_cmd_q; wait_queue_head_t notifier_wq; - wait_queue_head_t semaphore_wq; + struct nvgpu_cond semaphore_wq; u32 timeout_accumulated_ms; u32 timeout_gpfifo_get; diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c index 87c4f6be..3964c37d 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.c @@ -208,8 +208,8 @@ static int nvgpu_semaphore_fence_wait(struct gk20a_fence *f, long timeout) if (!nvgpu_semaphore_is_acquired(f->semaphore)) return 0; - remain = wait_event_interruptible_timeout( - *f->semaphore_wq, + remain = NVGPU_COND_WAIT_INTERRUPTIBLE( + f->semaphore_wq, !nvgpu_semaphore_is_acquired(f->semaphore), timeout); if (remain == 0 && nvgpu_semaphore_is_acquired(f->semaphore)) @@ -235,7 +235,7 @@ int gk20a_fence_from_semaphore( struct gk20a_fence *fence_out, struct sync_timeline *timeline, struct nvgpu_semaphore *semaphore, - wait_queue_head_t *semaphore_wq, + struct nvgpu_cond *semaphore_wq, bool wfi, bool need_sync_fence) { struct gk20a_fence *f = fence_out; diff --git a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h index 87fa9fdb..c479f359 100644 --- a/drivers/gpu/nvgpu/gk20a/fence_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/fence_gk20a.h @@ -17,8 +17,6 @@ #ifndef _GK20A_FENCE_H_ #define _GK20A_FENCE_H_ -#include - #include struct platform_device; @@ -42,7 +40,7 @@ struct gk20a_fence { /* Valid for fences created from semaphores: */ struct nvgpu_semaphore *semaphore; - wait_queue_head_t *semaphore_wq; + struct nvgpu_cond *semaphore_wq; /* Valid for fences created from syncpoints: */ struct platform_device *host1x_pdev; @@ -59,7 +57,7 @@ int gk20a_fence_from_semaphore( struct gk20a_fence *fence_out, struct sync_timeline *timeline, struct nvgpu_semaphore *semaphore, - wait_queue_head_t *semaphore_wq, + struct nvgpu_cond *semaphore_wq, bool wfi, bool need_sync_fence); int gk20a_fence_from_syncpt( diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index edd98896..f212e55b 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -1338,7 +1338,7 @@ static void gk20a_fifo_set_has_timedout_and_wake_up_wqs(struct gk20a *g, refch->has_timedout = true; wmb(); /* unblock pending waits */ - wake_up(&refch->semaphore_wq); + nvgpu_cond_broadcast_interruptible(&refch->semaphore_wq); wake_up(&refch->notifier_wq); } } diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index e645a1a4..04d494fc 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -5703,7 +5703,7 @@ static int gk20a_gr_handle_semaphore_pending(struct gk20a *g, NVGPU_IOCTL_CHANNEL_EVENT_ID_GR_SEMAPHORE_WRITE_AWAKEN); } - wake_up_interruptible_all(&ch->semaphore_wq); + nvgpu_cond_broadcast(&ch->semaphore_wq); return 0; } diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c index 9122e48b..5ea6a016 100644 --- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c @@ -710,7 +710,7 @@ static void vgpu_fifo_set_ctx_mmu_error(struct gk20a *g, ch->has_timedout = true; wmb(); /* unblock pending waits */ - wake_up(&ch->semaphore_wq); + nvgpu_cond_broadcast_interruptible(&ch->semaphore_wq); wake_up(&ch->notifier_wq); } diff --git a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c index 2a674feb..c7960c1f 100644 --- a/drivers/gpu/nvgpu/vgpu/gr_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/gr_vgpu.c @@ -928,7 +928,7 @@ int vgpu_gr_isr(struct gk20a *g, struct tegra_vgpu_gr_intr_info *info) wake_up(&ch->notifier_wq); break; case TEGRA_VGPU_GR_INTR_SEMAPHORE: - wake_up_interruptible_all(&ch->semaphore_wq); + nvgpu_cond_broadcast_interruptible(&ch->semaphore_wq); break; case TEGRA_VGPU_GR_INTR_SEMAPHORE_TIMEOUT: gk20a_set_error_notifier(ch, -- cgit v1.2.2