All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Peter Rosin <peda@axentia.se>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	David Airlie <airlied@linux.ie>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drm/atmel-hlcdc: prevent divide by zero
Date: Wed, 9 Jan 2019 11:12:24 +0100	[thread overview]
Message-ID: <20190109101224.GT21184@phenom.ffwll.local> (raw)
In-Reply-To: <20190108123129.20031-1-peda@axentia.se>

On Tue, Jan 08, 2019 at 12:31:36PM +0000, Peter Rosin wrote:
> While trying to temporarily hide a plane, one thing that was attempted
> was to call (from libdrm)
> 
> 	drmModeSetPlane(fd, plane_id, crtc_id, fb_id, 0,
> 			0, 0, 0, 0, 0, 0, 0, 0);
> 
> This call causes a pair of "Division by zero in kernel." messages. Kill
> those messages, but preserve the current behaviour that also happen to
> make the plane disappear with the above call.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> Side note, when comparing with drm_atomic_helper_check_plane_state(), I get
> the feeling that the src rect should be clipped together with the crtc rect
> if/when clipping is needed. That function calls drm_rect_clip_scaled(), and
> the equivalent does not seem to happen here. Should clipping be performed
> on the src rect?

Any reasons atmel can't switch over to that helper? Would compute a nice
->visible state variable for you ...
-Daniel

> 
> Cheers,
> Peter
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index 3cc489b870fe..1bdb30dc218c 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -675,10 +675,16 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
>  		state->crtc_y = 0;
>  	}
>  
> -	patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> -					  state->crtc_w);
> -	patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> -					  state->crtc_h);
> +	if (state->crtc_w)
> +		patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> +						  state->crtc_w);
> +	else
> +		patched_src_w = 0;
> +	if (state->crtc_h)
> +		patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> +						  state->crtc_h);
> +	else
> +		patched_src_h = 0;
>  
>  	hsub = drm_format_horz_chroma_subsampling(fb->format->format);
>  	vsub = drm_format_vert_chroma_subsampling(fb->format->format);
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Peter Rosin <peda@axentia.se>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	David Airlie <airlied@linux.ie>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drm/atmel-hlcdc: prevent divide by zero
Date: Wed, 9 Jan 2019 11:12:24 +0100	[thread overview]
Message-ID: <20190109101224.GT21184@phenom.ffwll.local> (raw)
In-Reply-To: <20190108123129.20031-1-peda@axentia.se>

On Tue, Jan 08, 2019 at 12:31:36PM +0000, Peter Rosin wrote:
> While trying to temporarily hide a plane, one thing that was attempted
> was to call (from libdrm)
> 
> 	drmModeSetPlane(fd, plane_id, crtc_id, fb_id, 0,
> 			0, 0, 0, 0, 0, 0, 0, 0);
> 
> This call causes a pair of "Division by zero in kernel." messages. Kill
> those messages, but preserve the current behaviour that also happen to
> make the plane disappear with the above call.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> Side note, when comparing with drm_atomic_helper_check_plane_state(), I get
> the feeling that the src rect should be clipped together with the crtc rect
> if/when clipping is needed. That function calls drm_rect_clip_scaled(), and
> the equivalent does not seem to happen here. Should clipping be performed
> on the src rect?

Any reasons atmel can't switch over to that helper? Would compute a nice
->visible state variable for you ...
-Daniel

> 
> Cheers,
> Peter
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index 3cc489b870fe..1bdb30dc218c 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -675,10 +675,16 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
>  		state->crtc_y = 0;
>  	}
>  
> -	patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> -					  state->crtc_w);
> -	patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> -					  state->crtc_h);
> +	if (state->crtc_w)
> +		patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> +						  state->crtc_w);
> +	else
> +		patched_src_w = 0;
> +	if (state->crtc_h)
> +		patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> +						  state->crtc_h);
> +	else
> +		patched_src_h = 0;
>  
>  	hsub = drm_format_horz_chroma_subsampling(fb->format->format);
>  	vsub = drm_format_vert_chroma_subsampling(fb->format->format);
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Peter Rosin <peda@axentia.se>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	David Airlie <airlied@linux.ie>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Boris Brezillon <boris.brezillon@bootlin.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drm/atmel-hlcdc: prevent divide by zero
Date: Wed, 9 Jan 2019 11:12:24 +0100	[thread overview]
Message-ID: <20190109101224.GT21184@phenom.ffwll.local> (raw)
In-Reply-To: <20190108123129.20031-1-peda@axentia.se>

On Tue, Jan 08, 2019 at 12:31:36PM +0000, Peter Rosin wrote:
> While trying to temporarily hide a plane, one thing that was attempted
> was to call (from libdrm)
> 
> 	drmModeSetPlane(fd, plane_id, crtc_id, fb_id, 0,
> 			0, 0, 0, 0, 0, 0, 0, 0);
> 
> This call causes a pair of "Division by zero in kernel." messages. Kill
> those messages, but preserve the current behaviour that also happen to
> make the plane disappear with the above call.
> 
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> Side note, when comparing with drm_atomic_helper_check_plane_state(), I get
> the feeling that the src rect should be clipped together with the crtc rect
> if/when clipping is needed. That function calls drm_rect_clip_scaled(), and
> the equivalent does not seem to happen here. Should clipping be performed
> on the src rect?

Any reasons atmel can't switch over to that helper? Would compute a nice
->visible state variable for you ...
-Daniel

> 
> Cheers,
> Peter
> 
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> index 3cc489b870fe..1bdb30dc218c 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
> @@ -675,10 +675,16 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
>  		state->crtc_y = 0;
>  	}
>  
> -	patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> -					  state->crtc_w);
> -	patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> -					  state->crtc_h);
> +	if (state->crtc_w)
> +		patched_src_w = DIV_ROUND_CLOSEST(patched_crtc_w * state->src_w,
> +						  state->crtc_w);
> +	else
> +		patched_src_w = 0;
> +	if (state->crtc_h)
> +		patched_src_h = DIV_ROUND_CLOSEST(patched_crtc_h * state->src_h,
> +						  state->crtc_h);
> +	else
> +		patched_src_h = 0;
>  
>  	hsub = drm_format_horz_chroma_subsampling(fb->format->format);
>  	vsub = drm_format_vert_chroma_subsampling(fb->format->format);
> -- 
> 2.11.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

  reply	other threads:[~2019-01-09 10:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-08 12:31 [PATCH] drm/atmel-hlcdc: prevent divide by zero Peter Rosin
2019-01-08 12:31 ` Peter Rosin
2019-01-09 10:12 ` Daniel Vetter [this message]
2019-01-09 10:12   ` Daniel Vetter
2019-01-09 10:12   ` Daniel Vetter
2019-01-09 11:37   ` Peter Rosin
2019-01-09 11:37     ` Peter Rosin
2019-01-09 12:00     ` Boris Brezillon
2019-01-09 12:00       ` Boris Brezillon
2019-01-09 11:37   ` Boris Brezillon
2019-01-09 11:37     ` Boris Brezillon
2019-01-09 11:37     ` Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190109101224.GT21184@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=alexandre.belloni@bootlin.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.