On Wed, 6 Sep 2023 10:32:24 +0200
Thomas Hellström <thomas.hellstrom@xxxxxxxxxxxxxxx> wrote:
FWIW, the panthor driver is designed this way (note that I'm notSo do I understand correctly that this because you want to update the+Introducing external (or shared) buffer objectsI need to think a bit more about locking of extobj and evicted
+===============================================
+
+Since shared buffer objects may be shared by multiple gpu_vm's they
+can't share their reservation object with a single gpu_vm, but
will rather
+have a reservation object of their own. The shared objects bound to a
+gpu_vm using one or many
+gpu_vmas are therefore typically put on a per-gpu_vm list which is
+protected by the gpu_vm lock. One could in theory protect it also
with
+the ``gpu_vm->resv``, but since the list of dma_resvs to take is
typically
+built before the ``gpu_vm->resv`` is locked due to a limitation in
+the current locking helpers, that is typically not done. Also see
+below for userptr gpu_vmas.
+
+At eviction time we now need to invalidate *all* gpu_vmas of a shared
+object, but we can no longer be certain that we hold the gpu_vm's
+dma_resv of all the object's gpu_vmas. We can only be certain that we
object tracking
in the case of processing 'drm_gpuva_ops' directly through callbacks
within the
fence signalling critical path as mentioend in [1].
In order to support that, we'd need to protect extobjs with a
separate lock,
and while iterating extobjs to acquire the dma-resv lock drop the
lock within
the loop before we actually acquire the dma-resv lock. Maple tree
supports that
already and this can be fully done within the GPUVA manager; no need
for the
driver to care about that.
gpuvm state while operations are progressing asynchronously?
If so, I wonder whether that could really be done? For example to
allocate enough memory for page-tables etc, you need to know the
details of the operations at IOCTL execution time, and to know the
details you need to know the state from the previous operation?
Right, sync and async bind can't run fully concurrently, but you could
"inject" a
sync one between two async ones such that the sync ones executed from
the IOCTL
directly while async execution is stalled meanwhile. This would be
possible because
the actual drm_gpuva_ops would be calculated within the async
execution path rather
than in the IOCTL. But yes, page-table management must be desinged to
support that.
supporting GEM eviction yet, so there might be subtleties I missed).
OK, well one of the main motivations for Xe is to be able to pipelineThe idea in this case is to detect when a GPU job dependency is a
interleaving binds and execs if needed, like so:
- Bind vmas for scene 1.
- Submit scene 1.
- Unbind vmas for scene 1.
- Bind vmas for scene 2.
- Submit scene 2.
- Unbind vmas for scene 2.
And being able to *submit* all of the above while the async binding of
vmas for scene (step 1) has not yet completed.
I can't really see how this could be done, while obeying dma-fence
rules, unless state is updated synchronously while submitting?
VM_BIND out-fence, turn drm_sched_fence->parent into an
xxx_vm_bind_job_fence object that's holding the GEM that's about to be
mapped (AFAICT, we don't need to do anything for unmap operations), and
then add our GPU job fence to this BO. This should not only guarantee
that the GEMs we depend on are mapped before the GPU job is executed
(the fence wait does that), but also that such yet-to-be-mapped GEMs
won't be evicted just after they've been mapped and before the GPU had
a chance to execute (unless I'm missing something, adding our GPU job
fence to the BO being targeted by a pending VM_BIND(async,map) operation
solves this problem).