All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/5] drm/nouveau: base fence timeout on time of emission
@ 2012-04-22 22:18 Marcin Slusarz
       [not found] ` <1335133112-8008-2-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Marcin Slusarz @ 2012-04-22 22:18 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Ben Skeggs
  Cc: Daniel Vetter

Wait loop can be interrupted by signal, so if signals are raised
periodically (e.g. SIGALRM) this loop may never finish. Use
emission time as a base for fence timeout.

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/gpu/drm/nouveau/nouveau_fence.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
index a22b9ad..59f92e9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fence.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
@@ -44,6 +44,7 @@ struct nouveau_fence {
 
 	uint32_t sequence;
 	bool signalled;
+	unsigned long emitted_at;
 
 	void (*work)(void *priv, bool signalled);
 	void *priv;
@@ -172,6 +173,7 @@ nouveau_fence_emit(struct nouveau_fence *fence)
 	}
 	OUT_RING (chan, fence->sequence);
 	FIRE_RING(chan);
+	fence->emitted_at = jiffies;
 
 	return 0;
 }
@@ -230,7 +232,8 @@ __nouveau_fence_signalled(void *sync_obj, void *sync_arg)
 int
 __nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
 {
-	unsigned long timeout = jiffies + (3 * DRM_HZ);
+	struct nouveau_fence *fence = nouveau_fence(sync_obj);
+	unsigned long timeout = fence->emitted_at + 3 * DRM_HZ;
 	unsigned long sleep_time = NSEC_PER_MSEC / 1000;
 	ktime_t t;
 	int ret = 0;
-- 
1.7.8.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] drm/nouveau: base fence timeout on time of emission
       [not found] ` <1335133112-8008-2-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-04-24  2:37   ` Ben Skeggs
  2012-04-24 18:34     ` Marcin Slusarz
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Skeggs @ 2012-04-24  2:37 UTC (permalink / raw)
  To: Marcin Slusarz
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	Daniel-CC+yJ3UmIYqDUpFQwHEjaQ, Vetter,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Mon, 2012-04-23 at 00:18 +0200, Marcin Slusarz wrote:
> Wait loop can be interrupted by signal, so if signals are raised
> periodically (e.g. SIGALRM) this loop may never finish. Use
> emission time as a base for fence timeout.
Ah, thanks for tackling this issue.  It's been long on my list of things
to do, but never quite made it to the top.

Rather than hardcoding the timeout in fence_wait(), I think perhaps
storing "fence->timeout = jiffies + (whatever * HZ);" is a better plan.
I can forsee us wanting longer timeouts for certain operations
(particularly long compute operations) in the future.

Ben.

> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/gpu/drm/nouveau/nouveau_fence.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
> index a22b9ad..59f92e9 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
> @@ -44,6 +44,7 @@ struct nouveau_fence {
>  
>  	uint32_t sequence;
>  	bool signalled;
> +	unsigned long emitted_at;
>  
>  	void (*work)(void *priv, bool signalled);
>  	void *priv;
> @@ -172,6 +173,7 @@ nouveau_fence_emit(struct nouveau_fence *fence)
>  	}
>  	OUT_RING (chan, fence->sequence);
>  	FIRE_RING(chan);
> +	fence->emitted_at = jiffies;
>  
>  	return 0;
>  }
> @@ -230,7 +232,8 @@ __nouveau_fence_signalled(void *sync_obj, void *sync_arg)
>  int
>  __nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
>  {
> -	unsigned long timeout = jiffies + (3 * DRM_HZ);
> +	struct nouveau_fence *fence = nouveau_fence(sync_obj);
> +	unsigned long timeout = fence->emitted_at + 3 * DRM_HZ;
>  	unsigned long sleep_time = NSEC_PER_MSEC / 1000;
>  	ktime_t t;
>  	int ret = 0;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] drm/nouveau: base fence timeout on time of emission
  2012-04-24  2:37   ` Ben Skeggs
@ 2012-04-24 18:34     ` Marcin Slusarz
  0 siblings, 0 replies; 3+ messages in thread
From: Marcin Slusarz @ 2012-04-24 18:34 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Daniel Vetter,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Tue, Apr 24, 2012 at 12:37:34PM +1000, Ben Skeggs wrote:
> On Mon, 2012-04-23 at 00:18 +0200, Marcin Slusarz wrote:
> > Wait loop can be interrupted by signal, so if signals are raised
> > periodically (e.g. SIGALRM) this loop may never finish. Use
> > emission time as a base for fence timeout.
> Ah, thanks for tackling this issue.  It's been long on my list of things
> to do, but never quite made it to the top.
> 
> Rather than hardcoding the timeout in fence_wait(), I think perhaps
> storing "fence->timeout = jiffies + (whatever * HZ);" is a better plan.
> I can forsee us wanting longer timeouts for certain operations
> (particularly long compute operations) in the future.

Yeah, good idea. Later, we will probably need to add code which will keep extending
this timeout as long as gpu is progressing.

Marcin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-04-24 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-22 22:18 [PATCH 2/5] drm/nouveau: base fence timeout on time of emission Marcin Slusarz
     [not found] ` <1335133112-8008-2-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-04-24  2:37   ` Ben Skeggs
2012-04-24 18:34     ` Marcin Slusarz

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.