aboutsummaryrefslogtreecommitdiffstats
path: root/include/pmgr/pwrpolicy.h
blob: 74f4937d2c4bdd708ce575c350b5381f8af3c87d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * general power channel structures & definitions
 *
 * Copyright (c) 2016-2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef NVGPU_PMGR_PWRPOLICY_H
#define NVGPU_PMGR_PWRPOLICY_H

#include <nvgpu/pmuif/nvgpu_gpmu_cmdif.h>
#include "boardobj/boardobjgrp.h"
#include "boardobj/boardobj.h"
#include "ctrl/ctrlpmgr.h"

#define PWR_POLICY_EXT_POWER_STATE_ID_COUNT 0x4U

enum pwr_policy_limit_id {
	PWR_POLICY_LIMIT_ID_MIN    = 0x00000000,
	PWR_POLICY_LIMIT_ID_RATED,
	PWR_POLICY_LIMIT_ID_MAX,
	PWR_POLICY_LIMIT_ID_CURR,
	PWR_POLICY_LIMIT_ID_BATT,
};

struct pwr_policy {
	struct boardobj super;
	u8 ch_idx;
	u8 num_limit_inputs;
	u8 limit_unit;
	s32 limit_delta;
	u32 limit_min;
	u32 limit_rated;
	u32 limit_max;
	u32 limit_batt;
	struct ctrl_pmgr_pwr_policy_info_integral integral;
	struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_min;
	struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_rated;
	struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_max;
	struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_batt;
	struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_curr;
	u8 sample_mult;
	enum ctrl_pmgr_pwr_policy_filter_type filter_type;
	union ctrl_pmgr_pwr_policy_filter_param filter_param;
};

struct pwr_policy_ext_limit {
	u8 policy_table_idx;
	u32 limit;
};

struct pwr_policy_batt_workitem {
	u32 power_state;
	bool b_full_deflection;
};

struct pwr_policy_client_workitem {
	u32 limit;
	bool b_pending;
};

struct pwr_policy_relationship {
	struct boardobj super;
	u8 policy_idx;
};

struct pmgr_pwr_policy {
	u8 version;
	bool b_enabled;
	struct nv_pmu_perf_domain_group_limits global_ceiling;
	u8 policy_idxs[CTRL_PMGR_PWR_POLICY_IDX_NUM_INDEXES];
	struct pwr_policy_ext_limit ext_limits[PWR_POLICY_EXT_POWER_STATE_ID_COUNT];
	s32 ext_power_state;
	u16 base_sample_period;
	u16 min_client_sample_period;
	u8 low_sampling_mult;
	struct boardobjgrp_e32 pwr_policies;
	struct boardobjgrp_e32 pwr_policy_rels;
	struct boardobjgrp_e32 pwr_violations;
	struct pwr_policy_client_workitem client_work_item;
};

struct pwr_policy_limit {
	struct pwr_policy super;
};

struct pwr_policy_hw_threshold {
	struct pwr_policy_limit super;
	u8 threshold_idx;
	u8 low_threshold_idx;
	bool b_use_low_threshold;
	u16 low_threshold_value;
};

struct pwr_policy_sw_threshold {
	struct pwr_policy_limit super;
	u8 threshold_idx;
	u8 low_threshold_idx;
	bool b_use_low_threshold;
	u16 low_threshold_value;
	u8 event_id;
};

union pwr_policy_data_union {
	struct boardobj boardobj;
	struct pwr_policy pwrpolicy;
	struct pwr_policy_hw_threshold hw_threshold;
	struct pwr_policy_sw_threshold sw_threshold;
} ;

#define PMGR_GET_PWR_POLICY(g, policy_idx)                                 \
	((struct pwr_policy *)BOARDOBJGRP_OBJ_GET_BY_IDX(                                 \
		&(g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super), (policy_idx)))

#define PMGR_PWR_POLICY_INCREMENT_LIMIT_INPUT_COUNT(ppolicy)                 \
	((ppolicy)->num_limit_inputs++)

int pmgr_policy_sw_setup(struct gk20a *g);

#endif /* NVGPU_PMGR_PWRPOLICY_H */
>349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616







































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
construct_w2.m