[Intel-gfx] [PATCH] drm/i915: Build request info on stack before printk

Chris Wilson chris at chris-wilson.co.uk
Tue Apr 24 01:01:36 UTC 2018


printk unhelpfully inserts a '\n' between consecutive calls, and since
our drm_printf wrapper may be emitting info a seq_file instead,
KERN_CONT is not an option. To work with any drm_printf destination, we
need to build up the output into a temporary buf on the stack and then
feed the complete line in a single call to printk.

Fixes: b7268c5eed0a ("drm/i915: Pack params to engine->schedule() into a struct")
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 drivers/gpu/drm/i915/intel_engine_cs.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index be608f7111f5..6a5e0a05b1ee 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -1113,14 +1113,16 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915)
 	return which;
 }
 
-static void print_sched_attr(struct drm_printer *m,
-			     const struct drm_i915_private *i915,
-			     const struct i915_sched_attr *attr)
+static int print_sched_attr(const struct i915_sched_attr *attr,
+			    char *buf, int offset, int len)
 {
 	if (attr->priority == I915_PRIORITY_INVALID)
-		return;
+		return offset;
+
+	offset += snprintf(buf + offset, len - offset,
+			   " prio=%d", attr->priority);
 
-	drm_printf(m, "prio=%d", attr->priority);
+	return offset;
 }
 
 static void print_request(struct drm_printer *m,
@@ -1128,14 +1130,17 @@ static void print_request(struct drm_printer *m,
 			  const char *prefix)
 {
 	const char *name = rq->fence.ops->get_timeline_name(&rq->fence);
+	char buf[80];
+	int x = 0;
+
+	x = print_sched_attr(&rq->sched.attr, buf, x, sizeof(buf));
 
-	drm_printf(m, "%s%x%s [%llx:%x] ",
+	drm_printf(m, "%s%x%s [%llx:%x]%s @ %dms: %s\n",
 		   prefix,
 		   rq->global_seqno,
 		   i915_request_completed(rq) ? "!" : "",
-		   rq->fence.context, rq->fence.seqno);
-	print_sched_attr(m, rq->i915, &rq->sched.attr);
-	drm_printf(m, " @ %dms: %s\n",
+		   rq->fence.context, rq->fence.seqno,
+		   buf,
 		   jiffies_to_msecs(jiffies - rq->emitted_jiffies),
 		   name);
 }
-- 
2.17.0



More information about the Intel-gfx mailing list