pass: rescon: Add support for multiple scenario pass_level 17/224717/7
authorChanwoo Choi <cw00.choi@samsung.com>
Tue, 28 Jan 2020 05:47:44 +0000 (14:47 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 26 Feb 2020 10:22:17 +0000 (19:22 +0900)
commitd54cf9cc4588b52f41a420d268e976c35b45f957
tree96a0ba8d34ff6e2461bd7b690ae0b7a23b905920
parenteef406453163717c34f9636fe717132755d17968
pass: rescon: Add support for multiple scenario pass_level

PASS provides multiple modules like CPUHP (CPU Hotplug Manager), PMQoS,
Thermal Monitor and so on. Each module requires their own pass_level
in order to change h/w resources such as the number of online CPU,
the minimum/maximum frequency of GPU.

Prior to that, PASS supports only 'pass_level'. If user of PASS want to
set 'AppLaunch' scenario of PMQoS module, PMQoS only requires the range
of 'pass_level' like the minimum and maximum 'pass_level'. It is not enough
to meet the requirements from 'AppLaunch' scenario. Some scenario might
require the more detailed changes than already defined 'pass_level'.

In result of these requirements, add support for new 'scenario pass_level'
for scenarios such as AppLaunch of PMQoS and WarningAction of Thermal
Monitor. 'scenario pass_level' is possible to specify the detailed value
of h/w resources such as the minimum/maximum frequency (limit_(min|max)_freq),
the minimum/maximum number of online CPU (limit_(min|max)_cpu)
and fault_around_bytes for memorh h/w resource.

In order to support the multiple scenario pass_level at the same time,
RESCON (Resource Controller) module adds new following functions and then
delete previous function.

PMQoS will use new functions for supporting the 'scenario pass_level'
and Thermal Monitor will use the new functions for 'scenario pass_level'
for constrainting the h/w resouece to prevent the dangerous overheating.

[Added new functions]
- int pass_rescon_sync(struct pass_resource *res);
- int pass_rescon_set_level_sync(struct pass_resource *res, int level);
- int pass_rescon_set_scenario_level_sync(struct pass_resource *res,
int scenario_level);
- int pass_rescon_unset_scenario_level_sync(struct pass_resource *res,
int scenario_level);
- int pass_rescon_set_scenario_level(struct pass_resource *res,
int scenario_level);
- int pass_rescon_unset_scenario_level(struct pass_resource *res,
int scenario_level);

[Deleted functions]
- int pass_rescon_set_level_scope(struct pass_resource *res, int new_level,
int min_level, int max_level, void *data);

[Deprecated functions. Because these functions are keeping
for the compatibility with legacy feature. It should be used on PMQoS module.]
- int pass_rescon_set_scenario_level_sync_with_data(struct pass_resource *res,
int scenario_level, void *data);
- int pass_rescon_unset_scenario_level_sync_with_data(struct pass_resource *res,
int scenario_level, void *data);

[Exmaple of multiple scenario pass_level on PMQoS and Thermal Monitor modules]
Case 1. AppLaunch scenario of PMQoS ,
- 'AppLaunch' scenario contains 'scenario_level=1' property as following:
[ScenarioLevel1]
limit_min_freq=1300000
limit_max_freq=1300000
limit_min_cpu=3
limit_max_cpu=4

- In result, RESCON (Resource Controller) set h/w resource as following:
The minimum frequency is 1300MHz.
The maximum frequency is 1300MHz.
The minimum number of online CPU is 3.
The maximum number of online CPU is 4.
-> It maintains 1300MHz and three online CPU.

Case 2. Warning scenario of Thermal Monitor,
- 'Warning' scenario contains 'scenario_level=2' property as following:
[ScenarioLevel2]
limit_min_freq=768000
limit_max_freq=1000000
limit_min_cpu=0
limit_max_cpu=2

- In result, RESCON (Resource Controller) set h/w resource as following:
The minimum frequency is 768MHz.
The maximum frequency is 1000MHz.
The minimum number of online CPU has no any constraint.
The maximum number of online CPU is 2.
-> It maintain 768MHz and doesn't turn on more than 2 CPU.

Case 3. AppLaunch scenario of PMQoS + Warning scenario of Thermal Monitor,
- 'AppLaunch' scenario contains 'scenario_level=1' property and
  'Warning' scenario contains 'scenario_level=2' property as following:

[ScenarioLevel1]
limit_min_freq=1300000
limit_max_freq=1300000
limit_min_cpu=3
limit_max_cpu=4

[ScenarioLevel2]
limit_min_freq=768000
limit_max_freq=1000000
limit_min_cpu=0
limit_max_cpu=2

- In result, RESCON (Resource Controller) set h/w resource as following:
The minimum frequency is 1000MHz because MAX(1300000, 768000) cannot be
                                 over thatn maximum frequency (1000MHz).
The maximum frequency is 1000MHz.
The minimum number of online CPU is 2.
The maximum number of online CPU is 2.
-> It maintain 1000MHz and doesn't turn on more than 2 CPU.

[ScenarioLevel0]
limit_min_freq=768000
limit_max_freq=1300000
limit_min_cpu=0
limit_max_cpu=4

[ScenarioLevel1]
limit_min_freq=1300000
limit_max_freq=1300000
limit_min_cpu=3
limit_max_cpu=4

[ScenarioLevel2]
limit_min_freq=768000
limit_max_freq=1000000
limit_min_cpu=0
limit_max_cpu=2

[PassScenario]
pass_scenario_support=yes
pass_num_scenarios=1

[Scenario0]
name=AppLaunch
support=yes
scenario_level=1 <- It indicates 'ScenarioLevel1' for AppLaunch scenario.

[thermal]
thermal_support=yes
thermal_number_of_scenario=2
thermal_timer_interval_ms=5000

[thermal.scenario0]
support=yes
name=Release
temperature=25
timer_interval_ms=5000
scenario_level=0

[thermal.scenario1]
support=yes
name=Warning
temperature=30
timer_interval_ms=3000
scenario_level=2 <- It indicates 'ScenarioLevel2' for Warning scenario.

Change-Id: I45e99b1794b85342f29bf0decec6a859f56f8f58
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-cpuhp.c
src/pass/pass-parser.c
src/pass/pass-pmqos.c
src/pass/pass-rescon.c
src/pass/pass-rescon.h
src/pass/pass.h