[PATCH 65/74] dma-buf-dbg

Chris Wilson chris at chris-wilson.co.uk
Sun Jul 16 19:01:06 UTC 2017


---
 drivers/dma-buf/dma-buf.c | 55 +++++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 4a038dcf5361..1fa7d2a30f44 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -1059,11 +1059,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 	int ret;
 	struct dma_buf *buf_obj;
 	struct dma_buf_attachment *attach_obj;
-	struct reservation_object *robj;
-	struct reservation_object_list *fobj;
-	struct dma_fence *fence;
-	unsigned seq;
-	int count = 0, attach_count, shared_count, i;
+	int count = 0, attach_count;
 	size_t size = 0;
 
 	ret = mutex_lock_interruptible(&db_list.lock);
@@ -1076,6 +1072,9 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 		   "size", "flags", "mode", "count");
 
 	list_for_each_entry(buf_obj, &db_list.head, list_node) {
+		struct dma_fence *excl, **shared;
+		unsigned int shared_count, i;
+
 		ret = mutex_lock_interruptible(&buf_obj->lock);
 
 		if (ret) {
@@ -1089,34 +1088,30 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 				buf_obj->file->f_flags, buf_obj->file->f_mode,
 				file_count(buf_obj->file),
 				buf_obj->exp_name);
+		if (!reservation_object_get_fences_rcu(buf_obj->resv,
+						       &excl,
+						       &shared_count,
+						       &shared)) {
+			if (excl) {
+				seq_printf(s, "\tExclusive fence: %s %s %ssignalled, error status %d\n",
+					   excl->ops->get_driver_name(excl),
+					   excl->ops->get_timeline_name(excl),
+					   dma_fence_is_signaled(excl) ? "" : "un",
+					   excl->error);
+				dma_fence_put(excl);
+			}
 
-		robj = buf_obj->resv;
-		while (true) {
-			seq = read_seqcount_begin(&robj->seq);
-			rcu_read_lock();
-			fobj = rcu_dereference(robj->fence);
-			shared_count = fobj ? fobj->shared_count : 0;
-			fence = rcu_dereference(robj->fence_excl);
-			if (!read_seqcount_retry(&robj->seq, seq))
-				break;
-			rcu_read_unlock();
-		}
+			for (i = 0; i < shared_count; i++) {
+				seq_printf(s, "\tShared fence: %s %s %ssignalled, error status %d\n",
+					   shared[i]->ops->get_driver_name(shared[i]),
+					   shared[i]->ops->get_timeline_name(shared[i]),
+					   dma_fence_is_signaled(shared[i]) ? "" : "un",
+					   shared[i]->error);
+				dma_fence_put(shared[i]);
+			}
 
-		if (fence)
-			seq_printf(s, "\tExclusive fence: %s %s %ssignalled\n",
-				   fence->ops->get_driver_name(fence),
-				   fence->ops->get_timeline_name(fence),
-				   dma_fence_is_signaled(fence) ? "" : "un");
-		for (i = 0; i < shared_count; i++) {
-			fence = rcu_dereference(fobj->shared[i]);
-			if (!dma_fence_get_rcu(fence))
-				continue;
-			seq_printf(s, "\tShared fence: %s %s %ssignalled\n",
-				   fence->ops->get_driver_name(fence),
-				   fence->ops->get_timeline_name(fence),
-				   dma_fence_is_signaled(fence) ? "" : "un");
+			kfree(shared);
 		}
-		rcu_read_unlock();
 
 		seq_puts(s, "\tAttached Devices:\n");
 		attach_count = 0;
-- 
2.13.2



More information about the Intel-gfx-trybot mailing list