| 433 | } |
| 434 | |
| 435 | uint32_t remote_call(virtgpu * gpu, |
| 436 | apir_encoder * encoder, |
| 437 | apir_decoder ** decoder, |
| 438 | float max_wait_ms, |
| 439 | long long * call_duration_ns) { |
| 440 | /* |
| 441 | * Prepare the reply notification pointer |
| 442 | */ |
| 443 | |
| 444 | volatile std::atomic_uint * atomic_reply_notif = (volatile std::atomic_uint *) gpu->reply_shmem.mmap_ptr; |
| 445 | *atomic_reply_notif = 0; |
| 446 | |
| 447 | /* |
| 448 | * Trigger the execbuf ioctl |
| 449 | */ |
| 450 | |
| 451 | drm_virtgpu_execbuffer args = { |
| 452 | .flags = VIRTGPU_EXECBUF_RING_IDX, |
| 453 | .size = (uint32_t) (encoder->cur - encoder->start), |
| 454 | .command = (uintptr_t) encoder->start, |
| 455 | |
| 456 | .bo_handles = 0, |
| 457 | .num_bo_handles = 0, |
| 458 | |
| 459 | .fence_fd = 0, |
| 460 | .ring_idx = 0, |
| 461 | .syncobj_stride = 0, |
| 462 | .num_in_syncobjs = 0, |
| 463 | .num_out_syncobjs = 0, |
| 464 | .in_syncobjs = 0, |
| 465 | .out_syncobjs = 0, |
| 466 | }; |
| 467 | |
| 468 | *decoder = NULL; |
| 469 | |
| 470 | int ret = drmIoctl(gpu->fd, DRM_IOCTL_VIRTGPU_EXECBUFFER, &args); |
| 471 | |
| 472 | if (ret != 0) { |
| 473 | GGML_ABORT(GGML_VIRTGPU "%s: the virtgpu EXECBUFFER ioctl failed (%d)", __func__, ret); |
| 474 | } |
| 475 | |
| 476 | /* |
| 477 | * Wait for the response notification |
| 478 | */ |
| 479 | timer_data wait_host_reply_timer = { 0, 0, 0 }; |
| 480 | |
| 481 | start_timer(&wait_host_reply_timer); |
| 482 | |
| 483 | timespec ts_start, ts_end; |
| 484 | clock_gettime(CLOCK_MONOTONIC, &ts_start); |
| 485 | long long start_time = (long long) ts_start.tv_sec * 1000000000LL + ts_start.tv_nsec; |
| 486 | |
| 487 | bool timedout = false; |
| 488 | uint32_t notif_value = 0; |
| 489 | while (true) { |
| 490 | notif_value = std::atomic_load_explicit(atomic_reply_notif, std::memory_order_acquire); |
| 491 | |
| 492 | if (notif_value != 0) { |
no test coverage detected