intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Ben Widawsky <ben@bwidawsk.net>
To: intel-gfx@lists.freedesktop.org
Cc: Ben Widawsky <ben@bwidawsk.net>
Subject: [PATCH 09/15] drm/i915: Keep track of open i915 clients
Date: Fri, 18 Nov 2011 18:24:26 -0800	[thread overview]
Message-ID: <1321669472-8045-10-git-send-email-ben@bwidawsk.net> (raw)
In-Reply-To: <1321669472-8045-1-git-send-email-ben@bwidawsk.net>

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@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

  parent reply	other threads:[~2011-11-19  2:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-19  2:24 [PATCH 00/15] [RFC] Forced throttling/scheduling Ben Widawsky
2011-11-19  2:24 ` [PATCH 01/15] drm/i915: refactor debugfs open function Ben Widawsky
2011-11-20 18:50   ` Kenneth Graunke
2011-11-19  2:24 ` [PATCH 02/15] drm/i915: refactor debugfs create functions Ben Widawsky
2011-11-19  2:24 ` [PATCH 03/15] drm/i915: relative_constants_mode race fix Ben Widawsky
2011-11-23 22:30   ` Ben Widawsky
2011-11-19  2:24 ` [PATCH 04/15] drm/i915: drop lock support for i915_wait_request Ben Widawsky
2011-11-19  2:24 ` [PATCH 05/15] drm/i915: remove mm structure from file_priv Ben Widawsky
2011-11-19  2:24 ` [PATCH 06/15] drm/i915: Keep track of drm_file in file_priv Ben Widawsky
2011-11-19  2:24 ` [PATCH 07/15] drm/i915: Keep track of request counts Ben Widawsky
2011-11-19  2:24 ` [PATCH 08/15] drm/i915: fairness Ben Widawsky
2011-11-19  2:24 ` Ben Widawsky [this message]
2011-11-19  2:24 ` [PATCH 10/15] drm/i915: debugfs entry for i915 clients Ben Widawsky
2011-11-19  2:24 ` [PATCH 11/15] drm/i915: debugfs entries for scheduler params Ben Widawsky
2011-11-19  2:24 ` [PATCH 12/15] drm/i915: infrastructure to support scheduler types Ben Widawsky
2011-11-19  2:24 ` [PATCH 13/15] drm/i915: get/set scheduler type from debugfs Ben Widawsky
2011-11-19  2:24 ` [PATCH 14/15] drm/i915: Implement batch scheduler Ben Widawsky
2011-11-19  2:24 ` [PATCH 15/15] drm/i915: Add handling for batch parameters in debugfs Ben Widawsky
2011-11-29 14:30 ` [PATCH 00/15] [RFC] Forced throttling/scheduling Eugeni Dodonov
2012-04-02 18:28 ` Ben Widawsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321669472-8045-10-git-send-email-ben@bwidawsk.net \
    --to=ben@bwidawsk.net \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).