Commit 2e1b8730 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Convert RPS tracking to a intel_rps_client struct

Now that we have internal clients, rather than faking a whole
drm_i915_file_private just for tracking RPS boosts, create a new struct
intel_rps_client and pass it along when waiting.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
[danvet: s/rq/req/]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent bcafc4e3
...@@ -2307,12 +2307,16 @@ static int i915_rps_boost_info(struct seq_file *m, void *data) ...@@ -2307,12 +2307,16 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
seq_printf(m, "%s [%d]: %d boosts%s\n", seq_printf(m, "%s [%d]: %d boosts%s\n",
task ? task->comm : "<unknown>", task ? task->comm : "<unknown>",
task ? task->pid : -1, task ? task->pid : -1,
file_priv->rps_boosts, file_priv->rps.boosts,
list_empty(&file_priv->rps_boost) ? "" : ", active"); list_empty(&file_priv->rps.link) ? "" : ", active");
rcu_read_unlock(); rcu_read_unlock();
} }
seq_printf(m, "Semaphore boosts: %d\n", dev_priv->rps.semaphores.rps_boosts); seq_printf(m, "Semaphore boosts: %d%s\n",
seq_printf(m, "MMIO flip boosts: %d\n", dev_priv->rps.mmioflips.rps_boosts); dev_priv->rps.semaphores.boosts,
list_empty(&dev_priv->rps.semaphores.link) ? "" : ", active");
seq_printf(m, "MMIO flip boosts: %d%s\n",
dev_priv->rps.mmioflips.boosts,
list_empty(&dev_priv->rps.mmioflips.link) ? "" : ", active");
seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts); seq_printf(m, "Kernel boosts: %d\n", dev_priv->rps.boosts);
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
......
...@@ -282,10 +282,12 @@ struct drm_i915_file_private { ...@@ -282,10 +282,12 @@ struct drm_i915_file_private {
} mm; } mm;
struct idr context_idr; struct idr context_idr;
struct list_head rps_boost; struct intel_rps_client {
struct intel_engine_cs *bsd_ring; struct list_head link;
unsigned boosts;
} rps;
unsigned rps_boosts; struct intel_engine_cs *bsd_ring;
}; };
enum intel_dpll_id { enum intel_dpll_id {
...@@ -1086,8 +1088,7 @@ struct intel_gen6_power_mgmt { ...@@ -1086,8 +1088,7 @@ struct intel_gen6_power_mgmt {
struct list_head clients; struct list_head clients;
unsigned boosts; unsigned boosts;
struct drm_i915_file_private semaphores; struct intel_rps_client semaphores, mmioflips;
struct drm_i915_file_private mmioflips;
/* manual wa residency calculations */ /* manual wa residency calculations */
struct intel_rps_ei up_ei, down_ei; struct intel_rps_ei up_ei, down_ei;
...@@ -2856,7 +2857,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, ...@@ -2856,7 +2857,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
unsigned reset_counter, unsigned reset_counter,
bool interruptible, bool interruptible,
s64 *timeout, s64 *timeout,
struct drm_i915_file_private *file_priv); struct intel_rps_client *rps);
int __must_check i915_wait_request(struct drm_i915_gem_request *req); int __must_check i915_wait_request(struct drm_i915_gem_request *req);
int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
int __must_check int __must_check
......
...@@ -1221,7 +1221,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req, ...@@ -1221,7 +1221,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
unsigned reset_counter, unsigned reset_counter,
bool interruptible, bool interruptible,
s64 *timeout, s64 *timeout,
struct drm_i915_file_private *file_priv) struct intel_rps_client *rps)
{ {
struct intel_engine_cs *ring = i915_gem_request_get_ring(req); struct intel_engine_cs *ring = i915_gem_request_get_ring(req);
struct drm_device *dev = ring->dev; struct drm_device *dev = ring->dev;
...@@ -1244,8 +1244,8 @@ int __i915_wait_request(struct drm_i915_gem_request *req, ...@@ -1244,8 +1244,8 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
timeout_expire = timeout ? timeout_expire = timeout ?
jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0; jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0;
if (INTEL_INFO(dev)->gen >= 6) if (INTEL_INFO(dev_priv)->gen >= 6)
gen6_rps_boost(dev_priv, file_priv); gen6_rps_boost(dev_priv, rps);
/* Record current time in case interrupted by signal, or wedged */ /* Record current time in case interrupted by signal, or wedged */
trace_i915_gem_request_wait_begin(req); trace_i915_gem_request_wait_begin(req);
...@@ -1493,7 +1493,7 @@ i915_gem_object_retire_request(struct drm_i915_gem_object *obj, ...@@ -1493,7 +1493,7 @@ i915_gem_object_retire_request(struct drm_i915_gem_object *obj,
*/ */
static __must_check int static __must_check int
i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj, i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
struct drm_i915_file_private *file_priv, struct intel_rps_client *rps,
bool readonly) bool readonly)
{ {
struct drm_device *dev = obj->base.dev; struct drm_device *dev = obj->base.dev;
...@@ -1545,7 +1545,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj, ...@@ -1545,7 +1545,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
for (i = 0; ret == 0 && i < n; i++) for (i = 0; ret == 0 && i < n; i++)
ret = __i915_wait_request(requests[i], reset_counter, true, ret = __i915_wait_request(requests[i], reset_counter, true,
NULL, file_priv); NULL, rps);
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
err: err:
...@@ -1558,6 +1558,12 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj, ...@@ -1558,6 +1558,12 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
return ret; return ret;
} }
static struct intel_rps_client *to_rps_client(struct drm_file *file)
{
struct drm_i915_file_private *fpriv = file->driver_priv;
return &fpriv->rps;
}
/** /**
* Called when user space prepares to use an object with the CPU, either * Called when user space prepares to use an object with the CPU, either
* through the mmap ioctl's mapping or a GTT mapping. * through the mmap ioctl's mapping or a GTT mapping.
...@@ -1600,7 +1606,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, ...@@ -1600,7 +1606,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
* to catch cases where we are gazumped. * to catch cases where we are gazumped.
*/ */
ret = i915_gem_object_wait_rendering__nonblocking(obj, ret = i915_gem_object_wait_rendering__nonblocking(obj,
file->driver_priv, to_rps_client(file),
!write_domain); !write_domain);
if (ret) if (ret)
goto unref; goto unref;
...@@ -5216,9 +5222,9 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file) ...@@ -5216,9 +5222,9 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
} }
spin_unlock(&file_priv->mm.lock); spin_unlock(&file_priv->mm.lock);
if (!list_empty(&file_priv->rps_boost)) { if (!list_empty(&file_priv->rps.link)) {
mutex_lock(&to_i915(dev)->rps.hw_lock); mutex_lock(&to_i915(dev)->rps.hw_lock);
list_del(&file_priv->rps_boost); list_del(&file_priv->rps.link);
mutex_unlock(&to_i915(dev)->rps.hw_lock); mutex_unlock(&to_i915(dev)->rps.hw_lock);
} }
} }
...@@ -5237,7 +5243,7 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) ...@@ -5237,7 +5243,7 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file)
file->driver_priv = file_priv; file->driver_priv = file_priv;
file_priv->dev_priv = dev->dev_private; file_priv->dev_priv = dev->dev_private;
file_priv->file = file; file_priv->file = file;
INIT_LIST_HEAD(&file_priv->rps_boost); INIT_LIST_HEAD(&file_priv->rps.link);
spin_lock_init(&file_priv->mm.lock); spin_lock_init(&file_priv->mm.lock);
INIT_LIST_HEAD(&file_priv->mm.request_list); INIT_LIST_HEAD(&file_priv->mm.request_list);
......
...@@ -1365,7 +1365,7 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv); ...@@ -1365,7 +1365,7 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv);
void gen6_rps_reset_ei(struct drm_i915_private *dev_priv); void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
void gen6_rps_idle(struct drm_i915_private *dev_priv); void gen6_rps_idle(struct drm_i915_private *dev_priv);
void gen6_rps_boost(struct drm_i915_private *dev_priv, void gen6_rps_boost(struct drm_i915_private *dev_priv,
struct drm_i915_file_private *file_priv); struct intel_rps_client *rps);
void intel_queue_rps_boost_for_request(struct drm_device *dev, void intel_queue_rps_boost_for_request(struct drm_device *dev,
struct drm_i915_gem_request *req); struct drm_i915_gem_request *req);
void ilk_wm_get_hw_state(struct drm_device *dev); void ilk_wm_get_hw_state(struct drm_device *dev);
......
...@@ -4150,7 +4150,7 @@ void gen6_rps_idle(struct drm_i915_private *dev_priv) ...@@ -4150,7 +4150,7 @@ void gen6_rps_idle(struct drm_i915_private *dev_priv)
} }
void gen6_rps_boost(struct drm_i915_private *dev_priv, void gen6_rps_boost(struct drm_i915_private *dev_priv,
struct drm_i915_file_private *file_priv) struct intel_rps_client *rps)
{ {
u32 val; u32 val;
...@@ -4159,13 +4159,13 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv, ...@@ -4159,13 +4159,13 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv,
if (dev_priv->rps.enabled && if (dev_priv->rps.enabled &&
dev_priv->mm.busy && dev_priv->mm.busy &&
dev_priv->rps.cur_freq < val && dev_priv->rps.cur_freq < val &&
(file_priv == NULL || list_empty(&file_priv->rps_boost))) { (rps == NULL || list_empty(&rps->link))) {
intel_set_rps(dev_priv->dev, val); intel_set_rps(dev_priv->dev, val);
dev_priv->rps.last_adj = 0; dev_priv->rps.last_adj = 0;
if (file_priv != NULL) { if (rps != NULL) {
list_add(&file_priv->rps_boost, &dev_priv->rps.clients); list_add(&rps->link, &dev_priv->rps.clients);
file_priv->rps_boosts++; rps->boosts++;
} else } else
dev_priv->rps.boosts++; dev_priv->rps.boosts++;
} }
...@@ -6884,8 +6884,8 @@ void intel_pm_setup(struct drm_device *dev) ...@@ -6884,8 +6884,8 @@ void intel_pm_setup(struct drm_device *dev)
INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work, INIT_DELAYED_WORK(&dev_priv->rps.delayed_resume_work,
intel_gen6_powersave_work); intel_gen6_powersave_work);
INIT_LIST_HEAD(&dev_priv->rps.clients); INIT_LIST_HEAD(&dev_priv->rps.clients);
INIT_LIST_HEAD(&dev_priv->rps.semaphores.rps_boost); INIT_LIST_HEAD(&dev_priv->rps.semaphores.link);
INIT_LIST_HEAD(&dev_priv->rps.mmioflips.rps_boost); INIT_LIST_HEAD(&dev_priv->rps.mmioflips.link);
dev_priv->pm.suspended = false; dev_priv->pm.suspended = false;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment