Skip to content

Commit 7e43335

Browse files
kpoosarodrigovivi
authored andcommitted
drm/xe/hwmon: Expose card power and energy attributes of BMG
In BMG there are separate registers for card/platform power and energy. These are exposed through channel 0 i.e power_1/energy1_xxx. Signed-off-by: Karthik Poosa <karthik.poosa@intel.com> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Link: https://lore.kernel.org/r/20240523144351.4040131-3-balasubramani.vivekanandan@intel.com Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240529050758.442056-3-balasubramani.vivekanandan@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent e90f7a5 commit 7e43335

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

drivers/gpu/drm/xe/regs/xe_pcode_regs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
#define BMG_PACKAGE_POWER_SKU_UNIT XE_REG(0x1380dc)
2323
#define BMG_PACKAGE_ENERGY_STATUS XE_REG(0x138120)
2424
#define BMG_PACKAGE_RAPL_LIMIT XE_REG(0x138440)
25+
#define BMG_PLATFORM_ENERGY_STATUS XE_REG(0x138458)
26+
#define BMG_PLATFORM_POWER_LIMIT XE_REG(0x138460)
2527

2628
#endif /* _XE_PCODE_REGS_H_ */

drivers/gpu/drm/xe/xe_hwmon.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ static struct xe_reg xe_hwmon_get_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg
8686

8787
switch (hwmon_reg) {
8888
case REG_PKG_RAPL_LIMIT:
89-
if (xe->info.platform == XE_BATTLEMAGE && channel == CHANNEL_PKG)
90-
return BMG_PACKAGE_RAPL_LIMIT;
91-
else if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG)
89+
if (xe->info.platform == XE_BATTLEMAGE) {
90+
if (channel == CHANNEL_PKG)
91+
return BMG_PACKAGE_RAPL_LIMIT;
92+
else
93+
return BMG_PLATFORM_POWER_LIMIT;
94+
} else if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG) {
9295
return PVC_GT0_PACKAGE_RAPL_LIMIT;
93-
else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG))
96+
} else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG)) {
9497
return PCU_CR_PACKAGE_RAPL_LIMIT;
98+
}
9599
break;
96100
case REG_PKG_POWER_SKU:
97101
if (xe->info.platform == XE_BATTLEMAGE)
@@ -114,12 +118,16 @@ static struct xe_reg xe_hwmon_get_reg(struct xe_hwmon *hwmon, enum xe_hwmon_reg
114118
return GT_PERF_STATUS;
115119
break;
116120
case REG_PKG_ENERGY_STATUS:
117-
if (xe->info.platform == XE_BATTLEMAGE && channel == CHANNEL_PKG)
118-
return BMG_PACKAGE_ENERGY_STATUS;
119-
else if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG)
121+
if (xe->info.platform == XE_BATTLEMAGE) {
122+
if (channel == CHANNEL_PKG)
123+
return BMG_PACKAGE_ENERGY_STATUS;
124+
else
125+
return BMG_PLATFORM_ENERGY_STATUS;
126+
} else if (xe->info.platform == XE_PVC && channel == CHANNEL_PKG) {
120127
return PVC_GT0_PLATFORM_ENERGY_STATUS;
121-
else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG))
128+
} else if ((xe->info.platform == XE_DG2) && (channel == CHANNEL_PKG)) {
122129
return PCU_CR_PACKAGE_ENERGY_STATUS;
130+
}
123131
break;
124132
default:
125133
drm_warn(&xe->drm, "Unknown xe hwmon reg id: %d\n", hwmon_reg);

0 commit comments

Comments
 (0)