[PATCH 07/15] drm/i915: Keep track of request counts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is already a list of requests outstanding for a given client.
Keeping a count is easy, and will give a quick way to determine when a
particular client has gotten too greedy.

For now a client is uniquely identified by its file descriptor. This is a
limitation in the design which is acceptable for now.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_dma.c |    1 +
 drivers/gpu/drm/i915/i915_drv.h |    1 +
 drivers/gpu/drm/i915/i915_gem.c |   10 ++++++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 697db7b..d1c9a6f 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2205,6 +2205,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 
 	spin_lock_init(&file_priv->lock);
 	INIT_LIST_HEAD(&file_priv->request_list);
+	file_priv->outstanding_requests = 0;
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b0ce5c8..406279c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -921,6 +921,7 @@ struct drm_i915_file_private {
 	struct spinlock lock;
 
 	struct list_head request_list;
+	int outstanding_requests;
 };
 
 #define INTEL_INFO(dev)	(((struct drm_i915_private *) (dev)->dev_private)->info)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c90c4b4..ee9a77a 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->request_list);
+		file_priv->outstanding_requests++;
 		spin_unlock(&file_priv->lock);
 	}
 
@@ -1706,6 +1707,10 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
 
 	spin_lock(&file_priv->lock);
 	if (request->file_priv) {
+		file_priv->outstanding_requests--;
+		if (WARN_ON(file_priv->outstanding_requests < 0)) {
+			file_priv->outstanding_requests = 0;
+		}
 		list_del(&request->client_list);
 		request->file_priv = NULL;
 	}
@@ -4139,8 +4144,13 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
 					   struct drm_i915_gem_request,
 					   client_list);
 		list_del(&request->client_list);
+		file_priv->outstanding_requests--;
 		request->file_priv = NULL;
 	}
+	if (file_priv->outstanding_requests != 0) {
+		DRM_ERROR("Count was %d\n", file_priv->outstanding_requests);
+	}
+	file_priv->outstanding_requests = -1;
 	spin_unlock(&file_priv->lock);
 }
 
-- 
1.7.7.3



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux