From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <zhaoguohan@kylinos.cn>
Cc: <lucas.demarchi@intel.com>, <thomas.hellstrom@linux.intel.com>,
<airlied@gmail.com>, <simona@ffwll.ch>, <badal.nilawar@intel.com>,
<karthik.poosa@intel.com>, <riana.tauro@intel.com>,
"open list:INTEL DRM XE DRIVER (Lunar Lake and newer)"
<intel-xe@lists.freedesktop.org>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] drm/xe/hwmon: Return early on power limit read failure
Date: Sun, 17 Aug 2025 12:20:05 -0400 [thread overview]
Message-ID: <aKIBNeuupayX6awq@intel.com> (raw)
In-Reply-To: <20250815063623.18162-1-zhaoguohan@kylinos.cn>
On Fri, Aug 15, 2025 at 02:36:23PM +0800, zhaoguohan@kylinos.cn wrote:
> From: GuoHan Zhao <zhaoguohan@kylinos.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
There are still missed/unanswered questions/concerns in the original review:
https://lore.kernel.org/intel-xe/aJtG0xmBBgwnTANg@intel.com
Please ensure to address all of them before re-iterating the patch.
Thanks,
Rodrigo.
>
> Signed-off-by: GuoHan Zhao <zhaoguohan@kylinos.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
>
prev parent reply other threads:[~2025-08-17 16:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 6:36 [PATCH v2] drm/xe/hwmon: Return early on power limit read failure zhaoguohan
2025-08-17 16:20 ` Rodrigo Vivi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aKIBNeuupayX6awq@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=airlied@gmail.com \
--cc=badal.nilawar@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=riana.tauro@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=zhaoguohan@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).