From: Ville Syrjälä <[email protected]>

Pull the "should we keep the bios fb in stolen?" logic into
into a helper function, same as was done for i915. Gives us
a single place where to tweak the heuristics.

Signed-off-by: Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/xe/display/intel_fbdev_fb.c   | 18 ++++++++++++++++++
 drivers/gpu/drm/xe/display/xe_plane_initial.c |  8 ++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c 
b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
index 816ad13821a8..f7905b382d06 100644
--- a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
+++ b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
@@ -11,6 +11,24 @@
 #include "xe_gt.h"
 #include "xe_ttm_stolen_mgr.h"
 
+bool intel_fbdev_fb_prefer_stolen(struct intel_display *display,
+                                 unsigned int size)
+{
+       struct xe_device *xe = to_xe_device(display->drm);
+       struct ttm_resource_manager *stolen;
+
+       stolen = ttm_manager_type(&xe->ttm, XE_PL_STOLEN);
+       if (!stolen)
+               return false;
+
+       /*
+        * If the FB is too big, just don't use it since fbdev is not very
+        * important and we should probably use that space with FBC or other
+        * features.
+        */
+       return stolen->size >= size * 2;
+}
+
 struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,
                                               struct 
drm_fb_helper_surface_size *sizes)
 {
diff --git a/drivers/gpu/drm/xe/display/xe_plane_initial.c 
b/drivers/gpu/drm/xe/display/xe_plane_initial.c
index 21965cc8a9ca..4c000e95aea5 100644
--- a/drivers/gpu/drm/xe/display/xe_plane_initial.c
+++ b/drivers/gpu/drm/xe/display/xe_plane_initial.c
@@ -15,6 +15,7 @@
 #include "intel_display_types.h"
 #include "intel_fb.h"
 #include "intel_fb_pin.h"
+#include "intel_fbdev_fb.h"
 #include "intel_frontbuffer.h"
 #include "intel_plane_initial.h"
 #include "xe_bo.h"
@@ -104,13 +105,8 @@ initial_plane_bo(struct xe_device *xe,
                phys_base = base;
                flags |= XE_BO_FLAG_STOLEN;
 
-               /*
-                * If the FB is too big, just don't use it since fbdev is not 
very
-                * important and we should probably use that space with FBC or 
other
-                * features.
-                */
                if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) &&
-                   plane_config->size * 2 > stolen->size)
+                   !intel_fbdev_fb_prefer_stolen(&xe->display, 
plane_config->size))
                        return NULL;
        }
 
-- 
2.44.2

Reply via email to