]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset
authorMaarten Lankhorst <dev@lankhorst.se>
Mon, 5 May 2025 12:19:22 +0000 (14:19 +0200)
committerMaarten Lankhorst <dev@lankhorst.se>
Mon, 9 Jun 2025 08:24:23 +0000 (10:24 +0200)
Split the GGTT PTE readout to a separate function, this is useful for
adding testcases in the next commit, and also cleaner than manually
reading out GGTT.

Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Link: https://lore.kernel.org/r/20250505121924.921544-10-dev@lankhorst.se
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
drivers/gpu/drm/xe/display/xe_plane_initial.c
drivers/gpu/drm/xe/xe_ggtt.c
drivers/gpu/drm/xe/xe_ggtt.h

index 6502b82741732cae2aa99954eed00720c54dc834..59b2ff2026d473d2e0c7affe56e8d690e6a18f44 100644 (file)
@@ -87,12 +87,8 @@ initial_plane_bo(struct xe_device *xe,
 
        base = round_down(plane_config->base, page_size);
        if (IS_DGFX(xe)) {
-               u64 __iomem *gte = tile0->mem.ggtt->gsm;
-               u64 pte;
+               u64 pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
 
-               gte += base / XE_PAGE_SIZE;
-
-               pte = ioread64(gte);
                if (!(pte & XE_GGTT_PTE_DM)) {
                        drm_err(&xe->drm,
                                "Initial plane programming missing DM bit\n");
index b4b3ecd1c1b9e6bfbff75970dbc105b7b8aa6164..ad0479c96b217040523ea476446e22c1fbf67889 100644 (file)
@@ -957,3 +957,15 @@ u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt,
 {
        return ggtt->pt_ops->pte_encode_flags(bo, pat_index);
 }
+
+/**
+ * xe_ggtt_read_pte - Read a PTE from the GGTT
+ * @ggtt: &xe_ggtt
+ * @offset: the offset for which the mapping should be read.
+ *
+ * Used by testcases, and by display reading out an inherited bios FB.
+ */
+u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)
+{
+       return ioread64(ggtt->gsm + (offset / XE_PAGE_SIZE));
+}
index fc4ffb090a5a04ab557b29f18aa77450fd4ef8f1..dd43c82f4cade30578c4c74fea294545dd31ebc8 100644 (file)
@@ -51,5 +51,6 @@ void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
 #endif
 
 u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
+u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
 
 #endif