diff mbox

[4/4] drm/i915: Introduce DRM_I915_THROTTLE_JIFFIES

Message ID 1432238508-28741-5-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson May 21, 2015, 8:01 p.m. UTC
As Daniel commented on

commit b7ffe1362c5f468b853223acc9268804aa92afc8
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Apr 27 13:41:24 2015 +0100

    drm/i915: Free RPS boosts for all laggards

it is better to be explicit when sharing hardcoded values such as
throttle/boost timeouts. Make it so!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/i915_drv.h | 6 ++++++
 drivers/gpu/drm/i915/i915_gem.c | 2 +-
 drivers/gpu/drm/i915/intel_pm.c | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

Comments

Daniel Vetter May 22, 2015, 7:03 a.m. UTC | #1
On Thu, May 21, 2015 at 09:01:48PM +0100, Chris Wilson wrote:
> As Daniel commented on
> 
> commit b7ffe1362c5f468b853223acc9268804aa92afc8
> Author: Chris Wilson <chris@chris-wilson.co.uk>
> Date:   Mon Apr 27 13:41:24 2015 +0100
> 
>     drm/i915: Free RPS boosts for all laggards
> 
> it is better to be explicit when sharing hardcoded values such as
> throttle/boost timeouts. Make it so!
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

I merged patch 1&4 from this to dinq. I'd like a "I want this" for 2. And
3 needs more time to properly review the locking and everything, I'll try
to do that later today.

Thanks, Daniel

> ---
>  drivers/gpu/drm/i915/i915_drv.h | 6 ++++++
>  drivers/gpu/drm/i915/i915_gem.c | 2 +-
>  drivers/gpu/drm/i915/intel_pm.c | 2 +-
>  3 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index abd0914b4849..30ffb9138116 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -279,6 +279,12 @@ struct drm_i915_file_private {
>  	struct {
>  		spinlock_t lock;
>  		struct list_head request_list;
> +/* 20ms is a fairly arbitrary limit (greater than the average frame time)
> + * chosen to prevent the CPU getting more than a frame ahead of the GPU
> + * (when using lax throttling for the frontbuffer). We also use it to
> + * offer free GPU waitboosts for severely congested workloads.
> + */
> +#define DRM_I915_THROTTLE_JIFFIES msecs_to_jiffies(20)
>  	} mm;
>  	struct idr context_idr;
>  
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index ca41fc56f246..9ae98b00ff56 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4211,7 +4211,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct drm_i915_file_private *file_priv = file->driver_priv;
> -	unsigned long recent_enough = jiffies - msecs_to_jiffies(20);
> +	unsigned long recent_enough = jiffies - DRM_I915_THROTTLE_JIFFIES;
>  	struct drm_i915_gem_request *request, *target = NULL;
>  	unsigned reset_counter;
>  	int ret;
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 833f9dd28fea..abeb7fca17c8 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -4164,7 +4164,7 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv,
>  	/* Force a RPS boost (and don't count it against the client) if
>  	 * the GPU is severely congested.
>  	 */
> -	if (rps && time_after(jiffies, submitted + msecs_to_jiffies(20)))
> +	if (rps && time_after(jiffies, submitted + DRM_I915_THROTTLE_JIFFIES))
>  		rps = NULL;
>  
>  	spin_lock(&dev_priv->rps.client_lock);
> -- 
> 2.1.4
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index abd0914b4849..30ffb9138116 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -279,6 +279,12 @@  struct drm_i915_file_private {
 	struct {
 		spinlock_t lock;
 		struct list_head request_list;
+/* 20ms is a fairly arbitrary limit (greater than the average frame time)
+ * chosen to prevent the CPU getting more than a frame ahead of the GPU
+ * (when using lax throttling for the frontbuffer). We also use it to
+ * offer free GPU waitboosts for severely congested workloads.
+ */
+#define DRM_I915_THROTTLE_JIFFIES msecs_to_jiffies(20)
 	} mm;
 	struct idr context_idr;
 
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index ca41fc56f246..9ae98b00ff56 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4211,7 +4211,7 @@  i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
-	unsigned long recent_enough = jiffies - msecs_to_jiffies(20);
+	unsigned long recent_enough = jiffies - DRM_I915_THROTTLE_JIFFIES;
 	struct drm_i915_gem_request *request, *target = NULL;
 	unsigned reset_counter;
 	int ret;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 833f9dd28fea..abeb7fca17c8 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -4164,7 +4164,7 @@  void gen6_rps_boost(struct drm_i915_private *dev_priv,
 	/* Force a RPS boost (and don't count it against the client) if
 	 * the GPU is severely congested.
 	 */
-	if (rps && time_after(jiffies, submitted + msecs_to_jiffies(20)))
+	if (rps && time_after(jiffies, submitted + DRM_I915_THROTTLE_JIFFIES))
 		rps = NULL;
 
 	spin_lock(&dev_priv->rps.client_lock);