From: "Anoop, Vijay" <anoop.c.vijay@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: umesh.nerlige.ramappa@intel.com, badal.nilawar@intel.com,
rodrigo.vivi@intel.com, aravind.iddamsetty@intel.com,
riana.tauro@intel.com, anshuman.gupta@intel.com,
mallesh.koujalagi@intel.com, michal.wajdeczko@intel.com,
matthew.d.roper@intel.com, michael.j.ruhl@intel.com,
paul.e.luse@intel.com, mohamed.mansoor.v@intel.com,
kam.nasim@intel.com, anoop.c.vijay@intel.com
Subject: [PATCH v1] drm/xe/sysctrl: Fix byte-order reversal in mailbox frame transport
Date: Mon, 21 Sep 2026 04:30:31 -0700 [thread overview]
Message-ID: <20260921113030.4075591-2-anoop.c.vijay@intel.com> (raw)
From: Anoop Vijay <anoop.c.vijay@intel.com>
sysctrl_write_frame()/sysctrl_read_frame() memcpy() mailbox payloads
into a u32 array before transferring them through the mailbox data
registers. This treats a little-endian byte stream as host-endian u32
values, causing word byte-swapping on big-endian systems.
Use get_unaligned_le32()/put_unaligned_le32() to convert each mailbox
word explicitly, preserving the little-endian wire format regardless
of host endianness.
Reported-by: Sashiko AI Reviewer <sashiko-bot@kernel.org>
Link: https://patchwork.freedesktop.org/patch/751309/?series=172513&rev=5
Signed-off-by: Anoop Vijay <anoop.c.vijay@intel.com>
---
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c b/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
index 72baf1aa4b3a..d5a34a24a0d6 100644
--- a/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
+++ b/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
@@ -8,6 +8,7 @@
#include <linux/minmax.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/unaligned.h>
#include "regs/xe_sysctrl_regs.h"
#include "xe_device.h"
@@ -63,16 +64,16 @@ static int sysctrl_write_frame(struct xe_sysctrl *sc, const void *frame,
SYSCTRL_MB_DATA0, SYSCTRL_MB_DATA1, SYSCTRL_MB_DATA2, SYSCTRL_MB_DATA3
};
struct xe_device *xe = sc_to_xe(sc);
- u32 val[XE_SYSCTRL_MB_FRAME_SIZE / sizeof(u32)] = {0};
+ u8 buf[XE_SYSCTRL_MB_FRAME_SIZE] = {};
u32 dw = DIV_ROUND_UP(len, sizeof(u32));
u32 i;
xe_assert(xe, len > 0 && len <= XE_SYSCTRL_MB_FRAME_SIZE);
- memcpy(val, frame, len);
+ memcpy(buf, frame, len);
for (i = 0; i < dw; i++)
- xe_mmio_write32(sc->mmio, regs[i], val[i]);
+ xe_mmio_write32(sc->mmio, regs[i], get_unaligned_le32(buf + i * sizeof(u32)));
return 0;
}
@@ -84,16 +85,16 @@ static int sysctrl_read_frame(struct xe_sysctrl *sc, void *frame,
SYSCTRL_MB_DATA0, SYSCTRL_MB_DATA1, SYSCTRL_MB_DATA2, SYSCTRL_MB_DATA3
};
struct xe_device *xe = sc_to_xe(sc);
- u32 val[XE_SYSCTRL_MB_FRAME_SIZE / sizeof(u32)] = {0};
+ u8 buf[XE_SYSCTRL_MB_FRAME_SIZE] = {};
u32 dw = DIV_ROUND_UP(len, sizeof(u32));
u32 i;
xe_assert(xe, len > 0 && len <= XE_SYSCTRL_MB_FRAME_SIZE);
for (i = 0; i < dw; i++)
- val[i] = xe_mmio_read32(sc->mmio, regs[i]);
+ put_unaligned_le32(xe_mmio_read32(sc->mmio, regs[i]), buf + i * sizeof(u32));
- memcpy(frame, val, len);
+ memcpy(frame, buf, len);
return 0;
}
--
2.43.0
next reply other threads:[~2026-09-21 11:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 11:30 Anoop, Vijay [this message]
2026-09-21 11:41 ` [PATCH v1] drm/xe/sysctrl: Fix byte-order reversal in mailbox frame transport sashiko-bot
2026-09-21 11:53 ` ✓ CI.KUnit: success for " Patchwork
2026-09-21 13:40 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-09-21 18:03 ` ✗ Xe.CI.FULL: " 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=20260921113030.4075591-2-anoop.c.vijay@intel.com \
--to=anoop.c.vijay@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=aravind.iddamsetty@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=kam.nasim@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michael.j.ruhl@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=mohamed.mansoor.v@intel.com \
--cc=paul.e.luse@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=umesh.nerlige.ramappa@intel.com \
/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