All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm: do not sleep on vblank while holding a 	mutex
Date: Fri, 28 Oct 2011 21:15:34 +0200	[thread overview]
Message-ID: <20111028191534.GD2919@phenom.ffwll.local> (raw)
In-Reply-To: <6866A4CD-A078-4CBB-926F-9B84E830BE10@tuebingen.mpg.de>

On Fri, Oct 28, 2011 at 08:15:11PM +0200, Mario Kleiner wrote:
> be careful with vblank_refcount. I think it probably should stay
> atomic. The drm_vblank_put() is often used in interrupt handlers of
> the kms drivers where you don't want to uneccessary wait on a lock,
> but be as quick as possible.

I don't think that's a real issue - if we have lock contention anywhere
with the current code, we already have a problem - and it looks like we
have ;-) And the spinlocks are all already switching off irqs locally, so
we should already strive for the shortest possible lock hold times.

[snip]

> The vblank_time_lock serves a different purpose from vbl_lock. It is
> used in the vblank irq handler drm_handle_vblank() and in the vblank
> irq on/off functions to protect the vblank timestamping and counting
> against races between the irq handler and the on/off code, and some
> funny races between the cpu reinitializing vblank counts and
> timestamps in non-irq path and the gpu firing vblank interrupts and/
> or updating its hardware vblank counter at the "wrong" moment.
> vblank_time_lock basically blocks/delays gpu vblank irq processing
> during such problematic periods. Timing there is criticial for
> reliable vblank timestamping, kms page flipping and artifact free
> dynamic gpu power-management. It should be locked as seldomly and
> held as short as possible. I initially tried to get away only with
> vbl_lock, but there were uses of vbl_lock that looked as if using it
> in the interrupt handler as well could cause long delays in irq
> processing.

I've gone through the code, and in almost all case where the vbl_lock is
hold for a bit more than just a few load and stores we are immediately
taking the vblank_time_lock and hold it almost as long. Which is why I
think this is redundant. The only exeption is the irq uninstall code,
which isn't really a fast path anyway.

Also, all these paths with longer lock-hold times are in the initial
vblank_get/final vblank_put. And because we delay the vblank disabling by
a full second, we should never hit that in steady state.

But I think you're one of the most timing-sensitive users of this vblank
stuff, so when I get around to clean this up I'll certainly put you on cc
so you can test for any adverse effects. Hopefully ripping out unecessary
atomic ops makes stuff faster, not slower.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2011-10-28 19:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.37.1319803862.23620.dri-devel@lists.freedesktop.org>
2011-10-28 18:15 ` [PATCH 3/3] drm: do not sleep on vblank while holding a mutex Mario Kleiner
2011-10-28 19:15   ` Daniel Vetter [this message]
2011-10-28 19:53     ` Mario Kleiner
2011-10-26  2:20 drm: fix one flawed mutex grab and remove some spurious mutex grabs Ilija Hadzic
2011-10-26  2:20 ` [PATCH 3/3] drm: do not sleep on vblank while holding a mutex Ilija Hadzic
2011-10-26  7:54   ` Daniel Vetter
2011-10-26 22:33     ` Ilija Hadzic
2011-10-27 10:43       ` Daniel Vetter
2011-10-27 14:10         ` Alan Coopersmith
2011-10-27 14:20           ` Ilija Hadzic
2011-10-28  3:19         ` Ilija Hadzic
2011-10-28  4:36           ` Ilija Hadzic
2011-10-28  6:59           ` Michel Dänzer
2011-10-28  9:20             ` Daniel Vetter
2011-10-28 12:10               ` Ilija Hadzic
2011-10-28 14:51                 ` Daniel Vetter
2011-10-28  9:30           ` Daniel Vetter
2011-10-26  8:02   ` Michel Dänzer
2011-10-26 22:50     ` Ilija Hadzic

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=20111028191534.GD2919@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mario.kleiner@tuebingen.mpg.de \
    /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.