From 2c0933de05db4a93f083c25340909ff222cf6cf5 Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Wed, 16 Jan 2019 14:08:02 -0800 Subject: [PATCH] gpu: nvgpu: rename ch_timedout to unserviceable ch_timedout is not a good variable name for broken and unusable state of the channel. Rename ch_timedout to unserviceable Bug 2092051 Bug 2429295 Change-Id: I633eaff61928d5ef9836dcdc162b07e7a5e03881 Signed-off-by: Seema Khowala Reviewed-on: https://git-master.nvidia.com/r/1996865 Reviewed-by: svc-misra-checker Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/channel.c | 44 +++++++++---------- drivers/gpu/nvgpu/common/fifo/submit.c | 4 +- .../gpu/nvgpu/common/vgpu/fifo/fifo_vgpu.c | 4 +- drivers/gpu/nvgpu/common/vgpu/vgpu.c | 2 +- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 4 +- drivers/gpu/nvgpu/include/nvgpu/channel.h | 9 ++-- drivers/gpu/nvgpu/os/linux/cde.c | 6 +-- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 12 ++--- drivers/gpu/nvgpu/os/linux/ioctl_tsg.c | 6 +-- 9 files changed, 46 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index a29918abd..e3bf6806a 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -213,22 +213,22 @@ void gk20a_channel_abort_clean_up(struct channel_gk20a *ch) gk20a_channel_update(ch); } -void gk20a_channel_set_timedout(struct channel_gk20a *ch) +void gk20a_channel_set_unserviceable(struct channel_gk20a *ch) { - nvgpu_spinlock_acquire(&ch->ch_timedout_lock); - ch->ch_timedout = true; - nvgpu_spinlock_release(&ch->ch_timedout_lock); + nvgpu_spinlock_acquire(&ch->unserviceable_lock); + ch->unserviceable = true; + nvgpu_spinlock_release(&ch->unserviceable_lock); } -bool gk20a_channel_check_timedout(struct channel_gk20a *ch) +bool gk20a_channel_check_unserviceable(struct channel_gk20a *ch) { - bool ch_timedout_status; + bool unserviceable_status; - nvgpu_spinlock_acquire(&ch->ch_timedout_lock); - ch_timedout_status = ch->ch_timedout; - nvgpu_spinlock_release(&ch->ch_timedout_lock); + nvgpu_spinlock_acquire(&ch->unserviceable_lock); + unserviceable_status = ch->unserviceable; + nvgpu_spinlock_release(&ch->unserviceable_lock); - return ch_timedout_status; + return unserviceable_status; } void gk20a_channel_abort(struct channel_gk20a *ch, bool channel_preempt) @@ -436,9 +436,9 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force) if (ch->user_sync != NULL) { /* * Set user managed syncpoint to safe state - * But it's already done if channel has timedout + * But it's already done if channel is recovered */ - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { nvgpu_channel_sync_destroy(ch->user_sync, false); } else { nvgpu_channel_sync_destroy(ch->user_sync, true); @@ -724,7 +724,7 @@ struct channel_gk20a *gk20a_open_new_channel(struct gk20a *g, /* set gr host default timeout */ ch->timeout_ms_max = gk20a_get_gr_idle_timeout(g); ch->timeout_debug_dump = true; - ch->ch_timedout = false; + ch->unserviceable = false; /* init kernel watchdog timeout */ ch->timeout.enabled = true; @@ -1381,7 +1381,7 @@ static void nvgpu_channel_set_has_timedout_and_wakeup_wqs(struct gk20a *g, struct channel_gk20a *ch) { /* mark channel as faulted */ - gk20a_channel_set_timedout(ch); + gk20a_channel_set_unserviceable(ch); /* unblock pending waits */ nvgpu_cond_broadcast_interruptible(&ch->semaphore_wq); @@ -1485,7 +1485,7 @@ u32 nvgpu_get_gp_free_count(struct channel_gk20a *c) static void __gk20a_channel_timeout_start(struct channel_gk20a *ch) { - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { ch->timeout.running = false; return; } @@ -1607,7 +1607,7 @@ void gk20a_channel_timeout_restart_all_channels(struct gk20a *g) struct channel_gk20a *ch = gk20a_channel_from_id(g, chid); if (ch != NULL) { - if (!gk20a_channel_check_timedout(ch)) { + if (!gk20a_channel_check_unserviceable(ch)) { gk20a_channel_timeout_rewind(ch); } gk20a_channel_put(ch); @@ -1635,7 +1635,7 @@ static void gk20a_channel_timeout_handler(struct channel_gk20a *ch) nvgpu_log_fn(g, " "); - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { /* channel is already recovered */ gk20a_channel_timeout_stop(ch); return; @@ -1706,7 +1706,7 @@ static void gk20a_channel_poll_timeouts(struct gk20a *g) struct channel_gk20a *ch = gk20a_channel_from_id(g, chid); if (ch != NULL) { - if (!gk20a_channel_check_timedout(ch)) { + if (!gk20a_channel_check_unserviceable(ch)) { gk20a_channel_timeout_check(ch); } gk20a_channel_put(ch); @@ -2334,7 +2334,7 @@ int gk20a_init_channel_support(struct gk20a *g, u32 chid) c->referenceable = false; nvgpu_cond_init(&c->ref_count_dec_wq); - nvgpu_spinlock_init(&c->ch_timedout_lock); + nvgpu_spinlock_init(&c->unserviceable_lock); #if GK20A_CHANNEL_REFCOUNT_TRACKING nvgpu_spinlock_init(&c->ref_actions_lock); @@ -2416,7 +2416,7 @@ int gk20a_channel_suspend(struct gk20a *g) if (ch == NULL) { continue; } - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { nvgpu_log_info(g, "do not suspend recovered " "channel %d", chid); } else { @@ -2445,7 +2445,7 @@ int gk20a_channel_suspend(struct gk20a *g) struct channel_gk20a *ch = gk20a_channel_from_id(g, chid); if (ch != NULL) { - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { nvgpu_log_info(g, "do not unbind " "recovered channel %d", chid); @@ -2476,7 +2476,7 @@ int gk20a_channel_resume(struct gk20a *g) if (ch == NULL) { continue; } - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { nvgpu_log_info(g, "do not resume recovered " "channel %d", chid); } else { diff --git a/drivers/gpu/nvgpu/common/fifo/submit.c b/drivers/gpu/nvgpu/common/fifo/submit.c index e278f0862..59f6e4f38 100644 --- a/drivers/gpu/nvgpu/common/fifo/submit.c +++ b/drivers/gpu/nvgpu/common/fifo/submit.c @@ -351,7 +351,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, return -ENODEV; } - if (gk20a_channel_check_timedout(c)) { + if (gk20a_channel_check_unserviceable(c)) { return -ETIMEDOUT; } @@ -516,7 +516,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c, } } - if (gk20a_channel_check_timedout(c)) { + if (gk20a_channel_check_unserviceable(c)) { err = -ETIMEDOUT; goto clean_up; } diff --git a/drivers/gpu/nvgpu/common/vgpu/fifo/fifo_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/fifo/fifo_vgpu.c index 9f1f738c1..f6803c50a 100644 --- a/drivers/gpu/nvgpu/common/vgpu/fifo/fifo_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/fifo/fifo_vgpu.c @@ -476,7 +476,7 @@ int vgpu_fifo_force_reset_ch(struct channel_gk20a *ch, if (gk20a_channel_get(ch_tsg)) { g->ops.fifo.set_error_notifier(ch_tsg, err_code); - gk20a_channel_set_timedout(ch_tsg); + gk20a_channel_set_unserviceable(ch_tsg); gk20a_channel_put(ch_tsg); } } @@ -510,7 +510,7 @@ static void vgpu_fifo_set_ctx_mmu_error_ch(struct gk20a *g, NVGPU_ERR_NOTIFIER_FIFO_ERROR_MMU_ERR_FLT); /* mark channel as faulted */ - gk20a_channel_set_timedout(ch); + gk20a_channel_set_unserviceable(ch); /* unblock pending waits */ nvgpu_cond_broadcast_interruptible(&ch->semaphore_wq); diff --git a/drivers/gpu/nvgpu/common/vgpu/vgpu.c b/drivers/gpu/nvgpu/common/vgpu/vgpu.c index d43f4e680..76f1b87bb 100644 --- a/drivers/gpu/nvgpu/common/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/vgpu.c @@ -130,7 +130,7 @@ static void vgpu_channel_abort_cleanup(struct gk20a *g, u32 chid) return; } - gk20a_channel_set_timedout(ch); + gk20a_channel_set_unserviceable(ch); g->ops.fifo.ch_abort_clean_up(ch); gk20a_channel_put(ch); } diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index 1148e8e38..7aac5cae0 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -1050,7 +1050,7 @@ void gk20a_fifo_abort_tsg(struct gk20a *g, struct tsg_gk20a *tsg, bool preempt) nvgpu_rwsem_down_read(&tsg->ch_list_lock); nvgpu_list_for_each_entry(ch, &tsg->ch_list, channel_gk20a, ch_entry) { if (gk20a_channel_get(ch) != NULL) { - gk20a_channel_set_timedout(ch); + gk20a_channel_set_unserviceable(ch); if (ch->g->ops.fifo.ch_abort_clean_up != NULL) { ch->g->ops.fifo.ch_abort_clean_up(ch); } @@ -1605,7 +1605,7 @@ int gk20a_fifo_tsg_unbind_channel(struct channel_gk20a *ch) /* If one channel in TSG times out, we disable all channels */ nvgpu_rwsem_down_write(&tsg->ch_list_lock); - tsg_timedout = gk20a_channel_check_timedout(ch); + tsg_timedout = gk20a_channel_check_unserviceable(ch); nvgpu_rwsem_up_write(&tsg->ch_list_lock); /* Disable TSG and examine status before unbinding channel */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/channel.h b/drivers/gpu/nvgpu/include/nvgpu/channel.h index fd714b8f6..64dc07469 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/channel.h +++ b/drivers/gpu/nvgpu/include/nvgpu/channel.h @@ -303,8 +303,9 @@ struct channel_gk20a { struct nvgpu_gr_subctx *subctx; - struct nvgpu_spinlock ch_timedout_lock; - bool ch_timedout; + struct nvgpu_spinlock unserviceable_lock; + bool unserviceable; + /* Any operating system specific data. */ void *os_priv; @@ -480,8 +481,8 @@ static inline void trace_write_pushbuffers(struct channel_gk20a *c, u32 count) } #endif -void gk20a_channel_set_timedout(struct channel_gk20a *ch); -bool gk20a_channel_check_timedout(struct channel_gk20a *ch); +void gk20a_channel_set_unserviceable(struct channel_gk20a *ch); +bool gk20a_channel_check_unserviceable(struct channel_gk20a *ch); static inline u64 gk20a_channel_userd_addr(struct channel_gk20a *c) { diff --git a/drivers/gpu/nvgpu/os/linux/cde.c b/drivers/gpu/nvgpu/os/linux/cde.c index 853494b52..0bcca6e54 100644 --- a/drivers/gpu/nvgpu/os/linux/cde.c +++ b/drivers/gpu/nvgpu/os/linux/cde.c @@ -1,7 +1,7 @@ /* * Color decompression engine support * - * Copyright (c) 2014-2018, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2014-2019, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -1274,7 +1274,7 @@ __releases(&cde_app->mutex) nvgpu_log_info(g, "double finish cde context %p on channel %p", cde_ctx, ch); - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { if (cde_ctx->is_temporary) { nvgpu_warn(g, "cde: channel had timed out" @@ -1301,7 +1301,7 @@ __releases(&cde_app->mutex) msecs_to_jiffies(CTX_DELETE_TIME)); } - if (!gk20a_channel_check_timedout(ch)) { + if (!gk20a_channel_check_unserviceable(ch)) { gk20a_cde_ctx_release(cde_ctx); } } diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index bcf7754f6..651896eda 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -663,7 +663,7 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch, int ret = 0; /* do not wait if channel has timed out */ - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { return -ETIMEDOUT; } @@ -685,7 +685,7 @@ static int gk20a_channel_wait_semaphore(struct channel_gk20a *ch, ret = NVGPU_COND_WAIT_INTERRUPTIBLE( &ch->semaphore_wq, *semaphore == payload || - gk20a_channel_check_timedout(ch), + gk20a_channel_check_unserviceable(ch), timeout); dma_buf_kunmap(dmabuf, offset >> PAGE_SHIFT, data); @@ -709,7 +709,7 @@ static int gk20a_channel_wait(struct channel_gk20a *ch, nvgpu_log_fn(g, " "); - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { return -ETIMEDOUT; } @@ -747,7 +747,7 @@ static int gk20a_channel_wait(struct channel_gk20a *ch, remain = NVGPU_COND_WAIT_INTERRUPTIBLE( &ch->notifier_wq, notif->status == 0 || - gk20a_channel_check_timedout(ch), + gk20a_channel_check_unserviceable(ch), args->timeout); if (remain == 0 && notif->status != 0) { @@ -817,7 +817,7 @@ static int gk20a_ioctl_channel_submit_gpfifo( profile = gk20a_fifo_profile_acquire(ch->g); gk20a_fifo_profile_snapshot(profile, PROFILE_IOCTL_ENTRY); - if (gk20a_channel_check_timedout(ch)) { + if (gk20a_channel_check_unserviceable(ch)) { return -ETIMEDOUT; } @@ -1320,7 +1320,7 @@ long gk20a_channel_ioctl(struct file *filp, } case NVGPU_IOCTL_CHANNEL_GET_TIMEDOUT: ((struct nvgpu_get_param_args *)buf)->value = - gk20a_channel_check_timedout(ch); + gk20a_channel_check_unserviceable(ch); break; case NVGPU_IOCTL_CHANNEL_ENABLE: err = gk20a_busy(ch->g); diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c index 2e49f1421..602f02b77 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_tsg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -140,10 +140,10 @@ static int gk20a_tsg_unbind_channel_fd(struct tsg_gk20a *tsg, int ch_fd) err = gk20a_tsg_unbind_channel(ch); /* - * Mark the channel timedout since channel unbound from TSG + * Mark the channel unserviceable since channel unbound from TSG * has no context of its own so it can't serve any job */ - gk20a_channel_set_timedout(ch); + gk20a_channel_set_unserviceable(ch); out: gk20a_channel_put(ch);