Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Piotr Piórkowski" <piotr.piorkowski@intel.com>,
	"Michal Wajdeczko" <michal.wajdeczko@intel.com>,
	"Michał Winiarski" <michal.winiarski@intel.com>,
	"Stuart Summers" <stuart.summers@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/pf: Program LMTT directory pointer on all GTs within a tile
Date: Sat, 25 Oct 2025 11:57:50 -0400	[thread overview]
Message-ID: <20251025160905.3857885-239-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

From: Piotr Piórkowski <piotr.piorkowski@intel.com>

[ Upstream commit ad69d62588cd6bf8cddaff5e3e2eb1b8dd876d35 ]

Previously, the LMTT directory pointer was only programmed for primary GT
within a tile. However, to ensure correct Local Memory access by VFs,
the LMTT configuration must be programmed on all GTs within the tile.
Lets program the LMTT directory pointer on every GT of the tile
to guarantee proper LMEM access across all GTs on VFs.

HSD: 18042797646
Bspec: 67468
Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Stuart Summers <stuart.summers@intel.com>
Link: https://lore.kernel.org/r/20250805091850.1508240-1-piotr.piorkowski@intel.com
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

YES

- What it fixes
  - The current code only programs the LMTT directory pointer for the
    primary GT of a tile, leaving any additional GTs (e.g., media GT)
    unconfigured. In this tree, that single write is at
    drivers/gpu/drm/xe/xe_lmtt.c:202 where it calls
    xe_mmio_write32(tile->primary_gt, ...).
  - Since LMTT governs LMEM access for VFs, failing to program
    LMEM_CFG/LMTT_DIR_PTR for all GTs can break VF access to LMEM on
    non-primary GTs. The commit message aligns with this: “to ensure
    correct Local Memory access by VFs, the LMTT configuration must be
    programmed on all GTs within the tile.”

- Why the current behavior is insufficient
  - LMTT_DIR_PTR and LMEM_EN are defined in GT register space
    (drivers/gpu/drm/xe/regs/xe_gt_regs.h:429–431), and the comment in
    that header explains the GSI range is replicated for the media GT.
    Writing the LMEM_CFG pointer for only the primary GT does not
    automatically configure the same register instance for the media GT.
  - xe_lmtt_init_hw() is only invoked from the primary (non-media) GT
    init path (drivers/gpu/drm/xe/xe_gt.c:531). With the current single
    write in lmtt_setup_dir_ptr(), the media GT’s instance of LMEM_CFG
    remains unprogrammed.

- What the change does
  - The patch replaces the single write with a loop to program
    LMEM_CFG/LMTT_DIR_PTR for every GT on the tile, ensuring both
    primary and media GTs are configured. In older codebases (as in your
    tree), this maps to performing the same write for `tile->primary_gt`
    and, if present, also for `tile->media_gt`. In newer codebases it
    shows up as for_each_gt_on_tile(...) followed by
    xe_mmio_write32(&gt->mmio, ...).

- Containment and risk
  - Scope is a single helper: lmtt_setup_dir_ptr(). No ABI/UAPI changes,
    no architectural refactoring.
  - The write is guarded by sanity checks (VRAM BO, 64K alignment) and
    performed during PF GT initialization after reset
    (xe_lmtt_init_hw()), i.e., early and in a controlled sequence.
  - Side effects are limited to programming the same register on
    additional GTs. On single-GT tiles, the loop degenerates to one
    write.
  - The register selection already handles platform differences
    (GRAPHICS_VER(xe) >= 20 ? XE2_LMEM_CFG : LMEM_CFG) within the same
    helper (drivers/gpu/drm/xe/xe_lmtt.c:203–204), so no new platform-
    specific branches are introduced.

- User impact and severity
  - Misprogramming LMTT on multi-GT tiles can break LMEM access for VFs
    using media engines, resulting in functional failures or GPU faults
    in SR-IOV scenarios. This is a practical, user-visible bug in
    virtualization setups, not a feature change.

- Backport considerations
  - Applicable stable series: Only those that include the Xe driver and
    SR-IOV PF LMTT support (e.g., v6.8.y and v6.9.y). The XE driver (and
    xe_lmtt.c) is not present in v6.6.y or older, so those are out of
    scope.
  - Minimal adaptation: Older trees (like v6.8/v6.9) do not have
    for_each_gt_on_tile(). The equivalent stable backport is to perform
    the existing write for `tile->primary_gt` and additionally, if non-
    NULL, for `tile->media_gt`. The existing code already uses
    xe_mmio_write32(gt, ...), so the change is straightforward and
    localized.
  - Invocation context: xe_lmtt_init_hw() is called from the primary GT
    init only (drivers/gpu/drm/xe/xe_gt.c:531), so programming all GTs
    inside lmtt_setup_dir_ptr() is the correct place to ensure media GT
    gets configured too.

- Stable rules fit
  - Important bugfix affecting real users (SR-IOV VFs on multi-GT
    tiles).
  - Small and contained patch touching only the Xe PF LMTT
    initialization routine.
  - No new features, no ABI changes, and minimal regression risk.
  - Clear intent and references in the commit message (HSD: 18042797646,
    Bspec: 67468), plus Reviewed-by and lore link.

Conclusion: This is a solid, low-risk bugfix that should be backported
to stable kernels that have the Xe driver and SR-IOV PF LMTT code (e.g.,
6.8.y and 6.9.y).

 drivers/gpu/drm/xe/xe_lmtt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_lmtt.c b/drivers/gpu/drm/xe/xe_lmtt.c
index a2000307d5bf9..a78c9d474a6ef 100644
--- a/drivers/gpu/drm/xe/xe_lmtt.c
+++ b/drivers/gpu/drm/xe/xe_lmtt.c
@@ -195,14 +195,17 @@ static void lmtt_setup_dir_ptr(struct xe_lmtt *lmtt)
 	struct xe_tile *tile = lmtt_to_tile(lmtt);
 	struct xe_device *xe = tile_to_xe(tile);
 	dma_addr_t offset = xe_bo_main_addr(lmtt->pd->bo, XE_PAGE_SIZE);
+	struct xe_gt *gt;
+	u8 id;
 
 	lmtt_debug(lmtt, "DIR offset %pad\n", &offset);
 	lmtt_assert(lmtt, xe_bo_is_vram(lmtt->pd->bo));
 	lmtt_assert(lmtt, IS_ALIGNED(offset, SZ_64K));
 
-	xe_mmio_write32(&tile->mmio,
-			GRAPHICS_VER(xe) >= 20 ? XE2_LMEM_CFG : LMEM_CFG,
-			LMEM_EN | REG_FIELD_PREP(LMTT_DIR_PTR, offset / SZ_64K));
+	for_each_gt_on_tile(gt, tile, id)
+		xe_mmio_write32(&gt->mmio,
+				GRAPHICS_VER(xe) >= 20 ? XE2_LMEM_CFG : LMEM_CFG,
+				LMEM_EN | REG_FIELD_PREP(LMTT_DIR_PTR, offset / SZ_64K));
 }
 
 /**
-- 
2.51.0


  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 ` [PATCH AUTOSEL 6.17] drm/xe: Make page size consistent in loop Sasha Levin
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 ` Sasha Levin [this message]
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-239-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=michal.winiarski@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=piotr.piorkowski@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=stuart.summers@intel.com \
    --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