From 70a219d4a358be1d0d41af5b33203aebb19aa9ec Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Mon, 31 Jan 2022 15:17:36 -0100 Subject: [PATCH] broadcom/simulator: enable multisync in the simulator Use drmSyncobjSignal to signal out_syncobjs when a GPU job submission ends in the simulator. With this, we can enable multisync support in the simulator and keep the multisync approach to process fence by submitting a serialized no-op job that adds the fence to the array of out syncobjs, i.e. syncobjs to be signaled in the kernel when a job completes (job post deps). Signed-off-by: Melissa Wen Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/simulator/v3d_simulator.c | 49 ++++++++++++++++++++++++- src/broadcom/simulator/v3dx_simulator.c | 2 +- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/broadcom/simulator/v3d_simulator.c b/src/broadcom/simulator/v3d_simulator.c index 494e5bb4475..878e38ed889 100644 --- a/src/broadcom/simulator/v3d_simulator.c +++ b/src/broadcom/simulator/v3d_simulator.c @@ -427,6 +427,32 @@ v3d_simulator_perfmon_switch(int fd, uint32_t perfid) file->active_perfid = perfid; } +static int +v3d_simulator_signal_syncobjs(int fd, struct drm_v3d_multi_sync *ms) +{ + struct drm_v3d_sem *out_syncs = (void *)(uintptr_t)ms->out_syncs; + int n_syncobjs = ms->out_sync_count; + uint32_t syncobjs[n_syncobjs]; + + for (int i = 0; i < n_syncobjs; i++) + syncobjs[i] = out_syncs[i].handle; + return drmSyncobjSignal(fd, (uint32_t *) &syncobjs, n_syncobjs); +} + +static int +v3d_simulator_process_post_deps(int fd, struct drm_v3d_extension *ext) +{ + int ret = 0; + while (ext && ext->id != DRM_V3D_EXT_ID_MULTI_SYNC) + ext = (void *)(uintptr_t) ext->next; + + if (ext) { + struct drm_v3d_multi_sync *ms = (struct drm_v3d_multi_sync *) ext; + ret = v3d_simulator_signal_syncobjs(fd, ms); + } + return ret; +} + static int v3d_simulator_submit_cl_ioctl(int fd, struct drm_v3d_submit_cl *submit) { @@ -459,7 +485,12 @@ v3d_simulator_submit_cl_ioctl(int fd, struct drm_v3d_submit_cl *submit) if (ret) return ret; - return 0; + if (submit->flags & DRM_V3D_SUBMIT_EXTENSION) { + struct drm_v3d_extension *ext = (void *)(uintptr_t)submit->extensions; + ret = v3d_simulator_process_post_deps(fd, ext); + } + + return ret; } /** @@ -590,6 +621,14 @@ v3d_simulator_submit_tfu_ioctl(int fd, struct drm_v3d_submit_tfu *args) v3d_simulator_copy_out_handle(file, args->bo_handles[0]); + if (ret) + return ret; + + if (args->flags & DRM_V3D_SUBMIT_EXTENSION) { + struct drm_v3d_extension *ext = (void *)(uintptr_t)args->extensions; + ret = v3d_simulator_process_post_deps(fd, ext); + } + return ret; } @@ -614,6 +653,14 @@ v3d_simulator_submit_csd_ioctl(int fd, struct drm_v3d_submit_csd *args) for (int i = 0; i < args->bo_handle_count; i++) v3d_simulator_copy_out_handle(file, bo_handles[i]); + if (ret < 0) + return ret; + + if (args->flags & DRM_V3D_SUBMIT_EXTENSION) { + struct drm_v3d_extension *ext = (void *)(uintptr_t)args->extensions; + ret = v3d_simulator_process_post_deps(fd, ext); + } + return ret; } diff --git a/src/broadcom/simulator/v3dx_simulator.c b/src/broadcom/simulator/v3dx_simulator.c index abc7f9196f1..0d8d0bf62a1 100644 --- a/src/broadcom/simulator/v3dx_simulator.c +++ b/src/broadcom/simulator/v3dx_simulator.c @@ -270,7 +270,7 @@ v3dX(simulator_get_param_ioctl)(struct v3d_hw *v3d, args->value = V3D_VERSION >= 41; return 0; case DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT: - args->value = 0; + args->value = 1; return 0; }