From b0f8ceb708d56f0bb129c9f927cdbdec64f16789 Mon Sep 17 00:00:00 2001 From: Mayank Kaushik Date: Thu, 4 Sep 2014 18:35:25 -0700 Subject: [PATCH] gpu: nvgpu: gk20a: check ctx valid bit When determining the chid for the current context, first check the ctx valid bit. Bug 1485555 Change-Id: I6c3096d800a6cef38b656d525437a2c4f8b45774 Signed-off-by: Mayank Kaushik Reviewed-on: http://git-master/r/496140 (cherry picked from commit 20a7a9635e9f969782da6695d99bc99c4ed8fa32) Reviewed-on: http://git-master/r/555054 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Winnie Hsu --- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 491f55bff50..e195b433f58 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -5055,6 +5055,7 @@ static int gk20a_gr_handle_notify_pending(struct gk20a *g, /* Used by sw interrupt thread to translate current ctx to chid. * For performance, we don't want to go through 128 channels every time. + * curr_ctx should be the value read from gr_fecs_current_ctx_r(). * A small tlb is used here to cache translation */ static int gk20a_gr_get_chid_from_ctx(struct gk20a *g, u32 curr_ctx) { @@ -5063,6 +5064,13 @@ static int gk20a_gr_get_chid_from_ctx(struct gk20a *g, u32 curr_ctx) u32 chid = -1; u32 i; + /* 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 -1; + spin_lock(&gr->ch_tlb_lock); /* check cache first */ -- 2.39.2