Hi Iago,
On 13/10/26 04:28, Iago Toral wrote:
El dom, 04-10-2026 a las 12:42 -0300, Maíra Canal escribió:
vc4_attach_fences() adds the job fence to the reservation of every BO
the
job touches, which is a O(bo_count) walk under job_lock. It was there
because vc4_exec_info could be freed by the job done worker the
moment the
lock was dropped.
As vc4_exec_info is refcounted now, hand the fences over after the
unlock.
Note that the render done handler dropped the fence as soon as the
job
completed, so the walk could find exec->fence already cleared. Leave
the
fence to be dropped by the release path. The submit path no longer
needs
a reference of its own to publish the fence through the sync object
either.
Signed-off-by: Maíra Canal <[email protected]>
---
drivers/gpu/drm/vc4/vc4_gem.c | 23 ++++++-----------------
drivers/gpu/drm/vc4/vc4_irq.c | 5 +----
2 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c
b/drivers/gpu/drm/vc4/vc4_gem.c
index 9cf343297f83..ae76868663ea 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -639,14 +639,6 @@ vc4_queue_submit(struct drm_device *dev, struct
vc4_exec_info *exec,
kref_get(&exec->refcount);
- /* The job can complete and drop exec->fence as soon as
job_lock is
- * released, so hold our own reference.
- */
- if (out_sync)
- dma_fence_get(&fence->base);
-
- vc4_attach_fences(exec);
-
list_add_tail(&exec->head, &vc4->bin_job_list);
/* If no bin job was executing and if the render job (if
any) has the
@@ -663,12 +655,12 @@ vc4_queue_submit(struct drm_device *dev, struct
vc4_exec_info *exec,
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+ vc4_attach_fences(exec);
+
Similar question as before: doesn't this mean we may submit this job
before we have installed the fences in the BO reservations? Wouldn't
that mean there is a small window where the BOs look idle to other
users when they are in fact being used by the GPU?
In this case, the window exists, but it isn't observable in a way that
actually matters. The reservations stay locked until drm_exec_fini(),
which runs after the fences are attached, so anyone taking the resv
lock, including another submit touching the same BOs, waits for them.
Other drivers, such as V3D and Panfrost, follow the same pattern: push
jobs -> attach fences -> replace the out syncobjs fences.
Best regards,
- Maíra