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