Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf/selftests: drop the mock_wait implementation

Actually test the documented expectation of dma_fence_wait() instead of
comming up with a mock_wait implementation which uses undocumented
and non standard return codes and behavior.

Additional to that increase the timeout to one second, otherwise the
test case is a bit unreliable.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Link: https://lore.kernel.org/r/346e3df8-5f3a-4394-9d90-4ba107294161@ursulin.net

+5 -46
+5 -46
drivers/dma-buf/st-dma-fence.c
··· 33 33 kmem_cache_free(slab_fences, to_mock_fence(f)); 34 34 } 35 35 36 - struct wait_cb { 37 - struct dma_fence_cb cb; 38 - struct task_struct *task; 39 - }; 40 - 41 - static void mock_wakeup(struct dma_fence *f, struct dma_fence_cb *cb) 42 - { 43 - wake_up_process(container_of(cb, struct wait_cb, cb)->task); 44 - } 45 - 46 - static long mock_wait(struct dma_fence *f, bool intr, long timeout) 47 - { 48 - const int state = intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; 49 - struct wait_cb cb = { .task = current }; 50 - 51 - if (dma_fence_add_callback(f, &cb.cb, mock_wakeup)) 52 - return timeout; 53 - 54 - while (timeout) { 55 - set_current_state(state); 56 - 57 - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &f->flags)) 58 - break; 59 - 60 - if (signal_pending_state(state, current)) 61 - break; 62 - 63 - timeout = schedule_timeout(timeout); 64 - } 65 - __set_current_state(TASK_RUNNING); 66 - 67 - if (!dma_fence_remove_callback(f, &cb.cb)) 68 - return timeout; 69 - 70 - if (signal_pending_state(state, current)) 71 - return -ERESTARTSYS; 72 - 73 - return -ETIME; 74 - } 75 - 76 36 static const struct dma_fence_ops mock_ops = { 77 37 .get_driver_name = mock_name, 78 38 .get_timeline_name = mock_name, 79 - .wait = mock_wait, 80 39 .release = mock_fence_release, 81 40 }; 82 41 ··· 308 349 309 350 dma_fence_enable_sw_signaling(f); 310 351 311 - if (dma_fence_wait_timeout(f, false, 0) != -ETIME) { 352 + if (dma_fence_wait_timeout(f, false, 0) != 0) { 312 353 pr_err("Wait reported complete before being signaled\n"); 313 354 goto err_free; 314 355 } 315 356 316 357 dma_fence_signal(f); 317 358 318 - if (dma_fence_wait_timeout(f, false, 0) != 0) { 359 + if (dma_fence_wait_timeout(f, false, 0) != 1) { 319 360 pr_err("Wait reported incomplete after being signaled\n"); 320 361 goto err_free; 321 362 } ··· 352 393 353 394 dma_fence_enable_sw_signaling(wt.f); 354 395 355 - if (dma_fence_wait_timeout(wt.f, false, 1) != -ETIME) { 396 + if (dma_fence_wait_timeout(wt.f, false, 1) != 0) { 356 397 pr_err("Wait reported complete before being signaled\n"); 357 398 goto err_free; 358 399 } 359 400 360 401 mod_timer(&wt.timer, jiffies + 1); 361 402 362 - if (dma_fence_wait_timeout(wt.f, false, 2) == -ETIME) { 403 + if (dma_fence_wait_timeout(wt.f, false, HZ) == 0) { 363 404 if (timer_pending(&wt.timer)) { 364 - pr_notice("Timer did not fire within the jiffy!\n"); 405 + pr_notice("Timer did not fire within one HZ!\n"); 365 406 err = 0; /* not our fault! */ 366 407 } else { 367 408 pr_err("Wait reported incomplete after timeout\n");