From: Daniel Vetter <daniel@ffwll.ch>
To: Jyri Sarha <jsarha@ti.com>
Cc: dri-devel@lists.freedesktop.org,
Darren Etheridge <detheridge@ti.com>,
tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH 03/12] drm/tilcdc: verify fb pitch
Date: Wed, 16 Dec 2015 09:37:04 +0100 [thread overview]
Message-ID: <20151216083704.GE30437@phenom.ffwll.local> (raw)
In-Reply-To: <63342ee4cb0d6fe3f2548700bd3e3a777134a098.1450202735.git.jsarha@ti.com>
On Tue, Dec 15, 2015 at 09:03:14PM +0200, Jyri Sarha wrote:
> From: Tomi Valkeinen <tomi.valkeinen@ti.com>
>
> LCDC hardware does not support fb pitch that is different (i.e. larger)
> than the screen size. The driver currently does no checks for this, and
> the results of too big pitch are are flickering and lower fps.
>
> This issue easily happens when using libdrm's modetest tool with non-32
> bpp modes. As modetest always allocated 4 bytes per pixel, it implies a
> bigger pitch for 16 or 24 bpp modes.
>
> This patch adds a check to reject pitches the hardware cannot support.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Signed-off-by: Darren Etheridge <detheridge@ti.com>
> Signed-off-by: Jyri Sarha <jsarha@ti.com>
> ---
> drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 7b687ae..105f286 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -151,6 +151,22 @@ static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
> kfree(tilcdc_crtc);
> }
>
> +static int tilcdc_verify_fb(struct drm_crtc *crtc, struct drm_framebuffer *fb)
> +{
> + struct drm_device *dev = crtc->dev;
> + unsigned int depth, bpp;
> +
> + drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
> +
> + if (fb->pitches[0] != crtc->mode.hdisplay * bpp / 8) {
> + dev_err(dev->dev,
> + "Invalid pitch: fb and crtc widths must be the same");
> + return -EINVAL;
> + }
> +
> + return 0;
This should be done in framebuffer_create instead if tilcdc has this
requirement everywhere. No point in allowing userspace to create an fb you
can't use. Only if you have planes with different limits should this be
checked after fb creation.
Also with atomic you'd only need to place this in one function, even if
you have different per-plane limitations ... hint, hint ;-)
Cheers, Daniel
> +}
> +
> static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
> struct drm_framebuffer *fb,
> struct drm_pending_vblank_event *event,
> @@ -158,6 +174,11 @@ static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
> {
> struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
> struct drm_device *dev = crtc->dev;
> + int r;
> +
> + r = tilcdc_verify_fb(crtc, fb);
> + if (r)
> + return r;
>
> if (tilcdc_crtc->event) {
> dev_err(dev->dev, "already pending page flip!\n");
> @@ -272,6 +293,10 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
> if (WARN_ON(!info))
> return -EINVAL;
>
> + ret = tilcdc_verify_fb(crtc, crtc->primary->fb);
> + if (ret)
> + return ret;
> +
> pm_runtime_get_sync(dev->dev);
>
> /* Configure the Burst Size and fifo threshold of DMA: */
> @@ -431,6 +456,12 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
> static int tilcdc_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
> struct drm_framebuffer *old_fb)
> {
> + int r;
> +
> + r = tilcdc_verify_fb(crtc, crtc->primary->fb);
> + if (r)
> + return r;
> +
> update_scanout(crtc);
> return 0;
> }
> --
> 1.9.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-12-16 8:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 19:03 [PATCH 00/12] drm/tilcdc: fixes and added features from TI tree Jyri Sarha
2015-12-15 19:03 ` [PATCH 01/12] drm/tilcdc: disable console switching during pm operations Jyri Sarha
2015-12-15 19:03 ` [PATCH 02/12] drm/tilcdc: rewrite pixel clock calculation Jyri Sarha
2015-12-15 19:03 ` [PATCH 03/12] drm/tilcdc: verify fb pitch Jyri Sarha
2015-12-16 8:37 ` Daniel Vetter [this message]
2016-02-10 13:18 ` Jyri Sarha
2016-02-10 13:26 ` Daniel Vetter
2015-12-15 19:03 ` [PATCH 04/12] drm/tilcdc: adopt pinctrl support Jyri Sarha
2015-12-15 19:03 ` [PATCH 05/12] drm/tilcdc: fix kernel panic on suspend when no hdmi monitor connected Jyri Sarha
2015-12-15 19:03 ` [PATCH 06/12] drm/tilcdc: make frame_done interrupt active at all times Jyri Sarha
2015-12-15 19:03 ` [PATCH 07/12] drm/tilcdc: disable the lcd controller/dma engine when suspend invoked Jyri Sarha
2015-12-15 19:03 ` [PATCH 08/12] drm/tilcdc: fix the ping-pong dma tearing issue seen on buffer flipping Jyri Sarha
2015-12-15 19:03 ` [PATCH 09/12] drm/tilcdc: correct the dmachannel tracking logic Jyri Sarha
2015-12-15 19:03 ` [PATCH 10/12] drm/tilcdc: make frame completion interrupt always enabled Jyri Sarha
2015-12-15 19:03 ` [PATCH 11/12] drm/tilcdc: Implement dma-buf support for tilcdc Jyri Sarha
2015-12-15 19:03 ` [PATCH 12/12] drm/tilcdc: fix build error when !CONFIG_CPU_FREQ Jyri Sarha
2015-12-16 8:23 ` [PATCH 00/12] drm/tilcdc: fixes and added features from TI tree Tomi Valkeinen
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=20151216083704.GE30437@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=detheridge@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jsarha@ti.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=tomi.valkeinen@ti.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox