diff mbox series

[19/20] drm/i915/fbdev: Adjust fbdev stolen mem usage heuristic

Message ID 20240705145254.3355-20-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/{i915, xe}: FBC cleanups + tweak fbdev stolen usage | expand

Commit Message

Ville Syrjälä July 5, 2024, 2:52 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Replace the "1/2 of stolen size" fbdev fb size heuristic with
something a bit more clever, that is ask the FBC code how much
stolen mem it would like to have avaialable for its CFB use.

TODO:
- This doesn't account for the fact that FBC's idea
  usable stolen size might differ from other users of stolen
- Would be nice to share the code with xe, but need to
  figure out how to abstract the stolen size and
  dgpu/lmem stuff

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_fbdev_fb.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Shankar, Uma July 10, 2024, 9:11 a.m. UTC | #1
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville
> Syrjala
> Sent: Friday, July 5, 2024 8:23 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: intel-xe@lists.freedesktop.org
> Subject: [PATCH 19/20] drm/i915/fbdev: Adjust fbdev stolen mem usage heuristic
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Replace the "1/2 of stolen size" fbdev fb size heuristic with something a bit more
> clever, that is ask the FBC code how much stolen mem it would like to have
> avaialable for its CFB use.

Looks Good to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> TODO:
> - This doesn't account for the fact that FBC's idea
>   usable stolen size might differ from other users of stolen
> - Would be nice to share the code with xe, but need to
>   figure out how to abstract the stolen size and
>   dgpu/lmem stuff
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_fbdev_fb.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> index 0a6445acb100..29f3241c9270 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> @@ -16,12 +16,11 @@ bool intel_fbdev_fb_prefer_stolen(struct intel_display
> *display,  {
>  	struct drm_i915_private *i915 = to_i915(display->drm);
> 
> -	/*
> -	 * 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 i915->dsm.usable_size >= size * 2;
> +	if (size > i915->dsm.usable_size)
> +		return false;
> +
> +	/* try to ensure FBC has enough stolen to do its job well */
> +	return i915->dsm.usable_size - size >=
> +intel_fbc_preferred_cfb_size(&i915->display);
>  }
> 
>  struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,
> --
> 2.44.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
index 0a6445acb100..29f3241c9270 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
@@ -16,12 +16,11 @@  bool intel_fbdev_fb_prefer_stolen(struct intel_display *display,
 {
 	struct drm_i915_private *i915 = to_i915(display->drm);
 
-	/*
-	 * 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 i915->dsm.usable_size >= size * 2;
+	if (size > i915->dsm.usable_size)
+		return false;
+
+	/* try to ensure FBC has enough stolen to do its job well */
+	return i915->dsm.usable_size - size >= intel_fbc_preferred_cfb_size(&i915->display);
 }
 
 struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,