From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Simon Richter <Simon.Richter@hogyros.de>,
Matthew Brost <matthew.brost@intel.com>,
Sasha Levin <sashal@kernel.org>,
lucas.demarchi@intel.com, thomas.hellstrom@linux.intel.com,
rodrigo.vivi@intel.com, intel-xe@lists.freedesktop.org
Subject: [PATCH AUTOSEL 6.17] drm/xe: Make page size consistent in loop
Date: Sat, 25 Oct 2025 11:57:36 -0400 [thread overview]
Message-ID: <20251025160905.3857885-225-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>
From: Simon Richter <Simon.Richter@hogyros.de>
[ Upstream commit b85bb2d677153d990924d31be9416166d22382eb ]
If PAGE_SIZE != XE_PAGE_SIZE (which is currently locked behind
CONFIG_BROKEN), this would generate the wrong number of PDEs.
Since these PDEs are consumed by the GPU, the GPU page size needs to be
used.
Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250818064806.2835-1-Simon.Richter@hogyros.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes
- The loop that writes PDEs uses the host `PAGE_SIZE` instead of the
GPU page size `XE_PAGE_SIZE`, causing an incorrect PDE count when
they differ. In 6.17.1, this is at
drivers/gpu/drm/xe/xe_migrate.c:292:
- Current: for (i = 0; i < map_ofs / PAGE_SIZE; i++) {
- Intended: for (i = 0; i < map_ofs / XE_PAGE_SIZE; i++) {
- The PDEs are consumed by the GPU and the offsets encoded for each
entry already use `XE_PAGE_SIZE`
(drivers/gpu/drm/xe/xe_migrate.c:293–297), so the loop bound must
match that unit.
- Why it matters
- When `PAGE_SIZE != XE_PAGE_SIZE` (e.g., 64K host pages vs 4K GPU
pages), the loop iterates too few times (by a factor of `PAGE_SIZE /
XE_PAGE_SIZE`), leaving a large portion of PDEs unwritten. That
results in incomplete page table coverage and GPU faults/hangs when
accessing those unmapped regions. The fix enforces GPU page
granularity for the loop count, which is the only correct
interpretation since the GPU page tables and the offsets (i *
XE_PAGE_SIZE) are in GPU page units.
- The rest of the function already treats `map_ofs` in GPU page units:
- PDE setup for upper levels uses `XE_PAGE_SIZE`
(drivers/gpu/drm/xe/xe_migrate.c:285–288).
- The VM suballocator capacity is computed with `map_ofs /
XE_PAGE_SIZE` (drivers/gpu/drm/xe/xe_migrate.c:356–357).
- This change removes an inconsistency within the same function and
aligns the loop with how `map_ofs` is used elsewhere.
- Scope and risk
- One-line change, confined to xe migrate VM setup
(`xe_migrate_prepare_vm()`), no API or architectural changes.
- On the common 4K-host-page configurations, `PAGE_SIZE ==
XE_PAGE_SIZE`, so behavior is identical. Risk of regression on
mainstream builds is effectively zero.
- On kernels where `PAGE_SIZE != XE_PAGE_SIZE`, it fixes real
misprogramming of PDEs that can manifest as GPU page faults/hangs.
- Current gating and impact
- `DRM_XE` Kconfig currently depends on `PAGE_SIZE_4KB || COMPILE_TEST
|| BROKEN` (drivers/gpu/drm/xe/Kconfig: depends on PAGE_SIZE_4KB ||
COMPILE_TEST || BROKEN). The commit message notes this path is
presently behind `CONFIG_BROKEN`. Even so, this is a correctness bug
that becomes user-visible as soon as non-4K is enabled, and it is
harmless on 4K systems.
- Stable criteria
- Fixes a clear bug in page table programming that can affect users
when the constraint is relaxed or under non-4K configurations.
- Minimal, well-contained change with no feature additions, and no
architectural rewrites.
- No adverse side effects; only enforces correct unit semantics.
- Reviewed by xe maintainers according to the commit tags.
Summary: Replace `map_ofs / PAGE_SIZE` with `map_ofs / XE_PAGE_SIZE` in
the PDE emission loop (drivers/gpu/drm/xe/xe_migrate.c:292) to make the
loop’s unit consistent with GPU page size and the rest of the function’s
logic. This is an obvious, low-risk bugfix suitable for stable backport.
drivers/gpu/drm/xe/xe_migrate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index 9b1e3dce1aea3..2a627ed64b8f8 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -291,7 +291,7 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
}
/* Write PDE's that point to our BO. */
- for (i = 0; i < map_ofs / PAGE_SIZE; i++) {
+ for (i = 0; i < map_ofs / XE_PAGE_SIZE; i++) {
entry = vm->pt_ops->pde_encode_bo(bo, (u64)i * XE_PAGE_SIZE);
xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE +
--
2.51.0
next prev parent reply other threads:[~2025-10-25 16:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe/pcode: Initialize data0 for pcode read routine Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: improve dma-resv handling for backup object Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: Extend wa_13012615864 to additional Xe2 and Xe3 platforms Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe/ptl: Apply Wa_16026007364 Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] drm/xe: Set GT as wedged before sending wedged uevent Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] drm/xe/i2c: Enable bus mastering Sasha Levin
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17] drm/xe/configfs: Enforce canonical device names Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] drm/xe: Extend Wa_22021007897 to Xe3 platforms Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] drm/xe: Cancel pending TLB inval workers on teardown Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] drm/xe/guc: Increase GuC crash dump buffer size Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] drm/xe/wcl: Extend L3bank mask workaround Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-6.12] drm/xe/guc: Set upper limit of H2G retries over CTB Sasha Levin
2025-10-25 15:57 ` Sasha Levin [this message]
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] drm/xe/guc: Add devm release action to safely tear down CT Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] drm/xe/pf: Program LMTT directory pointer on all GTs within a tile Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] drm/xe/guc: Always add CT disable action during second init step Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17] drm/xe/pf: Don't resume device from restart worker Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] drm/xe/guc: Return an error code if the GuC load fails Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] drm/xe: Ensure GT is in C0 during resumes Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17] drm/xe: rework PDE PAT index selection Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-6.12] drm/xe/guc: Add more GuC load error status codes Sasha Levin
2025-10-25 16:01 ` [PATCH AUTOSEL 6.17-6.12] drm/xe: Fix oops in xe_gem_fault when running core_hotunplug test Sasha Levin
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=20251025160905.3857885-225-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Simon.Richter@hogyros.de \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.brost@intel.com \
--cc=patches@lists.linux.dev \
--cc=rodrigo.vivi@intel.com \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.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