Skip to contentSkip to conversation

selftests: sync: add test that waits on a destroyed timeline

PATCH Superseded Gustavo Padovan 2 participants 3 messages Sep 4, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 selftests: sync: add test that waits on a destroyed timeline

From: Emilio López <[email protected]>

If a sw_sync_timeline is destroyed the fences associated to it need to be signalled. This test checks that.

---
 tools/testing/selftests/sync/sync_test.c |  1 +
 tools/testing/selftests/sync/sync_wait.c | 58 ++++++++++++++++++++++++++++++++
 tools/testing/selftests/sync/synctest.h  |  1 +
 3 files changed, 60 insertions(+)
tools/testing/selftests/sync/sync_test.c +1 -0
index 62fa666e501a..5d93c9dcc290 100644
@@ -79,6 +79,7 @@ int main(void)
 	err += RUN_TEST(test_fence_one_timeline_merge);
 	err += RUN_TEST(test_fence_merge_same_fence);
 	err += RUN_TEST(test_fence_multi_timeline_wait);
+	err += RUN_TEST(test_fence_wait_on_destroyed_timeline);
 	err += RUN_TEST(test_stress_two_threads_shared_timeline);
 	err += RUN_TEST(test_consumer_stress_multi_producer_single_consumer);
 	err += RUN_TEST(test_merge_stress_random_merge);
tools/testing/selftests/sync/sync_wait.c +58 -0

67 lines not on this page · raw message

tools/testing/selftests/sync/synctest.h +1 -0
index e7d1d57dba7a..1cbe1e3658b3 100644
@@ -53,6 +53,7 @@ int test_fence_merge_same_fence(void);
 
 /* Fence wait tests */
 int test_fence_multi_timeline_wait(void);
+int test_fence_wait_on_destroyed_timeline(void);
 
 /* Stress test - parallelism */
 int test_stress_two_threads_shared_timeline(void);
Signature · 6 lines
2.13.5

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

PATCH 2/2 dma-buf/sw_sync: force signal all unsignaled fences on dying timeline

From: Dominik Behr <[email protected]>

To avoid hanging userspace components that might have been waiting on the active fences of the destroyed timeline we need to signal with error all remaining fences on such timeline.

This restore the default behaviour of the Android sw_sync framework, which Android still relies on. It was broken on the dma fence conversion a few years ago and never fixed.

---
 drivers/dma-buf/sw_sync.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/dma-buf/sw_sync.c +12 -0
index 38cc7389a6c1..a85198c75a1b 100644
@@ -321,9 +321,21 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
 static int sw_sync_debugfs_release(struct inode *inode, struct file *file)
 {
 	struct sync_timeline *obj = file->private_data;
+	struct sync_pt *pt, *next;
 
 	smp_wmb();
 
+	spin_lock_irq(&obj->lock);
+
+	list_for_each_entry_safe(pt, next, &obj->pt_list, link) {
+		dma_fence_set_error(&pt->base, -ENOENT);
+		dma_fence_signal_locked(&pt->base);
+		list_del_init(&pt->link);
+		rb_erase(&pt->node, &obj->pt_tree);
+	}
+
+	spin_unlock_irq(&obj->lock);
+
 	sync_timeline_put(obj);
 	return 0;
 }
Signature · 6 lines
2.13.5

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

Re: [PATCH 2/2] dma-buf/sw_sync: force signal all unsignaled fences on dying timeline

Quoting Gustavo Padovan (2017-09-05 00:06:04)

Quoted 25 lines

From: Dominik Behr <[email protected]>

To avoid hanging userspace components that might have been waiting on the active fences of the destroyed timeline we need to signal with error all remaining fences on such timeline.

This restore the default behaviour of the Android sw_sync framework, which Android still relies on. It was broken on the dma fence conversion a few years ago and never fixed.

---
 drivers/dma-buf/sw_sync.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/dma-buf/sw_sync.c +1 -0
index 38cc7389a6c1..a85198c75a1b 100644
@@ -321,9 +321,21 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file)
 static int sw_sync_debugfs_release(struct inode *inode, struct file *file)
 {
        struct sync_timeline *obj = file->private_data;
+       struct sync_pt *pt, *next;

drivers/dma-buf/sw_sync.c static int sw_sync_debugfs_open(struct inode *inode, struct file *file) · line 334

Quoted 10 lines
drivers/dma-buf/sw_sync.c +7 -0
 
        smp_wmb();
 
+       spin_lock_irq(&obj->lock);
+
+       list_for_each_entry_safe(pt, next, &obj->pt_list, link) {
+               dma_fence_set_error(&pt->base, -ENOENT);
+               dma_fence_signal_locked(&pt->base);
+               list_del_init(&pt->link);
+               rb_erase(&pt->node, &obj->pt_tree);

Since the timeline is dead, we don't need to worry about trimming the completed signals from the timeline. No need for the list_del/rb_erase here, especially considering the trickiness required to avoid the potential deadlock which is missing here. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel