diff --git a/arch/nvgpu-hal-new.yaml b/arch/nvgpu-hal-new.yaml index 6ab1dbac7..7dd6a0ecc 100644 --- a/arch/nvgpu-hal-new.yaml +++ b/arch/nvgpu-hal-new.yaml @@ -316,8 +316,8 @@ therm: owner: Seshendra G sources: [ hal/therm/therm_gm20b.c, hal/therm/therm_gm20b.h, - hal/therm/therm_gp106.c, - hal/therm/therm_gp106.h, + hal/therm/therm_tu104.c, + hal/therm/therm_tu104.h, hal/therm/therm_gp10b.c, hal/therm/therm_gp10b.h, hal/therm/therm_gv11b.c, diff --git a/arch/nvgpu-linux.yaml b/arch/nvgpu-linux.yaml index c19dca68f..d6c6ae9f3 100644 --- a/arch/nvgpu-linux.yaml +++ b/arch/nvgpu-linux.yaml @@ -75,8 +75,8 @@ debug: os/linux/debug_pmu.h, os/linux/debug_sched.c, os/linux/debug_sched.h, - os/linux/debug_therm_gp106.c, - os/linux/debug_therm_gp106.h, + os/linux/debug_therm_tu104.c, + os/linux/debug_therm_tu104.h, os/linux/debug_xve.c, os/linux/debug_xve.h, os/linux/debug_s_param.c, diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index d19107411..c11c7a45b 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -254,7 +254,7 @@ nvgpu-y += \ hal/ce/ce_gv11b.o \ hal/therm/therm_gm20b.o \ hal/therm/therm_gp10b.o \ - hal/therm/therm_gp106.o \ + hal/therm/therm_tu104.o \ hal/therm/therm_gv11b.o \ hal/gr/falcon/gr_falcon_gm20b.o \ hal/gr/falcon/gr_falcon_gp10b.o \ @@ -425,7 +425,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \ os/linux/debug_allocator.o \ os/linux/debug_hal.o \ os/linux/debug_clk_gm20b.o \ - os/linux/debug_therm_gp106.o \ + os/linux/debug_therm_tu104.o \ os/linux/debug_bios.o \ os/linux/debug_ltc.o \ os/linux/debug_xve.o \ diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index b48307aee..42828bb88 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources @@ -411,7 +411,7 @@ srcs += \ common/pmu/pmu_mutex.c \ common/pmu/pmu_pstate.c \ common/clk_arb/clk_arb_gv100.c \ - hal/therm/therm_gp106.c \ + hal/therm/therm_tu104.c \ hal/pmu/pmu_gk20a.c \ hal/pmu/pmu_gm20b.c \ hal/pmu/pmu_gp10b.c \ diff --git a/drivers/gpu/nvgpu/hal/init/hal_tu104.c b/drivers/gpu/nvgpu/hal/init/hal_tu104.c index 0a158e84a..f264cbff2 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_tu104.c +++ b/drivers/gpu/nvgpu/hal/init/hal_tu104.c @@ -49,7 +49,7 @@ #include "hal/cbc/cbc_gm20b.h" #include "hal/cbc/cbc_tu104.h" #include "hal/therm/therm_gm20b.h" -#include "hal/therm/therm_gp106.h" +#include "hal/therm/therm_tu104.h" #include "hal/therm/therm_gv11b.h" #include "hal/ltc/ltc_gm20b.h" #include "hal/ltc/ltc_gp10b.h" @@ -1090,9 +1090,9 @@ static const struct gpu_ops tu104_ops = { .elcg_init_idle_filters = NULL, #ifdef CONFIG_NVGPU_LS_PMU .get_internal_sensor_curr_temp = - gp106_get_internal_sensor_curr_temp, + tu104_get_internal_sensor_curr_temp, .get_internal_sensor_limits = - gp106_get_internal_sensor_limits, + tu104_get_internal_sensor_limits, #endif }, #ifdef CONFIG_NVGPU_LS_PMU diff --git a/drivers/gpu/nvgpu/hal/therm/therm_gp106.c b/drivers/gpu/nvgpu/hal/therm/therm_gp106.c deleted file mode 100644 index 140ab6b8b..000000000 --- a/drivers/gpu/nvgpu/hal/therm/therm_gp106.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include - -#include "therm_gp106.h" - -#include - -#include - -void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8) -{ - *max_24_8 = (0x87 << 8); - *min_24_8 = (((u32)-216) << 8); -} - -int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) -{ - int err = 0; - u32 readval; - - readval = nvgpu_readl(g, therm_temp_sensor_tsense_r()); - - if ((therm_temp_sensor_tsense_state_v(readval) & - therm_temp_sensor_tsense_state_valid_v()) == 0U) { - nvgpu_err(g, - "Attempt to read temperature while sensor is OFF!"); - err = -EINVAL; - } else if ((therm_temp_sensor_tsense_state_v(readval) & - therm_temp_sensor_tsense_state_shadow_v()) != 0U) { - nvgpu_err(g, "Reading temperature from SHADOWed sensor!"); - } else { - nvgpu_log_info(g, "Finished reading temperature"); - } - - // Convert from F9.5 -> F27.5 -> F24.8. - readval &= therm_temp_sensor_tsense_fixed_point_m(); - - *temp_f24_8 = readval; - - return err; -} - -int gp106_elcg_init_idle_filters(struct gk20a *g) -{ - u32 gate_ctrl, idle_filter; - u32 engine_id; - u32 active_engine_id = 0; - struct nvgpu_fifo *f = &g->fifo; - - nvgpu_log_fn(g, " "); - - for (engine_id = 0; engine_id < f->num_engines; engine_id++) { - active_engine_id = f->active_engines_list[engine_id]; - gate_ctrl = nvgpu_readl(g, therm_gate_ctrl_r(active_engine_id)); - - gate_ctrl = set_field(gate_ctrl, - therm_gate_ctrl_eng_idle_filt_exp_m(), - therm_gate_ctrl_eng_idle_filt_exp_f(2)); - gate_ctrl = set_field(gate_ctrl, - therm_gate_ctrl_eng_idle_filt_mant_m(), - therm_gate_ctrl_eng_idle_filt_mant_f(1)); - gate_ctrl = set_field(gate_ctrl, - therm_gate_ctrl_eng_delay_before_m(), - therm_gate_ctrl_eng_delay_before_f(0)); - nvgpu_writel(g, therm_gate_ctrl_r(active_engine_id), gate_ctrl); - } - - /* default fecs_idle_filter to 0 */ - idle_filter = nvgpu_readl(g, therm_fecs_idle_filter_r()); - idle_filter &= ~therm_fecs_idle_filter_value_m(); - nvgpu_writel(g, therm_fecs_idle_filter_r(), idle_filter); - /* default hubmmu_idle_filter to 0 */ - idle_filter = nvgpu_readl(g, therm_hubmmu_idle_filter_r()); - idle_filter &= ~therm_hubmmu_idle_filter_value_m(); - nvgpu_writel(g, therm_hubmmu_idle_filter_r(), idle_filter); - - nvgpu_log_fn(g, "done"); - return 0; -} - -int gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp) -{ - int err = 0; - - if (g->curr_warn_temp != curr_warn_temp) { - g->curr_warn_temp = curr_warn_temp; - err = nvgpu_therm_configure_therm_alert(g, g->pmu); - } - - return err; -} diff --git a/drivers/gpu/nvgpu/hal/therm/therm_tu104.c b/drivers/gpu/nvgpu/hal/therm/therm_tu104.c new file mode 100644 index 000000000..df1a2100a --- /dev/null +++ b/drivers/gpu/nvgpu/hal/therm/therm_tu104.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +#include "therm_tu104.h" + +#include + +#include + +void tu104_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8) +{ + *max_24_8 = (0x87 << 8); + *min_24_8 = (((u32)-216) << 8); +} + +int tu104_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) +{ + int err = 0; + u32 readval; + + readval = nvgpu_readl(g, therm_i2cs_sensor_00_r()); + + /* Convert from celsius to f24_8 format*/ + *temp_f24_8 = (readval << 8); + + return err; +} + diff --git a/drivers/gpu/nvgpu/hal/therm/therm_gp106.h b/drivers/gpu/nvgpu/hal/therm/therm_tu104.h similarity index 76% rename from drivers/gpu/nvgpu/hal/therm/therm_gp106.h rename to drivers/gpu/nvgpu/hal/therm/therm_tu104.h index 682954742..58ed5911a 100644 --- a/drivers/gpu/nvgpu/hal/therm/therm_gp106.h +++ b/drivers/gpu/nvgpu/hal/therm/therm_tu104.h @@ -1,7 +1,7 @@ /* * general thermal control structures & definitions * - * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,16 +22,14 @@ * DEALINGS IN THE SOFTWARE. */ -#ifndef NVGPU_THERM_GP106_H -#define NVGPU_THERM_GP106_H +#ifndef NVGPU_THERM_TU104_H +#define NVGPU_THERM_TU104_H #include struct gk20a; -void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8); -int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8); -int gp106_elcg_init_idle_filters(struct gk20a *g); -int gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp); +void tu104_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8); +int tu104_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8); #endif diff --git a/drivers/gpu/nvgpu/include/nvgpu/hw/gp106/hw_therm_gp106.h b/drivers/gpu/nvgpu/include/nvgpu/hw/gp106/hw_therm_gp106.h index 8d60566eb..5310c6a71 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/hw/gp106/hw_therm_gp106.h +++ b/drivers/gpu/nvgpu/include/nvgpu/hw/gp106/hw_therm_gp106.h @@ -59,50 +59,6 @@ #include #include -static inline u32 therm_temp_sensor_tsense_r(void) -{ - return 0x00020460U; -} -static inline u32 therm_temp_sensor_tsense_fixed_point_f(u32 v) -{ - return (v & 0x3fffU) << 3U; -} -static inline u32 therm_temp_sensor_tsense_fixed_point_m(void) -{ - return U32(0x3fffU) << 3U; -} -static inline u32 therm_temp_sensor_tsense_fixed_point_v(u32 r) -{ - return (r >> 3U) & 0x3fffU; -} -static inline u32 therm_temp_sensor_tsense_fixed_point_min_v(void) -{ - return 0x00003b00U; -} -static inline u32 therm_temp_sensor_tsense_fixed_point_max_v(void) -{ - return 0x000010e0U; -} -static inline u32 therm_temp_sensor_tsense_state_f(u32 v) -{ - return (v & 0x3U) << 29U; -} -static inline u32 therm_temp_sensor_tsense_state_m(void) -{ - return U32(0x3U) << 29U; -} -static inline u32 therm_temp_sensor_tsense_state_v(u32 r) -{ - return (r >> 29U) & 0x3U; -} -static inline u32 therm_temp_sensor_tsense_state_valid_v(void) -{ - return 0x00000001U; -} -static inline u32 therm_temp_sensor_tsense_state_shadow_v(void) -{ - return 0x00000002U; -} static inline u32 therm_gate_ctrl_r(u32 i) { return nvgpu_safe_add_u32(0x00020200U, nvgpu_safe_mult_u32(i, 4U)); diff --git a/drivers/gpu/nvgpu/include/nvgpu/hw/tu104/hw_therm_tu104.h b/drivers/gpu/nvgpu/include/nvgpu/hw/tu104/hw_therm_tu104.h index e2170b36c..3d624f5ff 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/hw/tu104/hw_therm_tu104.h +++ b/drivers/gpu/nvgpu/include/nvgpu/hw/tu104/hw_therm_tu104.h @@ -299,4 +299,8 @@ static inline u32 therm_clk_timing_grad_slowdown_enabled_f(void) { return 0x10000U; } +static inline u32 therm_i2cs_sensor_00_r(void) +{ + return 0x00020400U; +} #endif diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c b/drivers/gpu/nvgpu/os/linux/debug_therm_tu104.c similarity index 92% rename from drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c rename to drivers/gpu/nvgpu/os/linux/debug_therm_tu104.c index dfe39461f..9f178cb80 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c +++ b/drivers/gpu/nvgpu/os/linux/debug_therm_tu104.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2019, NVIDIA Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -35,7 +35,7 @@ static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) } DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n"); -int gp106_therm_init_debugfs(struct gk20a *g) +int tu104_therm_init_debugfs(struct gk20a *g) { struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); struct dentry *dbgentry; diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h b/drivers/gpu/nvgpu/os/linux/debug_therm_tu104.h similarity index 88% rename from drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h rename to drivers/gpu/nvgpu/os/linux/debug_therm_tu104.h index 3e9380dfd..e994a7b43 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h +++ b/drivers/gpu/nvgpu/os/linux/debug_therm_tu104.h @@ -18,9 +18,9 @@ #define __DEBUG_THERM_GP106_H #ifdef CONFIG_DEBUG_FS -int gp106_therm_init_debugfs(struct gk20a *g); +int tu104_therm_init_debugfs(struct gk20a *g); #else -static inline int gp106_therm_init_debugfs(struct gk20a *g) +static inline int tu104_therm_init_debugfs(struct gk20a *g) { return 0; } diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c index 9d92bdfb4..733f3a1ae 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c @@ -17,7 +17,7 @@ #include "os_linux.h" #include "debug_clk_gv100.h" -#include "debug_therm_gp106.h" +#include "debug_therm_tu104.h" #include "debug_fecs_trace.h" static struct nvgpu_os_linux_ops gv100_os_linux_ops = { @@ -25,7 +25,7 @@ static struct nvgpu_os_linux_ops gv100_os_linux_ops = { .init_debugfs = gv100_clk_init_debugfs, }, .therm = { - .init_debugfs = gp106_therm_init_debugfs, + .init_debugfs = tu104_therm_init_debugfs, }, .fecs_trace = { .init_debugfs = nvgpu_fecs_trace_init_debugfs, diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_tu104.c b/drivers/gpu/nvgpu/os/linux/os_ops_tu104.c index 6b70b738a..15b091f5e 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops_tu104.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops_tu104.c @@ -16,14 +16,14 @@ #include "os/linux/os_linux.h" -#include "os/linux/debug_therm_gp106.h" +#include "os/linux/debug_therm_tu104.h" #include "os/linux/debug_clk_gv100.h" #include "os/linux/debug_volt.h" #include "os/linux/debug_s_param.h" static struct nvgpu_os_linux_ops tu104_os_linux_ops = { .therm = { - .init_debugfs = gp106_therm_init_debugfs, + .init_debugfs = tu104_therm_init_debugfs, }, .clk = { .init_debugfs = gv100_clk_init_debugfs,