From 821d1cab904d055264bc5d62b0c0d5187417ff13 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 8 Jun 2017 10:13:51 -0700 Subject: gpu: nvgpu: Move error notifier free to Linux module Freeing error notifier involves calling dma_buf API, which is Linux specific. Move the free to happen in Linux specific channel close path. JIRA NVGPU-65 Change-Id: Ifd8b31bb8c8af13975c34add00f51dd869cfd76a Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1498583 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman --- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 15 +++++++++++++++ drivers/gpu/nvgpu/gk20a/channel_gk20a.c | 18 +++--------------- drivers/gpu/nvgpu/gk20a/channel_gk20a.h | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 2c9fac0b..a083cb81 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -180,6 +180,19 @@ static int gk20a_channel_set_wdt_status(struct channel_gk20a *ch, return 0; } +static void gk20a_channel_free_error_notifiers(struct channel_gk20a *ch) +{ + nvgpu_mutex_acquire(&ch->error_notifier_mutex); + if (ch->error_notifier_ref) { + dma_buf_vunmap(ch->error_notifier_ref, ch->error_notifier_va); + dma_buf_put(ch->error_notifier_ref); + ch->error_notifier_ref = NULL; + ch->error_notifier = NULL; + ch->error_notifier_va = NULL; + } + nvgpu_mutex_release(&ch->error_notifier_mutex); +} + static int gk20a_init_error_notifier(struct channel_gk20a *ch, struct nvgpu_set_error_notifier *args) { @@ -262,6 +275,8 @@ int gk20a_channel_release(struct inode *inode, struct file *filp) trace_gk20a_channel_release(dev_name(g->dev)); gk20a_channel_close(ch); + gk20a_channel_free_error_notifiers(ch); + gk20a_idle(g); channel_release: diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c index fad6b6af..49d83069 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c @@ -17,7 +17,10 @@ */ #include + +#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_GK20A_CYCLE_STATS) #include +#endif #include #include @@ -389,19 +392,6 @@ void gk20a_set_error_notifier(struct channel_gk20a *ch, __u32 error) nvgpu_mutex_release(&ch->error_notifier_mutex); } -void gk20a_channel_free_error_notifiers(struct channel_gk20a *ch) -{ - nvgpu_mutex_acquire(&ch->error_notifier_mutex); - if (ch->error_notifier_ref) { - dma_buf_vunmap(ch->error_notifier_ref, ch->error_notifier_va); - dma_buf_put(ch->error_notifier_ref); - ch->error_notifier_ref = NULL; - ch->error_notifier = NULL; - ch->error_notifier_va = NULL; - } - nvgpu_mutex_release(&ch->error_notifier_mutex); -} - static void gk20a_wait_until_counter_is_N( struct channel_gk20a *ch, atomic_t *counter, int wait_value, struct nvgpu_cond *c, const char *caller, const char *counter_name) @@ -528,8 +518,6 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) gk20a_dbg_info("freeing bound channel context, timeout=%ld", timeout); - gk20a_channel_free_error_notifiers(ch); - if (g->ops.fecs_trace.unbind_channel && !ch->vpr) g->ops.fecs_trace.unbind_channel(g, ch); diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h index a636e13c..9872e1b2 100644 --- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h @@ -377,7 +377,6 @@ int gk20a_channel_alloc_gpfifo(struct channel_gk20a *c, unsigned int num_entries, unsigned int num_inflight_jobs, u32 flags); -void gk20a_channel_free_error_notifiers(struct channel_gk20a *ch); void gk20a_channel_free_cycle_stats_buffer(struct channel_gk20a *ch); int gk20a_channel_free_cycle_stats_snapshot(struct channel_gk20a *ch); -- cgit v1.2.2