[Intel-gfx] [PATCH 13/15] drm/i915: get/set scheduler type from debugfs

Ben Widawsky ben at bwidawsk.net
Sat Nov 19 03:24:30 CET 2011


Allows users to get and set the type of GPU scheduling done in the i915
driver.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_debugfs.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 790875d..903a004 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1543,6 +1543,9 @@ static const struct file_operations i915_cache_sharing_fops = {
 	.llseek = default_llseek,
 };
 
+static const char *sched_type[I915_SCHEDULER_INVALID] =
+	{"none", "fair"};
+
 static ssize_t
 i915_sched_read(struct file *filp,
 		char __user *ubuf,
@@ -1552,7 +1555,7 @@ i915_sched_read(struct file *filp,
 	struct drm_device *dev = filp->private_data;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_file_private *temp;
-	unsigned high, low;
+	unsigned high, low, type;
 	size_t len = 0;
 	char *buf, *buf2;
 	struct {
@@ -1564,13 +1567,11 @@ i915_sched_read(struct file *filp,
 	} requests[20];
 	int entries, entry_size, i = 0, ret = 0;
 
-	if (!i915_scheduler)
-		return 0;
-
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
 	if (ret)
 		return ret;
 
+	type = dev_priv->scheduler.type;
 	high = dev_priv->scheduler.high_watermark;
 	low = dev_priv->scheduler.low_watermark;
 	list_for_each_entry(temp, &dev_priv->i915_client_list, client_link) {
@@ -1600,7 +1601,7 @@ i915_sched_read(struct file *filp,
 				    "Scheduler = %s\n"
 				    "High watermark = %d buffers\n"
 				    "Low watermark = %d buffers\n",
-				     buf2, "fair", high, low);
+				     buf2, sched_type[type], high, low);
 
 	len = strlen(buf);
 
@@ -1620,7 +1621,7 @@ i915_sched_write(struct file *filp,
 	struct drm_device *dev = filp->private_data;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	char *buf, *ptr;
-	uint32_t high, low;
+	uint32_t high, low, type;
 	int ret;
 
 	buf = drm_malloc_ab(cnt + 1, 1);
@@ -1637,11 +1638,21 @@ i915_sched_write(struct file *filp,
 
 	low = dev_priv->scheduler.low_watermark;
 	high = dev_priv->scheduler.high_watermark;
+	type = dev_priv->scheduler.type;
 
 	buf[cnt] = 0;
 	ptr = buf;
 
 	while ((ptr != NULL) && *ptr != 0) {
+		if (!strncmp(ptr, "type=", 5)) {
+			char *tmp = strchr(ptr, '=');
+			if (tmp != NULL)
+				tmp += strspn(tmp, "= \t\n");
+			if (!strncmp("fair", tmp, 4))
+				type = I915_SCHEDULER_FAIR;
+			if (!strncmp("none", tmp, 4))
+				type = I915_SCHEDULER_NONE;
+		}
 		if (!strncmp(ptr, "high=", 5))
 			high = simple_strtoul(ptr + 5, NULL, 0);
 		if (!strncmp(ptr, "low=", 4))
@@ -1652,11 +1663,16 @@ i915_sched_write(struct file *filp,
 	}
 
 	if (high != dev_priv->scheduler.high_watermark ||
-	    low != dev_priv->scheduler.low_watermark) {
+	    (low != dev_priv->scheduler.low_watermark) ||
+	    (type != dev_priv->scheduler.type)) {
+		if (i915_gpu_idle(dev))
+			DRM_ERROR("Couldn't idle GPU before sched changes\n");
+		DRM_INFO("new type = %d\n", type);
 		DRM_INFO("new high = %d\n", high);
 		DRM_INFO("new low = %d\n", low);
 		dev_priv->scheduler.high_watermark = high;
 		dev_priv->scheduler.low_watermark = low;
+		dev_priv->scheduler.type = type;
 	}
 
 	mutex_unlock(&dev->struct_mutex);
-- 
1.7.7.3




More information about the Intel-gfx mailing list