Currently, we attempt to pin stolen memory using the ggtt address. This
doesn't appear to actually read the framebuffer that was setup by the
bios. Instead, we have to use the underlying physical address offset
within stolen memory.

Signed-off-by: Juasheem Sultan <[email protected]>
---
 drivers/gpu/drm/xe/display/xe_plane_initial.c | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/display/xe_plane_initial.c 
b/drivers/gpu/drm/xe/display/xe_plane_initial.c
index 94f00def811b..2b84d0cc97e3 100644
--- a/drivers/gpu/drm/xe/display/xe_plane_initial.c
+++ b/drivers/gpu/drm/xe/display/xe_plane_initial.c
@@ -22,6 +22,7 @@
 #include "intel_plane.h"
 #include "intel_plane_initial.h"
 #include "xe_bo.h"
+#include "xe_ttm_stolen_mgr.h"
 #include "xe_vram_types.h"
 #include "xe_wa.h"
 
@@ -120,7 +121,26 @@ initial_plane_bo(struct xe_device *xe,
 
                if (!stolen)
                        return NULL;
-               phys_base = base;
+
+               /* Read PTE to find physical address backing the GGTT address */
+               u64 pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
+               u64 phys_addr = pte & ~(page_size - 1);
+
+               u64 stolen_base = xe_ttm_stolen_gpu_offset(xe);
+
+               drm_dbg_kms(&xe->drm,
+                       "Stolen Framebuffer base=%x pte=%llx phys_addr=%llx 
stolen_base=%llx\n",
+                        base, pte, phys_addr, stolen_base);
+
+               /* Make sure that the physical address is in the range of 
stolen memory */
+               if (phys_addr >= stolen_base) {
+                       phys_base = phys_addr - stolen_base;
+               } else {
+                       drm_err(&xe->drm, "Stolen memory outside of stolen 
range phys_base=%pa\n",
+                               &phys_base);
+                       return NULL;
+               }
+
                flags |= XE_BO_FLAG_STOLEN;
 
                if (XE_GT_WA(xe_root_mmio_gt(xe), 22019338487_display))
-- 
2.52.0.457.g6b5491de43-goog

Reply via email to