[Intel-gfx] [PATCH 09/15] drm/i915: Keep track of open i915 clients
Ben Widawsky
ben at bwidawsk.net
Sat Nov 19 03:24:26 CET 2011
DRM core keeps track of open clients, but that may be include clients
which are not relevant to i915. So we keep our own count to help us
track when certain events are interesting.
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
drivers/gpu/drm/i915/i915_dma.c | 9 +++++++++
drivers/gpu/drm/i915/i915_drv.h | 6 ++++++
drivers/gpu/drm/i915/i915_gem.c | 7 +++++++
3 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 942c5c2..df06a7e 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -2073,6 +2073,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
ips_ping_for_i915_load();
+ INIT_LIST_HEAD(&dev_priv->i915_client_list);
+
return 0;
out_gem_unload:
@@ -2194,6 +2196,7 @@ int i915_driver_unload(struct drm_device *dev)
int i915_driver_open(struct drm_device *dev, struct drm_file *file)
{
struct drm_i915_file_private *file_priv;
+ struct drm_i915_private *dev_priv = dev->dev_private;
DRM_DEBUG_DRIVER("\n");
file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
@@ -2205,9 +2208,15 @@ 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);
+ INIT_LIST_HEAD(&file_priv->client_link);
file_priv->outstanding_requests = 0;
file_priv->forced_throttles = 0;
+ mutex_lock(&dev->struct_mutex);
+ dev_priv->num_clients++;
+ list_add(&file_priv->client_link, &dev_priv->i915_client_list);
+ mutex_unlock(&dev->struct_mutex);
+
return 0;
}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2917e54..3ce03a0 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -735,6 +735,10 @@ typedef struct drm_i915_private {
atomic_t forcewake_count;
+ int num_clients;
+ /* There's something already named client_list... too bad */
+ struct list_head i915_client_list;
+
/* For the foreseeable future, we will only have 2 real scheduler
* types, and both are really similar. If the count grows past that,
* we'd want to abstract this better.
@@ -934,6 +938,8 @@ struct drm_i915_file_private {
struct list_head request_list;
int outstanding_requests;
int forced_throttles;
+
+ struct list_head client_link;
};
#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 2a2f0cd..5b7072d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4135,6 +4135,7 @@ i915_gem_phys_pwrite(struct drm_device *dev,
void i915_gem_release(struct drm_device *dev, struct drm_file *file)
{
struct drm_i915_file_private *file_priv = file->driver_priv;
+ struct drm_i915_private *dev_priv = dev->dev_private;
/* Clean up our request list when the client is going away, so that
* later retire_requests won't dereference our soon-to-be-gone
@@ -4156,6 +4157,12 @@ void i915_gem_release(struct drm_device *dev, struct drm_file *file)
}
file_priv->outstanding_requests = -1;
spin_unlock(&file_priv->lock);
+
+ mutex_lock(&dev->struct_mutex);
+ --dev_priv->num_clients;
+ list_del(&file_priv->client_link);
+ mutex_unlock(&dev->struct_mutex);
+
}
static int
--
1.7.7.3
More information about the Intel-gfx
mailing list