drm/i915: boost GPU and CPU freq when leaving idle
Subsystems (2)
PATCH 1/1 drm/i915: boost GPU and CPU freq when leaving idle
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_drv.h | 2 ++ drivers/gpu/drm/i915/intel_pm.c | 24 ++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +24 -0
@@ -26,6 +26,7 @@* */ +#include <linux/cpufreq.h> #include <drm/drmP.h> #include <drm/i915_drm.h> #include "i915_drv.h"
@@ -1058,6 +1059,29 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } +/* +* Before dispatching, check if the GPU is busy. If not, +* boost the GPU and CPU freqs to maximum to make sure +* animation startup is smooth. +*/ +if (intel_gpu_idle (dev)) { +struct cpufreq_policy *policy; +unsigned int cpu =smp_processor_id (); +int cpu_freq; + +mutex_lock (&dev_priv->rps.hw_lock); +if (IS_VALLEYVIEW (dev)) +valleyview_set_rps (dev, dev_priv->rps.max_delay); +else if (IS_GEN6 (dev) ||IS_GEN7 (dev)) +gen6_set_rps (dev, dev_priv->rps.max_delay); +mutex_unlock (&dev_priv->rps.hw_lock); + + policy =cpufreq_cpu_get (cpu); + cpu_freq =cpufreq_quick_get_max (cpu); + +cpufreq_driver_target (policy, cpu_freq,CPUFREQ_RELATION_H ); + } + exec_start = batch_obj->gtt_offset + args->batch_start_offset; exec_len = args->batch_len;if (cliprects) {
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -840,4 +840,6 @@ extern bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,enum transcoder pch_transcoder, bool enable); +extern bool intel_gpu_idle (struct drm_device *dev); +#endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_pm.c +24 -0
@@ -5621,3 +5621,27 @@ int vlv_freq_opcode(int ddr_freq, int val)return val; } +bool intel_gpu_idle (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; + +if (IS_VALLEYVIEW (dev)) { +u32 gtlc_pw_status; + + gtlc_pw_status =I915_READ (VLV_GTLC_PW_STATUS ); +if (gtlc_pw_status & (1 <<7 )) +return false; +else +return true; + }else if (IS_GEN6 (dev) ||IS_GEN7 (dev)) { +u32 gt_core_status; + + gt_core_status =I915_READ (GEN6_GT_CORE_STATUS ); +if (gt_core_status &GEN6_CORE_CPD_STATE_MASK ) +return true; +else +return false; + }else { +return false; + } +}
Signature · 1 line
1.7.9.5
Quoted 8 lines · Jesse Barnes
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
Quoted 4 lines
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
Would seem like a good idea to make intel_mark_busy() dtrt and use them. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 9 lines · On Fri, 28 Jun 2013 19:37:01 +0100 Chris Wilson <[email protected]>…
Quoted 8 lines · Jesse Barnes
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
Quoted 6 lines
Quoted 4 lines
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
Would seem like a good idea to make
intel_mark_busy()dtrt and use them.
That'll give us a slightly delayed idle indicator, but it should work ok...
Owen, if this patch looks like it'll work for you, I'll update it to use our mark busy/idle stuff and see if we can merge it upstream.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 17 lines · Jesse Barnes
Quoted 14 lines · On Fri, 28 Jun 2013 19:37:01 +0100 Chris Wilson <[email protected]>…
Quoted 12 lines · Jesse Barnes
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
Quoted 7 lines
Quoted 1 line
Would seem like a good idea to make
intel_mark_busy()dtrt and use them.That'll give us a slightly delayed idle indicator, but it should work ok...
Owen, if this patch looks like it'll work for you, I'll update it to use our mark busy/idle stuff and see if we can merge it upstream.
I'm in favour of a bit of hystersis, probably because I think this is ultimately a firmware tuning issue. Something that userspace can only provide hints for, and only the hardware can respond fast enough.
Nevertheless will try out this pair to see if makes my systems sweat. -Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 9 lines · Chris Wilson
Quoted 8 lines · Jesse Barnes
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
Quoted 8 lines
Quoted 4 lines
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
Would seem like a good idea to make
intel_mark_busy()dtrt and use them. -Chris
Is there a way to force the GPU always to run at the top speed? (since it might well be the most efficient way to run things due to race-to-halt)
Quoted 15 lines · On Fri, 28 Jun 2013 12:10:51 -0700 Arjan van de Ven <[email protected]>…
Quoted 14 lines · Chris Wilson
Quoted 12 lines · Jesse Barnes
Coming out of idle is usually due to some sort of user input (swiping a screen, clicking a button) and often results in some sort of graphical animation. To prevent stutter for a CPU or GPU intensive animation, boost the GPU and CPU freq to the maximum to get the first frame out as quickly as possible. The normal CPU and GPU frequency management code will take over from there and (hopefully) clock down to save power as needed if the max frequencies aren't required.
This could probably be done more cleanly, and possibly without another uncached read in the execbuf path if we tracked idleness elsewhere. I'm also unsure about the cpufreq calls; I don't really know if this will do what I want...
Quoted 6 lines
Quoted 3 lines
Would seem like a good idea to make
intel_mark_busy()dtrt and use them. -ChrisIs there a way to force the GPU always to run at the top speed? (since it might well be the most efficient way to run things due to race-to-halt)
Yeah I posted a patch for that earlier; adds a new i915.enable_turbo param. If disabled, it just always runs at top speed when not in C6.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center