All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: Inki Dae <inki.dae@samsung.com>
Cc: linux-samsung-soc@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Daniel Kurtz <djkurtz@chromium.org>
Subject: Re: [PATCH 01/29] drm/exynos/fimd: only finish pageflip if START == START_S
Date: Mon, 12 Jan 2015 19:13:27 -0200	[thread overview]
Message-ID: <20150112211327.GF2001@joana> (raw)
In-Reply-To: <54A2B13F.1030908@samsung.com>

2014-12-30 Inki Dae <inki.dae@samsung.com>:

> On 2014년 12월 18일 22:58, Gustavo Padovan wrote:
> > From: Daniel Kurtz <djkurtz@chromium.org>
> > 
> > A framebuffer gets committed to FIMD's default window like this:
> >  exynos_drm_crtc_update()
> >   exynos_plane_commit()
> >    fimd_win_commit()
> > 
> > fimd_win_commit() programs BUF_START[0].  At each vblank, FIMD hardware
> > copies the value from BUF_START to BUF_START_S (BUF_START's shadow
> > register), starts scanning out from BUF_START_S, and asserts its irq.
> > 
> > This irq is handled by fimd_irq_handler(), which calls
> > exynos_drm_crtc_finish_pageflip() to free the old buffer that FIMD just
> > finished scanning out, and potentially commit the next pending flip.
> > 
> > There is a race, however, if fimd_win_commit() programs BUF_START(0)
> > between the actual vblank irq, and its corresponding fimd_irq_handler().
> > 
> >  => FIMD vblank: BUF_START_S[0] := BUF_START[0], and irq asserted
> >  | => fimd_win_commit(0) writes new BUF_START[0]
> >  |    exynos_drm_crtc_try_do_flip() marks exynos_fb as prepared
> >  => fimd_irq_handler()
> >     exynos_drm_crtc_finish_pageflip() sees prepared exynos_fb,
> >          and unmaps "old" fb
> >  ==> but, since BUF_START_S[0] still points to that "old" fb...
> >  ==> FIMD iommu fault
> > 
> > This patch ensures that fimd_irq_handler() only calls
> > exynos_drm_crtc_finish_pageflip() if any previously scheduled flip
> > has really completed.
> > 
> > This works because exynos_drm_crtc's flip fifo ensures that
> > fimd_win_commit() is never called more than once per
> > exynos_drm_crtc_finish_pageflip().
> > 
> > Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> > Reviewed-by: Sean Paul <seanpaul@chromium.org>
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > ---
> >  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 26 ++++++++++++++++++++++----
> >  include/video/samsung_fimd.h             |  1 +
> >  2 files changed, 23 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> > index e5810d1..b379182 100644
> > --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> > +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> > @@ -55,6 +55,7 @@
> >  #define VIDOSD_D(win)		(VIDOSD_BASE + 0x0C + (win) * 16)
> >  
> >  #define VIDWx_BUF_START(win, buf)	(VIDW_BUF_START(buf) + (win) * 8)
> > +#define VIDWx_BUF_START_S(win, buf)     (VIDW_BUF_START_S(buf) + (win) * 8)
> >  #define VIDWx_BUF_END(win, buf)		(VIDW_BUF_END(buf) + (win) * 8)
> >  #define VIDWx_BUF_SIZE(win, buf)	(VIDW_BUF_SIZE(buf) + (win) * 4)
> >  
> > @@ -1039,6 +1040,7 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
> >  {
> >  	struct fimd_context *ctx = (struct fimd_context *)dev_id;
> >  	u32 val, clear_bit;
> > +	u32 start, start_s;
> >  
> >  	val = readl(ctx->regs + VIDINTCON1);
> >  
> > @@ -1050,15 +1052,31 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
> >  	if (ctx->pipe < 0 || !ctx->drm_dev)
> >  		goto out;
> >  
> > -	if (ctx->i80_if) {
> > +	if (!ctx->i80_if)
> > +		drm_handle_vblank(ctx->drm_dev, ctx->pipe);
> > +
> > +	/*
> > +	 * Ensure finish_pageflip is called iff a pending flip has completed.
> 
> Maybe s/iff/if
> 
> > +	 * This works around a race between a page_flip request and the latency
> > +	 * between vblank interrupt and this irq_handler:
> > +	 *   => FIMD vblank: BUF_START_S[0] := BUF_START[0], and asserts irq
> > +	 *   | => fimd_win_commit(0) writes new BUF_START[0]
> > +	 *   |    exynos_drm_crtc_try_do_flip() marks exynos_fb as prepared
> > +	 *   => fimd_irq_handler()
> > +	 *       exynos_drm_crtc_finish_pageflip() sees prepared exynos_fb,
> > +	 *           and unmaps "old" fb
> > +	 *   ==> but, since BUF_START_S[0] still points to that "old" fb...
> > +	 *   ==> FIMD iommu fault
> > +	 */
> > +	start = readl(ctx->regs + VIDWx_BUF_START(0, 0));
> > +	start_s = readl(ctx->regs + VIDWx_BUF_START_S(0, 0));
> > +	if (start == start_s)
> >  		exynos_drm_crtc_finish_pageflip(ctx->drm_dev, ctx->pipe);
> 
> As I already mentioned before, above codes should be called only in case
> of RGB mode until checked for i80 mode. Have you ever tested above codes
> on i80 mode?

I haven't tested it as I don't have any hardware that does i80 mode.
Let's keep this check only for !i80 then. 

> 
> And what if 'start_s' has a value different from one of 'start'? Is it
> ok to skip finish_pageflip request this time? Shouldn't it ensure to
> wait for that until 'start_s' has a value same as one of 'start'?

I think it is okay to skip finish_pageflip, but we could return directly
if they are different, so we keep the wait_vsync_queue running until the next
irq happens or it timeouts. How does this look to you?

	Gustavo

  reply	other threads:[~2015-01-12 21:13 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 13:58 [PATCH 00/29] drm/exynos: clean up + atomic phases 1 and 2 Gustavo Padovan
2014-12-18 13:58 ` [PATCH 01/29] drm/exynos/fimd: only finish pageflip if START == START_S Gustavo Padovan
2014-12-30 14:05   ` Inki Dae
2015-01-12 21:13     ` Gustavo Padovan [this message]
2015-01-19 16:35       ` Daniel Stone
2014-12-18 13:58 ` [PATCH 02/29] drm/exynos: move to_exynos_crtc() macro to main header Gustavo Padovan
2014-12-18 13:58 ` [PATCH 03/29] drm/exynos: expose struct exynos_drm_crtc Gustavo Padovan
2014-12-18 13:58 ` [PATCH 04/29] drm/exynos: remove exynos_drm_crtc_plane_* wrappers Gustavo Padovan
2014-12-18 13:58 ` [PATCH 05/29] drm/exynos: remove struct exynos_drm_overlay Gustavo Padovan
2014-12-18 13:58 ` [PATCH 06/29] drm/exynos/fimd: don't initialize 'ret' variable in fimd_probe() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 07/29] drm/exynos/vidi: remove useless ops->commit() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 08/29] drm/exynos: Don't touch DPMS when updating overlay planes Gustavo Padovan
2014-12-18 13:58 ` [PATCH 09/29] drm/exynos: don't do any DPMS operation while updating planes Gustavo Padovan
2014-12-18 13:58 ` [PATCH 10/29] drm/exynos: remove exynos_plane_commit() wrapper Gustavo Padovan
2014-12-18 13:58 ` [PATCH 11/29] drm/exynos: unify plane update on exynos_update_plane() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 12/29] drm/exynos: call exynos_update_plane() directly on page flips Gustavo Padovan
2014-12-18 13:58 ` [PATCH 13/29] drm/exynos: remove exynos_drm_crtc_mode_set_commit() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 14/29] drm/exynos: rename base object of struct exynos_drm_crtc to 'base' Gustavo Padovan
2014-12-18 13:58 ` [PATCH 15/29] drm/exynos: add pipe param to exynos_drm_crtc_create() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 16/29] drm/exynos: remove pipe member of struct exynos_drm_manager Gustavo Padovan
2014-12-18 13:58 ` [PATCH 17/29] drm/exynos: move 'type' from manager to crtc struct Gustavo Padovan
2014-12-18 13:58 ` [PATCH 18/29] drm/exynos: remove drm_dev from struct exynos_drm_manager Gustavo Padovan
2014-12-18 13:58 ` [PATCH 19/29] drm/exynos: remove " Gustavo Padovan
2014-12-18 13:58 ` [PATCH 20/29] drm/exynos: don't duplicate drm_display_mode in fimd context Gustavo Padovan
2014-12-18 13:58 ` [PATCH 21/29] drm/exynos: remove mode_set() ops from exynos_crtc Gustavo Padovan
2014-12-18 13:58 ` [PATCH 22/29] drm/exynos: create exynos_check_plane() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 23/29] drm/exynos: atomic phase 1: use drm_plane_helper_update() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 24/29] drm/exynos: make exynos_plane_mode_set() static Gustavo Padovan
2014-12-18 13:58 ` [PATCH 25/29] drm/exynos: atomic phase 1: use drm_plane_helper_disable() Gustavo Padovan
2014-12-18 15:30   ` Daniel Vetter
2014-12-30 14:19   ` Inki Dae
2015-01-07 19:10     ` Gustavo Padovan
2014-12-18 13:58 ` [PATCH 26/29] drm/exynos: atomic phase 1: add atomic_begin()/atomic_flush() Gustavo Padovan
2014-12-30 14:42   ` Inki Dae
2015-01-07 19:29     ` Gustavo Padovan
2014-12-18 13:58 ` [PATCH 27/29] drm/exynos: atomic phase 1: add .mode_set_nofb() callback Gustavo Padovan
2014-12-18 13:58 ` [PATCH 28/29] drm/exynos: atomic phase 2: wire up state reset(), duplicate() and destroy() Gustavo Padovan
2014-12-18 13:58 ` [PATCH 29/29] drm/exynos: atomic phase 2: keep track of framebuffer pointer Gustavo Padovan
2015-01-11 17:16 ` [PATCH 00/29] drm/exynos: clean up + atomic phases 1 and 2 Inki Dae

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=20150112211327.GF2001@joana \
    --to=gustavo@padovan.org \
    --cc=djkurtz@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    /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.