[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250815063623.18162-1-zhaoguohan@kylinos.cn>
Date: Fri, 15 Aug 2025 14:36:23 +0800
From: zhaoguohan@...inos.cn
To: lucas.demarchi@...el.com,
thomas.hellstrom@...ux.intel.com,
rodrigo.vivi@...el.com,
airlied@...il.com,
simona@...ll.ch
Cc: badal.nilawar@...el.com,
karthik.poosa@...el.com,
riana.tauro@...el.com,
intel-xe@...ts.freedesktop.org (open list:INTEL DRM XE DRIVER (Lunar Lake and newer)),
dri-devel@...ts.freedesktop.org (open list:DRM DRIVERS),
linux-kernel@...r.kernel.org (open list),
GuoHan Zhao <zhaoguohan@...inos.cn>
Subject: [PATCH v2] drm/xe/hwmon: Return early on power limit read failure
From: GuoHan Zhao <zhaoguohan@...inos.cn>
In xe_hwmon_pcode_rmw_power_limit(), when xe_pcode_read() fails,
the function logs the error but continues to execute the subsequent
logic. This can result in undefined behavior as the values val0 and
val1 may contain invalid data.
Fix this by adding an early return after logging the read failure,
ensuring that we don't proceed with potentially corrupted data.
Fixes: 8aa7306631f0 ("drm/xe/hwmon: Fix xe_hwmon_power_max_write")
V2:
- Change 'drm_dbg' to 'drm_err'
- Added the Fixes tag in commit message
Signed-off-by: GuoHan Zhao <zhaoguohan@...inos.cn>
---
drivers/gpu/drm/xe/xe_hwmon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
index f08fc4377d25..8e29fa155d7e 100644
--- a/drivers/gpu/drm/xe/xe_hwmon.c
+++ b/drivers/gpu/drm/xe/xe_hwmon.c
@@ -190,9 +190,11 @@ static int xe_hwmon_pcode_rmw_power_limit(const struct xe_hwmon *hwmon, u32 attr
READ_PL_FROM_PCODE : READ_PL_FROM_FW),
&val0, &val1);
- if (ret)
- drm_dbg(&hwmon->xe->drm, "read failed ch %d val0 0x%08x, val1 0x%08x, ret %d\n",
+ if (ret) {
+ drm_err(&hwmon->xe->drm, "read failed ch %d val0 0x%08x, val1 0x%08x, ret %d\n",
channel, val0, val1, ret);
+ return ret;
+ }
if (attr == PL1_HWMON_ATTR)
val0 = (val0 & ~clr) | set;
--
2.43.0
Powered by blists - more mailing lists