public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: Properly lock the engine timeline in debugfs i915_gem_request
@ 2017-10-13 20:10 jeff.mcgee
  2017-10-13 20:10 ` [PATCH 2/2] drm/i915: Include current seqno " jeff.mcgee
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeff.mcgee @ 2017-10-13 20:10 UTC (permalink / raw)
  To: intel-gfx

From: Jeff McGee <jeff.mcgee@intel.com>

We are racing with updates to the timeline. This can cause an inconsistent
snapshot to be dumped, or even worse a NULL pointer dereference.

Signed-off-by: Jeff McGee <jeff.mcgee@intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 0bb6e01121fc..135828fb1904 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -657,33 +657,26 @@ static void print_request(struct seq_file *m,
 static int i915_gem_request_info(struct seq_file *m, void *data)
 {
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
-	struct drm_device *dev = &dev_priv->drm;
 	struct drm_i915_gem_request *req;
 	struct intel_engine_cs *engine;
 	enum intel_engine_id id;
-	int ret, any;
-
-	ret = mutex_lock_interruptible(&dev->struct_mutex);
-	if (ret)
-		return ret;
+	int any = 0;
 
-	any = 0;
 	for_each_engine(engine, dev_priv, id) {
-		int count;
+		int count = 0;
 
-		count = 0;
+		spin_lock_irq(&engine->timeline->lock);
 		list_for_each_entry(req, &engine->timeline->requests, link)
 			count++;
-		if (count == 0)
-			continue;
-
-		seq_printf(m, "%s requests: %d\n", engine->name, count);
-		list_for_each_entry(req, &engine->timeline->requests, link)
-			print_request(m, req, "    ");
 
-		any++;
+		if (count) {
+			seq_printf(m, "%s requests: %d\n", engine->name, count);
+			list_for_each_entry(req, &engine->timeline->requests, link)
+				print_request(m, req, "    ");
+			any++;
+		}
+		spin_unlock_irq(&engine->timeline->lock);
 	}
-	mutex_unlock(&dev->struct_mutex);
 
 	if (any == 0)
 		seq_puts(m, "No requests\n");
-- 
2.14.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-14  8:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-13 20:10 [PATCH 1/2] drm/i915: Properly lock the engine timeline in debugfs i915_gem_request jeff.mcgee
2017-10-13 20:10 ` [PATCH 2/2] drm/i915: Include current seqno " jeff.mcgee
2017-10-13 20:22 ` [PATCH 1/2] drm/i915: Properly lock the engine timeline " Chris Wilson
2017-10-13 21:26 ` ✓ Fi.CI.BAT: success for series starting with [1/2] " Patchwork
2017-10-14  8:49 ` ✓ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox