From 65513bc33d65c921cd556a72e4e9263565dca4bf Mon Sep 17 00:00:00 2001 From: seshendra Gadagottu Date: Tue, 12 Dec 2017 11:36:42 -0800 Subject: gpu: nvgpu: gv11b: update thermal settings For gv11b, update thermal settings as per hw POR: 1.Created gv11b specific HAL for init_therm_setup_hw 2.Update steps for gradual slowdown to 1x,1.5x,2x,4x,8x,16x,32x. 3.Modified gradual step duration cycles to 4. Bug 200365110 Change-Id: I93c28a3394857aacdf3d304103c9e7c25d4ad344 Signed-off-by: seshendra Gadagottu Reviewed-on: https://git-master.nvidia.com/r/1616600 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gv11b/hal_gv11b.c | 2 +- drivers/gpu/nvgpu/gv11b/therm_gv11b.c | 62 ++++++++++++++++++++++ drivers/gpu/nvgpu/gv11b/therm_gv11b.h | 1 + .../nvgpu/include/nvgpu/hw/gv11b/hw_therm_gv11b.h | 20 +++++++ 4 files changed, 84 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c index 65cae8de..193f6e83 100644 --- a/drivers/gpu/nvgpu/gv11b/hal_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/hal_gv11b.c @@ -586,7 +586,7 @@ static const struct gpu_ops gv11b_ops = { .fault_info_mem_destroy = gv11b_mm_fault_info_mem_destroy, }, .therm = { - .init_therm_setup_hw = gp10b_init_therm_setup_hw, + .init_therm_setup_hw = gv11b_init_therm_setup_hw, .elcg_init_idle_filters = gv11b_elcg_init_idle_filters, }, .pmu = { diff --git a/drivers/gpu/nvgpu/gv11b/therm_gv11b.c b/drivers/gpu/nvgpu/gv11b/therm_gv11b.c index 18987119..f2d929fa 100644 --- a/drivers/gpu/nvgpu/gv11b/therm_gv11b.c +++ b/drivers/gpu/nvgpu/gv11b/therm_gv11b.c @@ -28,6 +28,68 @@ #include +int gv11b_init_therm_setup_hw(struct gk20a *g) +{ + u32 v; + + gk20a_dbg_fn(""); + + /* program NV_THERM registers */ + gk20a_writel(g, therm_use_a_r(), therm_use_a_ext_therm_0_enable_f() | + therm_use_a_ext_therm_1_enable_f() | + therm_use_a_ext_therm_2_enable_f()); + gk20a_writel(g, therm_evt_ext_therm_0_r(), + therm_evt_ext_therm_0_slow_factor_f(0x2)); + gk20a_writel(g, therm_evt_ext_therm_1_r(), + therm_evt_ext_therm_1_slow_factor_f(0x6)); + gk20a_writel(g, therm_evt_ext_therm_2_r(), + therm_evt_ext_therm_2_slow_factor_f(0xe)); + + gk20a_writel(g, therm_grad_stepping_table_r(0), + therm_grad_stepping_table_slowdown_factor0_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by1_f()) | + therm_grad_stepping_table_slowdown_factor1_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f()) | + therm_grad_stepping_table_slowdown_factor2_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by2_f()) | + therm_grad_stepping_table_slowdown_factor3_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by4_f()) | + therm_grad_stepping_table_slowdown_factor4_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f())); + + gk20a_writel(g, therm_grad_stepping_table_r(1), + therm_grad_stepping_table_slowdown_factor0_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by16_f()) | + therm_grad_stepping_table_slowdown_factor1_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by32_f()) | + therm_grad_stepping_table_slowdown_factor2_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by32_f()) | + therm_grad_stepping_table_slowdown_factor3_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by32_f()) | + therm_grad_stepping_table_slowdown_factor4_f( + therm_grad_stepping_table_slowdown_factor0_fpdiv_by32_f())); + + v = gk20a_readl(g, therm_clk_timing_r(0)); + v |= therm_clk_timing_grad_slowdown_enabled_f(); + gk20a_writel(g, therm_clk_timing_r(0), v); + + v = gk20a_readl(g, therm_config2_r()); + v |= therm_config2_grad_enable_f(1); + v |= therm_config2_slowdown_factor_extended_f(1); + v = set_field(v, therm_config2_grad_step_duration_m(), + therm_config2_grad_step_duration_f(0)); + gk20a_writel(g, therm_config2_r(), v); + + gk20a_writel(g, therm_grad_stepping1_r(), + therm_grad_stepping1_pdiv_duration_f(0x40)); + + v = gk20a_readl(g, therm_grad_stepping0_r()); + v |= therm_grad_stepping0_feature_enable_f(); + gk20a_writel(g, therm_grad_stepping0_r(), v); + + return 0; +} + int gv11b_elcg_init_idle_filters(struct gk20a *g) { u32 gate_ctrl, idle_filter; diff --git a/drivers/gpu/nvgpu/gv11b/therm_gv11b.h b/drivers/gpu/nvgpu/gv11b/therm_gv11b.h index 1d89597b..bfe6231e 100644 --- a/drivers/gpu/nvgpu/gv11b/therm_gv11b.h +++ b/drivers/gpu/nvgpu/gv11b/therm_gv11b.h @@ -24,5 +24,6 @@ struct gk20a; int gv11b_elcg_init_idle_filters(struct gk20a *g); +int gv11b_init_therm_setup_hw(struct gk20a *g); #endif /* THERM_GV11B_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_therm_gv11b.h b/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_therm_gv11b.h index 8f8981e8..3afe7501 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_therm_gv11b.h +++ b/drivers/gpu/nvgpu/include/nvgpu/hw/gv11b/hw_therm_gv11b.h @@ -180,6 +180,14 @@ static inline u32 therm_config2_r(void) { return 0x00020130U; } +static inline u32 therm_config2_grad_step_duration_f(u32 v) +{ + return (v & 0xfU) << 8U; +} +static inline u32 therm_config2_grad_step_duration_m(void) +{ + return 0xfU << 8U; +} static inline u32 therm_config2_slowdown_factor_extended_f(u32 v) { return (v & 0x1U) << 24U; @@ -336,6 +344,10 @@ static inline u32 therm_grad_stepping_table_slowdown_factor0_m(void) { return 0x3fU << 0U; } +static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by1_f(void) +{ + return 0x0U; +} static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f(void) { return 0x1U; @@ -352,6 +364,14 @@ static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f(void) { return 0xeU; } +static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by16_f(void) +{ + return 0x1eU; +} +static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by32_f(void) +{ + return 0x3eU; +} static inline u32 therm_grad_stepping_table_slowdown_factor1_f(u32 v) { return (v & 0x3fU) << 6U; -- cgit v1.2.2