<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 12-06-2025 15:36, Nilawar, Badal
wrote:<br>
</div>
<blockquote type="cite" cite="mid:c7231452-78d3-4410-a309-f04d23d7b0f2@intel.com">
<br>
On 09-06-2025 11:43, Karthik Poosa wrote:
<br>
<blockquote type="cite">Prevent the power limit time interval from
being overwritten with 0.
<br>
This issue was due to a missing read and modify of current power
limit,
<br>
before setting a requested mailbox power limit, which is added
in this
<br>
patch.
<br>
<br>
v2:
<br>
- Improve commit message. (Anshuman)
<br>
<br>
Signed-off-by: Karthik Poosa <a class="moz-txt-link-rfc2396E" href="mailto:karthik.poosa@intel.com"><karthik.poosa@intel.com></a>
<br>
Fixes: 7596d839f6228 ("drm/xe/hwmon: Add support to manage power
limits though mailbox")
<br>
---
<br>
drivers/gpu/drm/xe/regs/xe_mchbar_regs.h | 1 +
<br>
drivers/gpu/drm/xe/xe_hwmon.c | 7 +++++--
<br>
2 files changed, 6 insertions(+), 2 deletions(-)
<br>
<br>
diff --git a/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
b/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
<br>
index 5394a1373a6b..ef2bf984723f 100644
<br>
--- a/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
<br>
+++ b/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
<br>
@@ -40,6 +40,7 @@
<br>
#define PCU_CR_PACKAGE_RAPL_LIMIT
XE_REG(MCHBAR_MIRROR_BASE_SNB + 0x59a0)
<br>
#define PWR_LIM_VAL REG_GENMASK(14, 0)
<br>
#define PWR_LIM_EN REG_BIT(15)
<br>
+#define PWR_LIM REG_GENMASK(15, 0)
<br>
#define PWR_LIM_TIME REG_GENMASK(23, 17)
<br>
#define PWR_LIM_TIME_X REG_GENMASK(23, 22)
<br>
#define PWR_LIM_TIME_Y REG_GENMASK(21, 17)
<br>
diff --git a/drivers/gpu/drm/xe/xe_hwmon.c
b/drivers/gpu/drm/xe/xe_hwmon.c
<br>
index 0d32e977537c..abb5c3693437 100644
<br>
--- a/drivers/gpu/drm/xe/xe_hwmon.c
<br>
+++ b/drivers/gpu/drm/xe/xe_hwmon.c
<br>
@@ -377,11 +377,14 @@ static int xe_hwmon_power_max_write(struct
xe_hwmon *hwmon, u32 attr, int channe
<br>
reg_val = PWR_LIM_EN | REG_FIELD_PREP(PWR_LIM_VAL,
reg_val);
<br>
- if (hwmon->xe->info.has_mbx_power_limits)
<br>
+ if (hwmon->xe->info.has_mbx_power_limits) {
<br>
+ xe_hwmon_pcode_read_power_limit(hwmon, attr, channel,
&max);
<br>
+ reg_val = (max & ~PWR_LIM) | reg_val;
<br>
ret = xe_hwmon_pcode_write_power_limit(hwmon, attr,
channel, reg_val);
<br>
</blockquote>
<br>
Like xe_mmio_rmw32 I will suggest to write
xe_hwmon_pcode_rmw_power_limit() function to handle this. <br>
</blockquote>
<p><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">The
mailbox power limit requires read-modify-write (rmw) only in<span> </span></span><code style="color: rgb(66, 66, 66); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">xe_hwmon_power_max_write</code><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>and<span> </span></span><code style="color: rgb(66, 66, 66); font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">xe_hwmon_power_max_interval_store</code><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">.</span></p>
<p><span style="color: rgb(66, 66, 66); font-family: "Segoe Sans", "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(250, 250, 250); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Since
no further updates are expected elsewhere, do we need a helper
function for these two instances ?</span></p>
<blockquote type="cite" cite="mid:c7231452-78d3-4410-a309-f04d23d7b0f2@intel.com"><br>
Regards,
<br>
Badal
<br>
<br>
<blockquote type="cite">- else
<br>
+ } else {
<br>
reg_val = xe_mmio_rmw32(mmio, rapl_limit, PWR_LIM_EN |
PWR_LIM_VAL,
<br>
reg_val);
<br>
+ }
<br>
unlock:
<br>
mutex_unlock(&hwmon->hwmon_lock);
<br>
return ret;
<br>
</blockquote>
</blockquote>
</body>
</html>