Allow specifying a syncobj on render job submission where we store the fence for the job. This gives userland flexible access to the fence. v2: Use 0 as invalid syncobj to drop flag (Eric) Don't reintroduce the padding (Eric)
Unified · Split
| @@ -656,7 +656,8 @@ retry: · 655 unmodified lines | ||
| 656 | 656 | */ |
| 657 | 657 | static int |
| 658 | 658 | vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, |
| 659 | − struct ww_acquire_ctx *acquire_ctx) | |
| 659 | + struct ww_acquire_ctx *acquire_ctx, | |
| 660 | + struct drm_syncobj *out_sync) | |
| 660 | 661 | { |
| 661 | 662 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
| 662 | 663 | struct vc4_exec_info *renderjob; |
| @@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, · 16 unmodified lines | ||
| 679 | 680 | fence->seqno = exec->seqno; |
| 680 | 681 | exec->fence = &fence->base; |
| 681 | 682 | |
| 683 | + if (out_sync) | |
| 684 | + drm_syncobj_replace_fence(out_sync, exec->fence); | |
| 685 | + | |
| 682 | 686 | vc4_update_bo_seqnos(exec, seqno); |
| 683 | 687 | |
| 684 | 688 | vc4_unlock_bo_reservations(dev, exec, acquire_ctx); |
| @@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, · 429 unmodified lines | ||
| 1114 | 1118 | struct vc4_dev *vc4 = to_vc4_dev(dev); |
| 1115 | 1119 | struct vc4_file *vc4file = file_priv->driver_priv; |
| 1116 | 1120 | struct drm_vc4_submit_cl *args = data; |
| 1121 | + struct drm_syncobj *out_sync = NULL; | |
| 1117 | 1122 | struct vc4_exec_info *exec; |
| 1118 | 1123 | struct ww_acquire_ctx acquire_ctx; |
| 1119 | 1124 | struct dma_fence *in_fence; |
| @@ -1201,12 +1206,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, · 81 unmodified lines | ||
| 1201 | 1206 | if (ret) |
| 1202 | 1207 | goto fail; |
| 1203 | 1208 | |
| 1209 | + if (args->out_sync) { | |
| 1210 | + out_sync = drm_syncobj_find(file_priv, args->out_sync); | |
| 1211 | + if (!out_sync) { | |
| 1212 | + ret = -EINVAL; | |
| 1213 | + goto fail; | |
| 1214 | + } | |
| 1215 | + | |
| 1216 | + /* We replace the fence in out_sync in vc4_queue_submit since | |
| 1217 | + * the render job could execute immediately after that call. | |
| 1218 | + * If it finishes before our ioctl processing resumes the | |
| 1219 | + * render job fence could already have been freed. | |
| 1220 | + */ | |
| 1221 | + } | |
| 1222 | + | |
| 1204 | 1223 | /* Clear this out of the struct we'll be putting in the queue, |
| 1205 | 1224 | * since it's part of our stack. |
| 1206 | 1225 | */ |
| 1207 | 1226 | exec->args = NULL; |
| 1208 | 1227 | |
| 1209 | − ret = vc4_queue_submit(dev, exec, &acquire_ctx); | |
| 1228 | + ret = vc4_queue_submit(dev, exec, &acquire_ctx, out_sync); | |
| 1229 | + | |
| 1230 | + /* The syncobj isn't part of the exec data and we need to free our | |
| 1231 | + * reference even if job submission failed. | |
| 1232 | + */ | |
| 1233 | + if (out_sync) | |
| 1234 | + drm_syncobj_put(out_sync); | |
| 1235 | + | |
| 1210 | 1236 | if (ret) |
| 1211 | 1237 | goto fail; |
| 1212 | 1238 | |
| @@ -187,6 +187,12 @@ struct drm_vc4_submit_cl { · 186 unmodified lines | ||
| 187 | 187 | * will not start until the syncobj is signaled. 0 means ignore. |
| 188 | 188 | */ |
| 189 | 189 | __u32 in_sync; |
| 190 | + | |
| 191 | + /* Syncobj handle to export fence to. If set, the fence in the syncobj | |
| 192 | + * will be replaced with a fence that signals upon completion of this | |
| 193 | + * render job. 0 means ignore. | |
| 194 | + */ | |
| 195 | + __u32 out_sync; | |
| 190 | 196 | }; |
| 191 | 197 | |
| 192 | 198 | /** |