From: sashiko-bot@kernel.org
To: "Karthik Poosa" <karthik.poosa@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v9 07/14] drm/xe/hwmon: Consolidate temperature sensor availability checks
Date: Fri, 09 Oct 2026 12:16:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-165508@kernel.org> (raw)
In-Reply-To: <20261009120335.52973-8-karthik.poosa@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] drm/xe/hwmon: live hardware read during probe permanently hides sysfs attributes on transient failure
- [Medium] drm/xe/hwmon: endianness bug when extracting thermal limits via union
--
commit bbb594b78c17c03bdb11a59f0ce797f39d14c3e9
Author: Karthik Poosa <karthik.poosa@intel.com>
Subject: drm/xe/hwmon: Consolidate temperature sensor availability checks
This commit replaces is_vram_ch_available() with a generalized
is_temp_available() function that validates multiple sensor types using new
helpers. It uses this new function during hwmon registration to ensure
attributes for absent sensors are not exposed.
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index accccadbe3e67..62e341ef37e9b 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
[ ... ]
> @@ -1008,19 +1008,39 @@ static void xe_hwmon_get_voltage(struct xe_hwmon *hwmon, int channel, long *valu
> *value = DIV_ROUND_CLOSEST(REG_FIELD_GET(VOLTAGE_MASK, reg_val) * 2500, SF_VOLTAGE);
> }
>
> -static inline bool is_vram_ch_available(struct xe_hwmon *hwmon, int channel)
> +static bool is_temp_available(struct xe_hwmon *hwmon, int channel)
> {
> struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe);
> - int vram_id = channel - CHANNEL_VRAM_N;
> - struct xe_reg vram_reg;
> + struct xe_reg reg;
> + u32 reg_val;
>
> - vram_reg = xe_hwmon_get_reg(hwmon, REG_TEMP, channel);
> - if (!xe_reg_is_valid(vram_reg) || !xe_mmio_read32(mmio, vram_reg))
> - return false;
> + switch (channel) {
> + case CHANNEL_PKG:
> + case CHANNEL_VRAM:
> + case CHANNEL_VRAM_N...CHANNEL_VRAM_N_MAX:
> + reg = xe_hwmon_get_reg(hwmon, REG_TEMP, channel);
> + if (!xe_reg_is_valid(reg))
> + return false;
> +
> + reg_val = xe_mmio_read32(mmio, reg);
> + if (!mmio_temp_valid(hwmon, reg_val)) {
[Severity: Medium]
Since this function is called during hwmon registration to determine attribute
visibility, does this live hardware read risk permanently hiding sysfs
attributes if the hardware is transiently busy or uninitialized?
If the sensor returns 0 (which mmio_temp_valid treats as invalid) during
driver probe, the attribute will be hidden for the entire boot cycle.
> + drm_dbg(&hwmon->xe->drm,
> + "channel %d temperature unavailable, val 0x%x\n", channel, reg_val);
> + return false;
> + }
> +
> + if (channel >= CHANNEL_VRAM_N)
> + sprintf(hwmon->temp.vram_label[channel - CHANNEL_VRAM_N],
> + "vram_ch_%d", channel - CHANNEL_VRAM_N);
>
> - /* Create label only for available vram channel */
> - sprintf(hwmon->temp.vram_label[vram_id], "vram_ch_%d", vram_id);
> - return true;
> + return true;
> + case CHANNEL_MCTRL:
> + return hwmon->temp.count && !get_mc_temp(hwmon, NULL);
[Severity: Medium]
Similar to the MMIO read above, could this PCODE mailbox read cause
attributes to be permanently hidden?
If the PCODE mailbox transiently times out during driver probe,
get_mc_temp() will return an error, causing the MCTRL attribute to be
permanently hidden for the duration of the boot cycle.
> + case CHANNEL_PCIE:
> + return hwmon->temp.count && !get_pcie_temp(hwmon, NULL);
> + default:
> + return false;
> + }
> }
>
> static umode_t
> @@ -1030,14 +1050,13 @@ xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
> case hwmon_temp_emergency:
> switch (channel) {
> case CHANNEL_PKG:
> - return hwmon->temp.limit[TEMP_LIMIT_PKG_SHUTDOWN] ? 0444 : 0;
> - case CHANNEL_VRAM:
> - return hwmon->temp.limit[TEMP_LIMIT_MEM_SHUTDOWN] ? 0444 : 0;
> case CHANNEL_MCTRL:
> case CHANNEL_PCIE:
> - return hwmon->temp.count ? 0444 : 0;
> + return (is_temp_available(hwmon, channel) &&
> + hwmon->temp.limit[TEMP_LIMIT_PKG_SHUTDOWN]) ? 0444 : 0;
[Severity: Medium]
Does extracting thermal limits this way introduce an endianness bug?
While looking at how the limits are accessed here, the xe_hwmon_thermal_info
struct aliases u8 arrays with u32 arrays:
union {
u8 limit[TEMP_LIMIT_MAX];
u32 data[DIV_ROUND_UP(TEMP_LIMIT_MAX, sizeof(u32))];
};
If the driver reads 32-bit values from PCODE into the u32 arrays, extracting
individual 8-bit limits by indexing into the u8 arrays assumes a little-endian
memory layout. On big-endian architectures, index 0 will map to bits 24:31
instead of bits 0:7, potentially causing the driver to extract incorrect
thermal limits.
> + case CHANNEL_VRAM:
> case CHANNEL_VRAM_N...CHANNEL_VRAM_N_MAX:
> - return (is_vram_ch_available(hwmon, channel) &&
> + return (is_temp_available(hwmon, channel) &&
> hwmon->temp.limit[TEMP_LIMIT_MEM_SHUTDOWN]) ? 0444 : 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009120335.52973-1-karthik.poosa@intel.com?part=7
next prev parent reply other threads:[~2026-10-09 12:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 12:03 [PATCH v9 00/14] drm/xe/hwmon: Update hwmon thermal mailbox Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 01/14] drm/xe/hwmon: Handle pcode read failures of xe_hwmon_pcode_rmw_power_limit Karthik Poosa
2026-10-09 12:14 ` sashiko-bot
2026-10-10 5:14 ` Poosa, Karthik
2026-10-12 11:09 ` Poosa, Karthik
2026-10-09 12:03 ` [PATCH v9 02/14] drm/xe/hwmon: Decode mailbox temperature as sign-magnitude Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 03/14] drm/xe/hwmon: Fix memory controller thermal data handling Karthik Poosa
2026-10-09 12:15 ` sashiko-bot
2026-10-09 12:03 ` [PATCH v9 04/14] drm/xe/hwmon: Add helpers to validate thermal sensor readings Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 05/14] drm/xe/hwmon: Handle unavailable memory controller sensors Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 06/14] drm/xe/hwmon: Detect unavailable PCIe thermal sensors Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 07/14] drm/xe/hwmon: Consolidate temperature sensor availability checks Karthik Poosa
2026-10-09 12:16 ` sashiko-bot [this message]
2026-10-10 5:19 ` Poosa, Karthik
2026-10-12 13:10 ` Poosa, Karthik
2026-10-09 12:03 ` [PATCH v9 08/14] drm/xe/hwmon: Cache temperature availability to reduce probe time Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 09/14] drm/xe/hwmon: use CRI-specific package and VRAM temperature registers Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 10/14] drm/xe/hwmon: Add platform-aware VRAM thermal channel support Karthik Poosa
2026-10-09 12:18 ` sashiko-bot
2026-10-10 5:39 ` Poosa, Karthik
2026-10-09 12:03 ` [PATCH v9 11/14] drm/xe/hwmon: Decode CRI temperature registers as IEEE-754 Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 12/14] drm/xe/hwmon: Update memory controller temperature offset for CRI Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 13/14] drm/xe/hwmon: add PCIe temperature support " Karthik Poosa
2026-10-09 12:03 ` [PATCH v9 14/14] drm/xe/hwmon: Simplify temperature channels config Karthik Poosa
2026-10-09 12:17 ` ✓ CI.KUnit: success for drm/xe/hwmon: Update hwmon thermal mailbox (rev6) Patchwork
2026-10-09 13:42 ` ✓ Xe.CI.BAT: " Patchwork
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=sashiko-outbox-165508@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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