summaryrefslogtreecommitdiff
path: root/tests/sw_sync.c
AgeCommit message (Collapse)Author
2019-03-19tests/sw_sync: Accept bytes transferred between sendmsg/recvmsgChris Wilson
sendmsg/recvmsg return the number of bytes transferred, not just an error code. Fixes: 520b6f7fbb6c ("sw_sync: Wait until the end") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110150 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2019-03-15sw_sync: Wait until the endChris Wilson
If we allow a fork-helper to exit normally before the parent tries to reap the helper (fork-helpers are intended to be only used for persistent background loads), then the helper unhelpful aborts because the child exited cleanly. Simplify by not using the so called helpers at all. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108889 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2019-01-31sw_sync: Initialise struct before useChris Wilson
sw_sync: ../lib/igt_core.c:1592: __igt_fork_helper: Assertion `!proc->running' Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108889 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
2018-11-22tests/sw_sync: use igt_fork_helperDaniel Vetter
I'll need to wrap a bit of magic around all the fork() calls in our tests. Simplest way to get there is to roll out the existing helpers, which even saves a bit of boilerplate code. Cc: Robert Foss <robert.foss@collabora.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2018-07-12tests/sw_sync: fix pthread start_routine declarationLucas De Marchi
pthread_create() expects a void *(*start_routine) (void *). Fix warning the following warning on gcc 8: ../tests/sw_sync.c:773:37: warning: cast between incompatible function types from ‘int (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type] pthread_create(&threads[i], NULL, (void * (*)(void *)) ^ Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
2018-06-15igt/sw_sync: Wrap threaded counter manipulation with mbChris Wilson
sw_sync/sync_multi_consumer_producer was communicating between threads using the sw_sync ioctl and manipulating a shared volatile counter. However, the ioctl itself does not imply a memory barrier, and so different CPUs may see different states of the counter (the volatile making GCC perform the operation in stages making the race even more likely). Instead of using volatile, use locked operations to make the counter manipulation thread-safe. References: https://bugs.freedesktop.org/show_bug.cgi?id=106344 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2017-09-12igt/sw_sync: Fix up close(timeline) tests for unsignaled fencesChris Wilson
Following kernel commit ea4d5a270b57fa8d4871f372ca9b97b7697fdfda Author: Dominik Behr <dbehr@chromium.org> Date: Thu Sep 7 16:02:46 2017 -0300 dma-buf/sw_sync: force signal all unsignaled fences on dying timeline 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. unsignaled fences are now signaled and flagged with ENOENT when the timeline is closed. Fixup timeline_closed_signaled to match. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102650 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
2016-12-17lib/sw_sync: Rename sync_fence_create()Chris Wilson
It takes a sw_sync_timeline and returns a fence (it is a factory), so call it sw_sync_timeline_create_fence() for better self-documentation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-12-17lib/sw_sync: Indicate that sync_merge() operates and create a sync_fenceChris Wilson
Improvements to self-documentating API that matches the rest of sw_sync. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-12-17lib/sw_sync: Bring sync_wait() API into lineChris Wilson
igt likes to return kernel-esque negative errno where we can, and indicate that we expect to operate on a sync_fence, otherwise it is merely a grandiose poll(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-12-14tests/sw_sync: Add subtest test_sync_busy_unixsocketRobert Foss
Add subtest test_sync_busy_fork which increments the timeline in a forked child process, where the timeline fd has been sent through a UNIX socket. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_busy_forkRobert Foss
Add subtest test_sync_busy_fork which increments the timeline in a forked child process. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_merge_invalidRobert Foss
Add subtest test_sync_merge_invalid that tests merging invalid fences. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add igt_require check for sw_sync featureRobert Foss
Make sure that this test is skipped if the sw_sync feature is missing from the host system. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_timeline_closed_signaledRobert Foss
Add subtest test_timeline_closed_signaled that verifies that a signaled fence stays signaled after its timeline has been closed. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_timeline_closedRobert Foss
This subtest verifies that the fences of a timeline are not signalled when a timelne is closed. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_expired_mergeRafael Antognolli
This test creates an already expired fence, then creates a merged fence out of that expired one (passed twice to the merge operation), and finally closes the merged fence. It shows that if the refcounts are wrong on the original expired fence, it might get freed while still in use. Usually a kernel panick will follow. Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com> Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_multi_producer_single_consumerRobert Foss
This subtest runs a single consumer thread and multiple producer thread that are synchronized using multiple timelines. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_multi_timeline_waitRobert Foss
This subtest verifies that waiting, timing out on a wait and that counting fences in various states works. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_random_mergeRobert Foss
This subtest verifies that creating many timelines and merging random fences from each timeline with eachother results in merged fences that are fully functional. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_multi_consumer_producerRobert Foss
This test verifies that stressing the kernel by creating multiple consumer/producer threads that wait on a single timeline to be incremented by another conumer/producer thread does not fail. And that the order amongst the threads is maintained. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_multi_consumerRobert Foss
This subtest verifies the access ordering of multiple consumer threads. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_merge_sameRobert Foss
This subtest verifies merging a fence with itself does not fail. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_mergeRobert Foss
Add subtest test_sync_merge that tests merging fences and the validity of the resulting merged fence. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_sync_busyRobert Foss
This subtest verifies that waiting on fences works properly. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_alloc_merge_fenceRobert Foss
This subtest verifies that merging two fences works in the simples possible case. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_alloc_fence_invalid_timelineRobert Foss
This subtests tests that creating fences on negative timelines fail. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14tests/sw_sync: Add subtest test_alloc_fenceRobert Foss
Add subtest alloc_fence that verifies that it's possible to allocate a fence on a timeline. Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-12-14test/sw_sync: Add sw_sync testRobert Foss
Add initial tests for sw_sync. Signed-off-by: Robert Foss <robert.foss@collabora.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>