summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-11-28 18:11:35 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-12-08 18:53:31 -0500
commitee0bc391e047bc11611323fb4d30d0be4389be6b (patch)
tree81d079c6fa53672e2125a5d357a2c74bfbd0533e
parentf3dcf5f534696dc6dbd63486469fbae7bdcae23f (diff)
gpu: nvgpu: pmgrpmu: Reduce stack usage
Allocate PMU PWRMGR structure from heap instead of stack. It is very big and can cause build errors on some compilers. Change-Id: I2727bb70d04b61c1ea43cfb7398b7b14b01e78ee Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1612646 GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgrpmu.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
index 6913c280..ed33c08c 100644
--- a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
+++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
@@ -180,12 +180,16 @@ static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g)
180 180
181static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g) 181static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g)
182{ 182{
183 struct nv_pmu_pmgr_pwr_device_desc_table pwr_desc_table; 183 struct nv_pmu_pmgr_pwr_device_desc_table *pwr_desc_table;
184 struct nv_pmu_pmgr_pwr_device_desc_table_header *ppwr_desc_header; 184 struct nv_pmu_pmgr_pwr_device_desc_table_header *ppwr_desc_header;
185 u32 status = 0; 185 u32 status = 0;
186 186
187 /* Set the BA-device-independent HW information */ 187 /* Set the BA-device-independent HW information */
188 ppwr_desc_header = &(pwr_desc_table.hdr.data); 188 pwr_desc_table = nvgpu_kzalloc(g, sizeof(*pwr_desc_table));
189 if (!pwr_desc_table)
190 return -ENOMEM;
191
192 ppwr_desc_header = &(pwr_desc_table->hdr.data);
189 ppwr_desc_header->ba_info.b_initialized_and_used = false; 193 ppwr_desc_header->ba_info.b_initialized_and_used = false;
190 194
191 /* populate the table */ 195 /* populate the table */
@@ -194,7 +198,7 @@ static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g)
194 198
195 status = boardobjgrp_pmudatainit_legacy(g, 199 status = boardobjgrp_pmudatainit_legacy(g,
196 &g->pmgr_pmu.pmgr_deviceobjs.super.super, 200 &g->pmgr_pmu.pmgr_deviceobjs.super.super,
197 (struct nv_pmu_boardobjgrp_super *)&pwr_desc_table); 201 (struct nv_pmu_boardobjgrp_super *)pwr_desc_table);
198 202
199 if (status) { 203 if (status) {
200 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x", 204 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x",
@@ -209,27 +213,32 @@ static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g)
209 (u16)sizeof( 213 (u16)sizeof(
210 union nv_pmu_pmgr_pwr_device_dmem_size), 214 union nv_pmu_pmgr_pwr_device_dmem_size),
211 (u16)sizeof(struct nv_pmu_pmgr_pwr_device_desc_table), 215 (u16)sizeof(struct nv_pmu_pmgr_pwr_device_desc_table),
212 &pwr_desc_table); 216 pwr_desc_table);
213 217
214 if (status) 218 if (status)
215 nvgpu_err(g, "pmgr_pmu_set_object failed %x", 219 nvgpu_err(g, "pmgr_pmu_set_object failed %x",
216 status); 220 status);
217 221
218exit: 222exit:
223 kfree(pwr_desc_table);
219 return status; 224 return status;
220} 225}
221 226
222static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g) 227static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
223{ 228{
224 struct nv_pmu_pmgr_pwr_monitor_pack pwr_monitor_pack; 229 struct nv_pmu_pmgr_pwr_monitor_pack *pwr_monitor_pack = NULL;
225 struct nv_pmu_pmgr_pwr_channel_header *pwr_channel_hdr; 230 struct nv_pmu_pmgr_pwr_channel_header *pwr_channel_hdr;
226 struct nv_pmu_pmgr_pwr_chrelationship_header *pwr_chrelationship_header; 231 struct nv_pmu_pmgr_pwr_chrelationship_header *pwr_chrelationship_header;
227 u32 max_dmem_size; 232 u32 max_dmem_size;
228 u32 status = 0; 233 u32 status = 0;
229 234
235 pwr_monitor_pack = nvgpu_kzalloc(g, sizeof(*pwr_monitor_pack));
236 if (!pwr_monitor_pack)
237 return -ENOMEM;
238
230 /* Copy all the global settings from the RM copy */ 239 /* Copy all the global settings from the RM copy */
231 pwr_channel_hdr = &(pwr_monitor_pack.channels.hdr.data); 240 pwr_channel_hdr = &(pwr_monitor_pack->channels.hdr.data);
232 pwr_monitor_pack = g->pmgr_pmu.pmgr_monitorobjs.pmu_data; 241 *pwr_monitor_pack = g->pmgr_pmu.pmgr_monitorobjs.pmu_data;
233 242
234 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_channel_hdr->super, 243 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_channel_hdr->super,
235 g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super.objmask); 244 g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super.objmask);
@@ -237,7 +246,7 @@ static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
237 /* Copy in each channel */ 246 /* Copy in each channel */
238 status = boardobjgrp_pmudatainit_legacy(g, 247 status = boardobjgrp_pmudatainit_legacy(g,
239 &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super, 248 &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super,
240 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.channels)); 249 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack->channels));
241 250
242 if (status) { 251 if (status) {
243 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x", 252 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x",
@@ -246,7 +255,7 @@ static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
246 } 255 }
247 256
248 /* Copy in each channel relationship */ 257 /* Copy in each channel relationship */
249 pwr_chrelationship_header = &(pwr_monitor_pack.ch_rels.hdr.data); 258 pwr_chrelationship_header = &(pwr_monitor_pack->ch_rels.hdr.data);
250 259
251 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_chrelationship_header->super, 260 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_chrelationship_header->super,
252 g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super.objmask); 261 g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super.objmask);
@@ -256,7 +265,7 @@ static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
256 265
257 status = boardobjgrp_pmudatainit_legacy(g, 266 status = boardobjgrp_pmudatainit_legacy(g,
258 &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super, 267 &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super,
259 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.ch_rels)); 268 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack->ch_rels));
260 269
261 if (status) { 270 if (status) {
262 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x", 271 nvgpu_err(g, "boardobjgrp_pmudatainit_legacy failed %x",
@@ -273,13 +282,14 @@ static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
273 NV_PMU_PMGR_OBJECT_PWR_MONITOR, 282 NV_PMU_PMGR_OBJECT_PWR_MONITOR,
274 (u16)max_dmem_size, 283 (u16)max_dmem_size,
275 (u16)sizeof(struct nv_pmu_pmgr_pwr_monitor_pack), 284 (u16)sizeof(struct nv_pmu_pmgr_pwr_monitor_pack),
276 &pwr_monitor_pack); 285 pwr_monitor_pack);
277 286
278 if (status) 287 if (status)
279 nvgpu_err(g, "pmgr_pmu_set_object failed %x", 288 nvgpu_err(g, "pmgr_pmu_set_object failed %x",
280 status); 289 status);
281 290
282exit: 291exit:
292 kfree(pwr_monitor_pack);
283 return status; 293 return status;
284} 294}
285 295