[PATCH] drm/xe: Exclude wopcm region from stolen memory on TGL/DG1

Zhenyu Yang <[email protected]>
Newsgroups org.kernel.feeds.b4-sent,org.freedesktop.lists.dri-devel,org.freedesktop.lists.intel-xe
Message-ID <[email protected]>
Top of DSM contains the WOPCM which shouldn't be accessed. Carve it out
from the stolen memory on TGL/DG1 as well.  This fixes excessive ATS faults
on an RPL laptop since v7.2-rc1.

Fixes: 1c76fa517214 ("drm/xe: Convert stolen memory over to ttm_range_manager")
Signed-off-by: Zhenyu Yang <[email protected]>
---
 drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index 5e9070739e65..75f4d064d711 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -180,12 +180,22 @@ extern struct resource intel_graphics_stolen_res;
 static u64 detect_stolen(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
 {
 #ifdef CONFIG_X86
+	u64 stolen_size, wopcm_size;
+
 	/* Map into GGTT */
 	mgr->io_base = pci_resource_start(to_pci_dev(xe->drm.dev), 2);
 
 	/* Stolen memory is x86 only */
 	mgr->stolen_base = intel_graphics_stolen_res.start;
-	return resource_size(&intel_graphics_stolen_res);
+	stolen_size = resource_size(&intel_graphics_stolen_res);
+
+	/* Carve out the top of DSM as it contains the reserved WOPCM region */
+	wopcm_size = get_wopcm_size(xe);
+	if (drm_WARN_ON(&xe->drm, !wopcm_size))
+		return 0;
+
+	xe_assert(xe, stolen_size >= wopcm_size);
+	return stolen_size - wopcm_size;
 #else
 	return 0;
 #endif

---
base-commit: db2ddb87143519e20a95aa36c60b36107b736a58
change-id: 20260811-fix-xe-ttm-4a9713d7cca9
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.