drm/xe/stolen: Exclude reserved lmem portion
authorNirmoy Das <nirmoy.das@intel.com>
Wed, 8 Mar 2023 16:23:22 +0000 (17:23 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:29:44 +0000 (18:29 -0500)
The address set by firmware in GEN12_DSMBASE in driver initialization
doesn't mean "anything above that and until end of lmem is part of DSM".
In fact, there may be a few KB that is not part of DSM on the end of
lmem. How large is that space is platform-dependent, but since it's
always less than the DSM granularity, it can be simplified by simply
aligning the size down.

Suggested-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c

index 2e8d07ad42aee488e9d5bb5f3ba1d7ec5891aa98..1116e217ebc29a73279849a21a08b9da903aa1ca 100644 (file)
@@ -88,7 +88,13 @@ static s64 detect_bar2_dgfx(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)
        if (mgr->stolen_base + stolen_size <= pci_resource_len(pdev, 2))
                mgr->io_base = pci_resource_start(pdev, 2) + mgr->stolen_base;
 
-       return stolen_size;
+       /*
+        * There may be few KB of platform dependent reserved memory at the end
+        * of lmem which is not part of the DSM. Such reserved memory portion is
+        * always less then DSM granularity so align down the stolen_size to DSM
+        * granularity to accommodate such reserve lmem portion.
+        */
+       return ALIGN_DOWN(stolen_size, SZ_1M);
 }
 
 static u32 detect_bar2_integrated(struct xe_device *xe, struct xe_ttm_stolen_mgr *mgr)