diff mbox series

[9/9] drm/i915/fbc: Allocate llb before cfb

Message ID 20210610183237.3920-10-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/fbc: Clean up cfb allocation code | expand

Commit Message

Ville Syrjala June 10, 2021, 6:32 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Since the llb allocation has a fixed size, let's grab it before
the potentially variable sized cfb. That should avoid some allocation
failure cases once we allow different compression ratios for FBC1.

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

Comments

Souza, Jose June 18, 2021, 9:07 p.m. UTC | #1
whole series is
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>

On Thu, 2021-06-10 at 21:32 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Since the llb allocation has a fixed size, let's grab it before
> the potentially variable sized cfb. That should avoid some allocation
> failure cases once we allow different compression ratios for FBC1.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_fbc.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c
> index b6bfb4439a8b..7dc72e4a4656 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbc.c
> @@ -492,6 +492,13 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv,
>  	drm_WARN_ON(&dev_priv->drm,
>  		    drm_mm_node_allocated(&fbc->compressed_llb));
>  
> +	if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv)) {
> +		ret = i915_gem_stolen_insert_node(dev_priv, &fbc->compressed_llb,
> +						  4096, 4096);
> +		if (ret)
> +			goto err;
> +	}
> +
>  	ret = find_compression_limit(dev_priv, size, fb_cpp);
>  	if (!ret)
>  		goto err_llb;
> @@ -502,22 +509,15 @@ static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv,
>  
>  	fbc->limit = ret;
>  
> -	if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv)) {
> -		ret = i915_gem_stolen_insert_node(dev_priv, &fbc->compressed_llb,
> -						  4096, 4096);
> -		if (ret)
> -			goto err_fb;
> -	}
> -
>  	drm_dbg_kms(&dev_priv->drm,
>  		    "reserved %llu bytes of contiguous stolen space for FBC, limit: %d\n",
>  		    fbc->compressed_fb.size, fbc->limit);
>  
>  	return 0;
>  
> -err_fb:
> -	i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb);
>  err_llb:
> +	i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_llb);
> +err:
>  	if (drm_mm_initialized(&dev_priv->mm.stolen))
>  		drm_info_once(&dev_priv->drm, "not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size);
>  	return -ENOSPC;
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c
index b6bfb4439a8b..7dc72e4a4656 100644
--- a/drivers/gpu/drm/i915/display/intel_fbc.c
+++ b/drivers/gpu/drm/i915/display/intel_fbc.c
@@ -492,6 +492,13 @@  static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv,
 	drm_WARN_ON(&dev_priv->drm,
 		    drm_mm_node_allocated(&fbc->compressed_llb));
 
+	if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv)) {
+		ret = i915_gem_stolen_insert_node(dev_priv, &fbc->compressed_llb,
+						  4096, 4096);
+		if (ret)
+			goto err;
+	}
+
 	ret = find_compression_limit(dev_priv, size, fb_cpp);
 	if (!ret)
 		goto err_llb;
@@ -502,22 +509,15 @@  static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv,
 
 	fbc->limit = ret;
 
-	if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv)) {
-		ret = i915_gem_stolen_insert_node(dev_priv, &fbc->compressed_llb,
-						  4096, 4096);
-		if (ret)
-			goto err_fb;
-	}
-
 	drm_dbg_kms(&dev_priv->drm,
 		    "reserved %llu bytes of contiguous stolen space for FBC, limit: %d\n",
 		    fbc->compressed_fb.size, fbc->limit);
 
 	return 0;
 
-err_fb:
-	i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb);
 err_llb:
+	i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_llb);
+err:
 	if (drm_mm_initialized(&dev_priv->mm.stolen))
 		drm_info_once(&dev_priv->drm, "not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size);
 	return -ENOSPC;