summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
diff options
context:
space:
mode:
authorLakshmanan M <lm@nvidia.com>2016-10-07 05:00:12 -0400
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 04:56:50 -0500
commit776ab920a7a4d31c6180e7dcb9f3fcea611e92bd (patch)
tree89931a821b7a3fa27e132fa640f27310695bbccf /drivers/gpu/nvgpu/pmgr/pwrpolicy.c
parent90f80a282eff04412858361df35c2f88372e88cb (diff)
gpu: nvgpu: Add SW_THRESHOLD policy support
Added SW_THRESHOLD policy support for over power protection. JIRA DNVGPU-70 Change-Id: I7a9d202619c997d6cab6fb750db7f3018229b2fd Signed-off-by: Lakshmanan M <lm@nvidia.com> Reviewed-on: http://git-master/r/1233055 (cherry picked from commit b233c74b9ba4a3802f111757aecf24a27c830fc1) Reviewed-on: http://git-master/r/1241960 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu/pmgr/pwrpolicy.c')
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrpolicy.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
index bec13b0c..d7926773 100644
--- a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
+++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
@@ -229,6 +229,17 @@ static u32 _pwr_domains_pmudatainit_hw_threshold(struct gk20a *g,
229 pmu_hw_threshold_data->b_use_low_threshold = p_hw_threshold->b_use_low_threshold; 229 pmu_hw_threshold_data->b_use_low_threshold = p_hw_threshold->b_use_low_threshold;
230 pmu_hw_threshold_data->low_threshold_value = p_hw_threshold->low_threshold_value; 230 pmu_hw_threshold_data->low_threshold_value = p_hw_threshold->low_threshold_value;
231 231
232 if (BOARDOBJ_GET_TYPE(board_obj_ptr) ==
233 CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD) {
234 struct nv_pmu_pmgr_pwr_policy_sw_threshold *pmu_sw_threshold_data;
235 struct pwr_policy_sw_threshold *p_sw_threshold;
236
237 p_sw_threshold = (struct pwr_policy_sw_threshold *)board_obj_ptr;
238 pmu_sw_threshold_data =
239 (struct nv_pmu_pmgr_pwr_policy_sw_threshold *) ppmudata;
240 pmu_sw_threshold_data->event_id =
241 p_sw_threshold->event_id;
242 }
232done: 243done:
233 return status; 244 return status;
234} 245}
@@ -326,6 +337,15 @@ static struct boardobj *construct_pwr_policy(struct gk20a *g,
326 pwrpolicyhwthreshold->low_threshold_idx = hwthreshold->low_threshold_idx; 337 pwrpolicyhwthreshold->low_threshold_idx = hwthreshold->low_threshold_idx;
327 pwrpolicyhwthreshold->low_threshold_value = hwthreshold->low_threshold_value; 338 pwrpolicyhwthreshold->low_threshold_value = hwthreshold->low_threshold_value;
328 339
340 if (type == CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD) {
341 struct pwr_policy_sw_threshold *pwrpolicyswthreshold;
342 struct pwr_policy_sw_threshold *swthreshold =
343 (struct pwr_policy_sw_threshold*)pargs;
344
345 pwrpolicyswthreshold = (struct pwr_policy_sw_threshold*)board_obj_ptr;
346 pwrpolicyswthreshold->event_id = swthreshold->event_id;
347 }
348
329 gk20a_dbg_info(" Done"); 349 gk20a_dbg_info(" Done");
330 350
331 return board_obj_ptr; 351 return board_obj_ptr;
@@ -378,6 +398,55 @@ done:
378 return status; 398 return status;
379} 399}
380 400
401static u32 _pwr_policy_construct_WAR_SW_Threshold_policy(struct gk20a *g,
402 struct pmgr_pwr_policy *ppwrpolicyobjs,
403 union pwr_policy_data_union *ppwrpolicydata,
404 u16 pwr_policy_size,
405 u32 obj_index)
406{
407 u32 status = 0;
408 struct boardobj *boardobj;
409
410 /* WARN policy */
411 ppwrpolicydata->pwrpolicy.limit_unit = 0;
412 ppwrpolicydata->pwrpolicy.limit_min = 10000;
413 ppwrpolicydata->pwrpolicy.limit_rated = 100000;
414 ppwrpolicydata->pwrpolicy.limit_max = 100000;
415 ppwrpolicydata->sw_threshold.threshold_idx = 1;
416 ppwrpolicydata->pwrpolicy.filter_type =
417 CTRL_PMGR_PWR_POLICY_FILTER_TYPE_MOVING_AVERAGE;
418 ppwrpolicydata->pwrpolicy.sample_mult = 5;
419
420 /* Filled the entry.filterParam value in the filterParam */
421 ppwrpolicydata->pwrpolicy.filter_param.moving_avg.window_size = 10;
422
423 ppwrpolicydata->sw_threshold.event_id = 0x01;
424
425 ppwrpolicydata->boardobj.type = CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD;
426
427 boardobj = construct_pwr_policy(g, ppwrpolicydata,
428 pwr_policy_size, ppwrpolicydata->boardobj.type);
429
430 if (!boardobj) {
431 gk20a_err(dev_from_gk20a(g),
432 "unable to create pwr policy for type %d", ppwrpolicydata->boardobj.type);
433 status = -EINVAL;
434 goto done;
435 }
436
437 status = boardobjgrp_objinsert(&ppwrpolicyobjs->pwr_policies.super,
438 boardobj, obj_index);
439
440 if (status) {
441 gk20a_err(dev_from_gk20a(g),
442 "unable to insert pwr policy boardobj for %d", obj_index);
443 status = -EINVAL;
444 goto done;
445 }
446done:
447 return status;
448}
449
381static u32 devinit_get_pwr_policy_table(struct gk20a *g, 450static u32 devinit_get_pwr_policy_table(struct gk20a *g,
382 struct pmgr_pwr_policy *ppwrpolicyobjs) 451 struct pmgr_pwr_policy *ppwrpolicyobjs)
383{ 452{
@@ -392,6 +461,7 @@ static u32 devinit_get_pwr_policy_table(struct gk20a *g,
392 u16 pwr_policy_size; 461 u16 pwr_policy_size;
393 bool integral_control = false; 462 bool integral_control = false;
394 u32 hw_threshold_policy_index = 0; 463 u32 hw_threshold_policy_index = 0;
464 u32 sw_threshold_policy_index = 0;
395 union pwr_policy_data_union pwr_policy_data; 465 union pwr_policy_data_union pwr_policy_data;
396 466
397 gk20a_dbg_info(""); 467 gk20a_dbg_info("");
@@ -603,6 +673,21 @@ static u32 devinit_get_pwr_policy_table(struct gk20a *g,
603 ++obj_index; 673 ++obj_index;
604 } 674 }
605 675
676 if (!sw_threshold_policy_index) {
677 status = _pwr_policy_construct_WAR_SW_Threshold_policy(g,
678 ppwrpolicyobjs,
679 &pwr_policy_data,
680 sizeof(struct pwr_policy_sw_threshold),
681 obj_index);
682 if (status) {
683 gk20a_err(dev_from_gk20a(g),
684 "unable to construct_WAR_policy");
685 status = -EINVAL;
686 goto done;
687 }
688 ++obj_index;
689 }
690
606done: 691done:
607 gk20a_dbg_info(" done status %x", status); 692 gk20a_dbg_info(" done status %x", status);
608 return status; 693 return status;