Skip to content

Commit a50b794

Browse files
kpoosalucasdemarchi
authored andcommitted
drm/xe/hwmon: Update xe_hwmon_get_reg to return struct xe_reg
Return struct xe_reg instead of reg.raw from xe_hwmon_get_reg to have abstracted usage of struct xe_reg. v2: - Use xe_reg_is_valid function instead of XE_REG_IS_VALID macro as it is removed. Signed-off-by: Karthik Poosa <[email protected]> Suggested-by: Lucas De Marchi <[email protected]> Cc: Badal Nilawar <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent b39c705 commit a50b794

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

drivers/gpu/drm/xe/xe_hwmon.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,46 +79,46 @@ struct xe_hwmon {
7979
struct xe_hwmon_energy_info ei[CHANNEL_MAX];
8080
};
8181

82-
static u32 xe_hwmon_get_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg hwmon_reg, int channel)
82+
static struct xe_reg xe_hwmon_get_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg hwmon_reg,
83+
int channel)
8384
{
8485
struct xe_device *xe = gt_to_xe(hwmon->gt);
85-
struct xe_reg reg = XE_REG(0);
8686

8787
switch (hwmon_reg) {
8888
case REG_PKG_RAPL_LIMIT:
8989
if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG)
90-
reg = PVC_GT0_PACKAGE_RAPL_LIMIT;
90+
return PVC_GT0_PACKAGE_RAPL_LIMIT;
9191
else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG))
92-
reg = PCU_CR_PACKAGE_RAPL_LIMIT;
92+
return PCU_CR_PACKAGE_RAPL_LIMIT;
9393
break;
9494
case REG_PKG_POWER_SKU:
9595
if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG)
96-
reg = PVC_GT0_PACKAGE_POWER_SKU;
96+
return PVC_GT0_PACKAGE_POWER_SKU;
9797
else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG))
98-
reg = PCU_CR_PACKAGE_POWER_SKU;
98+
return PCU_CR_PACKAGE_POWER_SKU;
9999
break;
100100
case REG_PKG_POWER_SKU_UNIT:
101101
if (xe->info.platform == XE_PVC)
102-
reg = PVC_GT0_PACKAGE_POWER_SKU_UNIT;
102+
return PVC_GT0_PACKAGE_POWER_SKU_UNIT;
103103
else if (xe->info.platform == XE_DG2)
104-
reg = PCU_CR_PACKAGE_POWER_SKU_UNIT;
104+
return PCU_CR_PACKAGE_POWER_SKU_UNIT;
105105
break;
106106
case REG_GT_PERF_STATUS:
107107
if (xe->info.platform == XE_DG2 && channel == CHANNEL_PKG)
108-
reg = GT_PERF_STATUS;
108+
return GT_PERF_STATUS;
109109
break;
110110
case REG_PKG_ENERGY_STATUS:
111111
if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG)
112-
reg = PVC_GT0_PLATFORM_ENERGY_STATUS;
112+
return PVC_GT0_PLATFORM_ENERGY_STATUS;
113113
else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG))
114-
reg = PCU_CR_PACKAGE_ENERGY_STATUS;
114+
return PCU_CR_PACKAGE_ENERGY_STATUS;
115115
break;
116116
default:
117117
drm_warn(&xe->drm, "Unknown xe hwmon reg id: %d\n", hwmon_reg);
118118
break;
119119
}
120120

121-
return reg.raw;
121+
return XE_REG(0);
122122
}
123123

124124
static void xe_hwmon_process_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg hwmon_reg,
@@ -127,9 +127,9 @@ static void xe_hwmon_process_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg hwmon
127127
{
128128
struct xe_reg reg;
129129

130-
reg.raw = xe_hwmon_get_reg(hwmon, hwmon_reg, channel);
130+
reg = xe_hwmon_get_reg(hwmon, hwmon_reg, channel);
131131

132-
if (!reg.raw)
132+
if (!xe_reg_is_valid(reg))
133133
return;
134134

135135
switch (operation) {
@@ -400,7 +400,7 @@ static umode_t xe_hwmon_attributes_visible(struct kobject *kobj,
400400

401401
xe_pm_runtime_get(gt_to_xe(hwmon->gt));
402402

403-
ret = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, index) ? attr->mode : 0;
403+
ret = xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, index)) ? attr->mode : 0;
404404

405405
xe_pm_runtime_put(gt_to_xe(hwmon->gt));
406406

@@ -496,16 +496,19 @@ xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
496496

497497
switch (attr) {
498498
case hwmon_power_max:
499-
return xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel) ? 0664 : 0;
499+
return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT,
500+
channel)) ? 0664 : 0;
500501
case hwmon_power_rated_max:
501-
return xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel) ? 0444 : 0;
502+
return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU,
503+
channel)) ? 0444 : 0;
502504
case hwmon_power_crit:
503505
if (channel == CHANNEL_PKG)
504506
return (xe_hwmon_pcode_read_i1(hwmon->gt, &uval) ||
505507
!(uval & POWER_SETUP_I1_WATTS)) ? 0 : 0644;
506508
break;
507509
case hwmon_power_label:
508-
return xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU_UNIT, channel) ? 0444 : 0;
510+
return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU_UNIT,
511+
channel)) ? 0444 : 0;
509512
default:
510513
return 0;
511514
}
@@ -588,7 +591,8 @@ xe_hwmon_in_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
588591
switch (attr) {
589592
case hwmon_in_input:
590593
case hwmon_in_label:
591-
return xe_hwmon_get_reg(hwmon, REG_GT_PERF_STATUS, channel) ? 0444 : 0;
594+
return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_GT_PERF_STATUS,
595+
channel)) ? 0444 : 0;
592596
default:
593597
return 0;
594598
}
@@ -612,7 +616,8 @@ xe_hwmon_energy_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
612616
switch (attr) {
613617
case hwmon_energy_input:
614618
case hwmon_energy_label:
615-
return xe_hwmon_get_reg(hwmon, REG_PKG_ENERGY_STATUS, channel) ? 0444 : 0;
619+
return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_ENERGY_STATUS,
620+
channel)) ? 0444 : 0;
616621
default:
617622
return 0;
618623
}
@@ -763,7 +768,7 @@ xe_hwmon_get_preregistration_info(struct xe_device *xe)
763768
* The contents of register PKG_POWER_SKU_UNIT do not change,
764769
* so read it once and store the shift values.
765770
*/
766-
if (xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU_UNIT, 0)) {
771+
if (xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU_UNIT, 0))) {
767772
xe_hwmon_process_reg(hwmon, REG_PKG_POWER_SKU_UNIT,
768773
REG_READ32, &val_sku_unit, 0, 0, 0);
769774
hwmon->scl_shift_power = REG_FIELD_GET(PKG_PWR_UNIT, val_sku_unit);

0 commit comments

Comments
 (0)