Skip to contentSkip to conversation

dma-buf: fence debugging

PATCH Applied Russell King 3 participants 3 messages Mar 31, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-buf: fence debugging

Add debugfs output to report shared and exclusive fences on a dma_buf object. This produces output such as:

Dma-buf Objects:

size    flags   mode    count   exp_name
08294400        00000000        00000005        00000005        drm

Exclusive fence: etnaviv 134000.gpu signalled Attached Devices:
gpu-subsystem
Total 1 devices attached

Total 1 objects, 8294400 bytes

---
 drivers/dma-buf/dma-buf.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletions(-)
drivers/dma-buf/dma-buf.c +33 -1
index 0007b792827b..f72aaacbe023 100644
@@ -1059,7 +1059,11 @@ 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;
-	int count = 0, attach_count;
+	struct reservation_object *robj;
+	struct reservation_object_list *fobj;
+	struct dma_fence *fence;
+	unsigned seq;
+	int count = 0, attach_count, shared_count, i;
 	size_t size = 0;
 
 	ret = mutex_lock_interruptible(&db_list.lock);
@@ -1085,6 +1090,34 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
 				file_count(buf_obj->file),
 				buf_obj->exp_name);
 
+		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();
+		}
+
+		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");
+		}
+		rcu_read_unlock();
+
 		seq_puts(s, "\tAttached Devices:\n");
 		attach_count = 0;
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw

Am 31.03.2017 um 12:00 schrieb Russell King:

Quoted 12 lines

Add debugfs output to report shared and exclusive fences on a dma_buf object. This produces output such as:

Dma-buf Objects:

size    flags   mode    count   exp_name
08294400        00000000        00000005        00000005        drm

Exclusive fence: etnaviv 134000.gpu signalled Attached Devices:
gpu-subsystem
Total 1 devices attached

Quoted 4 lines

Total 1 objects, 8294400 bytes

Quoted 46 lines
---
  drivers/dma-buf/dma-buf.c | 34 +++++++++++++++++++++++++++++++++-
  1 file changed, 33 insertions(+), 1 deletions(-)
drivers/dma-buf/dma-buf.c +26 -1
index 0007b792827b..f72aaacbe023 100644
@@ -1059,7 +1059,11 @@ 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;
-	int count = 0, attach_count;
+	struct reservation_object *robj;
+	struct reservation_object_list *fobj;
+	struct dma_fence *fence;
+	unsigned seq;
+	int count = 0, attach_count, shared_count, i;
  	size_t size = 0;
 
  	ret = mutex_lock_interruptible(&db_list.lock);
@@ -1085,6 +1090,34 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)
  				file_count(buf_obj->file),
  				buf_obj->exp_name);
 
+		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();
+		}
+
+		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;

drivers/dma-buf/dma-buf.c static int dma_buf_debug_show(struct seq_file *s, void *unused) · line 1123

Quoted 10 lines
drivers/dma-buf/dma-buf.c +7 -0
+			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");
+		}
+		rcu_read_unlock();
+
  		seq_puts(s, "\tAttached Devices:\n");
  		attach_count = 0;
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Russell King

Hi Russell,

2017-03-31 Russell King <[email protected]>:

Quoted 12 lines

Add debugfs output to report shared and exclusive fences on a dma_buf object. This produces output such as:

Dma-buf Objects:

size    flags   mode    count   exp_name
08294400        00000000        00000005        00000005        drm

Exclusive fence: etnaviv 134000.gpu signalled Attached Devices:
gpu-subsystem
Total 1 devices attached

Quoted 7 lines

Total 1 objects, 8294400 bytes

---
 drivers/dma-buf/dma-buf.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletions(-)

Applied to to drm-misc-next.

Quoted 6 lines
drivers/dma-buf/dma-buf.c +0 -0
index 0007b792827b..f72aaacbe023 100644

drivers/dma-buf/dma-buf.c static int dma_buf_debug_show(struct seq_file *s, void *unused) · line 1065

Quoted 8 lines
drivers/dma-buf/dma-buf.c +4 -1
@@ -1059,7 +1059,11 @@ 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;
-	int count = 0, attach_count;
+	struct reservation_object *robj;
+	struct reservation_object_list *fobj;
+	struct dma_fence *fence;
+	unsigned seq;

Our maintainer tools warned about this line, so I made it "unsigned int"

Gustavo