From: Daniel Vetter <daniel@ffwll.ch>
To: Ben Widawsky <ben@bwidawsk.net>
Cc: intel-gfx@lists.freedesktop.org,
Ben Widawsky <benjamin.widawsky@intel.com>
Subject: Re: [PATCH 07/10] drm/i915: timeout parameter for seqno wait
Date: Sun, 22 Apr 2012 14:52:32 +0200 [thread overview]
Message-ID: <20120422125232.GF4723@phenom.ffwll.local> (raw)
In-Reply-To: <1334971412-4826-8-git-send-email-ben@bwidawsk.net>
On Fri, Apr 20, 2012 at 06:23:29PM -0700, Ben Widawsky wrote:
> Insert a wait parameter in the code so we can possibly timeout on a
> seqno wait if need be. The code should be functionally the same as
> before because all the callers will continue to retry if an arbitrary
> timeout elapses.
>
> Signed-off-by: Ben Widawsky <benjamin.widawsky@intel.com>
Interface bikeshed: I think handling the wait_forever case in here would
be better, the do {} while (-ETIME) loops don't look to cute. That way we
can also ditch the rather arbitrary SEQNO_WAIT_DEFAULT.
> ---
> drivers/gpu/drm/i915/i915_gem.c | 41 ++++++++++++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 920dbc1..7bfad04 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1847,25 +1847,36 @@ i915_gem_retire_work_handler(struct work_struct *work)
> mutex_unlock(&dev->struct_mutex);
> }
>
> +#define SEQNO_WAIT_DEFAULT (3000000UL)
> static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
> - bool interruptible)
> + bool interruptible, long *usecs)
> {
> drm_i915_private_t *dev_priv = ring->dev->dev_private;
> - int ret = 0;
> + const long timeout = usecs_to_jiffies(*usecs);
> + long end;
>
> #define EXIT_COND \
> (i915_seqno_passed(ring->get_seqno(ring), seqno) || \
> atomic_read(&dev_priv->mm.wedged))
>
> if (interruptible)
> - ret = wait_event_interruptible(ring->irq_queue,
> - EXIT_COND);
> + end = wait_event_interruptible_timeout(ring->irq_queue,
> + EXIT_COND,
> + timeout);
> else
> - wait_event(ring->irq_queue, EXIT_COND);
> -
> + end = wait_event_timeout(ring->irq_queue, EXIT_COND, timeout);
> #undef EXIT_COND
>
> - return ret;
> + switch (end) {
> + case 0: /* Tiemout */
> + return -ETIME;
> + case -ERESTARTSYS: /* Signal */
> + return -ERESTARTSYS;
> + default: /* Completed */
> + BUG_ON(end < 0); /* We're not aware of other errors */
WARN_ON, we won't die right away when this ever happens.
> + *usecs = jiffies_to_usecs(timeout - end);
Safe when the ioctl restarting works different, you also need this for the
-ERESTARTSYS case. And it doesn't hurt for the timeout case.
> + return 0;
> + }
> }
>
> /**
> @@ -1916,7 +1927,12 @@ i915_wait_request(struct intel_ring_buffer *ring,
> if (WARN_ON(!ring->irq_get(ring)))
> return -EBUSY;
>
> - ret = __wait_seqno(ring, seqno, dev_priv->mm.interruptible);
> + do {
> + long time = SEQNO_WAIT_DEFAULT;
> + ret = __wait_seqno(ring, seqno,
> + dev_priv->mm.interruptible,
> + &time);
> + } while (ret == -ETIME);
>
> ring->irq_put(ring);
> trace_i915_gem_request_wait_end(ring, seqno);
> @@ -3012,13 +3028,16 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
> * lockless.
> */
> if (ring->irq_get(ring)) {
> - ret = __wait_seqno(ring, seqno, true);
> + do {
> + long time = SEQNO_WAIT_DEFAULT;
> + ret = __wait_seqno(ring, seqno, true, &time);
> + } while (ret == -ETIME);
> ring->irq_put(ring);
> -
> if (ret == 0 && atomic_read(&dev_priv->mm.wedged))
> ret = -EIO;
> - } else
> + } else {
> ret = -EBUSY;
> + }
> }
>
> if (ret == 0)
> --
> 1.7.10
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48
next prev parent reply other threads:[~2012-04-22 12:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-21 1:23 [PATCH 00/10] wait for BO with timeout Ben Widawsky
2012-04-21 1:23 ` [PATCH 01/10] drm/i915: remove do_retire from i915_wait_request Ben Widawsky
2012-04-21 17:17 ` Daniel Vetter
2012-04-21 17:27 ` Ben Widawsky
2012-04-21 17:36 ` Daniel Vetter
2012-04-21 1:23 ` [PATCH 02/10] drm/i915: move vbetool invoked ier stuff Ben Widawsky
2012-04-21 9:26 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 03/10] drm/i915: kill waiting_seqno Ben Widawsky
2012-04-22 13:46 ` Chris Wilson
2012-04-22 17:47 ` Ben Widawsky
2012-04-21 1:23 ` [PATCH 04/10] drm/i915: drop polled waits from i915_wait_request Ben Widawsky
2012-04-21 9:29 ` Chris Wilson
2012-04-21 16:14 ` Ben Widawsky
2012-04-21 1:23 ` [PATCH 05/10] drm/i915: extract __wait_seqno " Ben Widawsky
2012-04-21 1:23 ` [PATCH 06/10] drm/i915: use __wait_seqno for ring throttle Ben Widawsky
2012-04-22 14:17 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 07/10] drm/i915: timeout parameter for seqno wait Ben Widawsky
2012-04-22 12:52 ` Daniel Vetter [this message]
2012-04-21 1:23 ` [PATCH 08/10] drm/i915: real wait seqno with timeout Ben Widawsky
2012-04-21 1:23 ` [PATCH 09/10] drm/i915: wait render timeout ioctl Ben Widawsky
2012-04-21 9:41 ` Chris Wilson
2012-04-21 16:12 ` Ben Widawsky
2012-04-21 20:37 ` Ben Widawsky
2012-04-22 9:37 ` Chris Wilson
2012-04-22 9:48 ` Chris Wilson
2012-04-22 10:11 ` Daniel Vetter
2012-04-22 12:45 ` Daniel Vetter
2012-04-23 15:28 ` Ben Widawsky
2012-04-22 14:14 ` Chris Wilson
2012-04-21 1:23 ` [PATCH 10/10] drm/i915: s/i915_wait_reqest/i915_wait_seqno/g Ben Widawsky
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=20120422125232.GF4723@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=ben@bwidawsk.net \
--cc=benjamin.widawsky@intel.com \
--cc=intel-gfx@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox