From 581e8b4ec86b13706e4423609a543fc2510b4ffe Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Tue, 20 Jun 2017 12:25:05 -0700 Subject: gpu: nvgpu: check ctx valid bit at right place When contexts are unloaded from GR, the valid bit is reset but the instance pointer information remains intact. Check valid bit in *is_channel_ctx_resident* function as valid bit might not be set when *get_channel_from_ctx function* is called from gr_isr Bug 200289491 Change-Id: I4da7f04794c7e7e80b511756dbd851205cd76fbc Signed-off-by: Seema Khowala Reviewed-on: http://git-master/r/1505908 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 4219e841..2afa79f1 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -5906,11 +5906,10 @@ static struct channel_gk20a *gk20a_gr_get_channel_from_ctx( struct channel_gk20a *ret = NULL; /* when contexts are unloaded from GR, the valid bit is reset - * but the instance pointer information remains intact. So the - * valid bit must be checked to be absolutely certain that a - * valid context is currently resident. */ - if (!gr_fecs_current_ctx_valid_v(curr_ctx)) - return NULL; + * but the instance pointer information remains intact. + * This might be called from gr_isr where contexts might be + * unloaded. No need to check ctx_valid bit + */ nvgpu_spinlock_acquire(&gr->ch_tlb_lock); @@ -6475,10 +6474,12 @@ int gk20a_gr_isr(struct gk20a *g) isr_data.class_num = gr_fe_object_table_nvclass_v(obj_table); ch = gk20a_gr_get_channel_from_ctx(g, isr_data.curr_ctx, &tsgid); - if (ch) + if (ch) { isr_data.chid = ch->hw_chid; - else + } else { isr_data.chid = FIFO_INVAL_CHANNEL_ID; + nvgpu_err(g, "ch id is INVALID 0xffffffff"); + } gk20a_dbg(gpu_dbg_intr | gpu_dbg_gpu_dbg, "channel %d: addr 0x%08x, " @@ -8283,6 +8284,15 @@ bool gk20a_is_channel_ctx_resident(struct channel_gk20a *ch) bool ret = false; curr_gr_ctx = gk20a_readl(g, gr_fecs_current_ctx_r()); + + /* when contexts are unloaded from GR, the valid bit is reset + * but the instance pointer information remains intact. So the + * valid bit must be checked to be absolutely certain that a + * valid context is currently resident. + */ + if (!gr_fecs_current_ctx_valid_v(curr_gr_ctx)) + return NULL; + curr_ch = gk20a_gr_get_channel_from_ctx(g, curr_gr_ctx, &curr_gr_tsgid); -- cgit v1.2.2