From f391f53c089ec12fcc501c491430380b668e3cbf Mon Sep 17 00:00:00 2001 From: Sunny He Date: Wed, 26 Jul 2017 18:08:00 -0700 Subject: gpu: nvgpu: Reorg therm HAL initialization Reorganize HAL initialization to remove inheritance and construct the gpu_ops struct at compile time. This patch only covers the therm sub-module of the gpu_ops struct. Perform HAL function assignments in hal_gxxxx.c through the population of a chip-specific copy of gpu_ops. Jira NVGPU-74 Change-Id: Ic9d03304d3dcde0365cbf22af2dbe1e7eb0e04bb Signed-off-by: Sunny He Reviewed-on: https://git-master.nvidia.com/r/1527422 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gm20b/hal_gm20b.c | 7 ++++++- drivers/gpu/nvgpu/gm20b/therm_gm20b.c | 10 ++-------- drivers/gpu/nvgpu/gm20b/therm_gm20b.h | 6 +++--- drivers/gpu/nvgpu/gp106/hal_gp106.c | 12 +++++++++++- drivers/gpu/nvgpu/gp106/therm_gp106.c | 24 ++++++++---------------- drivers/gpu/nvgpu/gp106/therm_gp106.h | 13 ++++++++++--- drivers/gpu/nvgpu/gp10b/hal_gp10b.c | 6 +++++- drivers/gpu/nvgpu/gp10b/therm_gp10b.c | 4 ++-- drivers/gpu/nvgpu/gp10b/therm_gp10b.h | 7 ++++--- 9 files changed, 51 insertions(+), 38 deletions(-) (limited to 'drivers') diff --git a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c index 1a11b11c..407a442a 100644 --- a/drivers/gpu/nvgpu/gm20b/hal_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/hal_gm20b.c @@ -17,6 +17,7 @@ #include "gk20a/ce2_gk20a.h" #include "gk20a/dbg_gpu_gk20a.h" #include "gk20a/fifo_gk20a.h" +#include "gk20a/therm_gk20a.h" #include "gk20a/css_gr_gk20a.h" #include "gk20a/mc_gk20a.h" #include "gk20a/bus_gk20a.h" @@ -272,6 +273,10 @@ static const struct gpu_ops gm20b_ops = { .get_netlist_name = gr_gm20b_get_netlist_name, .is_fw_defined = gr_gm20b_is_firmware_defined, }, + .therm = { + .init_therm_setup_hw = gm20b_init_therm_setup_hw, + .elcg_init_idle_filters = gk20a_elcg_init_idle_filters, + }, .mc = { .intr_enable = mc_gk20a_intr_enable, .intr_unit_config = mc_gk20a_intr_unit_config, @@ -344,6 +349,7 @@ int gm20b_init_hal(struct gk20a *g) gops->clock_gating = gm20b_ops.clock_gating; gops->fifo = gm20b_ops.fifo; gops->gr_ctx = gm20b_ops.gr_ctx; + gops->therm = gm20b_ops.therm; gops->mc = gm20b_ops.mc; gops->dbg_session_ops = gm20b_ops.dbg_session_ops; gops->debug = gm20b_ops.debug; @@ -399,7 +405,6 @@ int gm20b_init_hal(struct gk20a *g) gm20b_init_pmu_ops(g); gm20b_init_clk_ops(gops); gm20b_init_regops(gops); - gm20b_init_therm_ops(gops); g->name = "gm20b"; diff --git a/drivers/gpu/nvgpu/gm20b/therm_gm20b.c b/drivers/gpu/nvgpu/gm20b/therm_gm20b.c index 84c1a071..a999151f 100644 --- a/drivers/gpu/nvgpu/gm20b/therm_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/therm_gm20b.c @@ -1,7 +1,7 @@ /* * GM20B THERMAL * - * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2017, 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, @@ -19,7 +19,7 @@ #include -static int gm20b_init_therm_setup_hw(struct gk20a *g) +int gm20b_init_therm_setup_hw(struct gk20a *g) { u32 v; @@ -67,9 +67,3 @@ static int gm20b_init_therm_setup_hw(struct gk20a *g) return 0; } - -void gm20b_init_therm_ops(struct gpu_ops *gops) -{ - gops->therm.init_therm_setup_hw = gm20b_init_therm_setup_hw; - gops->therm.elcg_init_idle_filters = gk20a_elcg_init_idle_filters; -} diff --git a/drivers/gpu/nvgpu/gm20b/therm_gm20b.h b/drivers/gpu/nvgpu/gm20b/therm_gm20b.h index c346c4f2..65147a64 100644 --- a/drivers/gpu/nvgpu/gm20b/therm_gm20b.h +++ b/drivers/gpu/nvgpu/gm20b/therm_gm20b.h @@ -1,7 +1,7 @@ /* * GM20B THERMAL * - * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2017, 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, @@ -15,7 +15,7 @@ #ifndef THERM_GM20B_H #define THERM_GM20B_H -struct gpu_ops; -void gm20b_init_therm_ops(struct gpu_ops *gops); +struct gk20a; +int gm20b_init_therm_setup_hw(struct gk20a *g); #endif /* THERM_GM20B_H */ diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index f9368621..8077c5e1 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c @@ -343,6 +343,16 @@ static const struct gpu_ops gp106_ops = { .exit = gk20a_pramin_exit, .data032_r = pram_data032_r, }, + .therm = { +#ifdef CONFIG_DEBUG_FS + .therm_debugfs_init = gp106_therm_debugfs_init, +#endif /* CONFIG_DEBUG_FS */ + .elcg_init_idle_filters = gp106_elcg_init_idle_filters, + .get_internal_sensor_curr_temp = + gp106_get_internal_sensor_curr_temp, + .get_internal_sensor_limits = gp106_get_internal_sensor_limits, + .configure_therm_alert = gp106_configure_therm_alert, + }, .mc = { .intr_enable = mc_gp10b_intr_enable, .intr_unit_config = mc_gp10b_intr_unit_config, @@ -436,6 +446,7 @@ int gp106_init_hal(struct gk20a *g) gops->gr_ctx = gp106_ops.gr_ctx; gops->fecs_trace = gp106_ops.fecs_trace; gops->pramin = gp106_ops.pramin; + gops->therm = gp106_ops.therm; gops->mc = gp106_ops.mc; gops->debug = gp106_ops.debug; gops->dbg_session_ops = gp106_ops.dbg_session_ops; @@ -467,7 +478,6 @@ int gp106_init_hal(struct gk20a *g) gp106_init_clk_ops(gops); gp106_init_clk_arb_ops(gops); gp106_init_regops(gops); - gp106_init_therm_ops(gops); g->name = "gp10x"; diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c index dacebe93..4be8e6cd 100644 --- a/drivers/gpu/nvgpu/gp106/therm_gp106.c +++ b/drivers/gpu/nvgpu/gp106/therm_gp106.c @@ -11,6 +11,8 @@ * more details. */ +#include "gk20a/gk20a.h" + #include "therm_gp106.h" #include "therm/thrmpmu.h" @@ -22,13 +24,13 @@ #include -static void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8) +void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8) { *max_24_8 = (0x87 << 8); *min_24_8 = ((-216) << 8); } -static int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) +int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) { int err = 0; u32 readval; @@ -68,7 +70,8 @@ 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"); -static void gp106_therm_debugfs_init(struct gk20a *g) { +void gp106_therm_debugfs_init(struct gk20a *g) +{ struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); struct dentry *dbgentry; @@ -79,7 +82,7 @@ static void gp106_therm_debugfs_init(struct gk20a *g) { } #endif -static int gp106_elcg_init_idle_filters(struct gk20a *g) +int gp106_elcg_init_idle_filters(struct gk20a *g) { u32 gate_ctrl, idle_filter; u32 engine_id; @@ -117,7 +120,7 @@ static int gp106_elcg_init_idle_filters(struct gk20a *g) return 0; } -static u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp) +u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp) { u32 err = 0; @@ -128,14 +131,3 @@ static u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp) return err; } - -void gp106_init_therm_ops(struct gpu_ops *gops) { -#ifdef CONFIG_DEBUG_FS - gops->therm.therm_debugfs_init = gp106_therm_debugfs_init; -#endif - gops->therm.elcg_init_idle_filters = gp106_elcg_init_idle_filters; - gops->therm.get_internal_sensor_curr_temp = gp106_get_internal_sensor_curr_temp; - gops->therm.get_internal_sensor_limits = - gp106_get_internal_sensor_limits; - gops->therm.configure_therm_alert = gp106_configure_therm_alert; -} diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.h b/drivers/gpu/nvgpu/gp106/therm_gp106.h index 6db17c47..2866320b 100644 --- a/drivers/gpu/nvgpu/gp106/therm_gp106.h +++ b/drivers/gpu/nvgpu/gp106/therm_gp106.h @@ -1,7 +1,7 @@ /* * general thermal control structures & definitions * - * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2017, 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, @@ -16,7 +16,14 @@ #ifndef NVGPU_THERM_GP106_H #define NVGPU_THERM_GP106_H -#include "gk20a/gk20a.h" +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); +#ifdef CONFIG_DEBUG_FS +void gp106_therm_debugfs_init(struct gk20a *g); +#endif +int gp106_elcg_init_idle_filters(struct gk20a *g); +u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp); -void gp106_init_therm_ops(struct gpu_ops *gops); #endif diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c index 3a44f1ef..a2aacd2e 100644 --- a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c @@ -309,6 +309,10 @@ static const struct gpu_ops gp10b_ops = { .exit = gk20a_pramin_exit, .data032_r = pram_data032_r, }, + .therm = { + .init_therm_setup_hw = gp10b_init_therm_setup_hw, + .elcg_init_idle_filters = gp10b_elcg_init_idle_filters, + }, .mc = { .intr_enable = mc_gp10b_intr_enable, .intr_unit_config = mc_gp10b_intr_unit_config, @@ -385,6 +389,7 @@ int gp10b_init_hal(struct gk20a *g) gops->gr_ctx = gp10b_ops.gr_ctx; gops->fecs_trace = gp10b_ops.fecs_trace; gops->pramin = gp10b_ops.pramin; + gops->therm = gp10b_ops.therm; gops->mc = gp10b_ops.mc; gops->debug = gp10b_ops.debug; gops->dbg_session_ops = gp10b_ops.dbg_session_ops; @@ -448,7 +453,6 @@ int gp10b_init_hal(struct gk20a *g) gp10b_init_mm(gops); gp10b_init_pmu_ops(g); gp10b_init_regops(gops); - gp10b_init_therm_ops(gops); g->name = "gp10b"; diff --git a/drivers/gpu/nvgpu/gp10b/therm_gp10b.c b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c index 925fc69b..43f44c92 100644 --- a/drivers/gpu/nvgpu/gp10b/therm_gp10b.c +++ b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c @@ -20,7 +20,7 @@ #include -static int gp10b_init_therm_setup_hw(struct gk20a *g) +int gp10b_init_therm_setup_hw(struct gk20a *g) { u32 v; @@ -80,7 +80,7 @@ static int gp10b_init_therm_setup_hw(struct gk20a *g) return 0; } -static int gp10b_elcg_init_idle_filters(struct gk20a *g) +int gp10b_elcg_init_idle_filters(struct gk20a *g) { u32 gate_ctrl, idle_filter; u32 engine_id; diff --git a/drivers/gpu/nvgpu/gp10b/therm_gp10b.h b/drivers/gpu/nvgpu/gp10b/therm_gp10b.h index 18c102fe..c9ed01e6 100644 --- a/drivers/gpu/nvgpu/gp10b/therm_gp10b.h +++ b/drivers/gpu/nvgpu/gp10b/therm_gp10b.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2015-2017, 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, @@ -13,7 +13,8 @@ #ifndef THERM_GP10B_H #define THERM_GP10B_H -struct gpu_ops; -void gp10b_init_therm_ops(struct gpu_ops *gops); +struct gk20a; +int gp10b_init_therm_setup_hw(struct gk20a *g); +int gp10b_elcg_init_idle_filters(struct gk20a *g); #endif /* THERM_GP10B_H */ -- cgit v1.2.2