All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lutomirski <luto@mit.edu>
To: Keith Packard <keithp@keithp.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm: Aggressively disable vblanks
Date: Mon, 20 Dec 2010 22:34:12 -0500	[thread overview]
Message-ID: <AANLkTik-1zni1DdS6i+1ARoenx6p=9jQAAiA6t5uGg_K@mail.gmail.com> (raw)
In-Reply-To: <yunfwtrrepv.fsf@aiko.keithp.com>

On Mon, Dec 20, 2010 at 10:23 PM, Keith Packard <keithp@keithp.com> wrote:
> On Mon, 20 Dec 2010 14:00:54 -0500, Andy Lutomirski <luto@MIT.EDU> wrote:
>
>> Enabling and disabling the vblank interrupt (on devices that
>> support it) is cheap.  So disable it quickly after each
>> interrupt.
>
> So, the concern (and reason for the original design) was that you might
> lose count of vblank interrupts as vblanks are counted differently while
> off than while on. If vblank interrupts get enabled near the interrupt
> time, is it possible that you'll end up off by one somehow?

So the race is:

1. Vblank happens.
2. vblank_get runs, reads hardware counter, and enables the interrupt
(and maybe not quite in that order)
3. Interrupt fires and increments the counter.  Now the counter is one too high.

What if we read the hardware counter from the IRQ the first time that
it fires after being enabled?  That way, if the hardware and software
counters match (mod 2^23 or whatever the magic number is), we don't
increment the counter.

>
> Leaving them enabled for 'a while' was supposed to reduce the impact of
> this potential error.
>

Fair enough,

But five seconds is a *long* time, and anything short enough that the
interrupt actually gets turned off in normal use risks the same race.

--Andy

  reply	other threads:[~2010-12-21  3:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 19:00 [PATCH] drm: Aggressively disable vblanks Andy Lutomirski
2010-12-21  3:23 ` Keith Packard
2010-12-21  3:34   ` Andrew Lutomirski [this message]
2010-12-21  3:47     ` [Intel-gfx] " Keith Packard
2010-12-21  3:55       ` Andrew Lutomirski
2010-12-21  4:03         ` Jesse Barnes
     [not found] <mailman.28.1292917668.19577.dri-devel@lists.freedesktop.org>
2010-12-22  4:36 ` [Intel-gfx] " Mario Kleiner
2010-12-22 17:23   ` Jesse Barnes
2010-12-22 21:06     ` Mario Kleiner
2010-12-26 14:53       ` Andrew Lutomirski
2010-12-26 23:58         ` Mario Kleiner
2010-12-27 11:16           ` Ville Syrjälä
2010-12-27 21:30             ` Mario Kleiner
2011-01-10  2:24           ` Andrew Lutomirski

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='AANLkTik-1zni1DdS6i+1ARoenx6p=9jQAAiA6t5uGg_K@mail.gmail.com' \
    --to=luto@mit.edu \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=keithp@keithp.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 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.