From 10d3259cdb3bbe49331f990f5e1466eb8af058f5 Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 9 Nov 2018 08:36:57 -0800 Subject: [PATCH] gpu: nvgpu: Remove thrm.h dependency from gk20a.h gk20a.h depends on definition of struct therm_pmupstate. Change that to a pointer and use forward declaration, and allocation and free functions. Fix a few build breaks by adding explicit includes where previously a header file had gotten included implicitly. JIRA NVGPU-596 Change-Id: I67010a979ed7f874070796dd834b9b3d1d9dad4c Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1946661 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/gk20a.h | 3 +- drivers/gpu/nvgpu/pstate/pstate.c | 38 +++++++++++++++---------- drivers/gpu/nvgpu/therm/thrm.c | 20 +++++++++++++ drivers/gpu/nvgpu/therm/thrm.h | 4 +++ drivers/gpu/nvgpu/therm/thrmchannel.c | 7 +++-- drivers/gpu/nvgpu/therm/thrmchannel.h | 3 ++ drivers/gpu/nvgpu/therm/thrmdev.c | 7 +++-- drivers/gpu/nvgpu/therm/thrmdev.h | 4 +++ drivers/gpu/nvgpu/therm/thrmpmu.c | 9 +++--- drivers/gpu/nvgpu/therm/thrmpmu.h | 2 ++ 10 files changed, 70 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h index 07743db43..6c8f6c5ca 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h @@ -80,7 +80,6 @@ struct set_fll_clk; #include "gk20a/fifo_gk20a.h" #include "gk20a/gr_gk20a.h" #include "pmgr/pmgr.h" -#include "therm/thrm.h" #ifdef CONFIG_DEBUG_FS struct railgate_stats { @@ -1496,7 +1495,7 @@ struct gk20a { struct clk_pmupstate *clk_pmu; struct perf_pmupstate *perf_pmu; struct pmgr_pmupstate pmgr_pmu; - struct therm_pmupstate therm_pmu; + struct therm_pmupstate *therm_pmu; struct nvgpu_sec2 sec2; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/nvgpu/pstate/pstate.c b/drivers/gpu/nvgpu/pstate/pstate.c index db2c68d17..53ff91983 100644 --- a/drivers/gpu/nvgpu/pstate/pstate.c +++ b/drivers/gpu/nvgpu/pstate/pstate.c @@ -36,6 +36,7 @@ static int pstate_sw_setup(struct gk20a *g); void gk20a_deinit_pstate_support(struct gk20a *g) { + therm_pmu_free_pmupstate(g); perf_pmu_free_pmupstate(g); clk_free_pmupstate(g); @@ -63,89 +64,96 @@ int gk20a_init_pstate_support(struct gk20a *g) goto err_clk_init_pmupstate; } - err = volt_rail_sw_setup(g); + err = therm_pmu_init_pmupstate(g); if (err != 0) { goto err_perf_pmu_init_pmupstate; } + err = volt_rail_sw_setup(g); + if (err != 0) { + goto err_therm_pmu_init_pmupstate; + } + err = volt_dev_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = volt_policy_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = clk_vin_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = clk_fll_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = therm_domain_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = vfe_var_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = vfe_equ_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = clk_domain_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = clk_vf_point_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = clk_prog_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } err = pstate_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } if(g->ops.clk.support_pmgr_domain) { err = pmgr_domain_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } } if (g->ops.clk.support_clk_freq_controller) { err = clk_freq_controller_sw_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } } if(g->ops.clk.support_lpwr_pg) { err = nvgpu_lpwr_pg_setup(g); if (err != 0) { - goto err_perf_pmu_init_pmupstate; + goto err_therm_pmu_init_pmupstate; } } return 0; +err_therm_pmu_init_pmupstate: + therm_pmu_free_pmupstate(g); err_perf_pmu_init_pmupstate: perf_pmu_free_pmupstate(g); err_clk_init_pmupstate: diff --git a/drivers/gpu/nvgpu/therm/thrm.c b/drivers/gpu/nvgpu/therm/thrm.c index bdcb28830..732235305 100644 --- a/drivers/gpu/nvgpu/therm/thrm.c +++ b/drivers/gpu/nvgpu/therm/thrm.c @@ -53,3 +53,23 @@ u32 therm_domain_pmu_setup(struct gk20a *g) { return therm_send_pmgr_tables_to_pmu(g); } + +int therm_pmu_init_pmupstate(struct gk20a *g) +{ + /* If already allocated, do not re-allocate */ + if (g->therm_pmu != NULL) { + return 0; + } + + g->therm_pmu = nvgpu_kzalloc(g, sizeof(*g->therm_pmu)); + if (g->therm_pmu == NULL) { + return -ENOMEM; + } + + return 0; +} + +void therm_pmu_free_pmupstate(struct gk20a *g) +{ + nvgpu_kfree(g, g->therm_pmu); +} diff --git a/drivers/gpu/nvgpu/therm/thrm.h b/drivers/gpu/nvgpu/therm/thrm.h index 0d6596633..d37112a18 100644 --- a/drivers/gpu/nvgpu/therm/thrm.h +++ b/drivers/gpu/nvgpu/therm/thrm.h @@ -27,6 +27,8 @@ #include "thrmdev.h" #include "thrmchannel.h" +struct gk20a; + struct therm_pmupstate { struct therm_devices therm_deviceobjs; struct therm_channels therm_channelobjs; @@ -34,5 +36,7 @@ struct therm_pmupstate { int therm_domain_sw_setup(struct gk20a *g); u32 therm_domain_pmu_setup(struct gk20a *g); +int therm_pmu_init_pmupstate(struct gk20a *g); +void therm_pmu_free_pmupstate(struct gk20a *g); #endif /* NVGPU_THERM_THRM_H */ diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.c b/drivers/gpu/nvgpu/therm/thrmchannel.c index 2c695a59c..99104333a 100644 --- a/drivers/gpu/nvgpu/therm/thrmchannel.c +++ b/drivers/gpu/nvgpu/therm/thrmchannel.c @@ -28,6 +28,7 @@ #include #include "thrmchannel.h" +#include "thrm.h" #include "gp106/bios_gp106.h" static int _therm_channel_pmudatainit_device(struct gk20a *g, @@ -222,7 +223,7 @@ int therm_channel_sw_setup(struct gk20a *g) /* Construct the Super Class and override the Interfaces */ status = boardobjgrpconstruct_e32(g, - &g->therm_pmu.therm_channelobjs.super); + &g->therm_pmu->therm_channelobjs.super); if (status != 0) { nvgpu_err(g, "error creating boardobjgrp for therm devices, status - 0x%x", @@ -230,8 +231,8 @@ int therm_channel_sw_setup(struct gk20a *g) goto done; } - pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super; - pthermchannelobjs = &(g->therm_pmu.therm_channelobjs); + pboardobjgrp = &g->therm_pmu->therm_channelobjs.super.super; + pthermchannelobjs = &(g->therm_pmu->therm_channelobjs); /* Override the Interfaces */ pboardobjgrp->pmudatainstget = _therm_channel_pmudata_instget; diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.h b/drivers/gpu/nvgpu/therm/thrmchannel.h index 7087dabe0..5d4811a5c 100644 --- a/drivers/gpu/nvgpu/therm/thrmchannel.h +++ b/drivers/gpu/nvgpu/therm/thrmchannel.h @@ -24,9 +24,12 @@ #ifndef NVGPU_THERM_THRMCHANNEL_H #define NVGPU_THERM_THRMCHANNEL_H +#include #include #include +struct gk20a; + struct therm_channel { struct boardobj super; s16 scaling; diff --git a/drivers/gpu/nvgpu/therm/thrmdev.c b/drivers/gpu/nvgpu/therm/thrmdev.c index 20ab639cb..0d26b438f 100644 --- a/drivers/gpu/nvgpu/therm/thrmdev.c +++ b/drivers/gpu/nvgpu/therm/thrmdev.c @@ -29,6 +29,7 @@ #include #include "thrmdev.h" +#include "thrm.h" #include "gp106/bios_gp106.h" static int _therm_device_pmudata_instget(struct gk20a *g, @@ -335,7 +336,7 @@ int therm_device_sw_setup(struct gk20a *g) /* Construct the Super Class and override the Interfaces */ status = boardobjgrpconstruct_e32(g, - &g->therm_pmu.therm_deviceobjs.super); + &g->therm_pmu->therm_deviceobjs.super); if (status != 0) { nvgpu_err(g, "error creating boardobjgrp for therm devices, status - 0x%x", @@ -343,8 +344,8 @@ int therm_device_sw_setup(struct gk20a *g) goto done; } - pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super; - pthermdeviceobjs = &(g->therm_pmu.therm_deviceobjs); + pboardobjgrp = &g->therm_pmu->therm_deviceobjs.super.super; + pthermdeviceobjs = &(g->therm_pmu->therm_deviceobjs); /* Override the Interfaces */ pboardobjgrp->pmudatainstget = _therm_device_pmudata_instget; diff --git a/drivers/gpu/nvgpu/therm/thrmdev.h b/drivers/gpu/nvgpu/therm/thrmdev.h index f05eeab96..0837087dc 100644 --- a/drivers/gpu/nvgpu/therm/thrmdev.h +++ b/drivers/gpu/nvgpu/therm/thrmdev.h @@ -24,8 +24,12 @@ #ifndef NVGPU_THERM_THRMDEV_H #define NVGPU_THERM_THRMDEV_H +#include #include #include +#include + +struct gk20a; struct therm_devices { struct boardobjgrp_e32 super; diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.c b/drivers/gpu/nvgpu/therm/thrmpmu.c index e51079aa5..573a000ee 100644 --- a/drivers/gpu/nvgpu/therm/thrmpmu.c +++ b/drivers/gpu/nvgpu/therm/thrmpmu.c @@ -24,6 +24,7 @@ #include #include "thrmpmu.h" +#include "thrm.h" #include struct therm_pmucmdhandler_params { @@ -56,8 +57,8 @@ int therm_send_pmgr_tables_to_pmu(struct gk20a *g) int status = 0; struct boardobjgrp *pboardobjgrp = NULL; - if (!BOARDOBJGRP_IS_EMPTY(&g->therm_pmu.therm_deviceobjs.super.super)) { - pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super; + if (!BOARDOBJGRP_IS_EMPTY(&g->therm_pmu->therm_deviceobjs.super.super)) { + pboardobjgrp = &g->therm_pmu->therm_deviceobjs.super.super; status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); if (status != 0) { nvgpu_err(g, @@ -68,8 +69,8 @@ int therm_send_pmgr_tables_to_pmu(struct gk20a *g) } if (!BOARDOBJGRP_IS_EMPTY( - &g->therm_pmu.therm_channelobjs.super.super)) { - pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super; + &g->therm_pmu->therm_channelobjs.super.super)) { + pboardobjgrp = &g->therm_pmu->therm_channelobjs.super.super; status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); if (status != 0) { nvgpu_err(g, diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.h b/drivers/gpu/nvgpu/therm/thrmpmu.h index 8081d8993..fdaffe998 100644 --- a/drivers/gpu/nvgpu/therm/thrmpmu.h +++ b/drivers/gpu/nvgpu/therm/thrmpmu.h @@ -24,6 +24,8 @@ #ifndef NVGPU_THERM_THRMPMU_H #define NVGPU_THERM_THRMPMU_H +struct gk20a; + int therm_send_pmgr_tables_to_pmu(struct gk20a *g); int therm_configure_therm_alert(struct gk20a *g);