From ffb1869144d9c37f4fbc40cdbc7cbba373148022 Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Wed, 6 Mar 2019 15:25:34 -0800 Subject: [PATCH] gpu: nvgpu: add nvgpu_pg_elpg_protected_call macro gr_gk20a_elpg_protected_call is renamed as nvgpu_pg_elpg_protected_call and resides in common/ power_features/pg.c JIRA NVGPU-2014 Change-Id: Id027d9a81ca93e0d47bbeeeb537d5fcd882f68d3 Signed-off-by: Seema Khowala Reviewed-on: https://git-master.nvidia.com/r/2034274 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- .../nvgpu/common/gr/fecs_trace/fecs_trace_gm20b.c | 13 ++++--------- .../nvgpu/common/gr/fecs_trace/fecs_trace_gp10b.c | 3 ++- drivers/gpu/nvgpu/common/gr/zbc/gr_zbc.c | 3 ++- drivers/gpu/nvgpu/common/mc/mc_gm20b.c | 3 ++- drivers/gpu/nvgpu/common/mc/mc_gp10b.c | 3 ++- drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c | 5 +++-- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 1 + drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 3 ++- drivers/gpu/nvgpu/gk20a/gr_gk20a.h | 15 --------------- drivers/gpu/nvgpu/gv11b/fifo_gv11b.c | 1 + .../gpu/nvgpu/include/nvgpu/power_features/pg.h | 14 ++++++++++++++ drivers/gpu/nvgpu/os/linux/debug.c | 3 ++- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 3 ++- drivers/gpu/nvgpu/os/linux/ioctl_dbg.c | 3 ++- drivers/gpu/nvgpu/os/linux/sysfs.c | 4 ++-- 15 files changed, 41 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gm20b.c b/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gm20b.c index 5482a6c36..295b3cd1d 100644 --- a/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gm20b.c +++ b/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gm20b.c @@ -23,12 +23,7 @@ #include #include #include -/* - * TODO: - * gr_gk20a.h is needed only for gr_gk20a_elpg_protected_call() - * remove this include when possible - */ -#include +#include #include "fecs_trace_gm20b.h" @@ -38,20 +33,20 @@ int gm20b_fecs_trace_get_read_index(struct gk20a *g) { - return gr_gk20a_elpg_protected_call(g, + return nvgpu_pg_elpg_protected_call(g, nvgpu_readl(g, gr_fecs_mailbox1_r())); } int gm20b_fecs_trace_get_write_index(struct gk20a *g) { - return gr_gk20a_elpg_protected_call(g, + return nvgpu_pg_elpg_protected_call(g, nvgpu_readl(g, gr_fecs_mailbox0_r())); } int gm20b_fecs_trace_set_read_index(struct gk20a *g, int index) { nvgpu_log(g, gpu_dbg_ctxsw, "set read=%d", index); - return gr_gk20a_elpg_protected_call(g, + return nvgpu_pg_elpg_protected_call(g, (nvgpu_writel(g, gr_fecs_mailbox1_r(), index), 0)); } diff --git a/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gp10b.c b/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gp10b.c index c54020d2b..805136cb3 100644 --- a/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gp10b.c +++ b/drivers/gpu/nvgpu/common/gr/fecs_trace/fecs_trace_gp10b.c @@ -22,6 +22,7 @@ #include #include +#include #include "gk20a/gr_gk20a.h" #include "fecs_trace_gp10b.h" @@ -44,7 +45,7 @@ int gp10b_fecs_trace_flush(struct gk20a *g) nvgpu_log(g, gpu_dbg_fn|gpu_dbg_ctxsw, " "); - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, gr_gk20a_submit_fecs_method_op(g, op, false)); if (err != 0) nvgpu_err(g, "write timestamp record failed"); diff --git a/drivers/gpu/nvgpu/common/gr/zbc/gr_zbc.c b/drivers/gpu/nvgpu/common/gr/zbc/gr_zbc.c index c9dce4940..a177700ec 100644 --- a/drivers/gpu/nvgpu/common/gr/zbc/gr_zbc.c +++ b/drivers/gpu/nvgpu/common/gr/zbc/gr_zbc.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gr_zbc.h" @@ -460,7 +461,7 @@ int nvgpu_gr_zbc_set_table(struct gk20a *g, struct nvgpu_gr_zbc *zbc, { nvgpu_log_fn(g, " "); - return gr_gk20a_elpg_protected_call(g, + return nvgpu_pg_elpg_protected_call(g, nvgpu_gr_zbc_add(g, zbc, zbc_val)); } diff --git a/drivers/gpu/nvgpu/common/mc/mc_gm20b.c b/drivers/gpu/nvgpu/common/mc/mc_gm20b.c index 7c1df455a..aa213d777 100644 --- a/drivers/gpu/nvgpu/common/mc/mc_gm20b.c +++ b/drivers/gpu/nvgpu/common/mc/mc_gm20b.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "mc_gm20b.h" @@ -53,7 +54,7 @@ void gm20b_mc_isr_stall(struct gk20a *g) engine_enum = g->fifo.engine_info[active_engine_id].engine_enum; /* GR Engine */ if (engine_enum == NVGPU_ENGINE_GR_GK20A) { - gr_gk20a_elpg_protected_call(g, gk20a_gr_isr(g)); + nvgpu_pg_elpg_protected_call(g, gk20a_gr_isr(g)); } /* CE Engine */ diff --git a/drivers/gpu/nvgpu/common/mc/mc_gp10b.c b/drivers/gpu/nvgpu/common/mc/mc_gp10b.c index 983fcc014..6a173e7bc 100644 --- a/drivers/gpu/nvgpu/common/mc/mc_gp10b.c +++ b/drivers/gpu/nvgpu/common/mc/mc_gp10b.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "mc_gp10b.h" @@ -109,7 +110,7 @@ void mc_gp10b_isr_stall(struct gk20a *g) engine_enum = g->fifo.engine_info[active_engine_id].engine_enum; /* GR Engine */ if (engine_enum == NVGPU_ENGINE_GR_GK20A) { - gr_gk20a_elpg_protected_call(g, gk20a_gr_isr(g)); + nvgpu_pg_elpg_protected_call(g, gk20a_gr_isr(g)); } /* CE Engine */ diff --git a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c index fe051359d..a40680c1b 100644 --- a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -269,7 +270,7 @@ int vgpu_gr_alloc_obj_ctx(struct channel_gk20a *c, u32 class_num, u32 flags) } /* load golden image */ - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, vgpu_gr_load_golden_ctx_image(g, c->virt_ctx)); if (err) { nvgpu_err(g, "fail to load golden ctx image"); @@ -284,7 +285,7 @@ int vgpu_gr_alloc_obj_ctx(struct channel_gk20a *c, u32 class_num, u32 flags) } #ifdef CONFIG_GK20A_CTXSW_TRACE /* for fecs bind channel */ - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, vgpu_gr_load_golden_ctx_image(g, c->virt_ctx)); if (err) { nvgpu_err(g, "fail to load golden ctx image"); diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index f8568fbea..05b53a018 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include "mm_gk20a.h" diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 589d36469..6e56db760 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -58,6 +58,7 @@ #include #include #include +#include #include "gr_gk20a.h" #include "gr_pri_gk20a.h" @@ -3920,7 +3921,7 @@ int gr_gk20a_handle_sm_exception(struct gk20a *g, u32 gpc, u32 tpc, u32 sm, nvgpu_log(g, gpu_dbg_intr | gpu_dbg_gpu_dbg, "sm hww global 0x%08x warp 0x%08x", global_esr, warp_esr); - gr_gk20a_elpg_protected_call(g, + nvgpu_pg_elpg_protected_call(g, g->ops.gr.record_sm_error_state(g, gpc, tpc, sm, fault_ch)); if (g->ops.gr.pre_process_sm_exception != NULL) { diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h index a2382cb6e..8f3ec479f 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h @@ -26,7 +26,6 @@ #include #include -#include #include "mm_gk20a.h" @@ -400,20 +399,6 @@ void gr_gk20a_init_cg_mode(struct gk20a *g, u32 cgmode, u32 mode_config); bool gk20a_gr_sm_debugger_attached(struct gk20a *g); u32 gk20a_gr_get_sm_no_lock_down_hww_global_esr_mask(struct gk20a *g); -#define gr_gk20a_elpg_protected_call(g, func) \ - ({ \ - int err = 0; \ - err = nvgpu_pg_elpg_disable(g);\ - if (err != 0) {\ - err = nvgpu_pg_elpg_enable(g);\ - }\ - if (err == 0) { \ - err = (func); \ - (void)nvgpu_pg_elpg_enable(g);\ - } \ - err; \ - }) - int gk20a_gr_suspend(struct gk20a *g); struct nvgpu_dbg_reg_op; diff --git a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c index cad6fef2c..c172e2e44 100644 --- a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include "gk20a/fifo_gk20a.h" diff --git a/drivers/gpu/nvgpu/include/nvgpu/power_features/pg.h b/drivers/gpu/nvgpu/include/nvgpu/power_features/pg.h index d73578071..7518949da 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/power_features/pg.h +++ b/drivers/gpu/nvgpu/include/nvgpu/power_features/pg.h @@ -28,6 +28,20 @@ struct gk20a; +#define nvgpu_pg_elpg_protected_call(g, func) \ + ({ \ + int err = 0; \ + err = nvgpu_pg_elpg_disable(g);\ + if (err != 0) {\ + err = nvgpu_pg_elpg_enable(g);\ + }\ + if (err == 0) { \ + err = (func); \ + (void)nvgpu_pg_elpg_enable(g);\ + } \ + err; \ + }) + int nvgpu_pg_elpg_disable(struct gk20a *g); int nvgpu_pg_elpg_enable(struct gk20a *g); bool nvgpu_pg_elpg_is_enabled(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/os/linux/debug.c b/drivers/gpu/nvgpu/os/linux/debug.c index 678ee6fc4..4ec657d6e 100644 --- a/drivers/gpu/nvgpu/os/linux/debug.c +++ b/drivers/gpu/nvgpu/os/linux/debug.c @@ -28,6 +28,7 @@ #include "platform_gk20a.h" #include +#include #include #include @@ -73,7 +74,7 @@ static int gk20a_gr_dump_regs(struct gk20a *g, struct gk20a_debug_output *o) { if (g->ops.gr.dump_gr_regs) - gr_gk20a_elpg_protected_call(g, g->ops.gr.dump_gr_regs(g, o)); + nvgpu_pg_elpg_protected_call(g, g->ops.gr.dump_gr_regs(g, o)); return 0; } diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 984b67023..4a04204c9 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "ioctl_ctrl.h" #include "ioctl_dbg.h" @@ -1819,7 +1820,7 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg break; case NVGPU_GPU_IOCTL_SET_SM_DEBUG_MODE: - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, nvgpu_gpu_ioctl_set_debug_mode(g, (struct nvgpu_gpu_sm_debug_mode_args *)buf)); break; diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c index 5dc92886c..fc0b39690 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_dbg.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -1469,7 +1470,7 @@ static int nvgpu_dbg_gpu_ioctl_clear_single_sm_error_state( return err; } - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, g->ops.gr.clear_sm_error_state(g, ch, sm_id)); gk20a_idle(g); diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index e8b0bd531..bcd7cbcbd 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -1061,7 +1061,7 @@ static ssize_t gfxp_wfi_timeout_count_store(struct device *dev, if (err) return err; - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, g->ops.gr.init_preemption_state(g)); gk20a_idle(g); @@ -1091,7 +1091,7 @@ static ssize_t gfxp_wfi_timeout_unit_store(struct device *dev, if (err) return err; - err = gr_gk20a_elpg_protected_call(g, + err = nvgpu_pg_elpg_protected_call(g, g->ops.gr.init_preemption_state(g)); gk20a_idle(g);