diff mbox

drm/i915: Do not WARN_ON with small framebuffers.

Message ID 20180116155331.75175-1-maarten.lankhorst@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst Jan. 16, 2018, 3:53 p.m. UTC
It's perfectly legal to create a fb with stride < 512, and one of
the kms_plane_scaling subtests creates a very small fb.

Downgrade the WARN_ON to a simple check check, and because this
function is potentially called on every atomic update/pageflip,
downgrade the other WARN_ON to a WARN_ON_ONCE, and do the right
thing here.

Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_fbc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Rodrigo Vivi Jan. 16, 2018, 11:57 p.m. UTC | #1
On Tue, Jan 16, 2018 at 03:53:31PM +0000, Maarten Lankhorst wrote:
> It's perfectly legal to create a fb with stride < 512, and one of
> the kms_plane_scaling subtests creates a very small fb.
> 
> Downgrade the WARN_ON to a simple check check, and because this
> function is potentially called on every atomic update/pageflip,
> downgrade the other WARN_ON to a WARN_ON_ONCE, and do the right
> thing here.
> 
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_fbc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index 7a64405f4514..c4e924e41db3 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -668,11 +668,13 @@ void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)
>  static bool stride_is_valid(struct drm_i915_private *dev_priv,
>  			    unsigned int stride)
>  {
> -	/* These should have been caught earlier. */
> -	WARN_ON(stride < 512);
> -	WARN_ON((stride & (64 - 1)) != 0);
> +	/* This should have been caught earlier. */
> +	if (WARN_ON_ONCE((stride & (64 - 1)) != 0))
> +		return false;
>  
>  	/* Below are the additional FBC restrictions. */
> +	if (stride < 512)
> +		return false;
>  
>  	if (IS_GEN2(dev_priv) || IS_GEN3(dev_priv))
>  		return stride == 4096 || stride == 8192;
> -- 
> 2.15.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Maarten Lankhorst Jan. 17, 2018, 9:15 a.m. UTC | #2
Op 17-01-18 om 00:57 schreef Rodrigo Vivi:
> On Tue, Jan 16, 2018 at 03:53:31PM +0000, Maarten Lankhorst wrote:
>> It's perfectly legal to create a fb with stride < 512, and one of
>> the kms_plane_scaling subtests creates a very small fb.
>>
>> Downgrade the WARN_ON to a simple check check, and because this
>> function is potentially called on every atomic update/pageflip,
>> downgrade the other WARN_ON to a WARN_ON_ONCE, and do the right
>> thing here.
>>
>> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>
Thanks, pushed. :)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
index 7a64405f4514..c4e924e41db3 100644
--- a/drivers/gpu/drm/i915/intel_fbc.c
+++ b/drivers/gpu/drm/i915/intel_fbc.c
@@ -668,11 +668,13 @@  void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)
 static bool stride_is_valid(struct drm_i915_private *dev_priv,
 			    unsigned int stride)
 {
-	/* These should have been caught earlier. */
-	WARN_ON(stride < 512);
-	WARN_ON((stride & (64 - 1)) != 0);
+	/* This should have been caught earlier. */
+	if (WARN_ON_ONCE((stride & (64 - 1)) != 0))
+		return false;
 
 	/* Below are the additional FBC restrictions. */
+	if (stride < 512)
+		return false;
 
 	if (IS_GEN2(dev_priv) || IS_GEN3(dev_priv))
 		return stride == 4096 || stride == 8192;