Skip to content

Commit 045610c

Browse files
zhang-ruirafaeljw
authored andcommitted
powercap: intel_rapl: Change primitive order
The same set of operations are shared by different Powert Limits, including Power Limit get/set, Power Limit enable/disable, clamping enable/disable, time window get/set, and max power get/set, etc. But the same operation for different Power Limit has different primitives because they use different registers/register bits. A lot of dirty/duplicate code was introduced to handle this difference. Instead of using hardcoded primitive name directly, using Power Limit id + operation type is much cleaner. For this sense, move POWER_LIMIT1/POWER_LIMIT2/POWER_LIMIT4 to the beginning of enum rapl_primitives so that they can be reused as Power Limit ids. No functional change. Signed-off-by: Zhang Rui <[email protected]> Tested-by: Wang Wendy <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 11edbe5 commit 045610c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

drivers/powercap/intel_rapl_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,14 @@ static u64 rapl_unit_xlate(struct rapl_domain *rd, enum unit_type type,
631631

632632
static struct rapl_primitive_info rpi_default[NR_RAPL_PRIMITIVES] = {
633633
/* name, mask, shift, msr index, unit divisor */
634-
[ENERGY_COUNTER] = PRIMITIVE_INFO_INIT(ENERGY_COUNTER, ENERGY_STATUS_MASK, 0,
635-
RAPL_DOMAIN_REG_STATUS, ENERGY_UNIT, 0),
636634
[POWER_LIMIT1] = PRIMITIVE_INFO_INIT(POWER_LIMIT1, POWER_LIMIT1_MASK, 0,
637635
RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
638636
[POWER_LIMIT2] = PRIMITIVE_INFO_INIT(POWER_LIMIT2, POWER_LIMIT2_MASK, 32,
639637
RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
640638
[POWER_LIMIT4] = PRIMITIVE_INFO_INIT(POWER_LIMIT4, POWER_LIMIT4_MASK, 0,
641639
RAPL_DOMAIN_REG_PL4, POWER_UNIT, 0),
640+
[ENERGY_COUNTER] = PRIMITIVE_INFO_INIT(ENERGY_COUNTER, ENERGY_STATUS_MASK, 0,
641+
RAPL_DOMAIN_REG_STATUS, ENERGY_UNIT, 0),
642642
[FW_LOCK] = PRIMITIVE_INFO_INIT(FW_LOCK, POWER_LOW_LOCK, 31,
643643
RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
644644
[PL1_ENABLE] = PRIMITIVE_INFO_INIT(PL1_ENABLE, POWER_LIMIT1_ENABLE, 15,

include/linux/intel_rapl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ enum rapl_domain_reg_id {
3737
struct rapl_domain;
3838

3939
enum rapl_primitives {
40-
ENERGY_COUNTER,
4140
POWER_LIMIT1,
4241
POWER_LIMIT2,
4342
POWER_LIMIT4,
43+
ENERGY_COUNTER,
4444
FW_LOCK,
4545

4646
PL1_ENABLE, /* power limit 1, aka long term */
@@ -75,7 +75,8 @@ struct rapl_domain_data {
7575
unsigned long timestamp;
7676
};
7777

78-
#define NR_POWER_LIMITS (3)
78+
#define NR_POWER_LIMITS (POWER_LIMIT4 + 1)
79+
7980
struct rapl_power_limit {
8081
struct powercap_zone_constraint *constraint;
8182
int prim_id; /* primitive ID used to enable */

0 commit comments

Comments
 (0)