From 64039b3ae04229ea0642141bf9299dc1ead7a3aa Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Tue, 13 Jan 2015 03:17:16 +0200 Subject: gpu: nvgpu: Do not panic if PMU/regops not supported Fix panics when using regops when PMU is disabled, or when whitelists have not been defined. Bug 1592505 Change-Id: I316c98147c54be7b1114ad23049ce3a634d4805e Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/671841 --- drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c | 6 ++++-- drivers/gpu/nvgpu/gk20a/regops_gk20a.c | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'drivers/gpu') diff --git a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c index 35a43130..daed2967 100644 --- a/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/dbg_gpu_gk20a.c @@ -600,7 +600,8 @@ static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, return -EPERM; /*do elpg disable before clock gating */ - gk20a_pmu_disable_elpg(g); + if (support_gk20a_pmu(g->dev)) + gk20a_pmu_disable_elpg(g); g->ops.clock_gating.slcg_gr_load_gating_prod(g, false); g->ops.clock_gating.slcg_perf_load_gating_prod(g, @@ -640,7 +641,8 @@ static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s, g->ops.clock_gating.slcg_perf_load_gating_prod(g, g->slcg_enabled); - gk20a_pmu_enable_elpg(g); + if (support_gk20a_pmu(g->dev)) + gk20a_pmu_enable_elpg(g); gk20a_dbg(gpu_dbg_gpu_dbg | gpu_dbg_fn, "module idle"); gk20a_idle(dbg_s->pdev); diff --git a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c index 04659bcf..11ab7bc3 100644 --- a/drivers/gpu/nvgpu/gk20a/regops_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/regops_gk20a.c @@ -561,7 +561,8 @@ static bool check_whitelists(struct dbg_session_gk20a *dbg_s, if (op->type == REGOP(TYPE_GLOBAL)) { /* search global list */ - valid = !!bsearch(&offset, + valid = g->ops.regops.get_global_whitelist_ranges && + !!bsearch(&offset, g->ops.regops.get_global_whitelist_ranges(), g->ops.regops.get_global_whitelist_ranges_count(), sizeof(*g->ops.regops.get_global_whitelist_ranges()), @@ -570,7 +571,8 @@ static bool check_whitelists(struct dbg_session_gk20a *dbg_s, /* if debug session and channel is bound search context list */ if ((!valid) && (!dbg_s->is_profiler && dbg_s->ch)) { /* binary search context list */ - valid = !!bsearch(&offset, + valid = g->ops.regops.get_context_whitelist_ranges && + !!bsearch(&offset, g->ops.regops.get_context_whitelist_ranges(), g->ops.regops.get_context_whitelist_ranges_count(), sizeof(*g->ops.regops.get_context_whitelist_ranges()), @@ -579,7 +581,8 @@ static bool check_whitelists(struct dbg_session_gk20a *dbg_s, /* if debug session and channel is bound search runcontrol list */ if ((!valid) && (!dbg_s->is_profiler && dbg_s->ch)) { - valid = linear_search(offset, + valid = g->ops.regops.get_runcontrol_whitelist && + linear_search(offset, g->ops.regops.get_runcontrol_whitelist(), g->ops.regops.get_runcontrol_whitelist_count()); } @@ -592,7 +595,8 @@ static bool check_whitelists(struct dbg_session_gk20a *dbg_s, } /* binary search context list */ - valid = !!bsearch(&offset, + valid = g->ops.regops.get_context_whitelist_ranges && + !!bsearch(&offset, g->ops.regops.get_context_whitelist_ranges(), g->ops.regops.get_context_whitelist_ranges_count(), sizeof(*g->ops.regops.get_context_whitelist_ranges()), @@ -600,13 +604,15 @@ static bool check_whitelists(struct dbg_session_gk20a *dbg_s, /* if debug session and channel is bound search runcontrol list */ if ((!valid) && (!dbg_s->is_profiler && dbg_s->ch)) { - valid = linear_search(offset, + valid = g->ops.regops.get_runcontrol_whitelist && + linear_search(offset, g->ops.regops.get_runcontrol_whitelist(), g->ops.regops.get_runcontrol_whitelist_count()); } } else if (op->type == REGOP(TYPE_GR_CTX_QUAD)) { - valid = linear_search(offset, + valid = g->ops.regops.get_qctl_whitelist && + linear_search(offset, g->ops.regops.get_qctl_whitelist(), g->ops.regops.get_qctl_whitelist_count()); } -- cgit v1.2.2