From 7a4cb4a6ab6c861a94e9105360967894df749f03 Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Wed, 15 Nov 2017 14:35:43 -0800 Subject: gpu: nvgpu: gv11b: gfxp wfi timeout For gv11b, configured gfx preemption wfi timeout in usec. Set timeout unit as usec in gr_gv11b_init_preemption_state. Used default timeout as 1msec and this timeout value can be modified through sysfs node: /sys/devices/gpu.0/gfxp_wfi_timeout_count For gp10b: gfxp_wfi_timeout_count is in syclk cycles For gv11b: gfxp_wfi_timeout_count is in usec Bug 2003668 Change-Id: I68d52ce996a83df90b8b3a8164debb07e5cb370f Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master.nvidia.com/r/1599658 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/sysfs.c | 6 ++-- .../nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c | 4 +++ .../nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c | 4 +++ drivers/gpu/nvgpu/gk20a/gk20a.h | 4 ++- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 4 +-- drivers/gpu/nvgpu/gp10b/gr_gp10b.c | 15 ++++++++++ drivers/gpu/nvgpu/gp10b/gr_gp10b.h | 2 ++ drivers/gpu/nvgpu/gp10b/hal_gp10b.c | 4 +++ drivers/gpu/nvgpu/gv11b/gr_gv11b.c | 34 ++++++++++++++++++++++ drivers/gpu/nvgpu/gv11b/gr_gv11b.h | 3 ++ drivers/gpu/nvgpu/gv11b/hal_gv11b.c | 6 +++- .../gpu/nvgpu/include/nvgpu/hw/gv11b/hw_gr_gv11b.h | 20 +++++++++++++ 12 files changed, 100 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c index b1e7d1ed..053c1a12 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c @@ -965,8 +965,10 @@ static ssize_t gfxp_wfi_timeout_count_store(struct device *dev, if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; - if (val >= 100*1000*1000) /* 100ms @ 1Ghz */ - return -EINVAL; + if (g->ops.gr.get_max_gfxp_wfi_timeout_count) { + if (val >= g->ops.gr.get_max_gfxp_wfi_timeout_count(g)) + return -EINVAL; + } gr->gfxp_wfi_timeout_count = val; diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c index b35cac90..acd0ad5d 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gp10b/vgpu_hal_gp10b.c @@ -209,6 +209,10 @@ static const struct gpu_ops vgpu_gp10b_ops = { .set_ctxsw_preemption_mode = vgpu_gr_gp10b_set_ctxsw_preemption_mode, .init_ctxsw_hdr_data = gr_gp10b_init_ctxsw_hdr_data, + .init_gfxp_wfi_timeout_count = + gr_gp10b_init_gfxp_wfi_timeout_count, + .get_max_gfxp_wfi_timeout_count = + gr_gp10b_get_max_gfxp_wfi_timeout_count, }, .fb = { .reset = fb_gk20a_reset, diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c b/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c index a7491b20..a470377c 100644 --- a/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c +++ b/drivers/gpu/nvgpu/common/linux/vgpu/gv11b/vgpu_hal_gv11b.c @@ -248,6 +248,10 @@ static const struct gpu_ops vgpu_gv11b_ops = { gr_gv11b_handle_tpc_sm_ecc_exception, .decode_egpc_addr = gv11b_gr_decode_egpc_addr, .init_ctxsw_hdr_data = gr_gp10b_init_ctxsw_hdr_data, + .init_gfxp_wfi_timeout_count = + gr_gv11b_init_gfxp_wfi_timeout_count, + .get_max_gfxp_wfi_timeout_count = + gr_gv11b_get_max_gfxp_wfi_timeout_count, }, .fb = { .reset = gv11b_fb_reset, diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 8f3900a1..a361648f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -433,7 +433,9 @@ struct gpu_ops { void (*disable_rd_coalesce)(struct gk20a *g); void (*init_ctxsw_hdr_data)(struct gk20a *g, struct nvgpu_mem *mem); - + void (*init_gfxp_wfi_timeout_count)(struct gk20a *g); + unsigned long (*get_max_gfxp_wfi_timeout_count) + (struct gk20a *g); } gr; struct { void (*init_hw)(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index 64b54699..73b49927 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -79,7 +79,6 @@ #define CTXSW_MEM_SCRUBBING_TIMEOUT_DEFAULT 10 #define FECS_ARB_CMD_TIMEOUT_MAX 40 #define FECS_ARB_CMD_TIMEOUT_DEFAULT 2 -#define GFXP_WFI_TIMEOUT_COUNT_DEFAULT 100000 static int gk20a_init_gr_bind_fecs_elpg(struct gk20a *g); @@ -4840,7 +4839,8 @@ static int gk20a_init_gr_setup_sw(struct gk20a *g) if (g->ops.gr.init_czf_bypass) g->ops.gr.init_czf_bypass(g); - gr->gfxp_wfi_timeout_count = GFXP_WFI_TIMEOUT_COUNT_DEFAULT; + if (g->ops.gr.init_gfxp_wfi_timeout_count) + g->ops.gr.init_gfxp_wfi_timeout_count(g); nvgpu_mutex_init(&gr->ctx_mutex); nvgpu_spinlock_init(&gr->ch_tlb_lock); diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c index 27a42a45..c232c4ab 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c @@ -46,6 +46,8 @@ #include #include +#define GFXP_WFI_TIMEOUT_COUNT_DEFAULT 100000 + bool gr_gp10b_is_valid_class(struct gk20a *g, u32 class_num) { bool valid = false; @@ -2351,3 +2353,16 @@ void gr_gp10b_init_ctxsw_hdr_data(struct gk20a *g, struct nvgpu_mem *mem) nvgpu_mem_wr(g, mem, ctxsw_prog_main_image_num_cilp_save_ops_o(), 0); } + +void gr_gp10b_init_gfxp_wfi_timeout_count(struct gk20a *g) +{ + struct gr_gk20a *gr = &g->gr; + + gr->gfxp_wfi_timeout_count = GFXP_WFI_TIMEOUT_COUNT_DEFAULT; +} + +unsigned long gr_gp10b_get_max_gfxp_wfi_timeout_count(struct gk20a *g) +{ + /* 100msec @ 1GHZ */ + return (100 * 1000 * 1000UL); +} diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h index 55117022..3b0f0f2e 100644 --- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h +++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h @@ -144,5 +144,7 @@ void gr_gp10b_set_preemption_buffer_va(struct gk20a *g, int gr_gp10b_set_czf_bypass(struct gk20a *g, struct channel_gk20a *ch); void gr_gp10b_init_czf_bypass(struct gk20a *g); void gr_gp10b_init_ctxsw_hdr_data(struct gk20a *g, struct nvgpu_mem *mem); +void gr_gp10b_init_gfxp_wfi_timeout_count(struct gk20a *g); +unsigned long gr_gp10b_get_max_gfxp_wfi_timeout_count(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c index f13c2735..5ae6b638 100644 --- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c @@ -332,6 +332,10 @@ static const struct gpu_ops gp10b_ops = { .create_gr_sysfs = gr_gp10b_create_sysfs, .set_ctxsw_preemption_mode = gr_gp10b_set_ctxsw_preemption_mode, .init_ctxsw_hdr_data = gr_gp10b_init_ctxsw_hdr_data, + .init_gfxp_wfi_timeout_count = + gr_gp10b_init_gfxp_wfi_timeout_count, + .get_max_gfxp_wfi_timeout_count = + gr_gp10b_get_max_gfxp_wfi_timeout_count, }, .fb = { .reset = fb_gk20a_reset, diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c index f2397108..9d6d8d05 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.c @@ -54,6 +54,8 @@ #include #include +#define GFXP_WFI_TIMEOUT_COUNT_IN_USEC_DEFAULT 1000 + bool gr_gv11b_is_valid_class(struct gk20a *g, u32 class_num) { bool valid = false; @@ -3625,3 +3627,35 @@ void gr_gv11b_init_gpc_mmu(struct gk20a *g) gk20a_writel(g, gr_gpcs_pri_mmu_debug_rd_r(), gk20a_readl(g, fb_mmu_debug_rd_r())); } + +int gr_gv11b_init_preemption_state(struct gk20a *g) +{ + u32 debug_2; + struct gr_gk20a *gr = &g->gr; + + nvgpu_log_fn(g, " "); + + gk20a_writel(g, gr_fe_gfxp_wfi_timeout_r(), + gr_fe_gfxp_wfi_timeout_count_f( + gr->gfxp_wfi_timeout_count)); + + debug_2 = gk20a_readl(g, gr_debug_2_r()); + debug_2 = set_field(debug_2, + gr_debug_2_gfxp_wfi_timeout_unit_m(), + gr_debug_2_gfxp_wfi_timeout_unit_usec_f()); + gk20a_writel(g, gr_debug_2_r(), debug_2); + + return 0; +} +void gr_gv11b_init_gfxp_wfi_timeout_count(struct gk20a *g) +{ + struct gr_gk20a *gr = &g->gr; + + gr->gfxp_wfi_timeout_count = GFXP_WFI_TIMEOUT_COUNT_IN_USEC_DEFAULT; +} + +unsigned long gr_gv11b_get_max_gfxp_wfi_timeout_count(struct gk20a *g) +{ + /* 100 msec in usec count */ + return (100 * 1000UL); +} diff --git a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h index 1941f239..7c56f62d 100644 --- a/drivers/gpu/nvgpu/gv11b/gr_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/gr_gv11b.h @@ -213,5 +213,8 @@ void gv11b_gr_egpc_etpc_priv_addr_table(struct gk20a *g, u32 addr, u32 gpc, u32 broadcast_flags, u32 *priv_addr_table, u32 *t); u32 gv11b_gr_get_egpc_base(struct gk20a *g); void gr_gv11b_init_gpc_mmu(struct gk20a *g); +int gr_gv11b_init_preemption_state(struct gk20a *g); +void gr_gv11b_init_gfxp_wfi_timeout_count(struct gk20a *g); +unsigned long gr_gv11b_get_max_gfxp_wfi_timeout_count(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c index 5649d758..e6cf0e62 100644 --- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c @@ -361,7 +361,7 @@ static const struct gpu_ops gv11b_ops = { .set_czf_bypass = NULL, .pre_process_sm_exception = gr_gv11b_pre_process_sm_exception, .set_preemption_buffer_va = gr_gv11b_set_preemption_buffer_va, - .init_preemption_state = NULL, + .init_preemption_state = gr_gv11b_init_preemption_state, .update_boosted_ctx = gr_gp10b_update_boosted_ctx, .set_bes_crop_debug3 = gr_gp10b_set_bes_crop_debug3, .create_gr_sysfs = gr_gv11b_create_sysfs, @@ -388,6 +388,10 @@ static const struct gpu_ops gv11b_ops = { gr_gv11b_handle_tpc_sm_ecc_exception, .decode_egpc_addr = gv11b_gr_decode_egpc_addr, .init_ctxsw_hdr_data = gr_gp10b_init_ctxsw_hdr_data, + .init_gfxp_wfi_timeout_count = + gr_gv11b_init_gfxp_wfi_timeout_count, + .get_max_gfxp_wfi_timeout_count = + gr_gv11b_get_max_gfxp_wfi_timeout_count, }, .fb = { .reset = gv11b_fb_reset, diff --git a/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_gr_gv11b.h b/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_gr_gv11b.h index 692b7ba3..805d8b0e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_gr_gv11b.h +++ b/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_gr_gv11b.h @@ -4292,6 +4292,10 @@ static inline u32 gr_fe_gfxp_wfi_timeout_count_disabled_f(void) { return 0x0U; } +static inline u32 gr_fe_gfxp_wfi_timeout_count_init_f(void) +{ + return 0x800U; +} static inline u32 gr_gpcs_tpcs_sm_texio_control_r(void) { return 0x00419bd8U; @@ -4936,4 +4940,20 @@ static inline u32 gr_fecs_falcon_ecc_uncorrected_err_count_unique_total_v(u32 r) { return (r >> 16U) & 0xffffU; } +static inline u32 gr_debug_2_r(void) +{ + return 0x00400088U; +} +static inline u32 gr_debug_2_gfxp_wfi_timeout_unit_m(void) +{ + return 0x1U << 27U; +} +static inline u32 gr_debug_2_gfxp_wfi_timeout_unit_usec_f(void) +{ + return 0x0U; +} +static inline u32 gr_debug_2_gfxp_wfi_timeout_unit_sysclk_f(void) +{ + return 0x8000000U; +} #endif -- cgit v1.2.2