Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jan Maslak" <jan.maslak@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 4/4] drm/xe/tests: Add xe_migrate_access_memory subtest
Date: Wed, 14 Oct 2026 14:45:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-171443@kernel.org> (raw)
In-Reply-To: <20261014142706.598490-5-jan.maslak@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] xe/tests: Endianness assumption in verify_access_memory_read()
- [Low] xe/tests: Unreachable dead code in unaligned_offset generation
--

commit 9484a3b8a65a7889a267c6cc520be578ff0d0b1f
Author: Jan Maslak <jan.maslak@intel.com>

drm/xe/tests: Add xe_migrate_access_memory subtest

This commit adds a new xe_migrate KUnit subtest to verify VRAM to SRAM
migration behavior. It specifically tests scenarios where the destination
address or the source buffer object offset is not 4-byte aligned.

> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
[ ... ]
> @@ -770,9 +773,308 @@ static void xe_validate_ccs_kunit(struct kunit *test)
> +static bool verify_access_memory_read(struct kunit *test, u8 *buf,
> +				      u32 buf_start, u32 bo_start,
> +				      u32 size, const char *scenario)
> +{
> +	u32 j;
> +
> +	for (j = 0; j < size; j++) {
> +		u32 bo_byte_offset = bo_start + j;
> +		u32 byte_in_cell = bo_byte_offset % sizeof(u32);
> +		u32 cell_idx = bo_byte_offset / sizeof(u32);
> +		u32 cell_value = cell_idx;
> +		u8 expected_byte = (cell_value >> (byte_in_cell * 8)) & 0xFF;

[Severity: Low]
Will this byte extraction logic fail on big-endian architectures?

The test buffer is primed using a host-endian assignment in
access_memory_test_run_tile():

	for (j = 0; j < ACCESS_MEM_NUM_CELLS; j++)
		((u32 *)buf)[j] = j;

However, extracting the expected byte using a bitwise right shift
implicitly assumes a little-endian memory layout (where byte 0 is the
least significant byte). On big-endian systems, the physical byte
sequence in memory won't match this extraction, causing spurious
test failures.

Should this either use cpu_to_le32(j) when priming the buffer, or use
an endian-aware extraction here?

[ ... ]
> +static void access_memory_test_run_tile(struct xe_device *xe,
> +					struct xe_tile *tile,
> +					struct kunit *test,
> +					bool use_random_offset)
> +{
> +	struct drm_exec *exec = XE_VALIDATION_OPT_OUT;
> +	unsigned int bo_flags = XE_BO_FLAG_VRAM_IF_DGFX(tile);
> +	struct xe_migrate *m = tile->migrate;
> +	u32 j, unaligned_offset;
> +	struct xe_bo *bo;
> +	long timeout;
> +	u8 *buf;
> +	int ret;
> +
> +	if (use_random_offset) {
> +		unaligned_offset = get_random_u32() % (ACCESS_MEM_BO_SIZE / 2);
> +		/* Ensure the offset is not 4-byte aligned */
> +		if (IS_ALIGNED(unaligned_offset, 4))
> +			unaligned_offset |= 2;
> +		if (!unaligned_offset)
> +			unaligned_offset = 3;

[Severity: Low]
Is this condition reachable?

If unaligned_offset is initially 0 (which is 4-byte aligned), the
previous check will execute unaligned_offset |= 2, making it 2. Since
unaligned_offset is mathematically guaranteed to be strictly greater
than 0 after the alignment check, the zero-check here appears to be
unreachable dead code.

> +	} else {
> +		unaligned_offset = ACCESS_MEM_UNALIGNED_OFFSET;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014142706.598490-1-jan.maslak@intel.com?part=4

  reply	other threads:[~2026-10-14 14:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 14:27 [PATCH v5 0/4] drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY Jan Maslak
2026-10-14 14:27 ` [PATCH v5 1/4] drm/xe/xe_migrate: Fix page tracking in access_memory Jan Maslak
2026-10-14 14:47   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 2/4] drm/xe/xe_migrate: Align MEM_COPY pitch with destination address Jan Maslak
2026-10-14 14:41   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 3/4] drm/xe/xe_migrate: Optimize unaligned access_memory copies Jan Maslak
2026-10-14 14:36   ` sashiko-bot
2026-10-14 14:27 ` [PATCH v5 4/4] drm/xe/tests: Add xe_migrate_access_memory subtest Jan Maslak
2026-10-14 14:45   ` sashiko-bot [this message]
2026-10-14 16:11 ` ✗ CI.checkpatch: warning for drm/xe/xe_migrate: Fix memory corruption with unaligned dst in MEM_COPY (rev5) Patchwork
2026-10-14 16:13 ` ✓ CI.KUnit: success " Patchwork
2026-10-14 23:56 ` ✗ Xe.CI.BAT: failure " 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-171443@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jan.maslak@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