[PATCH 16/20] drm/i915/fbdev: Extract intel_fbdev_fb_prefer_stolen()

Shankar, Uma uma.shankar at intel.com
Wed Jul 10 08:51:06 UTC 2024



> -----Original Message-----
> From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Ville Syrjala
> Sent: Friday, July 5, 2024 8:23 PM
> To: intel-gfx at lists.freedesktop.org
> Cc: intel-xe at lists.freedesktop.org
> Subject: [PATCH 16/20] drm/i915/fbdev: Extract intel_fbdev_fb_prefer_stolen()
> 
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Consolidate the "should we allocate fbdev fb in stolen?"
> check into a helper function. Makes it easier to change the heuristics without
> having to change so many places.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_fbdev_fb.c | 24 ++++++++++++-------
> drivers/gpu/drm/i915/display/intel_fbdev_fb.h |  5 +++-
>  .../drm/i915/display/intel_plane_initial.c    | 10 +++-----
>  3 files changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> index 497525ef9668..0a6445acb100 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbdev_fb.c
> @@ -11,6 +11,19 @@
>  #include "intel_display_types.h"
>  #include "intel_fbdev_fb.h"
> 
> +bool intel_fbdev_fb_prefer_stolen(struct intel_display *display,
> +				  unsigned int size)
> +{
> +	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; }
> +
>  struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,
>  					       struct drm_fb_helper_surface_size
> *sizes)  { @@ -42,14 +55,9 @@ struct intel_framebuffer
> *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,
> 
> I915_BO_ALLOC_CONTIGUOUS |
>  						  I915_BO_ALLOC_USER);
>  	} else {
> -		/*
> -		 * 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.
> -		 *
> -		 * Also skip stolen on MTL as Wa_22018444074 mitigation.
> -		 */
> -		if (!(IS_METEORLAKE(dev_priv)) && size * 2 < dev_priv-
> >dsm.usable_size)
> +		/* skip stolen on MTL as Wa_22018444074 mitigation */
> +		if (!IS_METEORLAKE(dev_priv) &&

Its better to move this platform check as well to the helper.

Also maybe we can extend this to LNL+ as well given the limitations (can be a separate change though).
Thoughts ?

> +		    intel_fbdev_fb_prefer_stolen(&dev_priv->display, size))
>  			obj = i915_gem_object_create_stolen(dev_priv, size);
>  		if (IS_ERR(obj))
>  			obj = i915_gem_object_create_shmem(dev_priv, size);
> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.h
> b/drivers/gpu/drm/i915/display/intel_fbdev_fb.h
> index 4832fe688fbf..3b9033bd2160 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.h
> +++ b/drivers/gpu/drm/i915/display/intel_fbdev_fb.h
> @@ -6,16 +6,19 @@
>  #ifndef __INTEL_FBDEV_FB_H__
>  #define __INTEL_FBDEV_FB_H__
> 
> +#include <linux/types.h>
> +
>  struct drm_fb_helper;
>  struct drm_fb_helper_surface_size;
>  struct drm_i915_gem_object;
>  struct drm_i915_private;
>  struct fb_info;
>  struct i915_vma;
> +struct intel_display;
> 
>  struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_fb_helper *helper,
>  					       struct drm_fb_helper_surface_size
> *sizes);  int intel_fbdev_fb_fill_info(struct drm_i915_private *i915, struct fb_info
> *info,
>  			     struct drm_i915_gem_object *obj, struct i915_vma
> *vma);
> -
> +bool intel_fbdev_fb_prefer_stolen(struct intel_display *display,
> +unsigned int size);
>  #endif
> diff --git a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> index ada1792df5b3..4622bb5f3426 100644
> --- a/drivers/gpu/drm/i915/display/intel_plane_initial.c
> +++ b/drivers/gpu/drm/i915/display/intel_plane_initial.c
> @@ -11,6 +11,7 @@
>  #include "intel_display.h"
>  #include "intel_display_types.h"
>  #include "intel_fb.h"
> +#include "intel_fbdev_fb.h"
>  #include "intel_frontbuffer.h"
>  #include "intel_plane_initial.h"
> 
> @@ -160,15 +161,10 @@ initial_plane_vma(struct drm_i915_private *i915,
>  			mem->min_page_size);
>  	size -= base;
> 
> -	/*
> -	 * 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) &&
>  	    mem == i915->mm.stolen_region &&
> -	    size * 2 > i915->dsm.usable_size) {
> -		drm_dbg_kms(&i915->drm, "Initial FB size exceeds half of stolen,
> discarding\n");
> +	    !intel_fbdev_fb_prefer_stolen(&i915->display, size)) {
> +		drm_dbg_kms(&i915->drm, "Initial FB size uses too much stolen,
> +discarding\n");
>  		return NULL;
>  	}
> 
> --
> 2.44.2



More information about the Intel-gfx mailing list