Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/hwmon: Store mailbox temperature data as bytes
@ 2026-10-23 10:36 Mallesh Koujalagi
  2026-10-23 11:33 ` ✓ CI.KUnit: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Mallesh Koujalagi @ 2026-10-23 10:36 UTC (permalink / raw)
  To: intel-xe, rodrigo.vivi, matthew.brost
  Cc: anshuman.gupta, badal.nilawar, vinay.belgaumkar, riana.tauro,
	karthik.poosa, sk.anirban, raag.jadav, aravind.iddamsetty,
	Mallesh Koujalagi

Store pcode mailbox temperature data directly in the byte array
using put_unaligned_le32() instead of accessing it through
different views of the same storage.

This keeps the layout unchanged and makes the data access
consistent and endian-safe.

Fixes: ca6e33701de8 ("drm/xe/hwmon: Fix thermal sensor data handling")
Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
---
 drivers/gpu/drm/xe/xe_hwmon.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
index 42acfeb8818c..7bb1223dc30b 100644
--- a/drivers/gpu/drm/xe/xe_hwmon.c
+++ b/drivers/gpu/drm/xe/xe_hwmon.c
@@ -7,6 +7,7 @@
 #include <linux/hwmon.h>
 #include <linux/jiffies.h>
 #include <linux/types.h>
+#include <linux/unaligned.h>
 #include <linux/units.h>
 
 #include <drm/drm_managed.h>
@@ -165,12 +166,12 @@ struct xe_hwmon_thermal_info {
 	bool available[CHANNEL_MAX];
 	/** @msu_mask: VRAM subsystem enable mask read from MMIO */
 	u32 msu_mask;
-	union {
-		/** @value: per-sensor raw mailbox temperature; bit7=sign, bits6:0=magnitude */
-		u8 value[U8_MAX + 1];
-		/** @dword: sensor values as little-endian dwords, u32-aligned for pcode reads */
-		__le32 dword[DIV_ROUND_UP(U8_MAX + 1, sizeof(u32))];
-	};
+	/**
+	 * @value: per-sensor raw mailbox temperature; bit7=sign, bits6:0=magnitude.
+	 * Written one dword at a time via put_unaligned_le32() to
+	 * avoid inconsistent union access between dword and byte views.
+	 */
+	u8 value[U8_MAX + 1];
 	/** @vram_label: vram label names, dynamically allocated based on vram_count */
 	char (*vram_label)[MAX_LABEL_SIZE];
 };
@@ -995,7 +996,7 @@ static int get_mc_temp(struct xe_hwmon *hwmon, long *val)
 		if (ret)
 			return ret;
 		drm_dbg(&hwmon->xe->drm, "thermal data for group %d val 0x%x\n", i, data);
-		hwmon->temp.dword[i] = cpu_to_le32(data);
+		put_unaligned_le32(data, &hwmon->temp.value[i * sizeof(u32)]);
 	}
 
 	for (i = start; i < end; i++) {
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-28 16:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23 10:36 [PATCH] drm/xe/hwmon: Store mailbox temperature data as bytes Mallesh Koujalagi
2026-10-23 11:33 ` ✓ CI.KUnit: success for " Patchwork
2026-10-23 12:09 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-23 16:16 ` ✓ Xe.CI.FULL: " Patchwork
2026-10-26 11:17 ` [PATCH] " Poosa, Karthik
2026-10-26 11:54   ` Mallesh, Koujalagi
2026-10-28 11:36     ` Poosa, Karthik
2026-10-28 13:06       ` Mallesh, Koujalagi
2026-10-28 16:02         ` Poosa, Karthik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox