Bug 111032

Summary: Need to set gt_min_freq_mhz to max value to avoid sync issues on Gemini Lake N5000/J5005
Product: DRI Reporter: Ross Nicholson <phunkyfish>
Component: DRM/IntelAssignee: Intel GFX Bugs mailing list <intel-gfx-bugs>
Status: CLOSED WORKSFORME QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: medium CC: intel-gfx-bugs
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard: Triaged
i915 platform: GLK i915 features:

Description Ross Nicholson 2019-07-01 08:32:22 UTC
Running Libreelec on various gemini lake boxes using either N5000 or J5005. Almost since the beginning I have set the max value for gt_min_freq_mhz to avoid sync/stuttering issues. It's almost like the GPU doesn't know it should step up or boost itself while playing back video.

Without setting the value playback will fall out of the sync/stutter, however if I bring up an overlay this will stop. This action must cause the GPU to up it's clock speed.

Here are the settings I use for gt_min_freq_mhz on LibreElec:

In ~/.config/autostart.sh enter the following on an N5000:

(
echo 750 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_min_freq_mhz
) &
nohup script.sh &

And on a J5005:

(
echo 800 > /sys/devices/pci0000:00/0000:00:02.0/drm/card0/gt_min_freq_mhz
) &
nohup script.sh &
Comment 1 Chris Wilson 2019-07-01 08:53:46 UTC
The GPU bases its decision on throughput, it it is saturated it will signal it needs a higher frequency. Video decode is usually efficiently by the GPU and can quite happily run with low clocks.

However, users are latency sensitive! For latency, we look at pageflips and if the GPU is still busy when we expected to flip, we boost the clocks. The idea being that with one missed frame, we then put ourselves in a regime where the next sequence of frames do not miss.

As always, make sure you have the latest kernel (drm-tip is preferable if you want to help test patches), and you can watch the decision process via /sys/kernel/debug/dri/0/i915_rps_boost_info. To ensure that there is frame info being provided, make sure you are either running the video fullscreen (with flipping enabled) or under a compositor that flips.
Comment 2 Ross Nicholson 2019-07-01 09:23:13 UTC
Yes, video would be full screen.

How do I check if flipping is enabled?
Comment 3 Chris Wilson 2019-07-20 11:58:05 UTC
Nothing that I'm aware of, the tracepoints I used to use are gone, so just a matter of looking at dmesg and discerning the flips...

If you watch /sys/kernel/debug/dri/0/i915_rps_boost_info, that should mention whether or not is in an "Interactive?" mode that is enabled if we are pageflipping.
Comment 4 Lakshmi 2019-07-29 12:31:59 UTC
(In reply to Ross Nicholson from comment #2)
> Yes, video would be full screen.
> 
> How do I check if flipping is enabled?

(In reply to Chris Wilson from comment #3)
> Nothing that I'm aware of, the tracepoints I used to use are gone, so just a
> matter of looking at dmesg and discerning the flips...
> 
> If you watch /sys/kernel/debug/dri/0/i915_rps_boost_info, that should
> mention whether or not is in an "Interactive?" mode that is enabled if we
> are pageflipping.

Ross, Any progress here?
Comment 5 Ross Nicholson 2019-07-29 17:55:21 UTC
Sorry, was travelling. Will check this tomorrow
Comment 6 Ross Nicholson 2019-07-29 19:10:33 UTC
Ok, got some time to check this just now.

I get laggy video occasionally during normal playback unless I bring up an overlay. I'nm not forcing gt_min_freq_mhz when doing this.

First this is during normal playback (no overlay):

_____________________________________________________________________


LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [3 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 383, actual 400
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 24 boosts
Kernel (anonymous) boosts: 577

RPS Autotuning (current "high power" window):
  Avg. up: 6% [above threshold? 85%]
  Avg. down: 64% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 0
Frequency requested 333, actual 350
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 24 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 64% [above threshold? 85%]
  Avg. down: 59% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 317, actual 350
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 24 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 5% [above threshold? 85%]
  Avg. down: 70% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 217, actual 250
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 64% [above threshold? 85%]
  Avg. down: 99% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 233, actual 250
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 8% [above threshold? 85%]
  Avg. down: 34% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [1 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 333, actual 350
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 99% [above threshold? 85%]
  Avg. down: 84% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [1 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 317, actual 350
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 99% [above threshold? 85%]
  Avg. down: 80% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [1 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 200, actual 200
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 15% [above threshold? 85%]
  Avg. down: 54% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 383, actual 400
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 25% [above threshold? 85%]
  Avg. down: 37% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [2 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 200, actual 200
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 25 boosts
Kernel (anonymous) boosts: 579

RPS Autotuning (current "high power" window):
  Avg. up: 38% [above threshold? 85%]
  Avg. down: 60% [below threshold? 60%]

_____________________________________________________________________


And if I bring up an overlay:

_____________________________________________________________________

LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [1 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 383, actual 400
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 5 boosts
Kernel (anonymous) boosts: 543

RPS Autotuning (current "high power" window):
  Avg. up: 6% [above threshold? 85%]
  Avg. down: 33% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [4 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 783, actual 550
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 16 boosts
Kernel (anonymous) boosts: 546

RPS Autotuning (current "high power" window):
  Avg. up: 98% [above threshold? 85%]
  Avg. down: 51% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [4 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 550, actual 550
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 16 boosts
Kernel (anonymous) boosts: 550

RPS Autotuning (current "high power" window):
  Avg. up: 80% [above threshold? 85%]
  Avg. down: 70% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [4 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 633, actual 450
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 16 boosts
Kernel (anonymous) boosts: 551

RPS Autotuning (current "high power" window):
  Avg. up: 99% [above threshold? 85%]
  Avg. down: 63% [below threshold? 60%]
LibreELECSR:/sys/kernel/debug/dri/0 # cat i915_rps_boost_info 
RPS enabled? 1
GPU busy? yes [4 requests]
Boosts outstanding? 0
Interactive? 1
Frequency requested 783, actual 500
  min hard:100, soft:100; max soft:800, hard:800
  idle:100, efficient:250, boost:800
Xorg [580]: 0 boosts
kodi.bin [606]: 0 boosts
VideoPlayer [841]: 16 boosts
Kernel (anonymous) boosts: 552

RPS Autotuning (current "high power" window):
  Avg. up: 94% [above threshold? 85%]
  Avg. down: 21% [below threshold? 60%]
Comment 7 Ross Nicholson 2019-07-30 10:24:33 UTC
I mention in my post above that this is occasionally occurring. However it occurs all the time.
Comment 8 Lakshmi 2019-08-28 10:57:21 UTC
(In reply to Ross Nicholson from comment #7)
> I mention in my post above that this is occasionally occurring. However it
> occurs all the time.

Are you experiencing this issue with the latest kernel? If not, can you verify this with the drmtip? (https://cgit.freedesktop.org/drm-tip)
Comment 9 Ross Nicholson 2019-08-28 12:16:04 UTC
Which kernel version do I require?

I can request a build of LibreElec with that version.
Comment 10 Lakshmi 2019-08-29 08:19:35 UTC
(In reply to Ross Nicholson from comment #9)
> Which kernel version do I require?
> 
> I can request a build of LibreElec with that version.

Drmtip will always have latest changes on top of the 5.3 rc6. So we always recommend to use drmtip kernel (https://cgit.freedesktop.org/drm-tip).
Comment 11 Ross Nicholson 2019-08-29 10:07:07 UTC
Thanks, will make the request and report back.
Comment 12 Ross Nicholson 2019-09-13 08:55:07 UTC
Tested with DRMTip on N5000, there is a huge improvement. Thank you! 

Will also test on J5005 for next 2 days and report back.

LibreELECBR:~ # cat /sys/kernel/debug/dri/0/i915_rps_boost_info
RPS enabled? 1
GPU busy? yes
Boosts outstanding? 0
Interactive? 1
Frequency requested 500, actual 450
  min hard:100, soft:100; max soft:750, hard:750
  idle:100, efficient:200, boost:750
Wait boosts: 396

RPS Autotuning (current "high power" window):
  Avg. up: 1% [above threshold? 85%]
  Avg. down: 14% [below threshold? 60%]

LibreELECBR:~ # cat /sys/kernel/debug/dri/0/i915_rps_boost_info
RPS enabled? 1
GPU busy? yes
Boosts outstanding? 0
Interactive? 1
Frequency requested 667, actual 450
  min hard:100, soft:100; max soft:750, hard:750
  idle:100, efficient:200, boost:750
Wait boosts: 398

RPS Autotuning (current "high power" window):
  Avg. up: 6% [above threshold? 85%]
  Avg. down: 27% [below threshold? 60%]
LibreELECBR:~ # cat /sys/kernel/debug/dri/0/i915_rps_boost_info
RPS enabled? 1
GPU busy? yes
Boosts outstanding? 0
Interactive? 1
Frequency requested 200, actual 200
  min hard:100, soft:100; max soft:750, hard:750
  idle:100, efficient:200, boost:750
Wait boosts: 398

RPS Autotuning (current "high power" window):
  Avg. up: 2% [above threshold? 85%]
  Avg. down: 30% [below threshold? 60%]
Comment 13 Ross Nicholson 2019-09-13 09:21:25 UTC
Also confirmed on J5005, amazing work, thanks again.

Will this make it into the next RC?
Comment 14 Ross Nicholson 2019-09-13 21:37:35 UTC
Having had more time to observe this I can see that occasionally there is lag. Maybe once every 10/15 mins. Quickly bring up an overlay and removing it will resolve it.

So this is greatly improved, but not quite perfect yet.
Comment 15 Lakshmi 2019-09-16 14:35:35 UTC
(In reply to Ross Nicholson from comment #13)
> Also confirmed on J5005, amazing work, thanks again.
> 
> Will this make it into the next RC?

Not sure which change has brought this improvement. You can always update to the latest RC and try if the issue has gone. If you are happy with drmtip we can close this issue as WORKSFORME.
Comment 16 Lakshmi 2019-10-03 07:05:24 UTC
(In reply to Lakshmi from comment #15)
> (In reply to Ross Nicholson from comment #13)
> > Also confirmed on J5005, amazing work, thanks again.
> > 
> > Will this make it into the next RC?
> 
> Not sure which change has brought this improvement. You can always update to
> the latest RC and try if the issue has gone. If you are happy with drmtip we
> can close this issue as WORKSFORME.

@Ross, any updates here? Can we close this issue?
Comment 17 Ross Nicholson 2019-10-04 22:23:06 UTC
Yes. Please close. 

Sorry I thought I had already replied requesting it.

Thanks again!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.