From 3197a918d5052c71ad854f6b22fdb35bfe7cebe2 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Thu, 10 Aug 2017 16:34:16 -0700 Subject: gpu: nvgpu: gv11b: add max_subctx_count to g->fifo.t19x - For better performance. It used to read register every time referencing max_subctx_count. - Avoid reading registers for vgpu. Jira VFND-3797 Change-Id: Id6e6b15a0d9a035795e8a9a2c6bb63524c5eb544 Signed-off-by: Richard Zhao Reviewed-on: https://git-master.nvidia.com/r/1537009 Reviewed-by: svccoveritychecker Reviewed-by: Seshendra Gadagottu GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c | 2 +- drivers/gpu/nvgpu/fifo_t19x.h | 1 + drivers/gpu/nvgpu/gv11b/fifo_gv11b.c | 7 ++++++- drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 2 +- drivers/gpu/nvgpu/gv11b/subctx_gv11b.c | 13 ++----------- drivers/gpu/nvgpu/gv11b/subctx_gv11b.h | 1 - 6 files changed, 11 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c index bf6088ab..b0b1f9c4 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg_t19x.c @@ -44,7 +44,7 @@ static int gv11b_tsg_ioctl_bind_channel_ex(struct gk20a *g, ch = gk20a_get_channel_from_file(arg->channel_fd); if (!ch) return -EINVAL; - if (arg->subcontext_id < gv11b_get_max_subctx_count(g)) + if (arg->subcontext_id < g->fifo.t19x.max_subctx_count) ch->t19x.subctx_id = arg->subcontext_id; else return -EINVAL; diff --git a/drivers/gpu/nvgpu/fifo_t19x.h b/drivers/gpu/nvgpu/fifo_t19x.h index 531c6f34..25d5f41d 100644 --- a/drivers/gpu/nvgpu/fifo_t19x.h +++ b/drivers/gpu/nvgpu/fifo_t19x.h @@ -16,6 +16,7 @@ struct fifo_t19x { void __iomem *usermode_regs; + u32 max_subctx_count; }; #endif diff --git a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c index e210d40d..bd769f75 100644 --- a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "fifo_gv11b.h" #include "subctx_gv11b.h" @@ -1717,16 +1718,20 @@ int gv11b_init_fifo_setup_hw(struct gk20a *g) struct fifo_gk20a *f = &g->fifo; f->t19x.usermode_regs = g->regs + usermode_cfg0_r(); + f->t19x.max_subctx_count = + gr_pri_fe_chip_def_info_max_veid_count_v( + gk20a_readl(g, gr_pri_fe_chip_def_info_r())); return 0; } static u32 gv11b_mmu_fault_id_to_gr_veid(struct gk20a *g, u32 gr_eng_fault_id, u32 mmu_fault_id) { + struct fifo_gk20a *f = &g->fifo; u32 num_subctx; u32 veid = FIFO_INVAL_VEID; - num_subctx = gv11b_get_max_subctx_count(g); + num_subctx = f->t19x.max_subctx_count; if (mmu_fault_id >= gr_eng_fault_id && mmu_fault_id < (gr_eng_fault_id + num_subctx)) diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c index 850315f7..b95152eb 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c @@ -2021,7 +2021,7 @@ static void gv11b_write_bundle_veid_state(struct gk20a *g, u32 index) u32 j; u32 num_subctx, err = 0; - num_subctx = gv11b_get_max_subctx_count(g); + num_subctx = g->fifo.t19x.max_subctx_count; for (j = 0; j < num_subctx; j++) { diff --git a/drivers/gpu/nvgpu/gv11b/subctx_gv11b.c b/drivers/gpu/nvgpu/gv11b/subctx_gv11b.c index 72a66530..4f64843c 100644 --- a/drivers/gpu/nvgpu/gv11b/subctx_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/subctx_gv11b.c @@ -26,7 +26,6 @@ #include #include -#include static void gv11b_init_subcontext_pdb(struct channel_gk20a *c, struct nvgpu_mem *inst_block); @@ -143,6 +142,7 @@ void gv11b_subctx_commit_pdb(struct channel_gk20a *c, struct nvgpu_mem *inst_block) { struct gk20a *g = c->g; + struct fifo_gk20a *f = &g->fifo; struct vm_gk20a *vm = c->vm; u32 lo, hi; u32 subctx_id = 0; @@ -164,19 +164,10 @@ void gv11b_subctx_commit_pdb(struct channel_gk20a *c, ram_in_sc_page_dir_base_lo_0_f(pdb_addr_lo); nvgpu_log(g, gpu_dbg_info, " pdb info lo %x hi %x", format_word, pdb_addr_hi); - for (subctx_id = 0; subctx_id < gv11b_get_max_subctx_count(g); - subctx_id++) { + for (subctx_id = 0; subctx_id < f->t19x.max_subctx_count; subctx_id++) { lo = ram_in_sc_page_dir_base_vol_0_w() + (4 * subctx_id); hi = ram_in_sc_page_dir_base_hi_0_w() + (4 * subctx_id); nvgpu_mem_wr32(g, inst_block, lo, format_word); nvgpu_mem_wr32(g, inst_block, hi, pdb_addr_hi); } } - - -u32 gv11b_get_max_subctx_count(struct gk20a *g) -{ - u32 data = gk20a_readl(g, gr_pri_fe_chip_def_info_r()); - - return gr_pri_fe_chip_def_info_max_veid_count_v(data); -} diff --git a/drivers/gpu/nvgpu/gv11b/subctx_gv11b.h b/drivers/gpu/nvgpu/gv11b/subctx_gv11b.h index 5e4e99f5..d199711d 100644 --- a/drivers/gpu/nvgpu/gv11b/subctx_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/subctx_gv11b.h @@ -25,5 +25,4 @@ void gv11b_free_subctx_header(struct channel_gk20a *c); int gv11b_update_subctx_header(struct channel_gk20a *c, u64 gpu_va); -u32 gv11b_get_max_subctx_count(struct gk20a *g); #endif /* __SUBCONTEXT_GV11B_H__ */ -- cgit v1.2.2