[Intel-gfx] [PATCH 1/3] drm/i915: Keep track of request counts
Ben Widawsky
ben at bwidawsk.net
Sat Oct 29 07:55:27 CEST 2011
There is already a list of requests outstanding for a given client.
Keeping a count is easy, and will give some information necessary to
enable a more fair throttling scheme.
For now a client is uniquely identified by its file descriptor, however
this may change in the future with new process APIs.
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
drivers/gpu/drm/i915/i915_drv.h | 1 +
drivers/gpu/drm/i915/i915_gem.c | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 06a37f4..a251d22 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -919,6 +919,7 @@ struct drm_i915_file_private {
struct {
struct spinlock lock;
struct list_head request_list;
+ atomic_t outstanding_requests;
} mm;
};
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 6651c36..20d8a41 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1678,6 +1678,7 @@ i915_add_request(struct intel_ring_buffer *ring,
request->file_priv = file_priv;
list_add_tail(&request->client_list,
&file_priv->mm.request_list);
+ atomic_inc(&file_priv->mm.outstanding_requests);
spin_unlock(&file_priv->mm.lock);
}
@@ -1706,6 +1707,10 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
spin_lock(&file_priv->mm.lock);
if (request->file_priv) {
+ atomic_dec(&file_priv->mm.outstanding_requests);
+ if (WARN_ON(atomic_read(&file_priv->mm.outstanding_requests) < 0)) {
+ atomic_set(&file_priv->mm.outstanding_requests, 0);
+ }
list_del(&request->client_list);
request->file_priv = NULL;
}
@@ -4119,6 +4124,9 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
struct drm_i915_gem_request,
client_list);
list_del(&request->client_list);
+ atomic_dec(&file_priv->mm.outstanding_requests);
+ if (WARN_ON(atomic_read(&file_priv->mm.outstanding_requests)))
+ atomic_set(&file_priv->mm.outstanding_requests, 0);
request->file_priv = NULL;
}
spin_unlock(&file_priv->mm.lock);
--
1.7.7.1
More information about the Intel-gfx
mailing list