Skip to contentSkip to conversation

drm/i915: use hrtimer in wait for vblank

PATCH Superseded Arun R Murthy 5 participants 8 messages Mar 25, 2014 – Apr 1, 2014

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 drm/i915: use hrtimer in wait for vblank

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

---
 drivers/gpu/drm/i915/intel_drv.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_drv.h +4 -1
index 44067bc..29a8664 100644
@@ -52,7 +52,10 @@
 			break;						\
 		}							\
 		if (W && drm_can_sleep())  {				\
-			msleep(W);					\
+			if (W > 20)					\
+				msleep(W);				\
+			else						\
+				usleep_range(W * 1000, W * 2 * 1000);	\
 		} else {						\
 			cpu_relax();					\
 		}							\
Signature · 1 line
1.7.9.5
Reviewed-by on v4 1/1
#1 lore raw
Quoted 9 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
maintainer
#2 lore raw
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

Quoted 7 lines
Quoted 4 lines

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

Arun, please don't immediately reply with updated patches if there's discussion still going on. See what the conclusion is first. Thanks.

BR,
Jani.

Quoted 6 lines

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
#3 lore raw
Quoted 11 lines · Jani Nikula
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Quoted 8 lines
Quoted 2 lines

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

wait_for(COND, TIMEOUT, ATOMIC, MS)
and remove all wait_for_X

function will look like
_wait_for(COND< TIMEOUT, ATOMIC, MS)

{
    /* loop */
        /* check condition */
        if (atomic)
            cpu_relax()
        else
            if (ms > 20)
                msleep
            else
                usleep_range
}

caller for wait_for will be setting all the parameters and hence no tweaks.

Thanks and Regards,
Arun R Murthy
-------------------

#4 lore raw
Quoted 37 lines · Arun R
Quoted 11 lines · Jani Nikula
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Quoted 8 lines
Quoted 2 lines

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

wait_for(COND, TIMEOUT, ATOMIC, MS)
and remove all wait_for_X

function will look like
_wait_for(COND< TIMEOUT, ATOMIC, MS)

{
      /* loop */
          /* check condition */
          if (atomic)
              cpu_relax()
          else
              if (ms > 20)
                  msleep
              else
                  usleep_range
}
Quoted 1 line

caller for wait_for will be setting all the parameters and hence no tweaks.

Any comments on this?

Thanks and Regards,
Arun R Murthy
-------------------

#5 lore raw
Quoted 38 lines · Arun R
Quoted 37 lines · Arun R
Quoted 11 lines · Jani Nikula
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Quoted 8 lines
Quoted 2 lines

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

wait_for(COND, TIMEOUT, ATOMIC, MS)
and remove all wait_for_X

function will look like
_wait_for(COND< TIMEOUT, ATOMIC, MS)

{
       /* loop */
           /* check condition */
           if (atomic)
               cpu_relax()
           else
               if (ms > 20)
                   msleep
               else
                   usleep_range
}
Quoted 2 lines
Quoted 1 line

caller for wait_for will be setting all the parameters and hence no tweaks.

Any comments on this?

Gentle reminder!

Thanks and Regards,
Arun R Murthy
-------------------

#6 lore raw
Quoted 39 lines · Arun R
Quoted 38 lines · Arun R
Quoted 37 lines · Arun R
Quoted 11 lines · Jani Nikula
Quoted 10 lines · Chris Wilson
Quoted 9 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Quoted 8 lines
Quoted 2 lines

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

wait_for(COND, TIMEOUT, ATOMIC, MS)
and remove all wait_for_X

function will look like
_wait_for(COND< TIMEOUT, ATOMIC, MS)

{
      /* loop */
          /* check condition */
          if (atomic)
              cpu_relax()
          else
              if (ms > 20)
                  msleep
              else
                  usleep_range
}
Quoted 3 lines
Quoted 2 lines
Quoted 1 line

caller for wait_for will be setting all the parameters and hence no tweaks.

Any comments on this?

Gentle reminder!

See my other mail somewhere in one your patch resends:

http://www.spinics.net/lists/intel-gfx/msg42439.html

If this is really just to optimize vblank waits we can do much better. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#7 lore raw
In reply to Jani Nikula
Quoted 19 lines · Jani Nikula
Quoted 6 lines · Chris Wilson
Quoted 5 lines · Arun R Murthy

In wait for vblank use usleep_range, which will use hrtimers instead of msleep. Using msleep(1~20) there are more chances of sleeping for 20ms. Using usleep_range uses hrtimers and hence are precise, worst case will trigger an interrupt at the higher/max timeout.

Quoted 7 lines
Quoted 4 lines

As per kernel document "Documentation/timers/timers-howto.txt" sleeping for 10us to 20ms its recomended to use usleep_range.

Lgtm, I still feel that our use of W=1 is fairly arbitrary and worth tweaking in future.

With the current code, this is essentially the same as the original patch. We never have W > 20, and thus we always take the usleep_range() path. So W is definitely worth tweaking if we go with this now.

Quoted 5 lines

Nitpick, the macro params should be parenthesized. This will now break for _wait_for(cond, 10, 2 + 1) and such.

Arun, please don't immediately reply with updated patches if there's discussion still going on. See what the conclusion is first. Thanks.

Also when quickly replying a single patch please use in-reply-to to the correct thread. This way the discussion is still kept tighlty grouped together even when you resend quickly.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch