diff mbox series

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

Message ID 20240705145254.3355-17-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>

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@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(-)

Comments

kernel test robot July 6, 2024, 12:06 p.m. UTC | #1
Hi Ville,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-xe/drm-xe-next drm-tip/drm-tip next-20240703]
[cannot apply to drm-intel/for-linux-next-fixes linus/master v6.10-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-i915-fbc-Extract-intel_fbc_has_fences/20240706-041642
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/20240705145254.3355-17-ville.syrjala%40linux.intel.com
patch subject: [PATCH 16/20] drm/i915/fbdev: Extract intel_fbdev_fb_prefer_stolen()
config: x86_64-randconfig-014-20240706 (https://download.01.org/0day-ci/archive/20240706/202407061958.ScN1NFtC-lkp@intel.com/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240706/202407061958.ScN1NFtC-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407061958.ScN1NFtC-lkp@intel.com/

All errors (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/ext4/ext4-inode-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/fat/fat_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nfs/nfsv4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp775.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp855.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp861.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp862.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp863.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp865.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp866.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp869.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp874.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp949.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp950.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ascii.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-3.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-5.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-13.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-celtic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-centeuro.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-iceland.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/cramfs/cramfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/hfs/hfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/qnx4/qnx4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/adfs/adfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in security/keys/trusted-keys/trusted.o
WARNING: modpost: missing MODULE_DESCRIPTION() in security/keys/encrypted-keys/encrypted-keys.o
WARNING: modpost: missing MODULE_DESCRIPTION() in crypto/xor.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/math/prime_numbers.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/zlib_deflate/zlib_deflate.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08_i2c.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/platform_lcd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_accel.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_DAC1064.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_Ti3026.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/vfb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/acpi/platform_profile.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/clk-gate_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/clk-fractional-divider_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/virtio/virtio_dma_buf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/max20411-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/rt4831-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/agp/intel-agp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/agp/intel-gtt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/agp/via-agp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/tlclk.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_kunit_helpers.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_buddy_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_cmdline_parser_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_connector_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_damage_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_dp_mst_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_exec_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_format_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_framebuffer_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_gem_shmem_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_managed_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_mm_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_modes_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_plane_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_probe_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_rect_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tiny/bochs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tiny/cirrus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/drm_panel_orientation_quirks.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-raw-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/arizona.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/pcf50633-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dax/device_dax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dax/dax_cxl.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/scsi/scsi_common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/scsi/BusLogic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/scsi/aha1740.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/scsi/atp870u.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/input/touchscreen/cyttsp_i2c_common.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/input/tests/input_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/lib_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/sdio_uart.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/x86/ibm_rtl.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/x86/firmware_attributes_class.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/platform/x86/siemens/simatic-ipc.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/greybus/greybus.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/bytestream-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/dma-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/inttype-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kfifo/record-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kobject-example.o
WARNING: modpost: missing MODULE_DESCRIPTION() in samples/kobject/kset-example.o
>> ERROR: modpost: "intel_fbdev_fb_prefer_stolen" [drivers/gpu/drm/i915/i915.ko] undefined!
Lucas De Marchi July 9, 2024, 8:28 p.m. UTC | #2
On Fri, Jul 05, 2024 at 05:52:50PM GMT, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@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@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) &&

shouldn't this be inside intel_fbdev_fb_prefer_stolen()?

And also pull the same logic on the xe side a few patches after this.

Lucas De Marchi

>+		    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
>
Shankar, Uma July 10, 2024, 8:51 a.m. UTC | #3
> -----Original Message-----
> From: Intel-xe <intel-xe-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 16/20] drm/i915/fbdev: Extract intel_fbdev_fb_prefer_stolen()
> 
> From: Ville Syrjälä <ville.syrjala@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@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
Ville Syrjälä July 10, 2024, 11:47 a.m. UTC | #4
On Tue, Jul 09, 2024 at 03:28:15PM -0500, Lucas De Marchi wrote:
> On Fri, Jul 05, 2024 at 05:52:50PM GMT, Ville Syrjälä wrote:
> >From: Ville Syrjälä <ville.syrjala@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@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) &&
> 
> shouldn't this be inside intel_fbdev_fb_prefer_stolen()?

That would also apply it to the BIOS fb takeover, so change the
behaviour. The correct answer is likely just removing the MTL check
entirely, but I left that out for now to avoid too many functional
changes.

> 
> And also pull the same logic on the xe side a few patches after this.
> 
> Lucas De Marchi
> 
> >+		    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
> >
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 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) &&
+		    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;
 	}