gpu: nvgpu: rename has_timedout and make it thread safe

Currently has_timedout variable is protected by wmb at places
where it is being set and there is no correspoding rmb whenever
has_timedout variable is read. This is prone to errors for
concurrent execution. This change is supposed to fix this issue.
Rename has_timedout variable of channel struct to ch_timedout.
Also to avoid rmb every time ch_timedout is read,
ch_timedout_spinlock is added to protect ch_timedout
variable for taking care of concurrent execution.

Bug 2404865
Bug 2092051

Change-Id: I0bee9f50af0a48720aa8b54cbc3af97ef9f6df00
Signed-off-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1930935
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Seema Khowala
2018-10-19 12:08:46 -07:00
committed by mobile promotions
parent 503b897b45
commit 1f54ea09e3
9 changed files with 54 additions and 24 deletions

View File

@@ -212,6 +212,24 @@ void gk20a_channel_abort_clean_up(struct channel_gk20a *ch)
gk20a_channel_update(ch);
}
void gk20a_channel_set_timedout(struct channel_gk20a *ch)
{
nvgpu_spinlock_acquire(&ch->ch_timedout_lock);
ch->ch_timedout = true;
nvgpu_spinlock_release(&ch->ch_timedout_lock);
}
bool gk20a_channel_check_timedout(struct channel_gk20a *ch)
{
bool ch_timedout_status;
nvgpu_spinlock_acquire(&ch->ch_timedout_lock);
ch_timedout_status = ch->ch_timedout;
nvgpu_spinlock_release(&ch->ch_timedout_lock);
return ch_timedout_status;
}
void gk20a_channel_abort(struct channel_gk20a *ch, bool channel_preempt)
{
nvgpu_log_fn(ch->g, " ");
@@ -221,7 +239,7 @@ void gk20a_channel_abort(struct channel_gk20a *ch, bool channel_preempt)
}
/* make sure new kickoffs are prevented */
ch->has_timedout = true;
gk20a_channel_set_timedout(ch);
ch->g->ops.fifo.disable_channel(ch);
@@ -423,7 +441,7 @@ static void gk20a_free_channel(struct channel_gk20a *ch, bool force)
* Set user managed syncpoint to safe state
* But it's already done if channel has timedout
*/
if (ch->has_timedout) {
if (gk20a_channel_check_timedout(ch)) {
nvgpu_channel_sync_destroy(ch->user_sync, false);
} else {
nvgpu_channel_sync_destroy(ch->user_sync, true);
@@ -697,7 +715,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->has_timedout = false;
ch->ch_timedout = false;
/* init kernel watchdog timeout */
ch->timeout.enabled = true;
@@ -2187,6 +2205,8 @@ 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);
#if GK20A_CHANNEL_REFCOUNT_TRACKING
nvgpu_spinlock_init(&c->ref_actions_lock);
#endif

View File

@@ -348,7 +348,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c,
return -ENODEV;
}
if (c->has_timedout) {
if (gk20a_channel_check_timedout(c)) {
return -ETIMEDOUT;
}
@@ -513,7 +513,7 @@ static int nvgpu_submit_channel_gpfifo(struct channel_gk20a *c,
}
}
if (c->has_timedout) {
if (gk20a_channel_check_timedout(c)) {
err = -ETIMEDOUT;
goto clean_up;
}