diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/pmgr/pwrpolicy.c | 85 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/pmgr/pwrpolicy.h | 10 |
2 files changed, 95 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 | } | ||
232 | done: | 243 | done: |
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 | ||
401 | static 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 | } | ||
446 | done: | ||
447 | return status; | ||
448 | } | ||
449 | |||
381 | static u32 devinit_get_pwr_policy_table(struct gk20a *g, | 450 | static 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 | |||
606 | done: | 691 | done: |
607 | gk20a_dbg_info(" done status %x", status); | 692 | gk20a_dbg_info(" done status %x", status); |
608 | return status; | 693 | return status; |
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.h b/drivers/gpu/nvgpu/pmgr/pwrpolicy.h index 82289137..008282d3 100644 --- a/drivers/gpu/nvgpu/pmgr/pwrpolicy.h +++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.h | |||
@@ -99,10 +99,20 @@ struct pwr_policy_hw_threshold { | |||
99 | u16 low_threshold_value; | 99 | u16 low_threshold_value; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | struct pwr_policy_sw_threshold { | ||
103 | struct pwr_policy_limit super; | ||
104 | u8 threshold_idx; | ||
105 | u8 low_threshold_idx; | ||
106 | bool b_use_low_threshold; | ||
107 | u16 low_threshold_value; | ||
108 | u8 event_id; | ||
109 | }; | ||
110 | |||
102 | union pwr_policy_data_union { | 111 | union pwr_policy_data_union { |
103 | struct boardobj boardobj; | 112 | struct boardobj boardobj; |
104 | struct pwr_policy pwrpolicy; | 113 | struct pwr_policy pwrpolicy; |
105 | struct pwr_policy_hw_threshold hw_threshold; | 114 | struct pwr_policy_hw_threshold hw_threshold; |
115 | struct pwr_policy_sw_threshold sw_threshold; | ||
106 | } ; | 116 | } ; |
107 | 117 | ||
108 | #define PMGR_GET_PWR_POLICY(g, policy_idx) \ | 118 | #define PMGR_GET_PWR_POLICY(g, policy_idx) \ |